@tamagui/use-store 2.0.0-rc.8 → 2.0.0

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.
Files changed (101) hide show
  1. package/dist/cjs/comparators.cjs +18 -14
  2. package/dist/cjs/comparators.native.js +21 -17
  3. package/dist/cjs/comparators.native.js.map +1 -1
  4. package/dist/cjs/configureUseStore.cjs +12 -10
  5. package/dist/cjs/configureUseStore.native.js +12 -10
  6. package/dist/cjs/configureUseStore.native.js.map +1 -1
  7. package/dist/cjs/constants.cjs +17 -15
  8. package/dist/cjs/constants.native.js +17 -15
  9. package/dist/cjs/constants.native.js.map +1 -1
  10. package/dist/cjs/decorators.cjs +14 -11
  11. package/dist/cjs/decorators.native.js +14 -11
  12. package/dist/cjs/decorators.native.js.map +1 -1
  13. package/dist/cjs/helpers.cjs +28 -21
  14. package/dist/cjs/helpers.native.js +29 -23
  15. package/dist/cjs/helpers.native.js.map +1 -1
  16. package/dist/cjs/index.cjs +13 -11
  17. package/dist/cjs/index.native.js +30 -19
  18. package/dist/cjs/index.native.js.map +1 -1
  19. package/dist/cjs/interfaces.cjs +7 -5
  20. package/dist/cjs/interfaces.native.js +7 -5
  21. package/dist/cjs/interfaces.native.js.map +1 -1
  22. package/dist/cjs/observe.cjs +105 -59
  23. package/dist/cjs/observe.native.js +159 -111
  24. package/dist/cjs/observe.native.js.map +1 -1
  25. package/dist/cjs/useStore.cjs +271 -194
  26. package/dist/cjs/useStore.native.js +438 -374
  27. package/dist/cjs/useStore.native.js.map +1 -1
  28. package/dist/cjs/useStoreDebug.cjs +42 -31
  29. package/dist/cjs/useStoreDebug.native.js +42 -36
  30. package/dist/cjs/useStoreDebug.native.js.map +1 -1
  31. package/dist/esm/comparators.mjs +6 -4
  32. package/dist/esm/comparators.mjs.map +1 -1
  33. package/dist/esm/comparators.native.js +9 -7
  34. package/dist/esm/comparators.native.js.map +1 -1
  35. package/dist/esm/constants.mjs +5 -5
  36. package/dist/esm/constants.mjs.map +1 -1
  37. package/dist/esm/constants.native.js +5 -5
  38. package/dist/esm/constants.native.js.map +1 -1
  39. package/dist/esm/decorators.mjs +2 -1
  40. package/dist/esm/decorators.mjs.map +1 -1
  41. package/dist/esm/decorators.native.js +2 -1
  42. package/dist/esm/decorators.native.js.map +1 -1
  43. package/dist/esm/helpers.mjs +16 -11
  44. package/dist/esm/helpers.mjs.map +1 -1
  45. package/dist/esm/helpers.native.js +17 -13
  46. package/dist/esm/helpers.native.js.map +1 -1
  47. package/dist/esm/index.js +8 -12
  48. package/dist/esm/index.js.map +1 -6
  49. package/dist/esm/index.native.js +17 -8
  50. package/dist/esm/index.native.js.map +1 -1
  51. package/dist/esm/observe.mjs +77 -33
  52. package/dist/esm/observe.mjs.map +1 -1
  53. package/dist/esm/observe.native.js +128 -82
  54. package/dist/esm/observe.native.js.map +1 -1
  55. package/dist/esm/useStore.mjs +241 -166
  56. package/dist/esm/useStore.mjs.map +1 -1
  57. package/dist/esm/useStore.native.js +408 -346
  58. package/dist/esm/useStore.native.js.map +1 -1
  59. package/dist/esm/useStoreDebug.mjs +18 -9
  60. package/dist/esm/useStoreDebug.mjs.map +1 -1
  61. package/dist/esm/useStoreDebug.native.js +14 -10
  62. package/dist/esm/useStoreDebug.native.js.map +1 -1
  63. package/package.json +6 -9
  64. package/dist/cjs/comparators.js +0 -33
  65. package/dist/cjs/comparators.js.map +0 -6
  66. package/dist/cjs/configureUseStore.js +0 -25
  67. package/dist/cjs/configureUseStore.js.map +0 -6
  68. package/dist/cjs/constants.js +0 -25
  69. package/dist/cjs/constants.js.map +0 -6
  70. package/dist/cjs/decorators.js +0 -25
  71. package/dist/cjs/decorators.js.map +0 -6
  72. package/dist/cjs/helpers.js +0 -50
  73. package/dist/cjs/helpers.js.map +0 -6
  74. package/dist/cjs/index.js +0 -34
  75. package/dist/cjs/index.js.map +0 -6
  76. package/dist/cjs/interfaces.js +0 -14
  77. package/dist/cjs/interfaces.js.map +0 -6
  78. package/dist/cjs/observe.js +0 -105
  79. package/dist/cjs/observe.js.map +0 -6
  80. package/dist/cjs/useStore.js +0 -353
  81. package/dist/cjs/useStore.js.map +0 -6
  82. package/dist/cjs/useStoreDebug.js +0 -46
  83. package/dist/cjs/useStoreDebug.js.map +0 -6
  84. package/dist/esm/comparators.js +0 -17
  85. package/dist/esm/comparators.js.map +0 -6
  86. package/dist/esm/configureUseStore.js +0 -9
  87. package/dist/esm/configureUseStore.js.map +0 -6
  88. package/dist/esm/constants.js +0 -9
  89. package/dist/esm/constants.js.map +0 -6
  90. package/dist/esm/decorators.js +0 -9
  91. package/dist/esm/decorators.js.map +0 -6
  92. package/dist/esm/helpers.js +0 -34
  93. package/dist/esm/helpers.js.map +0 -6
  94. package/dist/esm/interfaces.js +0 -1
  95. package/dist/esm/interfaces.js.map +0 -6
  96. package/dist/esm/observe.js +0 -84
  97. package/dist/esm/observe.js.map +0 -6
  98. package/dist/esm/useStore.js +0 -340
  99. package/dist/esm/useStore.js.map +0 -6
  100. package/dist/esm/useStoreDebug.js +0 -22
  101. package/dist/esm/useStoreDebug.js.map +0 -6
@@ -1,353 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var useStore_exports = {};
24
- __export(useStore_exports, {
25
- allStores: () => allStores,
26
- createStore: () => createStore,
27
- createUseStore: () => createUseStore,
28
- createUseStoreSelector: () => createUseStoreSelector,
29
- getOrCreateStore: () => getOrCreateStore,
30
- getStore: () => getStore,
31
- getStoreInfo: () => getStoreInfo,
32
- onCreateStore: () => onCreateStore,
33
- setIsInReaction: () => setIsInReaction,
34
- trackStoresAccess: () => trackStoresAccess,
35
- useGlobalStore: () => useGlobalStore,
36
- useGlobalStoreSelector: () => useGlobalStoreSelector,
37
- useStore: () => useStore,
38
- useStoreDebug: () => useStoreDebug,
39
- useStoreSelector: () => useStoreSelector
40
- });
41
- module.exports = __toCommonJS(useStore_exports);
42
- var import_react = __toESM(require("react"), 1), import_comparators = require("./comparators"), import_configureUseStore = require("./configureUseStore"), import_constants = require("./constants"), import_helpers = require("./helpers"), import_useStoreDebug = require("./useStoreDebug");
43
- const idFn = (_) => _;
44
- function useStore(StoreKlass, props, options = import_constants.defaultOptions) {
45
- const info = getOrCreateStoreInfo(StoreKlass, props, options);
46
- return useStoreFromInfo(info, options.selector, options);
47
- }
48
- function useStoreDebug(StoreKlass, props) {
49
- return useStore(StoreKlass, props, { debug: !0 });
50
- }
51
- function createStore(StoreKlass, props, options) {
52
- return getOrCreateStoreInfo(StoreKlass, props, options)?.store;
53
- }
54
- function useGlobalStore(instance, debug) {
55
- const store = instance[import_constants.UNWRAP_PROXY], uid = (0, import_helpers.getStoreUid)(store.constructor, store.props), info = import_helpers.cache.get(uid);
56
- if (!info)
57
- throw new Error("This store not created using createStore()");
58
- return useStoreFromInfo(info, void 0, { debug });
59
- }
60
- function useGlobalStoreSelector(instance, selector, debug) {
61
- const store = instance[import_constants.UNWRAP_PROXY], uid = (0, import_helpers.getStoreUid)(store.constructor, store.props), info = import_helpers.cache.get(uid);
62
- if (!info)
63
- throw new Error("This store not created using createStore()");
64
- return useStoreFromInfo(info, selector, { debug });
65
- }
66
- function createUseStore(StoreKlass) {
67
- return (props, options) => useStore(StoreKlass, props, options);
68
- }
69
- function createUseStoreSelector(StoreKlass, selector) {
70
- return (props) => useStore(StoreKlass, props, { selector });
71
- }
72
- function useStoreSelector(StoreKlass, selector, props) {
73
- return useStore(StoreKlass, props, { selector });
74
- }
75
- const storeAccessTrackers = /* @__PURE__ */ new Set();
76
- function trackStoresAccess(cb) {
77
- return storeAccessTrackers.add(cb), () => {
78
- storeAccessTrackers.delete(cb);
79
- };
80
- }
81
- function getStore(StoreKlass, props) {
82
- return getStoreInfo(StoreKlass, props)?.store;
83
- }
84
- function getOrCreateStore(StoreKlass, props) {
85
- return getOrCreateStoreInfo(StoreKlass, props, {
86
- refuseCreation: !1
87
- })?.store;
88
- }
89
- function getStoreInfo(StoreKlass, props) {
90
- return getOrCreateStoreInfo(StoreKlass, props, {
91
- refuseCreation: !0
92
- });
93
- }
94
- const onCreateListeners = /* @__PURE__ */ new Set();
95
- function onCreateStore(cb) {
96
- return onCreateListeners.add(cb), () => {
97
- onCreateListeners.delete(cb);
98
- };
99
- }
100
- function getOrCreateStoreInfo(StoreKlass, props, options, propsKeyCalculated) {
101
- if (!StoreKlass)
102
- return null;
103
- const uid = (0, import_helpers.getStoreUid)(StoreKlass, propsKeyCalculated ?? props);
104
- if (!options?.avoidCache && import_helpers.cache.has(uid))
105
- return import_helpers.cache.get(uid);
106
- if (options?.refuseCreation)
107
- throw new Error(`No store exists (${StoreKlass.name}) with props: ${props}`);
108
- const storeInstance = new StoreKlass(props);
109
- storeInstance.props = props;
110
- const getters = {}, actions = {}, stateKeys = /* @__PURE__ */ new Set(), descriptors = (0, import_helpers.getStoreDescriptors)(storeInstance);
111
- for (const key in descriptors) {
112
- const descriptor = descriptors[key];
113
- typeof descriptor.value == "function" ? actions[key] = descriptor.value : typeof descriptor.get == "function" ? getters[key] = descriptor.get : key !== "props" && key[0] !== "_" && stateKeys.add(key);
114
- }
115
- const keyComparators = storeInstance._comparators, listeners = /* @__PURE__ */ new Set(), storeInfo = {
116
- uid,
117
- keyComparators,
118
- storeInstance,
119
- getters,
120
- stateKeys,
121
- props,
122
- actions,
123
- debug: options?.debug,
124
- disableTracking: !1,
125
- gettersState: {
126
- getCache: /* @__PURE__ */ new Map(),
127
- depsToGetter: /* @__PURE__ */ new Map(),
128
- curGetKeys: /* @__PURE__ */ new Set(),
129
- isGetting: !1
130
- },
131
- listeners,
132
- trackers: /* @__PURE__ */ new Set(),
133
- version: 0,
134
- subscribe: (onChanged) => (listeners.add(onChanged), () => {
135
- listeners.delete(onChanged);
136
- }),
137
- triggerUpdate: () => {
138
- storeInfo.version = (storeInfo.version + 1) % Number.MAX_SAFE_INTEGER;
139
- for (const cb of listeners)
140
- cb();
141
- }
142
- }, store = createProxiedStore(
143
- // we assign store right after and proxiedStore never accesses it until later on
144
- storeInfo
145
- );
146
- process.env.NODE_ENV === "development" && (allStores[StoreKlass.name + uid] = store), store.mount?.(), storeInfo.store = store;
147
- const result = storeInfo;
148
- return import_helpers.cache.set(uid, result), onCreateListeners.forEach((cb) => cb(result)), result;
149
- }
150
- const allStores = {};
151
- process.env.NODE_ENV === "development" && (globalThis.Store ||= allStores);
152
- const emptyObj = {}, selectKeys = (obj, keys) => {
153
- if (!keys.length)
154
- return emptyObj;
155
- const res = {};
156
- for (const key of keys)
157
- res[key] = obj[key];
158
- return res;
159
- };
160
- let isInReaction = !1;
161
- const setIsInReaction = (val) => {
162
- isInReaction = val;
163
- };
164
- function useStoreFromInfo(info, userSelector, options) {
165
- const store = info?.store, internal = import_react.default.useRef(void 0), component = (0, import_useStoreDebug.useCurrentComponent)();
166
- internal.current || (internal.current = {
167
- component,
168
- tracked: /* @__PURE__ */ new Set(),
169
- last: null,
170
- lastKeys: null
171
- });
172
- const curInternal = internal.current, shouldPrintDebug = options?.debug, getSnapshot = import_react.default.useCallback(() => {
173
- if (!info || !store) return;
174
- const curInternal2 = internal.current, isTracking = curInternal2.tracked.size, keys = [...isTracking ? curInternal2.tracked : info.stateKeys], nextKeys = `${info.version}${keys.join("")}${userSelector || ""}`, lastKeys = curInternal2.lastKeys;
175
- if (nextKeys === curInternal2.lastKeys)
176
- return curInternal2.last;
177
- curInternal2.lastKeys = nextKeys;
178
- let snap;
179
- info.disableTracking = !0;
180
- const last = curInternal2.last;
181
- userSelector ? snap = userSelector(store) : snap = selectKeys(store, keys), info.disableTracking = !1;
182
- const isUnchanged = !userSelector && !isTracking && last || typeof last < "u" && (0, import_comparators.isEqualSubsetShallow)(last, snap, {
183
- keyComparators: info.keyComparators
184
- });
185
- return shouldPrintDebug && console.info("\u{1F311} getSnapshot", {
186
- storeState: selectKeys(store, Object.keys(store)),
187
- userSelector,
188
- info,
189
- isUnchanged,
190
- component,
191
- keys,
192
- last,
193
- snap,
194
- curInternal: curInternal2,
195
- nextKeys,
196
- lastKeys
197
- }), isUnchanged ? last : (curInternal2.last = snap, snap);
198
- }, [store]), state = import_react.default.useSyncExternalStore(
199
- info?.subscribe || idFn,
200
- getSnapshot,
201
- getSnapshot
202
- );
203
- return !info || !store || !state || userSelector ? state : new Proxy(store, {
204
- get(target, key) {
205
- const curVal = Reflect.get(target, key);
206
- if (isInReaction)
207
- return curVal;
208
- const keyString = key;
209
- 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;
210
- }
211
- });
212
- }
213
- let setters = /* @__PURE__ */ new Set();
214
- const logStack = /* @__PURE__ */ new Set();
215
- function createProxiedStore(storeInfo) {
216
- const { actions, storeInstance, getters, gettersState } = storeInfo, { getCache, curGetKeys, depsToGetter } = gettersState, constr = storeInstance.constructor, shouldDebug2 = storeInfo.debug ?? import_useStoreDebug.DebugStores.has(constr);
217
- let didSet = !1;
218
- const wrappedActions = {};
219
- for (const key in actions) {
220
- if (key === "subscribe")
221
- continue;
222
- const actionFn = actions[key], isGetFn = key.startsWith("get");
223
- if (wrappedActions[key] = function(...args) {
224
- let res;
225
- 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));
226
- }, process.env.NODE_ENV === "development") {
227
- let hashCode = function(str) {
228
- let hash = 0;
229
- for (let i = 0; i < str.length; i++)
230
- hash = str.charCodeAt(i) + ((hash << 5) - hash);
231
- return hash;
232
- }, strColor = function(str) {
233
- return `hsl(${hashCode(str) % 360}, 90%, 40%)`;
234
- };
235
- if (!key.startsWith("get") && !key.startsWith("_") && key !== "subscribe") {
236
- const ogAction = wrappedActions[key];
237
- wrappedActions[key] = new Proxy(ogAction, {
238
- apply(target, thisArg, args) {
239
- const isDebugging = shouldDebug2 || storeInfo.debug;
240
- if (!(process.env.LOG_LEVEL !== "0" && (isDebugging || import_configureUseStore.configureOpts.logLevel !== "error")))
241
- return Reflect.apply(target, thisArg, args);
242
- setters = /* @__PURE__ */ new Set();
243
- const curSetters = setters, isTopLevelLogger = logStack.size == 0, logs = /* @__PURE__ */ new Set();
244
- logStack.add(logs);
245
- let res;
246
- const id = counter++;
247
- try {
248
- res = Reflect.apply(target, thisArg, args);
249
- } catch (err) {
250
- throw console.error("Error", err), err;
251
- } finally {
252
- logStack.add("end");
253
- const name = constr.name, color = strColor(name), simpleArgs = args.map(import_helpers.simpleStr);
254
- if (logs.add([
255
- `%c \u{1F311} ${id} ${name.padStart(
256
- isTopLevelLogger ? 8 : 4
257
- )}%c.${key}(${simpleArgs.join(", ")})${isTopLevelLogger && logStack.size > 1 ? ` (+${logStack.size - 1})` : ""}`,
258
- `color: ${color};`,
259
- "color: black;"
260
- ]), curSetters.size && curSetters.forEach(({ key: key2, value }) => {
261
- typeof value == "string" || typeof value == "number" || typeof value == "boolean" ? logs.add([` SET ${key2} ${value}`, value]) : logs.add([` SET ${key2}`, value]);
262
- }), isTopLevelLogger) {
263
- let error = null;
264
- try {
265
- for (const item of logStack) {
266
- if (item === "end") {
267
- console.groupEnd();
268
- continue;
269
- }
270
- const [head, ...rest] = item;
271
- if (head) {
272
- console.groupCollapsed(...head), console.groupCollapsed("..."), console.info("args", args), console.info("response", res), console.groupCollapsed("trace"), console.trace(), console.groupEnd(), console.groupEnd();
273
- for (const [name2, ...log] of rest)
274
- console.groupCollapsed(name2), console.info(...log), console.groupEnd();
275
- } else
276
- console.info("Weird log", head, ...rest);
277
- }
278
- } catch (err) {
279
- error = err;
280
- }
281
- for (const _ of logStack)
282
- console.groupEnd();
283
- error && console.error("error loggin", error), logStack.clear();
284
- }
285
- return res;
286
- }
287
- }
288
- });
289
- }
290
- }
291
- }
292
- const finishAction = (val) => (process.env.NODE_ENV === "development" && shouldDebug2 && console.info("(debug) finishAction", { didSet }), didSet && (storeInfo.triggerUpdate(), didSet = !1), val);
293
- let isTriggering = !1;
294
- const proxiedStore = new Proxy(storeInstance, {
295
- // GET
296
- get(_, key) {
297
- if (key in wrappedActions)
298
- return wrappedActions[key];
299
- if (key in passThroughKeys)
300
- return Reflect.get(storeInstance, key);
301
- if (key === import_constants.UNWRAP_PROXY)
302
- return storeInstance;
303
- if (key === import_helpers.UNWRAP_STORE_INFO)
304
- return storeInfo;
305
- if (storeAccessTrackers.size && storeAccessTrackers.forEach((cb) => cb(storeInfo)), typeof key != "string")
306
- return Reflect.get(storeInstance, key);
307
- if (storeInfo.disableTracking || gettersState.isGetting && gettersState.curGetKeys.add(key), key in getters) {
308
- if (getCache.has(key))
309
- return getCache.get(key);
310
- curGetKeys.clear();
311
- const isSubGetter = gettersState.isGetting;
312
- gettersState.isGetting = !0;
313
- const res = getters[key].call(proxiedStore);
314
- isSubGetter || (gettersState.isGetting = !1);
315
- for (const gk of curGetKeys)
316
- depsToGetter.has(gk) || depsToGetter.set(gk, /* @__PURE__ */ new Set()), depsToGetter.get(gk).add(key);
317
- return getCache.set(key, res), res;
318
- }
319
- return Reflect.get(storeInstance, key);
320
- },
321
- // SET
322
- set(target, key, value, receiver) {
323
- const cur = Reflect.get(target, key), res = Reflect.set(target, key, value, receiver);
324
- return res && cur !== value && (typeof key == "string" && (clearGetterCache(key), shouldDebug2 && (setters.add({ key, value }), getShouldDebug(storeInfo) && console.info("(debug) SET", res, key, value)), process.env.NODE_ENV === "development" && shouldDebug2 && console.info("SET...", { key, value })), isTriggering || (isTriggering = !0, waitForEventLoop(() => {
325
- storeInfo.triggerUpdate(), isTriggering = !1;
326
- }))), res;
327
- }
328
- });
329
- function clearGetterCache(setKey) {
330
- const parentGetters = depsToGetter.get(setKey);
331
- if (getCache.delete(setKey), !!parentGetters)
332
- for (const gk of parentGetters)
333
- getCache.delete(gk), depsToGetter.has(gk) && clearGetterCache(gk);
334
- }
335
- return proxiedStore;
336
- }
337
- const waitForEventLoop = process.env.NODE_ENV === "test" ? (cb) => cb() : queueMicrotask;
338
- let counter = 0;
339
- const passThroughKeys = {
340
- subscribe: !0,
341
- _version: !0,
342
- _trackers: !0,
343
- $$typeof: !0,
344
- _listeners: !0,
345
- _enableTracking: !0
346
- };
347
- function getShouldDebug(storeInfo) {
348
- const info = { storeInstance: storeInfo.store };
349
- return [...storeInfo.trackers].some(
350
- (tracker) => tracker.component && (0, import_useStoreDebug.shouldDebug)(tracker.component, info)
351
- );
352
- }
353
- //# sourceMappingURL=useStore.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/useStore.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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MAAM,CAAC,GACtB,eAAe,SAAS,KAC1B,QAAQ,KAAK,eAAe,KAAK,KAAK,KAAK,IAG3C,QAAQ,IAAI,aAAa,iBAAiBA,gBAC5C,QAAQ,KAAK,UAAU,EAAE,KAAK,MAAM,CAAC,IAIpC,iBAEH,eAAe,IACf,iBAAiB,MAAM;AACrB,kBAAU,cAAc,GACxB,eAAe;AAAA,MACjB,CAAC,KAGE;AAAA,IACT;AAAA,EACF,CAAC;AAED,WAAS,iBAAiB,QAAgB;AACxC,UAAM,gBAAgB,aAAa,IAAI,MAAM;AAG7C,QAFA,SAAS,OAAO,MAAM,GAElB,EAAC;AAGL,iBAAW,MAAM;AACf,iBAAS,OAAO,EAAE,GACd,aAAa,IAAI,EAAE,KACrB,iBAAiB,EAAE;AAAA,EAGzB;AAEA,SAAO;AACT;AAEA,MAAM,mBACJ,QAAQ,IAAI,aAAa,SACrB,CAAC,OAAiB,GAAG,IACrB;AAEN,IAAI,UAAU;AAEd,MAAM,kBAAkB;AAAA,EACtB,WAAW;AAAA,EACX,UAAU;AAAA,EACV,WAAW;AAAA,EACX,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,iBAAiB;AACnB;AASA,SAAS,eAAe,WAAsB;AAC5C,QAAM,OAAO,EAAE,eAAe,UAAU,MAAM;AAE9C,SAAO,CAAC,GADS,UAAU,QACR,EAAE;AAAA,IACnB,CAAC,YAAY,QAAQ,iBAAa,kCAAY,QAAQ,WAAW,IAAI;AAAA,EACvE;AACF;",
5
- "names": ["React", "curInternal", "shouldDebug", "key", "name"]
6
- }
@@ -1,46 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: !0 });
9
- }, __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from == "object" || typeof from == "function")
11
- for (let key of __getOwnPropNames(from))
12
- !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
13
- return to;
14
- };
15
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
16
- // If the importer is in node compatibility mode or this is not an ESM
17
- // file that has been converted to a CommonJS file using a Babel-
18
- // compatible transform (i.e. "__esModule" has not been set), then set
19
- // "default" to the CommonJS "module.exports" for node compatibility.
20
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target,
21
- mod
22
- )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod);
23
- var useStoreDebug_exports = {};
24
- __export(useStoreDebug_exports, {
25
- DebugComponents: () => DebugComponents,
26
- DebugStores: () => DebugStores,
27
- shouldDebug: () => shouldDebug,
28
- useCurrentComponent: () => useCurrentComponent,
29
- useDebugStoreComponent: () => useDebugStoreComponent
30
- });
31
- module.exports = __toCommonJS(useStoreDebug_exports);
32
- var import_react = __toESM(require("react"), 1);
33
- const useCurrentComponent = () => ({});
34
- function useDebugStoreComponent(StoreCons) {
35
- const cmp = useCurrentComponent();
36
- DebugStores.add(StoreCons), DebugComponents.has(cmp) || DebugComponents.set(cmp, /* @__PURE__ */ new Set());
37
- const stores = DebugComponents.get(cmp);
38
- stores.add(StoreCons), import_react.default.useLayoutEffect(() => () => {
39
- DebugStores.delete(StoreCons), stores.delete(StoreCons);
40
- }, []);
41
- }
42
- const shouldDebug = (component, info) => {
43
- const StoreCons = info.storeInstance?.constructor;
44
- return DebugComponents.get(component)?.has(StoreCons);
45
- }, DebugComponents = /* @__PURE__ */ new Map(), DebugStores = /* @__PURE__ */ new Set();
46
- //# sourceMappingURL=useStoreDebug.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/useStoreDebug.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAkB;AAMX,MAAM,sBAAsB,OAC1B,CAAC;AAQH,SAAS,uBAAuB,WAAgB;AACrD,QAAM,MAAM,oBAAoB;AAGhC,cAAY,IAAI,SAAS,GACpB,gBAAgB,IAAI,GAAG,KAC1B,gBAAgB,IAAI,KAAK,oBAAI,IAAI,CAAC;AAEpC,QAAM,SAAS,gBAAgB,IAAI,GAAG;AACtC,SAAO,IAAI,SAAS,GAEpB,aAAAA,QAAM,gBAAgB,MACb,MAAM;AACX,gBAAY,OAAO,SAAS,GAC5B,OAAO,OAAO,SAAS;AAAA,EACzB,GACC,CAAC,CAAC;AACP;AAEO,MAAM,cAAc,CAAC,WAAgB,SAA2C;AACrF,QAAM,YAAY,KAAK,eAAe;AACtC,SAAO,gBAAgB,IAAI,SAAS,GAAG,IAAI,SAAS;AACtD,GAEa,kBAAkB,oBAAI,IAAmB,GACzC,cAAc,oBAAI,IAAS;",
5
- "names": ["React"]
6
- }
@@ -1,17 +0,0 @@
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])
8
- return !1;
9
- }
10
- return !0;
11
- }
12
- return a === b;
13
- };
14
- export {
15
- isEqualSubsetShallow
16
- };
17
- //# sourceMappingURL=comparators.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/comparators.tsx"],
4
- "mappings": "AAAO,MAAM,uBAAuB,CAClC,GACA,GACA,SACG;AACH,MAAI,KAAK,QAAQ,KAAK,KAAM,QAAO,MAAM;AACzC,MAAI,OAAO,KAAM,OAAO,EAAG,QAAO;AAClC,MAAI,OAAO,KAAM,UAAU;AACzB,eAAW,OAAO,GAAG;AACnB,YAAM,UAAU,MAAM,iBAAiB,GAAG;AAC1C,UAAI,UAAU,CAAC,QAAQ,EAAE,GAAG,GAAG,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,MAAM,EAAE,GAAG;AACvD,eAAO;AAAA,IAEX;AACA,WAAO;AAAA,EACT;AACA,SAAO,MAAM;AACf;",
5
- "names": []
6
- }
@@ -1,9 +0,0 @@
1
- let configureOpts = {};
2
- function configureUseStore(opts) {
3
- configureOpts = opts;
4
- }
5
- export {
6
- configureOpts,
7
- configureUseStore
8
- };
9
- //# sourceMappingURL=configureUseStore.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/configureUseStore.tsx"],
4
- "mappings": "AAEO,IAAI,gBAAgC,CAAC;AAErC,SAAS,kBAAkB,MAAsB;AACtD,kBAAgB;AAClB;",
5
- "names": []
6
- }
@@ -1,9 +0,0 @@
1
- const UNWRAP_PROXY = /* @__PURE__ */ Symbol(), defaultOptions = {
2
- once: !1,
3
- selector: void 0
4
- };
5
- export {
6
- UNWRAP_PROXY,
7
- defaultOptions
8
- };
9
- //# sourceMappingURL=constants.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/constants.tsx"],
4
- "mappings": "AAAO,MAAM,eAAe,uBAAO,GAEtB,iBAAiB;AAAA,EAC5B,MAAM;AAAA,EACN,UAAU;AACZ;",
5
- "names": []
6
- }
@@ -1,9 +0,0 @@
1
- function compare(comparator) {
2
- return (target, propertyKey) => {
3
- target._comparators = target._comparators || {}, target._comparators[propertyKey] = comparator;
4
- };
5
- }
6
- export {
7
- compare
8
- };
9
- //# sourceMappingURL=decorators.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/decorators.tsx"],
4
- "mappings": "AAEO,SAAS,QAAQ,YAA0B;AAChD,SAAO,CAAC,QAAa,gBAA6B;AAChD,WAAO,eAAkB,OAAO,gBAAmB,CAAC,GACpD,OAAO,aAAgB,WAAW,IAAI;AAAA,EACxC;AACF;",
5
- "names": []
6
- }
@@ -1,34 +0,0 @@
1
- import { simpleHash } from "@tamagui/simple-hash";
2
- function getStoreUid(Constructor, props) {
3
- return simpleHash(
4
- `${Constructor}${props ? typeof props == "string" ? props : JSON.stringify(props) : ""}`,
5
- "strict"
6
- );
7
- }
8
- const UNWRAP_STORE_INFO = /* @__PURE__ */ Symbol("UNWRAP_STORE_INFO"), cache = /* @__PURE__ */ new Map();
9
- function getStoreDescriptors(storeInstance) {
10
- const proto = Object.getPrototypeOf(storeInstance), instanceDescriptors = Object.getOwnPropertyDescriptors(storeInstance), 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 {
26
- UNWRAP_STORE_INFO,
27
- cache,
28
- get,
29
- getStoreDebugInfo,
30
- getStoreDescriptors,
31
- getStoreUid,
32
- simpleStr
33
- };
34
- //# sourceMappingURL=helpers.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/helpers.tsx"],
4
- "mappings": "AAAA,SAAS,kBAAkB;AAIpB,SAAS,YAAY,aAAkB,OAA+B;AAC3E,SAAO;AAAA,IACL,GAAG,WAAW,GACX,QAAa,OAAO,SAAU,WAAW,QAAQ,KAAK,UAAU,KAAK,IAA7D,EACX;AAAA,IACA;AAAA,EACF;AACF;AAEO,MAAM,oBAAoB,uBAAO,mBAAmB,GAC9C,QAAQ,oBAAI,IAAuB;AAEzC,SAAS,oBAAoB,eAAoB;AACtD,QAAM,QAAQ,OAAO,eAAe,aAAa,GAC3C,sBAAsB,OAAO,0BAA0B,aAAa,GAEpE,cAAc;AAAA,IAClB,GAFuB,OAAO,0BAA0B,KAAK;AAAA,IAG7D,GAAG;AAAA,EACL;AAEA,gBAAO,YAAY,aACZ;AACT;AAEO,SAAS,IAAO,GAAM,GAAyD;AACpF,SAAO;AACT;AAEO,SAAS,UAAU,KAAU;AAClC,SAAI,QAAQ,IAAI,aAAa,gBACpB,OAAO,OAAQ,aAClB,OACA,OAAO,OAAQ,WACb,IAAI,GAAG,MACN,QAEC,OAAO,OAAQ,WACb,MACA,MAAM,QAAQ,GAAG,IACf,UACA,WAEP;AACT;AAGO,SAAS,kBAAkB,OAAY;AAC5C,SACE,MAAM,iBAAiB,KAAK,MAAM,IAAI,YAAY,MAAM,aAAa,MAAM,KAAK,CAAC;AAErF;",
5
- "names": []
6
- }
@@ -1 +0,0 @@
1
- //# sourceMappingURL=interfaces.js.map
@@ -1,6 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": [],
4
- "mappings": "",
5
- "names": []
6
- }
@@ -1,84 +0,0 @@
1
- import React from "react";
2
- import { isEqualSubsetShallow } from "./comparators";
3
- import { UNWRAP_PROXY } from "./constants";
4
- import { trackStoresAccess } from "./useStore";
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}` : ""}`, storeNames = stores.map(getStoreLogName).join(", "), name = `\u{1F311} \u25B6\uFE0F %c${fn.name} ${storeNames} () ${last} => ${next}`;
7
- console.groupCollapsed(name, "color: tomato;"), console.groupCollapsed("trace >"), console.trace(), console.groupEnd(), console.info(" next", next), console.groupEnd();
8
- } : null;
9
- function observe(fn) {
10
- let prev = getObserverValueAndStoresAccessed(fn), disposeValue = null;
11
- const subscribe = () => {
12
- const stores = [...prev.storeInfos];
13
- return subscribeToStores(stores, () => {
14
- disposeValue?.();
15
- const next = getObserverValueAndStoresAccessed(fn);
16
- if (typeof next.value == "function") {
17
- disposeValue = next.value, process.env.NODE_ENV === "development" && logUpdate(fn, [...next.storeInfos], "(fn)", "(fn)");
18
- return;
19
- }
20
- 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());
21
- });
22
- };
23
- let dispose = subscribe();
24
- return {
25
- dispose: () => {
26
- dispose(), disposeValue?.();
27
- },
28
- getValue: () => prev.value
29
- };
30
- }
31
- function useObserve(fn) {
32
- const [state, setState] = React.useState(() => getObserverValueAndStoresAccessed(fn));
33
- return React.useEffect(() => {
34
- let dispose;
35
- const unsub = subscribeToStores([...state.storeInfos], () => {
36
- dispose?.();
37
- const next = getObserverValueAndStoresAccessed(fn), nextStoreInfos = [...next.storeInfos], prevStoreInfos = [...state.storeInfos];
38
- if (typeof next.value == "function") {
39
- process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, "(fn)", "(fn)"), dispose = next.value;
40
- return;
41
- }
42
- setState((prev) => isEqualSubsetShallow(prevStoreInfos, nextStoreInfos) && isEqualSubsetShallow(prev.value, next.value) ? prev : (process.env.NODE_ENV === "development" && logUpdate(fn, nextStoreInfos, prev.value, next.value), next));
43
- });
44
- return () => {
45
- unsub(), dispose?.();
46
- };
47
- }, [[...state.storeInfos].map((i) => i.uid).join(",")]), state.value;
48
- }
49
- function getObserverValueAndStoresAccessed(selector) {
50
- const storeInfos = /* @__PURE__ */ new Set(), dispose = trackStoresAccess((storeInfo) => {
51
- storeInfos.add(storeInfo);
52
- }), value = selector();
53
- return dispose(), {
54
- value,
55
- storeInfos
56
- };
57
- }
58
- function subscribeToStores(storeInfos, onUpdate) {
59
- const disposes = [];
60
- let isUpdating = !1;
61
- const onUpdateDebouncedWithoutTracking = () => {
62
- isUpdating || (isUpdating = !0, queueMicrotask(() => {
63
- try {
64
- for (const storeInfo of storeInfos)
65
- storeInfo.disableTracking = !0;
66
- onUpdate();
67
- } finally {
68
- isUpdating = !1;
69
- for (const storeInfo of storeInfos)
70
- storeInfo.disableTracking = !1;
71
- }
72
- }));
73
- };
74
- for (const storeInfo of storeInfos)
75
- disposes.push(storeInfo.subscribe(onUpdateDebouncedWithoutTracking));
76
- return () => {
77
- disposes.forEach((x) => x());
78
- };
79
- }
80
- export {
81
- observe,
82
- useObserve
83
- };
84
- //# sourceMappingURL=observe.js.map