@tamagui/use-store 1.88.13 → 1.88.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/esm/comparators.mjs +13 -0
- package/dist/esm/configureUseStore.mjs +5 -0
- package/dist/esm/constants.mjs +6 -0
- package/dist/esm/decorators.mjs +6 -0
- package/dist/esm/helpers.mjs +25 -0
- package/dist/esm/index.mjs +13 -0
- package/dist/esm/interfaces.mjs +0 -0
- package/dist/esm/observe.mjs +84 -0
- package/dist/esm/useStore.mjs +341 -0
- package/dist/esm/useStoreDebug.mjs +20 -0
- package/package.json +3 -3
- package/src/configureUseStore.tsx +1 -1
- package/src/helpers.tsx +1 -1
- package/src/interfaces.tsx +1 -1
- package/src/observe.tsx +1 -1
- package/src/useStore.tsx +1 -1
- package/src/useStoreDebug.tsx +1 -1
- package/types/configureUseStore.d.ts +1 -1
- package/types/configureUseStore.d.ts.map +1 -1
- package/types/helpers.d.ts +1 -1
- package/types/helpers.d.ts.map +1 -1
- package/types/interfaces.d.ts +1 -1
- package/types/interfaces.d.ts.map +1 -1
- package/types/useStore.d.ts +1 -1
- package/types/useStore.d.ts.map +1 -1
- package/types/useStoreDebug.d.ts +1 -1
- package/types/useStoreDebug.d.ts.map +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const isEqualSubsetShallow = (a, b, opts) => {
|
|
2
|
+
if (b == null || a == null) return a === b;
|
|
3
|
+
if (typeof a != typeof b) return !1;
|
|
4
|
+
if (typeof b == "object") {
|
|
5
|
+
for (const key in b) {
|
|
6
|
+
const compare = opts?.keyComparators?.[key];
|
|
7
|
+
if (compare ? !compare(a[key], b[key]) : b[key] !== a[key]) return !1;
|
|
8
|
+
}
|
|
9
|
+
return !0;
|
|
10
|
+
}
|
|
11
|
+
return a === b;
|
|
12
|
+
};
|
|
13
|
+
export { isEqualSubsetShallow };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { simpleHash } from "@tamagui/simple-hash";
|
|
2
|
+
function getStoreUid(Constructor, props) {
|
|
3
|
+
return simpleHash(`${Constructor}${props ? typeof props == "string" ? props : JSON.stringify(props) : ""}`, "strict");
|
|
4
|
+
}
|
|
5
|
+
const UNWRAP_STORE_INFO = Symbol("UNWRAP_STORE_INFO"),
|
|
6
|
+
cache = /* @__PURE__ */new Map();
|
|
7
|
+
function getStoreDescriptors(storeInstance) {
|
|
8
|
+
const proto = Object.getPrototypeOf(storeInstance),
|
|
9
|
+
instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance),
|
|
10
|
+
descriptors = {
|
|
11
|
+
...Object.getOwnPropertyDescriptors(proto),
|
|
12
|
+
...instanceDescriptors
|
|
13
|
+
};
|
|
14
|
+
return delete descriptors.constructor, descriptors;
|
|
15
|
+
}
|
|
16
|
+
function get(_, b) {
|
|
17
|
+
return _;
|
|
18
|
+
}
|
|
19
|
+
function simpleStr(arg) {
|
|
20
|
+
return process.env.NODE_ENV === "development" ? typeof arg == "function" ? "fn" : typeof arg == "string" ? `"${arg}"` : arg && (typeof arg != "object" ? arg : Array.isArray(arg) ? "[...]" : "{...}") : arg;
|
|
21
|
+
}
|
|
22
|
+
function getStoreDebugInfo(store) {
|
|
23
|
+
return store[UNWRAP_STORE_INFO] ?? cache.get(getStoreUid(store.constructor, store.props));
|
|
24
|
+
}
|
|
25
|
+
export { UNWRAP_STORE_INFO, cache, get, getStoreDebugInfo, getStoreDescriptors, getStoreUid, simpleStr };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from "./useStore.mjs";
|
|
2
|
+
import { configureUseStore } from "./configureUseStore.mjs";
|
|
3
|
+
export * from "./interfaces.mjs";
|
|
4
|
+
export * from "./observe.mjs";
|
|
5
|
+
import { UNWRAP_PROXY } from "./constants.mjs";
|
|
6
|
+
export * from "./comparators.mjs";
|
|
7
|
+
export * from "./decorators.mjs";
|
|
8
|
+
class Store {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
this.props = props;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export { Store, UNWRAP_PROXY, configureUseStore };
|
|
File without changes
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
import { isEqualSubsetShallow } from "./comparators.mjs";
|
|
3
|
+
import { UNWRAP_PROXY } from "./constants.mjs";
|
|
4
|
+
import { trackStoresAccess } from "./useStore.mjs";
|
|
5
|
+
const logUpdate = process.env.NODE_ENV === "development" ? (fn, stores, last, next) => {
|
|
6
|
+
const getStoreLogName = store => `${(store[UNWRAP_PROXY] ?? store).constructor.name}${store.props?.id ? `:${store.props.id}` : ""}`,
|
|
7
|
+
storeNames = stores.map(getStoreLogName).join(", "),
|
|
8
|
+
name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
|
|
9
|
+
console.groupCollapsed(name, "color: tomato;"), console.groupCollapsed("trace >"), console.trace(), console.groupEnd(), console.info(" next", next), console.groupEnd();
|
|
10
|
+
} : null;
|
|
11
|
+
function observe(fn) {
|
|
12
|
+
let prev = getObserverValueAndStoresAccessed(fn),
|
|
13
|
+
disposeValue = null;
|
|
14
|
+
const subscribe = () => {
|
|
15
|
+
const stores = [...prev.storeInfos];
|
|
16
|
+
return subscribeToStores(stores, () => {
|
|
17
|
+
disposeValue?.();
|
|
18
|
+
const next = getObserverValueAndStoresAccessed(fn);
|
|
19
|
+
if (typeof next.value == "function") {
|
|
20
|
+
disposeValue = next.value, process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
isEqualSubsetShallow(prev.storeInfos, next.storeInfos) && isEqualSubsetShallow(prev.value, next.value) || (process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], prev.value, next.value), prev = next, dispose(), dispose = subscribe());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
let dispose = subscribe();
|
|
27
|
+
return {
|
|
28
|
+
dispose: () => {
|
|
29
|
+
dispose(), disposeValue?.();
|
|
30
|
+
},
|
|
31
|
+
getValue: () => prev.value
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function useObserve(fn) {
|
|
35
|
+
const [state, setState] = useState(() => getObserverValueAndStoresAccessed(fn));
|
|
36
|
+
return useEffect(() => {
|
|
37
|
+
let dispose;
|
|
38
|
+
const unsub = subscribeToStores([...state.storeInfos], () => {
|
|
39
|
+
dispose?.();
|
|
40
|
+
const next = getObserverValueAndStoresAccessed(fn),
|
|
41
|
+
nextStoreInfos = [...next.storeInfos],
|
|
42
|
+
prevStoreInfos = [...state.storeInfos];
|
|
43
|
+
if (typeof next.value == "function") {
|
|
44
|
+
process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, "(fn)", "(fn)"), dispose = next.value;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
setState(prev => isEqualSubsetShallow(prevStoreInfos, nextStoreInfos) && isEqualSubsetShallow(prev.value, next.value) ? prev : (process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, prev.value, next.value), next));
|
|
48
|
+
});
|
|
49
|
+
return () => {
|
|
50
|
+
unsub(), dispose?.();
|
|
51
|
+
};
|
|
52
|
+
}, [[...state.storeInfos].map(i => i.uid).join(",")]), state.value;
|
|
53
|
+
}
|
|
54
|
+
function getObserverValueAndStoresAccessed(selector) {
|
|
55
|
+
const storeInfos = /* @__PURE__ */new Set(),
|
|
56
|
+
dispose = trackStoresAccess(storeInfo => {
|
|
57
|
+
storeInfos.add(storeInfo);
|
|
58
|
+
}),
|
|
59
|
+
value = selector();
|
|
60
|
+
return dispose(), {
|
|
61
|
+
value,
|
|
62
|
+
storeInfos
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
function subscribeToStores(storeInfos, onUpdate) {
|
|
66
|
+
const disposes = [];
|
|
67
|
+
let isUpdating = !1;
|
|
68
|
+
const onUpdateDebouncedWithoutTracking = () => {
|
|
69
|
+
isUpdating || (isUpdating = !0, queueMicrotask(() => {
|
|
70
|
+
try {
|
|
71
|
+
for (const storeInfo of storeInfos) storeInfo.disableTracking = !0;
|
|
72
|
+
onUpdate();
|
|
73
|
+
} finally {
|
|
74
|
+
isUpdating = !1;
|
|
75
|
+
for (const storeInfo of storeInfos) storeInfo.disableTracking = !1;
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
};
|
|
79
|
+
for (const storeInfo of storeInfos) disposes.push(storeInfo.subscribe(onUpdateDebouncedWithoutTracking));
|
|
80
|
+
return () => {
|
|
81
|
+
disposes.forEach(x => x());
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
export { observe, useObserve };
|
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
import { useCallback, useRef, useSyncExternalStore } from "react";
|
|
2
|
+
import { isEqualSubsetShallow } from "./comparators.mjs";
|
|
3
|
+
import { configureOpts } from "./configureUseStore.mjs";
|
|
4
|
+
import { UNWRAP_PROXY, defaultOptions } from "./constants.mjs";
|
|
5
|
+
import { UNWRAP_STORE_INFO, cache, getStoreDescriptors, getStoreUid, simpleStr } from "./helpers.mjs";
|
|
6
|
+
import { DebugStores, shouldDebug, useCurrentComponent } from "./useStoreDebug.mjs";
|
|
7
|
+
const idFn = _ => _;
|
|
8
|
+
function useStore(StoreKlass, props, options = defaultOptions) {
|
|
9
|
+
const info = getOrCreateStoreInfo(StoreKlass, props, options);
|
|
10
|
+
return useStoreFromInfo(info, options.selector, options);
|
|
11
|
+
}
|
|
12
|
+
function useStoreDebug(StoreKlass, props) {
|
|
13
|
+
return useStore(StoreKlass, props, {
|
|
14
|
+
debug: !0
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
function createStore(StoreKlass, props, options) {
|
|
18
|
+
return getOrCreateStoreInfo(StoreKlass, props, options)?.store;
|
|
19
|
+
}
|
|
20
|
+
function useGlobalStore(instance, debug) {
|
|
21
|
+
const store = instance[UNWRAP_PROXY],
|
|
22
|
+
uid = getStoreUid(store.constructor, store.props),
|
|
23
|
+
info = cache.get(uid);
|
|
24
|
+
if (!info) throw new Error("This store not created using createStore()");
|
|
25
|
+
return useStoreFromInfo(info, void 0, {
|
|
26
|
+
debug
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function useGlobalStoreSelector(instance, selector, debug) {
|
|
30
|
+
const store = instance[UNWRAP_PROXY],
|
|
31
|
+
uid = getStoreUid(store.constructor, store.props),
|
|
32
|
+
info = cache.get(uid);
|
|
33
|
+
if (!info) throw new Error("This store not created using createStore()");
|
|
34
|
+
return useStoreFromInfo(info, selector, {
|
|
35
|
+
debug
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
function createUseStore(StoreKlass) {
|
|
39
|
+
return (props, options) => useStore(StoreKlass, props, options);
|
|
40
|
+
}
|
|
41
|
+
function createUseStoreSelector(StoreKlass, selector) {
|
|
42
|
+
return props => useStore(StoreKlass, props, {
|
|
43
|
+
selector
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function useStoreSelector(StoreKlass, selector, props) {
|
|
47
|
+
return useStore(StoreKlass, props, {
|
|
48
|
+
selector
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const storeAccessTrackers = /* @__PURE__ */new Set();
|
|
52
|
+
function trackStoresAccess(cb) {
|
|
53
|
+
return storeAccessTrackers.add(cb), () => {
|
|
54
|
+
storeAccessTrackers.delete(cb);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function getStore(StoreKlass, props) {
|
|
58
|
+
return getStoreInfo(StoreKlass, props)?.store;
|
|
59
|
+
}
|
|
60
|
+
function getOrCreateStore(StoreKlass, props) {
|
|
61
|
+
return getOrCreateStoreInfo(StoreKlass, props, {
|
|
62
|
+
refuseCreation: !1
|
|
63
|
+
})?.store;
|
|
64
|
+
}
|
|
65
|
+
function getStoreInfo(StoreKlass, props) {
|
|
66
|
+
return getOrCreateStoreInfo(StoreKlass, props, {
|
|
67
|
+
refuseCreation: !0
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
const onCreateListeners = /* @__PURE__ */new Set();
|
|
71
|
+
function onCreateStore(cb) {
|
|
72
|
+
return onCreateListeners.add(cb), () => {
|
|
73
|
+
onCreateListeners.delete(cb);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
|
|
77
|
+
if (!StoreKlass) return null;
|
|
78
|
+
const uid = getStoreUid(StoreKlass, propsKeyCalculated ?? props);
|
|
79
|
+
if (!options?.avoidCache && cache.has(uid)) return cache.get(uid);
|
|
80
|
+
if (options?.refuseCreation) throw new Error(`No store exists (${StoreKlass.name}) with props: ${props}`);
|
|
81
|
+
const storeInstance = new StoreKlass(props);
|
|
82
|
+
storeInstance.props = props;
|
|
83
|
+
const getters = {},
|
|
84
|
+
actions = {},
|
|
85
|
+
stateKeys = /* @__PURE__ */new Set(),
|
|
86
|
+
descriptors = getStoreDescriptors(storeInstance);
|
|
87
|
+
for (const key in descriptors) {
|
|
88
|
+
const descriptor = descriptors[key];
|
|
89
|
+
typeof descriptor.value == "function" ? actions[key] = descriptor.value : typeof descriptor.get == "function" ? getters[key] = descriptor.get : key !== "props" && key[0] !== "_" && stateKeys.add(key);
|
|
90
|
+
}
|
|
91
|
+
const keyComparators = storeInstance._comparators,
|
|
92
|
+
listeners = /* @__PURE__ */new Set(),
|
|
93
|
+
storeInfo = {
|
|
94
|
+
uid,
|
|
95
|
+
keyComparators,
|
|
96
|
+
storeInstance,
|
|
97
|
+
getters,
|
|
98
|
+
stateKeys,
|
|
99
|
+
props,
|
|
100
|
+
actions,
|
|
101
|
+
debug: options?.debug,
|
|
102
|
+
disableTracking: !1,
|
|
103
|
+
gettersState: {
|
|
104
|
+
getCache: /* @__PURE__ */new Map(),
|
|
105
|
+
depsToGetter: /* @__PURE__ */new Map(),
|
|
106
|
+
curGetKeys: /* @__PURE__ */new Set(),
|
|
107
|
+
isGetting: !1
|
|
108
|
+
},
|
|
109
|
+
listeners,
|
|
110
|
+
trackers: /* @__PURE__ */new Set(),
|
|
111
|
+
version: 0,
|
|
112
|
+
subscribe: onChanged => (listeners.add(onChanged), () => {
|
|
113
|
+
listeners.delete(onChanged);
|
|
114
|
+
}),
|
|
115
|
+
triggerUpdate: () => {
|
|
116
|
+
storeInfo.version = (storeInfo.version + 1) % Number.MAX_SAFE_INTEGER;
|
|
117
|
+
for (const cb of listeners) cb();
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
store = createProxiedStore(
|
|
121
|
+
// we assign store right after and proxiedStore never accesses it until later on
|
|
122
|
+
storeInfo);
|
|
123
|
+
process.env.NODE_ENV === "development" && (allStores[StoreKlass.name + uid] = store), store.mount?.(), storeInfo.store = store;
|
|
124
|
+
const result = storeInfo;
|
|
125
|
+
return cache.set(uid, result), onCreateListeners.forEach(cb => cb(result)), result;
|
|
126
|
+
}
|
|
127
|
+
const allStores = {};
|
|
128
|
+
process.env.NODE_ENV === "development" && (globalThis.Store ||= allStores);
|
|
129
|
+
const emptyObj = {},
|
|
130
|
+
selectKeys = (obj, keys) => {
|
|
131
|
+
if (!keys.length) return emptyObj;
|
|
132
|
+
const res = {};
|
|
133
|
+
for (const key of keys) res[key] = obj[key];
|
|
134
|
+
return res;
|
|
135
|
+
};
|
|
136
|
+
let isInReaction = !1;
|
|
137
|
+
const setIsInReaction = val => {
|
|
138
|
+
isInReaction = val;
|
|
139
|
+
};
|
|
140
|
+
function useStoreFromInfo(info, userSelector, options) {
|
|
141
|
+
const store = info?.store,
|
|
142
|
+
internal = useRef(),
|
|
143
|
+
component = useCurrentComponent();
|
|
144
|
+
internal.current || (internal.current = {
|
|
145
|
+
component,
|
|
146
|
+
tracked: /* @__PURE__ */new Set(),
|
|
147
|
+
last: null,
|
|
148
|
+
lastKeys: null
|
|
149
|
+
});
|
|
150
|
+
const curInternal = internal.current,
|
|
151
|
+
shouldPrintDebug = options?.debug,
|
|
152
|
+
getSnapshot = useCallback(() => {
|
|
153
|
+
if (!info || !store) return;
|
|
154
|
+
const curInternal2 = internal.current,
|
|
155
|
+
isTracking = curInternal2.tracked.size,
|
|
156
|
+
keys = [...(isTracking ? curInternal2.tracked : info.stateKeys)],
|
|
157
|
+
nextKeys = `${info.version}${keys.join("")}${userSelector || ""}`,
|
|
158
|
+
lastKeys = curInternal2.lastKeys;
|
|
159
|
+
if (nextKeys === curInternal2.lastKeys) return curInternal2.last;
|
|
160
|
+
curInternal2.lastKeys = nextKeys;
|
|
161
|
+
let snap;
|
|
162
|
+
info.disableTracking = !0;
|
|
163
|
+
const last = curInternal2.last;
|
|
164
|
+
userSelector ? snap = userSelector(store) : snap = selectKeys(store, keys), info.disableTracking = !1;
|
|
165
|
+
const isUnchanged = !userSelector && !isTracking && last || typeof last < "u" && isEqualSubsetShallow(last, snap, {
|
|
166
|
+
keyComparators: info.keyComparators
|
|
167
|
+
});
|
|
168
|
+
return shouldPrintDebug && console.info("\u{1F311} getSnapshot", {
|
|
169
|
+
storeState: selectKeys(store, Object.keys(store)),
|
|
170
|
+
userSelector,
|
|
171
|
+
info,
|
|
172
|
+
isUnchanged,
|
|
173
|
+
component,
|
|
174
|
+
keys,
|
|
175
|
+
last,
|
|
176
|
+
snap,
|
|
177
|
+
curInternal: curInternal2,
|
|
178
|
+
nextKeys,
|
|
179
|
+
lastKeys
|
|
180
|
+
}), isUnchanged ? last : (curInternal2.last = snap, snap);
|
|
181
|
+
}, [store]),
|
|
182
|
+
state = useSyncExternalStore(info?.subscribe || idFn, getSnapshot, getSnapshot);
|
|
183
|
+
return !info || !store || !state || userSelector ? state : new Proxy(store, {
|
|
184
|
+
get(target, key) {
|
|
185
|
+
const curVal = Reflect.get(target, key);
|
|
186
|
+
if (isInReaction) return curVal;
|
|
187
|
+
const keyString = key;
|
|
188
|
+
return (info.stateKeys.has(keyString) || keyString in info.getters) && (shouldPrintDebug && console.info("\u{1F440} tracking", keyString), curInternal.tracked.add(keyString)), Reflect.has(state, key) ? Reflect.get(state, key) : curVal;
|
|
189
|
+
}
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
let setters = /* @__PURE__ */new Set();
|
|
193
|
+
const logStack = /* @__PURE__ */new Set();
|
|
194
|
+
function createProxiedStore(storeInfo) {
|
|
195
|
+
const {
|
|
196
|
+
actions,
|
|
197
|
+
storeInstance,
|
|
198
|
+
getters,
|
|
199
|
+
gettersState
|
|
200
|
+
} = storeInfo,
|
|
201
|
+
{
|
|
202
|
+
getCache,
|
|
203
|
+
curGetKeys,
|
|
204
|
+
depsToGetter
|
|
205
|
+
} = gettersState,
|
|
206
|
+
constr = storeInstance.constructor,
|
|
207
|
+
shouldDebug2 = storeInfo.debug ?? DebugStores.has(constr);
|
|
208
|
+
let didSet = !1;
|
|
209
|
+
const wrappedActions = {};
|
|
210
|
+
for (const key in actions) {
|
|
211
|
+
if (key === "subscribe") continue;
|
|
212
|
+
const actionFn = actions[key],
|
|
213
|
+
isGetFn = key.startsWith("get");
|
|
214
|
+
if (wrappedActions[key] = function (...args) {
|
|
215
|
+
let res;
|
|
216
|
+
return isGetFn || gettersState.isGetting ? Reflect.apply(actionFn, proxiedStore, args) : (process.env.NODE_ENV === "development" && shouldDebug2 && console.info("(debug) startAction", key), res = Reflect.apply(actionFn, proxiedStore, args), res instanceof Promise ? res.then(finishAction) : (finishAction(), res));
|
|
217
|
+
}, process.env.NODE_ENV === "development") {
|
|
218
|
+
let hashCode = function (str) {
|
|
219
|
+
let hash = 0;
|
|
220
|
+
for (let i = 0; i < str.length; i++) hash = str.charCodeAt(i) + ((hash << 5) - hash);
|
|
221
|
+
return hash;
|
|
222
|
+
},
|
|
223
|
+
strColor = function (str) {
|
|
224
|
+
return `hsl(${hashCode(str) % 360}, 90%, 40%)`;
|
|
225
|
+
};
|
|
226
|
+
if (!key.startsWith("get") && !key.startsWith("_") && key !== "subscribe") {
|
|
227
|
+
const ogAction = wrappedActions[key];
|
|
228
|
+
wrappedActions[key] = new Proxy(ogAction, {
|
|
229
|
+
apply(target, thisArg, args) {
|
|
230
|
+
const isDebugging = shouldDebug2 || storeInfo.debug;
|
|
231
|
+
if (!(process.env.LOG_LEVEL !== "0" && (isDebugging || configureOpts.logLevel !== "error"))) return Reflect.apply(target, thisArg, args);
|
|
232
|
+
setters = /* @__PURE__ */new Set();
|
|
233
|
+
const curSetters = setters,
|
|
234
|
+
isTopLevelLogger = logStack.size == 0,
|
|
235
|
+
logs = /* @__PURE__ */new Set();
|
|
236
|
+
logStack.add(logs);
|
|
237
|
+
let res;
|
|
238
|
+
const id = counter++;
|
|
239
|
+
try {
|
|
240
|
+
res = Reflect.apply(target, thisArg, args);
|
|
241
|
+
} catch (err) {
|
|
242
|
+
throw console.error("Error", err), err;
|
|
243
|
+
} finally {
|
|
244
|
+
logStack.add("end");
|
|
245
|
+
const name = constr.name,
|
|
246
|
+
color = strColor(name),
|
|
247
|
+
simpleArgs = args.map(simpleStr);
|
|
248
|
+
if (logs.add([`%c \u{1F311} ${id} ${name.padStart(isTopLevelLogger ? 8 : 4)}%c.${key}(${simpleArgs.join(", ")})${isTopLevelLogger && logStack.size > 1 ? ` (+${logStack.size - 1})` : ""}`, `color: ${color};`, "color: black;"]), curSetters.size && curSetters.forEach(({
|
|
249
|
+
key: key2,
|
|
250
|
+
value
|
|
251
|
+
}) => {
|
|
252
|
+
typeof value == "string" || typeof value == "number" || typeof value == "boolean" ? logs.add([` SET ${key2} ${value}`, value]) : logs.add([` SET ${key2}`, value]);
|
|
253
|
+
}), isTopLevelLogger) {
|
|
254
|
+
let error = null;
|
|
255
|
+
try {
|
|
256
|
+
for (const item of [...logStack]) {
|
|
257
|
+
if (item === "end") {
|
|
258
|
+
console.groupEnd();
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const [head, ...rest] = item;
|
|
262
|
+
if (head) {
|
|
263
|
+
console.groupCollapsed(...head), console.groupCollapsed("..."), console.info("args", args), console.info("response", res), console.groupCollapsed("trace"), console.trace(), console.groupEnd(), console.groupEnd();
|
|
264
|
+
for (const [name2, ...log] of rest) console.groupCollapsed(name2), console.info(...log), console.groupEnd();
|
|
265
|
+
} else console.info("Weird log", head, ...rest);
|
|
266
|
+
}
|
|
267
|
+
} catch (err) {
|
|
268
|
+
error = err;
|
|
269
|
+
}
|
|
270
|
+
for (const _ of [...logStack]) console.groupEnd();
|
|
271
|
+
error && console.error("error loggin", error), logStack.clear();
|
|
272
|
+
}
|
|
273
|
+
return res;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
const finishAction = val => (process.env.NODE_ENV === "development" && shouldDebug2 && console.info("(debug) finishAction", {
|
|
281
|
+
didSet
|
|
282
|
+
}), didSet && (storeInfo.triggerUpdate(), didSet = !1), val);
|
|
283
|
+
let isTriggering = !1;
|
|
284
|
+
const proxiedStore = new Proxy(storeInstance, {
|
|
285
|
+
// GET
|
|
286
|
+
get(_, key) {
|
|
287
|
+
if (key in wrappedActions) return wrappedActions[key];
|
|
288
|
+
if (key in passThroughKeys) return Reflect.get(storeInstance, key);
|
|
289
|
+
if (key === UNWRAP_PROXY) return storeInstance;
|
|
290
|
+
if (key === UNWRAP_STORE_INFO) return storeInfo;
|
|
291
|
+
if (storeAccessTrackers.size && storeAccessTrackers.forEach(cb => cb(storeInfo)), typeof key != "string") return Reflect.get(storeInstance, key);
|
|
292
|
+
if (storeInfo.disableTracking || gettersState.isGetting && gettersState.curGetKeys.add(key), key in getters) {
|
|
293
|
+
if (getCache.has(key)) return getCache.get(key);
|
|
294
|
+
curGetKeys.clear();
|
|
295
|
+
const isSubGetter = gettersState.isGetting;
|
|
296
|
+
gettersState.isGetting = !0;
|
|
297
|
+
const res = getters[key].call(proxiedStore);
|
|
298
|
+
isSubGetter || (gettersState.isGetting = !1);
|
|
299
|
+
for (const gk of curGetKeys) depsToGetter.has(gk) || depsToGetter.set(gk, /* @__PURE__ */new Set()), depsToGetter.get(gk).add(key);
|
|
300
|
+
return getCache.set(key, res), res;
|
|
301
|
+
}
|
|
302
|
+
return Reflect.get(storeInstance, key);
|
|
303
|
+
},
|
|
304
|
+
// SET
|
|
305
|
+
set(target, key, value, receiver) {
|
|
306
|
+
const cur = Reflect.get(target, key),
|
|
307
|
+
res = Reflect.set(target, key, value, receiver);
|
|
308
|
+
return res && cur !== value && (typeof key == "string" && (clearGetterCache(key), shouldDebug2 && (setters.add({
|
|
309
|
+
key,
|
|
310
|
+
value
|
|
311
|
+
}), getShouldDebug(storeInfo) && console.info("(debug) SET", res, key, value)), process.env.NODE_ENV === "development" && shouldDebug2 && console.info("SET...", {
|
|
312
|
+
key,
|
|
313
|
+
value
|
|
314
|
+
})), isTriggering || (isTriggering = !0, waitForEventLoop(() => {
|
|
315
|
+
storeInfo.triggerUpdate(), isTriggering = !1;
|
|
316
|
+
}))), res;
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
function clearGetterCache(setKey) {
|
|
320
|
+
const parentGetters = depsToGetter.get(setKey);
|
|
321
|
+
if (getCache.delete(setKey), !!parentGetters) for (const gk of parentGetters) getCache.delete(gk), depsToGetter.has(gk) && clearGetterCache(gk);
|
|
322
|
+
}
|
|
323
|
+
return proxiedStore;
|
|
324
|
+
}
|
|
325
|
+
const waitForEventLoop = process.env.NODE_ENV === "test" ? cb => cb() : queueMicrotask;
|
|
326
|
+
let counter = 0;
|
|
327
|
+
const passThroughKeys = {
|
|
328
|
+
subscribe: !0,
|
|
329
|
+
_version: !0,
|
|
330
|
+
_trackers: !0,
|
|
331
|
+
$$typeof: !0,
|
|
332
|
+
_listeners: !0,
|
|
333
|
+
_enableTracking: !0
|
|
334
|
+
};
|
|
335
|
+
function getShouldDebug(storeInfo) {
|
|
336
|
+
const info = {
|
|
337
|
+
storeInstance: storeInfo.store
|
|
338
|
+
};
|
|
339
|
+
return [...storeInfo.trackers].some(tracker => tracker.component && shouldDebug(tracker.component, info));
|
|
340
|
+
}
|
|
341
|
+
export { allStores, createStore, createUseStore, createUseStoreSelector, getOrCreateStore, getStore, getStoreInfo, onCreateStore, setIsInReaction, trackStoresAccess, useGlobalStore, useGlobalStoreSelector, useStore, useStoreDebug, useStoreSelector };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React, { useLayoutEffect } from "react";
|
|
2
|
+
const {
|
|
3
|
+
ReactCurrentOwner
|
|
4
|
+
} = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
5
|
+
useCurrentComponent = () => ReactCurrentOwner && ReactCurrentOwner.current && ReactCurrentOwner.current.elementType ? ReactCurrentOwner.current.elementType : {};
|
|
6
|
+
function useDebugStoreComponent(StoreCons) {
|
|
7
|
+
const cmp = useCurrentComponent();
|
|
8
|
+
DebugStores.add(StoreCons), DebugComponents.has(cmp) || DebugComponents.set(cmp, /* @__PURE__ */new Set());
|
|
9
|
+
const stores = DebugComponents.get(cmp);
|
|
10
|
+
stores.add(StoreCons), useLayoutEffect(() => () => {
|
|
11
|
+
DebugStores.delete(StoreCons), stores.delete(StoreCons);
|
|
12
|
+
}, []);
|
|
13
|
+
}
|
|
14
|
+
const shouldDebug = (component, info) => {
|
|
15
|
+
const StoreCons = info.storeInstance?.constructor;
|
|
16
|
+
return DebugComponents.get(component)?.has(StoreCons);
|
|
17
|
+
},
|
|
18
|
+
DebugComponents = /* @__PURE__ */new Map(),
|
|
19
|
+
DebugStores = /* @__PURE__ */new Set();
|
|
20
|
+
export { DebugComponents, DebugStores, shouldDebug, useCurrentComponent, useDebugStoreComponent };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/use-store",
|
|
3
|
-
"version": "1.88.
|
|
3
|
+
"version": "1.88.14",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
}
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@tamagui/simple-hash": "1.88.
|
|
31
|
+
"@tamagui/simple-hash": "1.88.14"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@tamagui/build": "1.88.
|
|
34
|
+
"@tamagui/build": "1.88.14",
|
|
35
35
|
"@testing-library/react": "^14.0.0",
|
|
36
36
|
"react": "^18.2.0",
|
|
37
37
|
"vitest": "^0.34.3"
|
package/src/helpers.tsx
CHANGED
package/src/interfaces.tsx
CHANGED
package/src/observe.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'
|
|
|
2
2
|
|
|
3
3
|
import { isEqualSubsetShallow } from './comparators'
|
|
4
4
|
import { UNWRAP_PROXY } from './constants'
|
|
5
|
-
import { StoreInfo } from './interfaces'
|
|
5
|
+
import type { StoreInfo } from './interfaces'
|
|
6
6
|
import { trackStoresAccess } from './useStore'
|
|
7
7
|
|
|
8
8
|
const logUpdate =
|
package/src/useStore.tsx
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
getStoreUid,
|
|
11
11
|
simpleStr,
|
|
12
12
|
} from './helpers'
|
|
13
|
-
import { Selector, Store, StoreInfo, UseStoreOptions } from './interfaces'
|
|
13
|
+
import type { Selector, Store, StoreInfo, UseStoreOptions } from './interfaces'
|
|
14
14
|
import { DebugStores, shouldDebug, useCurrentComponent } from './useStoreDebug'
|
|
15
15
|
|
|
16
16
|
const idFn = (_) => _
|
package/src/useStoreDebug.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UseStoreConfig } from './interfaces';
|
|
1
|
+
import type { UseStoreConfig } from './interfaces';
|
|
2
2
|
export declare let configureOpts: UseStoreConfig;
|
|
3
3
|
export declare function configureUseStore(opts: UseStoreConfig): void;
|
|
4
4
|
//# sourceMappingURL=configureUseStore.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configureUseStore.d.ts","sourceRoot":"","sources":["../src/configureUseStore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"configureUseStore.d.ts","sourceRoot":"","sources":["../src/configureUseStore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAElD,eAAO,IAAI,aAAa,EAAE,cAAmB,CAAA;AAE7C,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,cAAc,QAErD"}
|
package/types/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreInfo } from './interfaces';
|
|
1
|
+
import type { StoreInfo } from './interfaces';
|
|
2
2
|
export declare function getStoreUid(Constructor: any, props: string | Object | void): any;
|
|
3
3
|
export declare const UNWRAP_STORE_INFO: unique symbol;
|
|
4
4
|
export declare const cache: Map<string, StoreInfo>;
|
package/types/helpers.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAE7C,wBAAgB,WAAW,CAAC,WAAW,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,OAO1E;AAED,eAAO,MAAM,iBAAiB,eAA8B,CAAA;AAC5D,eAAO,MAAM,KAAK,wBAA+B,CAAA;AAEjD,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,GAAG;;EAWrD;AAED,wBAAgB,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,SAAS,KAAK,KAAK,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAEpF;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,GAAG,OAejC;AAGD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,OAI3C"}
|
package/types/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreTracker } from './useStore';
|
|
1
|
+
import type { StoreTracker } from './useStore';
|
|
2
2
|
export type Selector<A = unknown, B = unknown> = (x: A) => B;
|
|
3
3
|
export type UseStoreSelector<Store, Res> = (store: Store) => Res;
|
|
4
4
|
export type UseStoreOptions<Store = any, SelectorRes = any> = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../src/interfaces.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAA;AAE5D,MAAM,MAAM,gBAAgB,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,GAAG,CAAA;AAChE,MAAM,MAAM,eAAe,CAAC,KAAK,GAAG,GAAG,EAAE,WAAW,GAAG,GAAG,IAAI;IAC5D,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,QAAQ,CAAC,EAAE,gBAAgB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,OAAO,CAAA;CACf,CAAA;AAED,MAAM,WAAW,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS;IACnE,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,CAAA;IACzB,KAAK,EAAE,KAAK,CAAA;CACb;AAED,MAAM,MAAM,SAAS,CAAC,CAAC,GAAG,KAAK,IAAI;IACjC,GAAG,EAAE,MAAM,CAAA;IACX,cAAc,CAAC,EAAE;QACf,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;KAC3C,CAAA;IAED,KAAK,EAAE,CAAC,CAAA;IACR,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,CAAA;IACjC,aAAa,EAAE,GAAG,CAAA;IAClB,OAAO,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAAA;IAC/B,OAAO,EAAE,GAAG,CAAA;IACZ,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;IACtB,KAAK,CAAC,EAAE,OAAO,CAAA;IACf,YAAY,EAAE;QACZ,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;QAC1B,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAA;QACtC,UAAU,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;QACvB,SAAS,EAAE,OAAO,CAAA;KACnB,CAAA;IACD,SAAS,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAA;IACxB,QAAQ,EAAE,GAAG,CAAC,YAAY,CAAC,CAAA;IAC3B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,CAAC,SAAS,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAA;IAChD,aAAa,EAAE,QAAQ,CAAA;IACvB,eAAe,EAAE,OAAO,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,OAAO,CAAA;CACtC,CAAA"}
|
package/types/useStore.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Selector, Store, StoreInfo, UseStoreOptions } from './interfaces';
|
|
1
|
+
import type { Selector, Store, StoreInfo, UseStoreOptions } from './interfaces';
|
|
2
2
|
export declare function useStore<A, B extends Object>(StoreKlass: (new (props: B) => A) | (new () => A) | null | undefined, props?: B | null, options?: UseStoreOptions<A, any>): A;
|
|
3
3
|
export declare function useStoreDebug<A, B extends Object>(StoreKlass: (new (props: B) => A) | (new () => A), props?: B): A;
|
|
4
4
|
export declare function createStore<A, B extends Object>(StoreKlass: new (props: B) => A | (new () => A) | null | undefined, props?: B, options?: UseStoreOptions<A, any>): A;
|
package/types/useStore.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../src/useStore.tsx"],"names":[],"mappings":"AAYA,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"useStore.d.ts","sourceRoot":"","sources":["../src/useStore.tsx"],"names":[],"mappings":"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"}
|
package/types/useStoreDebug.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StoreInfo } from './interfaces';
|
|
1
|
+
import type { StoreInfo } from './interfaces';
|
|
2
2
|
export declare const useCurrentComponent: () => any;
|
|
3
3
|
export declare function useDebugStoreComponent(StoreCons: any): void;
|
|
4
4
|
export declare const shouldDebug: (component: any, info: Pick<StoreInfo, 'storeInstance'>) => boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useStoreDebug.d.ts","sourceRoot":"","sources":["../src/useStoreDebug.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"useStoreDebug.d.ts","sourceRoot":"","sources":["../src/useStoreDebug.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAI7C,eAAO,MAAM,mBAAmB,WAM/B,CAAA;AAED,wBAAgB,sBAAsB,CAAC,SAAS,EAAE,GAAG,QAiBpD;AAED,eAAO,MAAM,WAAW,cAAe,GAAG,QAAQ,KAAK,SAAS,EAAE,eAAe,CAAC,wBAGjF,CAAA;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA;AACvD,eAAO,MAAM,WAAW,UAAiB,CAAA"}
|