@powerhousedao/connect 1.0.0-dev.225 → 1.0.0-dev.227
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/dist/.env +1 -1
- package/dist/assets/Compass-C76eC2wG.js +7 -0
- package/dist/assets/DescendenceModified-342EmN5F.js +7 -0
- package/dist/assets/DownloadFile-CG56Of8p.js +7 -0
- package/dist/assets/ExportCsv-C7-cdsgH.js +7 -0
- package/dist/assets/ExportJson-dmS3d6_7.js +7 -0
- package/dist/assets/ExportPdf-DwZayNuB.js +7 -0
- package/dist/assets/ExportUbl-DwfYquKC.js +7 -0
- package/dist/assets/ExportZip-v1bseKb6.js +7 -0
- package/dist/assets/Tube-CxlaYTDX.js +7 -0
- package/dist/assets/{app-DS1CKnZX.js → app-CNNFwixT.js} +2679 -4936
- package/dist/assets/app-CSi6MS9b.css +5589 -0
- package/dist/assets/{app-loader-C6FgR-r9.css → app-loader-9W65A3zy.css} +396 -347
- package/dist/assets/{app-loader-CQk_i65y.js → app-loader-D-97SWGk.js} +584 -785
- package/dist/assets/{ccip-h0SFswcH.js → ccip-Cr6bQJks.js} +3 -3
- package/dist/assets/{content-dCYtAq_j.js → content-DutUK-bf.js} +64 -89
- package/dist/assets/{index-BaJByDnQ.js → index-BLTsDYqr.js} +4 -4
- package/dist/assets/{index-BP3HovgJ.js → index-CM6wHalm.js} +3 -3
- package/dist/assets/{index-BgGO2KiQ.js → index-CV70vblU.js} +34 -80
- package/dist/assets/{main.BTNubzb3.js → main.Bd8QiM-U.js} +1 -1
- package/dist/assets/{style-DFCtruT_.css → style-ICX7vBg_.css} +2 -2
- package/dist/assets/{types-b4BfZ8ti.js → types-DJg5CO3J.js} +9 -0
- package/dist/index.html +4 -4
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-M2UUQ5LH.js → chunk-56M56AY3.js} +4 -4
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-GAG4Z4JD.js → chunk-6VFLMUEK.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-G6LMXRY5.js → chunk-AVKPBC5Q.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-55TZMPQQ.js → chunk-C3OQGBKD.js} +11 -207
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-FW7N6EJH.js → chunk-D2ZLIUVV.js} +337 -378
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-X3GCDCJN.js → chunk-IIX6OOYS.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-F3RCGUF6.js → chunk-NNVEKADD.js} +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-726EFDQ6.js → chunk-X7WYJJFB.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-4C7V2GAN.js → chunk-Y2S6GVIW.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/{chunk-45DCPCA7.js → chunk-YIBO3HUQ.js} +1 -1
- package/dist/modules/@powerhousedao/reactor-browser/context/index.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/context/read-mode.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/index.js +10 -10
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useAddDebouncedOperations.js +3 -3
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useConnectCrypto.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentDrives.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDocumentEditor.js +7 -7
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActions.js +2 -2
- package/dist/modules/@powerhousedao/reactor-browser/hooks/useDriveActionsWithUiNodes.js +3 -3
- package/dist/modules/@powerhousedao/reactor-browser/index.js +12 -12
- package/dist/modules/@powerhousedao/reactor-browser/reactor.js +2 -2
- package/dist/swEnv.js +1 -1
- package/dist/vite-envs.sh +10 -10
- package/package.json +13 -12
- package/dist/assets/app-ClxoJuGw.css +0 -1242
- package/scripts/install-packages.js +0 -9
|
@@ -1,7 +1,65 @@
|
|
|
1
|
-
// ../../node_modules/.pnpm/jotai@2.
|
|
1
|
+
// ../../node_modules/.pnpm/jotai@2.11.1_@types+react@18.3.18_react@18.3.1/node_modules/jotai/esm/vanilla.mjs
|
|
2
|
+
var keyCount = 0;
|
|
3
|
+
function atom(read, write) {
|
|
4
|
+
const key = `atom${++keyCount}`;
|
|
5
|
+
const config = {
|
|
6
|
+
toString() {
|
|
7
|
+
return (import.meta.env ? import.meta.env.MODE : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key;
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
if (typeof read === "function") {
|
|
11
|
+
config.read = read;
|
|
12
|
+
} else {
|
|
13
|
+
config.init = read;
|
|
14
|
+
config.read = defaultRead;
|
|
15
|
+
config.write = defaultWrite;
|
|
16
|
+
}
|
|
17
|
+
if (write) {
|
|
18
|
+
config.write = write;
|
|
19
|
+
}
|
|
20
|
+
return config;
|
|
21
|
+
}
|
|
22
|
+
function defaultRead(get) {
|
|
23
|
+
return get(this);
|
|
24
|
+
}
|
|
25
|
+
function defaultWrite(get, set, arg) {
|
|
26
|
+
return set(
|
|
27
|
+
this,
|
|
28
|
+
typeof arg === "function" ? arg(get(this)) : arg
|
|
29
|
+
);
|
|
30
|
+
}
|
|
2
31
|
var isSelfAtom = (atom2, a) => atom2.unstable_is ? atom2.unstable_is(a) : a === atom2;
|
|
3
32
|
var hasInitialValue = (atom2) => "init" in atom2;
|
|
4
33
|
var isActuallyWritableAtom = (atom2) => !!atom2.write;
|
|
34
|
+
var cancelablePromiseMap = /* @__PURE__ */ new WeakMap();
|
|
35
|
+
var isPendingPromise = (value) => {
|
|
36
|
+
var _a;
|
|
37
|
+
return isPromiseLike(value) && !((_a = cancelablePromiseMap.get(value)) == null ? void 0 : _a[1]);
|
|
38
|
+
};
|
|
39
|
+
var cancelPromise = (promise, nextValue) => {
|
|
40
|
+
const promiseState = cancelablePromiseMap.get(promise);
|
|
41
|
+
if (promiseState) {
|
|
42
|
+
promiseState[1] = true;
|
|
43
|
+
promiseState[0].forEach((fn) => fn(nextValue));
|
|
44
|
+
} else if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
|
|
45
|
+
throw new Error("[Bug] cancelable promise not found");
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var patchPromiseForCancelability = (promise) => {
|
|
49
|
+
if (cancelablePromiseMap.has(promise)) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const promiseState = [/* @__PURE__ */ new Set(), false];
|
|
53
|
+
cancelablePromiseMap.set(promise, promiseState);
|
|
54
|
+
const settle = () => {
|
|
55
|
+
promiseState[1] = true;
|
|
56
|
+
};
|
|
57
|
+
promise.then(settle, settle);
|
|
58
|
+
promise.onCancel = (fn) => {
|
|
59
|
+
promiseState[0].add(fn);
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
var isPromiseLike = (p) => typeof (p == null ? void 0 : p.then) === "function";
|
|
5
63
|
var isAtomStateInitialized = (atomState) => "v" in atomState || "e" in atomState;
|
|
6
64
|
var returnAtomValue = (atomState) => {
|
|
7
65
|
if ("e" in atomState) {
|
|
@@ -12,31 +70,6 @@ var returnAtomValue = (atomState) => {
|
|
|
12
70
|
}
|
|
13
71
|
return atomState.v;
|
|
14
72
|
};
|
|
15
|
-
var promiseStateMap = /* @__PURE__ */ new WeakMap();
|
|
16
|
-
var isPendingPromise = (value) => {
|
|
17
|
-
var _a;
|
|
18
|
-
return isPromiseLike(value) && !!((_a = promiseStateMap.get(value)) == null ? void 0 : _a[0]);
|
|
19
|
-
};
|
|
20
|
-
var abortPromise = (promise) => {
|
|
21
|
-
const promiseState = promiseStateMap.get(promise);
|
|
22
|
-
if (promiseState == null ? void 0 : promiseState[0]) {
|
|
23
|
-
promiseState[0] = false;
|
|
24
|
-
promiseState[1].forEach((fn) => fn());
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
var registerAbortHandler = (promise, abortHandler) => {
|
|
28
|
-
let promiseState = promiseStateMap.get(promise);
|
|
29
|
-
if (!promiseState) {
|
|
30
|
-
promiseState = [true, /* @__PURE__ */ new Set()];
|
|
31
|
-
promiseStateMap.set(promise, promiseState);
|
|
32
|
-
const settle = () => {
|
|
33
|
-
promiseState[0] = false;
|
|
34
|
-
};
|
|
35
|
-
promise.then(settle, settle);
|
|
36
|
-
}
|
|
37
|
-
promiseState[1].add(abortHandler);
|
|
38
|
-
};
|
|
39
|
-
var isPromiseLike = (p) => typeof (p == null ? void 0 : p.then) === "function";
|
|
40
73
|
var addPendingPromiseToDependency = (atom2, promise, dependencyAtomState) => {
|
|
41
74
|
if (!dependencyAtomState.p.has(atom2)) {
|
|
42
75
|
dependencyAtomState.p.add(atom2);
|
|
@@ -50,99 +83,45 @@ var addPendingPromiseToDependency = (atom2, promise, dependencyAtomState) => {
|
|
|
50
83
|
);
|
|
51
84
|
}
|
|
52
85
|
};
|
|
53
|
-
var
|
|
54
|
-
const atomState = ensureAtomState(atom2);
|
|
55
|
-
const hasPrevValue = "v" in atomState;
|
|
56
|
-
const prevValue = atomState.v;
|
|
57
|
-
if (isPromiseLike(valueOrPromise)) {
|
|
58
|
-
for (const a of atomState.d.keys()) {
|
|
59
|
-
addPendingPromiseToDependency(atom2, valueOrPromise, ensureAtomState(a));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
atomState.v = valueOrPromise;
|
|
63
|
-
delete atomState.e;
|
|
64
|
-
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
|
|
65
|
-
++atomState.n;
|
|
66
|
-
if (isPromiseLike(prevValue)) {
|
|
67
|
-
abortPromise(prevValue);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
var getMountedOrPendingDependents = (atom2, atomState, mountedMap) => {
|
|
86
|
+
var addDependency = (atom2, atomState, a, aState) => {
|
|
72
87
|
var _a;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
if (mountedMap.has(a)) {
|
|
76
|
-
dependents.add(a);
|
|
77
|
-
}
|
|
88
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && a === atom2) {
|
|
89
|
+
throw new Error("[Bug] atom cannot depend on itself");
|
|
78
90
|
}
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
atomState.d.set(a, aState.n);
|
|
92
|
+
if (isPendingPromise(atomState.v)) {
|
|
93
|
+
addPendingPromiseToDependency(atom2, atomState.v, aState);
|
|
81
94
|
}
|
|
82
|
-
|
|
95
|
+
(_a = aState.m) == null ? void 0 : _a.t.add(atom2);
|
|
83
96
|
};
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return notify;
|
|
96
|
-
};
|
|
97
|
-
var createStoreHookForAtoms = () => {
|
|
98
|
-
const all = {};
|
|
99
|
-
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
100
|
-
const notify = (atom2) => {
|
|
101
|
-
var _a, _b;
|
|
102
|
-
(_a = callbacks.get(all)) == null ? void 0 : _a.forEach((fn) => fn(atom2));
|
|
103
|
-
(_b = callbacks.get(atom2)) == null ? void 0 : _b.forEach((fn) => fn());
|
|
104
|
-
};
|
|
105
|
-
notify.add = (atom2, fn) => {
|
|
106
|
-
const key = atom2 || all;
|
|
107
|
-
const fns = (callbacks.has(key) ? callbacks : callbacks.set(key, /* @__PURE__ */ new Set())).get(key);
|
|
108
|
-
fns.add(fn);
|
|
109
|
-
return () => {
|
|
110
|
-
fns == null ? void 0 : fns.delete(fn);
|
|
111
|
-
if (!fns.size) {
|
|
112
|
-
callbacks.delete(key);
|
|
113
|
-
}
|
|
114
|
-
};
|
|
115
|
-
};
|
|
116
|
-
return notify;
|
|
117
|
-
};
|
|
118
|
-
var initializeStoreHooks = (storeHooks) => {
|
|
119
|
-
storeHooks.c || (storeHooks.c = createStoreHookForAtoms());
|
|
120
|
-
storeHooks.m || (storeHooks.m = createStoreHookForAtoms());
|
|
121
|
-
storeHooks.u || (storeHooks.u = createStoreHookForAtoms());
|
|
122
|
-
storeHooks.f || (storeHooks.f = createStoreHook());
|
|
123
|
-
return storeHooks;
|
|
124
|
-
};
|
|
125
|
-
var BUILDING_BLOCKS = Symbol();
|
|
126
|
-
var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /* @__PURE__ */ new WeakMap(), invalidatedAtoms = /* @__PURE__ */ new WeakMap(), changedAtoms = /* @__PURE__ */ new Set(), mountCallbacks = /* @__PURE__ */ new Set(), unmountCallbacks = /* @__PURE__ */ new Set(), storeHooks = {}, atomRead = (atom2, ...params) => atom2.read(...params), atomWrite = (atom2, ...params) => atom2.write(...params), atomOnInit = (atom2, store) => {
|
|
127
|
-
var _a;
|
|
128
|
-
return (_a = atom2.unstable_onInit) == null ? void 0 : _a.call(atom2, store);
|
|
129
|
-
}, atomOnMount = (atom2, setAtom) => {
|
|
130
|
-
var _a;
|
|
131
|
-
return (_a = atom2.onMount) == null ? void 0 : _a.call(atom2, setAtom);
|
|
132
|
-
}, ...buildingBlockFunctions) => {
|
|
133
|
-
const ensureAtomState = buildingBlockFunctions[0] || ((atom2) => {
|
|
97
|
+
var INTERNAL_flushStoreHook = Symbol.for("JOTAI.EXPERIMENTAL.FLUSHSTOREHOOK");
|
|
98
|
+
var buildStore = (...storeArgs) => {
|
|
99
|
+
const [
|
|
100
|
+
getAtomState,
|
|
101
|
+
setAtomState,
|
|
102
|
+
atomRead,
|
|
103
|
+
atomWrite,
|
|
104
|
+
atomOnInit,
|
|
105
|
+
atomOnMount
|
|
106
|
+
] = storeArgs;
|
|
107
|
+
const ensureAtomState = (atom2) => {
|
|
134
108
|
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && !atom2) {
|
|
135
109
|
throw new Error("Atom is undefined or null");
|
|
136
110
|
}
|
|
137
|
-
let atomState =
|
|
111
|
+
let atomState = getAtomState(atom2);
|
|
138
112
|
if (!atomState) {
|
|
139
113
|
atomState = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 };
|
|
140
|
-
|
|
114
|
+
setAtomState(atom2, atomState);
|
|
141
115
|
atomOnInit == null ? void 0 : atomOnInit(atom2, store);
|
|
142
116
|
}
|
|
143
117
|
return atomState;
|
|
144
|
-
}
|
|
145
|
-
const
|
|
118
|
+
};
|
|
119
|
+
const invalidatedAtoms = /* @__PURE__ */ new WeakMap();
|
|
120
|
+
const changedAtoms = /* @__PURE__ */ new Map();
|
|
121
|
+
const unmountCallbacks = /* @__PURE__ */ new Set();
|
|
122
|
+
const mountCallbacks = /* @__PURE__ */ new Set();
|
|
123
|
+
const flushCallbacks = () => {
|
|
124
|
+
var _a;
|
|
146
125
|
const errors = [];
|
|
147
126
|
const call = (fn) => {
|
|
148
127
|
try {
|
|
@@ -152,14 +131,12 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
152
131
|
}
|
|
153
132
|
};
|
|
154
133
|
do {
|
|
155
|
-
|
|
156
|
-
call(storeHooks.f);
|
|
157
|
-
}
|
|
134
|
+
(_a = store[INTERNAL_flushStoreHook]) == null ? void 0 : _a.call(store);
|
|
158
135
|
const callbacks = /* @__PURE__ */ new Set();
|
|
159
136
|
const add = callbacks.add.bind(callbacks);
|
|
160
|
-
changedAtoms.forEach((
|
|
161
|
-
var
|
|
162
|
-
return (
|
|
137
|
+
changedAtoms.forEach((atomState) => {
|
|
138
|
+
var _a2;
|
|
139
|
+
return (_a2 = atomState.m) == null ? void 0 : _a2.l.forEach(add);
|
|
163
140
|
});
|
|
164
141
|
changedAtoms.clear();
|
|
165
142
|
unmountCallbacks.forEach(add);
|
|
@@ -172,59 +149,35 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
172
149
|
}
|
|
173
150
|
} while (changedAtoms.size || unmountCallbacks.size || mountCallbacks.size);
|
|
174
151
|
if (errors.length) {
|
|
175
|
-
throw
|
|
152
|
+
throw errors[0];
|
|
176
153
|
}
|
|
177
|
-
}
|
|
178
|
-
const
|
|
179
|
-
const
|
|
180
|
-
const
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
const a
|
|
185
|
-
|
|
186
|
-
if (visited.has(a)) {
|
|
187
|
-
stack.pop();
|
|
188
|
-
continue;
|
|
189
|
-
}
|
|
190
|
-
if (visiting.has(a)) {
|
|
191
|
-
if (invalidatedAtoms.get(a) === aState.n) {
|
|
192
|
-
topSortedReversed.push([a, aState]);
|
|
193
|
-
} else if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && invalidatedAtoms.has(a)) {
|
|
194
|
-
throw new Error("[Bug] invalidated atom exists");
|
|
195
|
-
}
|
|
196
|
-
visited.add(a);
|
|
197
|
-
stack.pop();
|
|
198
|
-
continue;
|
|
199
|
-
}
|
|
200
|
-
visiting.add(a);
|
|
201
|
-
for (const d of getMountedOrPendingDependents(a, aState, mountedMap)) {
|
|
202
|
-
if (!visiting.has(d)) {
|
|
203
|
-
stack.push(d);
|
|
204
|
-
}
|
|
154
|
+
};
|
|
155
|
+
const setAtomStateValueOrPromise = (atom2, atomState, valueOrPromise) => {
|
|
156
|
+
const hasPrevValue = "v" in atomState;
|
|
157
|
+
const prevValue = atomState.v;
|
|
158
|
+
const pendingPromise = isPendingPromise(atomState.v) ? atomState.v : null;
|
|
159
|
+
if (isPromiseLike(valueOrPromise)) {
|
|
160
|
+
patchPromiseForCancelability(valueOrPromise);
|
|
161
|
+
for (const a of atomState.d.keys()) {
|
|
162
|
+
addPendingPromiseToDependency(atom2, valueOrPromise, ensureAtomState(a));
|
|
205
163
|
}
|
|
164
|
+
atomState.v = valueOrPromise;
|
|
165
|
+
} else {
|
|
166
|
+
atomState.v = valueOrPromise;
|
|
206
167
|
}
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
hasChangedDeps = true;
|
|
213
|
-
break;
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
if (hasChangedDeps) {
|
|
217
|
-
readAtomState(a);
|
|
218
|
-
mountDependencies(a);
|
|
168
|
+
delete atomState.e;
|
|
169
|
+
if (!hasPrevValue || !Object.is(prevValue, atomState.v)) {
|
|
170
|
+
++atomState.n;
|
|
171
|
+
if (pendingPromise) {
|
|
172
|
+
cancelPromise(pendingPromise, valueOrPromise);
|
|
219
173
|
}
|
|
220
|
-
invalidatedAtoms.delete(a);
|
|
221
174
|
}
|
|
222
|
-
}
|
|
223
|
-
const readAtomState =
|
|
175
|
+
};
|
|
176
|
+
const readAtomState = (atom2) => {
|
|
224
177
|
var _a;
|
|
225
178
|
const atomState = ensureAtomState(atom2);
|
|
226
179
|
if (isAtomStateInitialized(atomState)) {
|
|
227
|
-
if (
|
|
180
|
+
if (atomState.m && invalidatedAtoms.get(atom2) !== atomState.n) {
|
|
228
181
|
return atomState;
|
|
229
182
|
}
|
|
230
183
|
if (Array.from(atomState.d).every(
|
|
@@ -240,19 +193,18 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
240
193
|
atomState.d.clear();
|
|
241
194
|
let isSync = true;
|
|
242
195
|
const mountDependenciesIfAsync = () => {
|
|
243
|
-
if (
|
|
244
|
-
mountDependencies(atom2);
|
|
196
|
+
if (atomState.m) {
|
|
197
|
+
mountDependencies(atom2, atomState);
|
|
245
198
|
recomputeInvalidatedAtoms();
|
|
246
199
|
flushCallbacks();
|
|
247
200
|
}
|
|
248
201
|
};
|
|
249
202
|
const getter = (a) => {
|
|
250
|
-
var _a2;
|
|
251
203
|
if (isSelfAtom(atom2, a)) {
|
|
252
204
|
const aState2 = ensureAtomState(a);
|
|
253
205
|
if (!isAtomStateInitialized(aState2)) {
|
|
254
206
|
if (hasInitialValue(a)) {
|
|
255
|
-
setAtomStateValueOrPromise(a, a.init
|
|
207
|
+
setAtomStateValueOrPromise(a, aState2, a.init);
|
|
256
208
|
} else {
|
|
257
209
|
throw new Error("no atom init");
|
|
258
210
|
}
|
|
@@ -263,11 +215,7 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
263
215
|
try {
|
|
264
216
|
return returnAtomValue(aState);
|
|
265
217
|
} finally {
|
|
266
|
-
atomState
|
|
267
|
-
if (isPendingPromise(atomState.v)) {
|
|
268
|
-
addPendingPromiseToDependency(atom2, atomState.v, aState);
|
|
269
|
-
}
|
|
270
|
-
(_a2 = mountedMap.get(a)) == null ? void 0 : _a2.t.add(atom2);
|
|
218
|
+
addDependency(atom2, atomState, a, aState);
|
|
271
219
|
if (!isSync) {
|
|
272
220
|
mountDependenciesIfAsync();
|
|
273
221
|
}
|
|
@@ -292,28 +240,19 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
292
240
|
console.warn("setSelf function cannot be called in sync");
|
|
293
241
|
}
|
|
294
242
|
if (!isSync) {
|
|
295
|
-
|
|
296
|
-
return writeAtomState(atom2, ...args);
|
|
297
|
-
} finally {
|
|
298
|
-
recomputeInvalidatedAtoms();
|
|
299
|
-
flushCallbacks();
|
|
300
|
-
}
|
|
243
|
+
return writeAtom(atom2, ...args);
|
|
301
244
|
}
|
|
302
245
|
};
|
|
303
246
|
}
|
|
304
247
|
return setSelf;
|
|
305
248
|
}
|
|
306
249
|
};
|
|
307
|
-
const prevEpochNumber = atomState.n;
|
|
308
250
|
try {
|
|
309
251
|
const valueOrPromise = atomRead(atom2, getter, options);
|
|
310
|
-
setAtomStateValueOrPromise(atom2,
|
|
252
|
+
setAtomStateValueOrPromise(atom2, atomState, valueOrPromise);
|
|
311
253
|
if (isPromiseLike(valueOrPromise)) {
|
|
312
|
-
|
|
313
|
-
valueOrPromise.then(
|
|
314
|
-
mountDependenciesIfAsync,
|
|
315
|
-
mountDependenciesIfAsync
|
|
316
|
-
);
|
|
254
|
+
(_a = valueOrPromise.onCancel) == null ? void 0 : _a.call(valueOrPromise, () => controller == null ? void 0 : controller.abort());
|
|
255
|
+
valueOrPromise.then(mountDependenciesIfAsync, mountDependenciesIfAsync);
|
|
317
256
|
}
|
|
318
257
|
return atomState;
|
|
319
258
|
} catch (error) {
|
|
@@ -323,26 +262,89 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
323
262
|
return atomState;
|
|
324
263
|
} finally {
|
|
325
264
|
isSync = false;
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
265
|
+
}
|
|
266
|
+
};
|
|
267
|
+
const readAtom = (atom2) => returnAtomValue(readAtomState(atom2));
|
|
268
|
+
const getMountedOrPendingDependents = (atomState) => {
|
|
269
|
+
var _a;
|
|
270
|
+
const dependents = /* @__PURE__ */ new Map();
|
|
271
|
+
for (const a of ((_a = atomState.m) == null ? void 0 : _a.t) || []) {
|
|
272
|
+
const aState = ensureAtomState(a);
|
|
273
|
+
if (aState.m) {
|
|
274
|
+
dependents.set(a, aState);
|
|
330
275
|
}
|
|
331
276
|
}
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
277
|
+
for (const atomWithPendingPromise of atomState.p) {
|
|
278
|
+
dependents.set(
|
|
279
|
+
atomWithPendingPromise,
|
|
280
|
+
ensureAtomState(atomWithPendingPromise)
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
return dependents;
|
|
284
|
+
};
|
|
285
|
+
const invalidateDependents = (atomState) => {
|
|
286
|
+
const stack = [atomState];
|
|
335
287
|
while (stack.length) {
|
|
336
|
-
const
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
288
|
+
const aState = stack.pop();
|
|
289
|
+
for (const [d, s] of getMountedOrPendingDependents(aState)) {
|
|
290
|
+
if (!invalidatedAtoms.has(d)) {
|
|
291
|
+
invalidatedAtoms.set(d, s.n);
|
|
292
|
+
stack.push(s);
|
|
293
|
+
}
|
|
342
294
|
}
|
|
343
295
|
}
|
|
344
|
-
}
|
|
345
|
-
const
|
|
296
|
+
};
|
|
297
|
+
const recomputeInvalidatedAtoms = () => {
|
|
298
|
+
var _a;
|
|
299
|
+
const topSortedReversed = [];
|
|
300
|
+
const visiting = /* @__PURE__ */ new WeakSet();
|
|
301
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
302
|
+
const stack = Array.from(changedAtoms);
|
|
303
|
+
while (stack.length) {
|
|
304
|
+
const [a, aState] = stack[stack.length - 1];
|
|
305
|
+
if (visited.has(a)) {
|
|
306
|
+
stack.pop();
|
|
307
|
+
continue;
|
|
308
|
+
}
|
|
309
|
+
if (visiting.has(a)) {
|
|
310
|
+
if (invalidatedAtoms.get(a) === aState.n) {
|
|
311
|
+
topSortedReversed.push([a, aState, aState.n]);
|
|
312
|
+
} else {
|
|
313
|
+
invalidatedAtoms.delete(a);
|
|
314
|
+
changedAtoms.set(a, aState);
|
|
315
|
+
}
|
|
316
|
+
visited.add(a);
|
|
317
|
+
stack.pop();
|
|
318
|
+
continue;
|
|
319
|
+
}
|
|
320
|
+
visiting.add(a);
|
|
321
|
+
for (const [d, s] of getMountedOrPendingDependents(aState)) {
|
|
322
|
+
if (!visiting.has(d)) {
|
|
323
|
+
stack.push([d, s]);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
for (let i = topSortedReversed.length - 1; i >= 0; --i) {
|
|
328
|
+
const [a, aState, prevEpochNumber] = topSortedReversed[i];
|
|
329
|
+
let hasChangedDeps = false;
|
|
330
|
+
for (const dep of aState.d.keys()) {
|
|
331
|
+
if (dep !== a && changedAtoms.has(dep)) {
|
|
332
|
+
hasChangedDeps = true;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (hasChangedDeps) {
|
|
337
|
+
readAtomState(a);
|
|
338
|
+
mountDependencies(a, aState);
|
|
339
|
+
if (prevEpochNumber !== aState.n) {
|
|
340
|
+
changedAtoms.set(a, aState);
|
|
341
|
+
(_a = aState.u) == null ? void 0 : _a.call(aState);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
invalidatedAtoms.delete(a);
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
const writeAtomState = (atom2, ...args) => {
|
|
346
348
|
let isSync = true;
|
|
347
349
|
const getter = (a) => returnAtomValue(readAtomState(a));
|
|
348
350
|
const setter = (a, ...args2) => {
|
|
@@ -355,12 +357,12 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
355
357
|
}
|
|
356
358
|
const prevEpochNumber = aState.n;
|
|
357
359
|
const v = args2[0];
|
|
358
|
-
setAtomStateValueOrPromise(a,
|
|
359
|
-
mountDependencies(a);
|
|
360
|
+
setAtomStateValueOrPromise(a, aState, v);
|
|
361
|
+
mountDependencies(a, aState);
|
|
360
362
|
if (prevEpochNumber !== aState.n) {
|
|
361
|
-
changedAtoms.
|
|
362
|
-
(_a =
|
|
363
|
-
invalidateDependents(
|
|
363
|
+
changedAtoms.set(a, aState);
|
|
364
|
+
(_a = aState.u) == null ? void 0 : _a.call(aState);
|
|
365
|
+
invalidateDependents(aState);
|
|
364
366
|
}
|
|
365
367
|
return void 0;
|
|
366
368
|
} else {
|
|
@@ -378,52 +380,56 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
378
380
|
} finally {
|
|
379
381
|
isSync = false;
|
|
380
382
|
}
|
|
381
|
-
}
|
|
382
|
-
const
|
|
383
|
+
};
|
|
384
|
+
const writeAtom = (atom2, ...args) => {
|
|
385
|
+
try {
|
|
386
|
+
return writeAtomState(atom2, ...args);
|
|
387
|
+
} finally {
|
|
388
|
+
recomputeInvalidatedAtoms();
|
|
389
|
+
flushCallbacks();
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
const mountDependencies = (atom2, atomState) => {
|
|
383
393
|
var _a;
|
|
384
|
-
|
|
385
|
-
const mounted = mountedMap.get(atom2);
|
|
386
|
-
if (mounted && !isPendingPromise(atomState.v)) {
|
|
394
|
+
if (atomState.m && !isPendingPromise(atomState.v)) {
|
|
387
395
|
for (const [a, n] of atomState.d) {
|
|
388
|
-
if (!
|
|
396
|
+
if (!atomState.m.d.has(a)) {
|
|
389
397
|
const aState = ensureAtomState(a);
|
|
390
|
-
const aMounted = mountAtom(a);
|
|
398
|
+
const aMounted = mountAtom(a, aState);
|
|
391
399
|
aMounted.t.add(atom2);
|
|
392
|
-
|
|
400
|
+
atomState.m.d.add(a);
|
|
393
401
|
if (n !== aState.n) {
|
|
394
|
-
changedAtoms.
|
|
395
|
-
(_a =
|
|
396
|
-
invalidateDependents(
|
|
402
|
+
changedAtoms.set(a, aState);
|
|
403
|
+
(_a = aState.u) == null ? void 0 : _a.call(aState);
|
|
404
|
+
invalidateDependents(aState);
|
|
397
405
|
}
|
|
398
406
|
}
|
|
399
407
|
}
|
|
400
|
-
for (const a of
|
|
408
|
+
for (const a of atomState.m.d || []) {
|
|
401
409
|
if (!atomState.d.has(a)) {
|
|
402
|
-
|
|
403
|
-
const aMounted = unmountAtom(a);
|
|
410
|
+
atomState.m.d.delete(a);
|
|
411
|
+
const aMounted = unmountAtom(a, ensureAtomState(a));
|
|
404
412
|
aMounted == null ? void 0 : aMounted.t.delete(atom2);
|
|
405
413
|
}
|
|
406
414
|
}
|
|
407
415
|
}
|
|
408
|
-
}
|
|
409
|
-
const mountAtom =
|
|
416
|
+
};
|
|
417
|
+
const mountAtom = (atom2, atomState) => {
|
|
410
418
|
var _a;
|
|
411
|
-
|
|
412
|
-
let mounted = mountedMap.get(atom2);
|
|
413
|
-
if (!mounted) {
|
|
419
|
+
if (!atomState.m) {
|
|
414
420
|
readAtomState(atom2);
|
|
415
421
|
for (const a of atomState.d.keys()) {
|
|
416
|
-
const aMounted = mountAtom(a);
|
|
422
|
+
const aMounted = mountAtom(a, ensureAtomState(a));
|
|
417
423
|
aMounted.t.add(atom2);
|
|
418
424
|
}
|
|
419
|
-
|
|
425
|
+
atomState.m = {
|
|
420
426
|
l: /* @__PURE__ */ new Set(),
|
|
421
427
|
d: new Set(atomState.d.keys()),
|
|
422
428
|
t: /* @__PURE__ */ new Set()
|
|
423
429
|
};
|
|
424
|
-
|
|
425
|
-
(_a = storeHooks.m) == null ? void 0 : _a.call(storeHooks, atom2);
|
|
430
|
+
(_a = atomState.h) == null ? void 0 : _a.call(atomState);
|
|
426
431
|
if (isActuallyWritableAtom(atom2)) {
|
|
432
|
+
const mounted = atomState.m;
|
|
427
433
|
const processOnMount = () => {
|
|
428
434
|
let isSync = true;
|
|
429
435
|
const setAtom = (...args) => {
|
|
@@ -455,149 +461,88 @@ var buildStore = (atomStateMap = /* @__PURE__ */ new WeakMap(), mountedMap = /*
|
|
|
455
461
|
mountCallbacks.add(processOnMount);
|
|
456
462
|
}
|
|
457
463
|
}
|
|
458
|
-
return
|
|
459
|
-
}
|
|
460
|
-
const unmountAtom =
|
|
464
|
+
return atomState.m;
|
|
465
|
+
};
|
|
466
|
+
const unmountAtom = (atom2, atomState) => {
|
|
461
467
|
var _a;
|
|
462
|
-
|
|
463
|
-
let mounted = mountedMap.get(atom2);
|
|
464
|
-
if (mounted && !mounted.l.size && !Array.from(mounted.t).some((a) => {
|
|
468
|
+
if (atomState.m && !atomState.m.l.size && !Array.from(atomState.m.t).some((a) => {
|
|
465
469
|
var _a2;
|
|
466
|
-
return (_a2 =
|
|
470
|
+
return (_a2 = ensureAtomState(a).m) == null ? void 0 : _a2.d.has(atom2);
|
|
467
471
|
})) {
|
|
468
|
-
|
|
469
|
-
|
|
472
|
+
const onUnmount = atomState.m.u;
|
|
473
|
+
if (onUnmount) {
|
|
474
|
+
unmountCallbacks.add(onUnmount);
|
|
470
475
|
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
(_a = storeHooks.u) == null ? void 0 : _a.call(storeHooks, atom2);
|
|
476
|
+
delete atomState.m;
|
|
477
|
+
(_a = atomState.h) == null ? void 0 : _a.call(atomState);
|
|
474
478
|
for (const a of atomState.d.keys()) {
|
|
475
|
-
const aMounted = unmountAtom(a);
|
|
479
|
+
const aMounted = unmountAtom(a, ensureAtomState(a));
|
|
476
480
|
aMounted == null ? void 0 : aMounted.t.delete(atom2);
|
|
477
481
|
}
|
|
478
482
|
return void 0;
|
|
479
483
|
}
|
|
480
|
-
return
|
|
481
|
-
}
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// atom intercepters
|
|
492
|
-
atomRead,
|
|
493
|
-
atomWrite,
|
|
494
|
-
atomOnInit,
|
|
495
|
-
atomOnMount,
|
|
496
|
-
// building-block functions
|
|
497
|
-
ensureAtomState,
|
|
498
|
-
flushCallbacks,
|
|
499
|
-
recomputeInvalidatedAtoms,
|
|
500
|
-
readAtomState,
|
|
501
|
-
invalidateDependents,
|
|
502
|
-
writeAtomState,
|
|
503
|
-
mountDependencies,
|
|
504
|
-
mountAtom,
|
|
505
|
-
unmountAtom
|
|
506
|
-
];
|
|
507
|
-
const store = {
|
|
508
|
-
get: (atom2) => returnAtomValue(readAtomState(atom2)),
|
|
509
|
-
set: (atom2, ...args) => {
|
|
510
|
-
try {
|
|
511
|
-
return writeAtomState(atom2, ...args);
|
|
512
|
-
} finally {
|
|
513
|
-
recomputeInvalidatedAtoms();
|
|
514
|
-
flushCallbacks();
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
sub: (atom2, listener) => {
|
|
518
|
-
const mounted = mountAtom(atom2);
|
|
519
|
-
const listeners = mounted.l;
|
|
520
|
-
listeners.add(listener);
|
|
484
|
+
return atomState.m;
|
|
485
|
+
};
|
|
486
|
+
const subscribeAtom = (atom2, listener) => {
|
|
487
|
+
const atomState = ensureAtomState(atom2);
|
|
488
|
+
const mounted = mountAtom(atom2, atomState);
|
|
489
|
+
const listeners = mounted.l;
|
|
490
|
+
listeners.add(listener);
|
|
491
|
+
flushCallbacks();
|
|
492
|
+
return () => {
|
|
493
|
+
listeners.delete(listener);
|
|
494
|
+
unmountAtom(atom2, atomState);
|
|
521
495
|
flushCallbacks();
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
496
|
+
};
|
|
497
|
+
};
|
|
498
|
+
const unstable_derive = (fn) => buildStore(...fn(...storeArgs));
|
|
499
|
+
const store = {
|
|
500
|
+
get: readAtom,
|
|
501
|
+
set: writeAtom,
|
|
502
|
+
sub: subscribeAtom,
|
|
503
|
+
unstable_derive
|
|
528
504
|
};
|
|
529
|
-
Object.defineProperty(store, BUILDING_BLOCKS, { value: buildingBlocks });
|
|
530
505
|
return store;
|
|
531
506
|
};
|
|
532
|
-
var
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
// ../../node_modules/.pnpm/jotai@2.12.2_@types+react@18.3.18_react@18.3.1/node_modules/jotai/esm/vanilla.mjs
|
|
537
|
-
var keyCount = 0;
|
|
538
|
-
function atom(read, write) {
|
|
539
|
-
const key = `atom${++keyCount}`;
|
|
540
|
-
const config = {
|
|
541
|
-
toString() {
|
|
542
|
-
return (import.meta.env ? import.meta.env.MODE : void 0) !== "production" && this.debugLabel ? key + ":" + this.debugLabel : key;
|
|
543
|
-
}
|
|
544
|
-
};
|
|
545
|
-
if (typeof read === "function") {
|
|
546
|
-
config.read = read;
|
|
547
|
-
} else {
|
|
548
|
-
config.init = read;
|
|
549
|
-
config.read = defaultRead;
|
|
550
|
-
config.write = defaultWrite;
|
|
551
|
-
}
|
|
552
|
-
if (write) {
|
|
553
|
-
config.write = write;
|
|
554
|
-
}
|
|
555
|
-
return config;
|
|
556
|
-
}
|
|
557
|
-
function defaultRead(get) {
|
|
558
|
-
return get(this);
|
|
559
|
-
}
|
|
560
|
-
function defaultWrite(get, set, arg) {
|
|
561
|
-
return set(
|
|
562
|
-
this,
|
|
563
|
-
typeof arg === "function" ? arg(get(this)) : arg
|
|
564
|
-
);
|
|
565
|
-
}
|
|
566
|
-
var createDevStoreRev4 = () => {
|
|
507
|
+
var deriveDevStoreRev4 = (store) => {
|
|
508
|
+
const debugMountedAtoms = /* @__PURE__ */ new Set();
|
|
509
|
+
let savedGetAtomState;
|
|
567
510
|
let inRestoreAtom = 0;
|
|
568
|
-
const
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
511
|
+
const derivedStore = store.unstable_derive((...storeArgs) => {
|
|
512
|
+
const [getAtomState, setAtomState, , atomWrite] = storeArgs;
|
|
513
|
+
savedGetAtomState = getAtomState;
|
|
514
|
+
storeArgs[1] = function devSetAtomState(atom2, atomState) {
|
|
515
|
+
setAtomState(atom2, atomState);
|
|
516
|
+
const originalMounted = atomState.h;
|
|
517
|
+
atomState.h = () => {
|
|
518
|
+
originalMounted == null ? void 0 : originalMounted();
|
|
519
|
+
if (atomState.m) {
|
|
520
|
+
debugMountedAtoms.add(atom2);
|
|
521
|
+
} else {
|
|
522
|
+
debugMountedAtoms.delete(atom2);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
};
|
|
526
|
+
storeArgs[3] = function devAtomWrite(atom2, getter, setter, ...args) {
|
|
581
527
|
if (inRestoreAtom) {
|
|
582
|
-
return
|
|
528
|
+
return setter(atom2, ...args);
|
|
583
529
|
}
|
|
584
|
-
return atom2
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
const debugMountedAtoms = /* @__PURE__ */ new Set();
|
|
588
|
-
storeHooks.m.add(void 0, (atom2) => {
|
|
589
|
-
debugMountedAtoms.add(atom2);
|
|
590
|
-
const atomState = atomStateMap.get(atom2);
|
|
591
|
-
atomState.m = mountedAtoms.get(atom2);
|
|
592
|
-
});
|
|
593
|
-
storeHooks.u.add(void 0, (atom2) => {
|
|
594
|
-
debugMountedAtoms.delete(atom2);
|
|
595
|
-
const atomState = atomStateMap.get(atom2);
|
|
596
|
-
delete atomState.m;
|
|
530
|
+
return atomWrite(atom2, getter, setter, ...args);
|
|
531
|
+
};
|
|
532
|
+
return storeArgs;
|
|
597
533
|
});
|
|
534
|
+
const savedStoreSet = derivedStore.set;
|
|
598
535
|
const devStore = {
|
|
599
536
|
// store dev methods (these are tentative and subject to change without notice)
|
|
600
|
-
dev4_get_internal_weak_map: () =>
|
|
537
|
+
dev4_get_internal_weak_map: () => ({
|
|
538
|
+
get: (atom2) => {
|
|
539
|
+
const atomState = savedGetAtomState(atom2);
|
|
540
|
+
if (!atomState || atomState.n === 0) {
|
|
541
|
+
return void 0;
|
|
542
|
+
}
|
|
543
|
+
return atomState;
|
|
544
|
+
}
|
|
545
|
+
}),
|
|
601
546
|
dev4_get_mounted_atoms: () => debugMountedAtoms,
|
|
602
547
|
dev4_restore_atoms: (values) => {
|
|
603
548
|
const restoreAtom = {
|
|
@@ -606,7 +551,7 @@ var createDevStoreRev4 = () => {
|
|
|
606
551
|
++inRestoreAtom;
|
|
607
552
|
try {
|
|
608
553
|
for (const [atom2, value] of values) {
|
|
609
|
-
if (
|
|
554
|
+
if (hasInitialValue(atom2)) {
|
|
610
555
|
set(atom2, value);
|
|
611
556
|
}
|
|
612
557
|
}
|
|
@@ -615,20 +560,34 @@ var createDevStoreRev4 = () => {
|
|
|
615
560
|
}
|
|
616
561
|
}
|
|
617
562
|
};
|
|
618
|
-
|
|
563
|
+
savedStoreSet(restoreAtom);
|
|
619
564
|
}
|
|
620
565
|
};
|
|
621
|
-
return Object.assign(
|
|
566
|
+
return Object.assign(derivedStore, devStore);
|
|
622
567
|
};
|
|
623
|
-
|
|
568
|
+
var createStore = () => {
|
|
569
|
+
const atomStateMap = /* @__PURE__ */ new WeakMap();
|
|
570
|
+
const store = buildStore(
|
|
571
|
+
(atom2) => atomStateMap.get(atom2),
|
|
572
|
+
(atom2, atomState) => atomStateMap.set(atom2, atomState).get(atom2),
|
|
573
|
+
(atom2, ...params) => atom2.read(...params),
|
|
574
|
+
(atom2, ...params) => atom2.write(...params),
|
|
575
|
+
(atom2, ...params) => {
|
|
576
|
+
var _a;
|
|
577
|
+
return (_a = atom2.unstable_onInit) == null ? void 0 : _a.call(atom2, ...params);
|
|
578
|
+
},
|
|
579
|
+
(atom2, ...params) => {
|
|
580
|
+
var _a;
|
|
581
|
+
return (_a = atom2.onMount) == null ? void 0 : _a.call(atom2, ...params);
|
|
582
|
+
}
|
|
583
|
+
);
|
|
624
584
|
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
|
|
625
|
-
return
|
|
585
|
+
return deriveDevStoreRev4(store);
|
|
626
586
|
}
|
|
627
|
-
const store = INTERNAL_buildStoreRev1();
|
|
628
587
|
return store;
|
|
629
|
-
}
|
|
588
|
+
};
|
|
630
589
|
var defaultStore;
|
|
631
|
-
|
|
590
|
+
var getDefaultStore = () => {
|
|
632
591
|
if (!defaultStore) {
|
|
633
592
|
defaultStore = createStore();
|
|
634
593
|
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production") {
|
|
@@ -641,17 +600,17 @@ function getDefaultStore() {
|
|
|
641
600
|
}
|
|
642
601
|
}
|
|
643
602
|
return defaultStore;
|
|
644
|
-
}
|
|
603
|
+
};
|
|
645
604
|
|
|
646
|
-
// ../../node_modules/.pnpm/jotai@2.
|
|
605
|
+
// ../../node_modules/.pnpm/jotai@2.11.1_@types+react@18.3.18_react@18.3.1/node_modules/jotai/esm/react.mjs
|
|
647
606
|
import ReactExports, { createContext, useContext, useRef, createElement, useReducer, useEffect, useDebugValue, useCallback } from "react";
|
|
648
607
|
var StoreContext = createContext(
|
|
649
608
|
void 0
|
|
650
609
|
);
|
|
651
|
-
|
|
610
|
+
var useStore = (options) => {
|
|
652
611
|
const store = useContext(StoreContext);
|
|
653
612
|
return (options == null ? void 0 : options.store) || store || getDefaultStore();
|
|
654
|
-
}
|
|
613
|
+
};
|
|
655
614
|
var isPromiseLike2 = (x) => typeof (x == null ? void 0 : x.then) === "function";
|
|
656
615
|
var attachPromiseMeta = (promise) => {
|
|
657
616
|
promise.status = "pending";
|
|
@@ -679,7 +638,7 @@ var use = ReactExports.use || ((promise) => {
|
|
|
679
638
|
}
|
|
680
639
|
});
|
|
681
640
|
var continuablePromiseMap = /* @__PURE__ */ new WeakMap();
|
|
682
|
-
var createContinuablePromise = (promise
|
|
641
|
+
var createContinuablePromise = (promise) => {
|
|
683
642
|
let continuablePromise = continuablePromiseMap.get(promise);
|
|
684
643
|
if (!continuablePromise) {
|
|
685
644
|
continuablePromise = new Promise((resolve, reject) => {
|
|
@@ -694,23 +653,25 @@ var createContinuablePromise = (promise, getValue) => {
|
|
|
694
653
|
reject(e);
|
|
695
654
|
}
|
|
696
655
|
};
|
|
697
|
-
const
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
656
|
+
const registerCancelHandler = (p) => {
|
|
657
|
+
if ("onCancel" in p && typeof p.onCancel === "function") {
|
|
658
|
+
p.onCancel((nextValue) => {
|
|
659
|
+
if ((import.meta.env ? import.meta.env.MODE : void 0) !== "production" && nextValue === p) {
|
|
660
|
+
throw new Error("[Bug] p is not updated even after cancelation");
|
|
661
|
+
}
|
|
662
|
+
if (isPromiseLike2(nextValue)) {
|
|
663
|
+
continuablePromiseMap.set(nextValue, continuablePromise);
|
|
664
|
+
curr = nextValue;
|
|
665
|
+
nextValue.then(onFulfilled(nextValue), onRejected(nextValue));
|
|
666
|
+
registerCancelHandler(nextValue);
|
|
667
|
+
} else {
|
|
668
|
+
resolve(nextValue);
|
|
669
|
+
}
|
|
670
|
+
});
|
|
710
671
|
}
|
|
711
672
|
};
|
|
712
673
|
promise.then(onFulfilled(promise), onRejected(promise));
|
|
713
|
-
|
|
674
|
+
registerCancelHandler(promise);
|
|
714
675
|
});
|
|
715
676
|
continuablePromiseMap.set(promise, continuablePromise);
|
|
716
677
|
}
|
|
@@ -740,9 +701,7 @@ function useAtomValue(atom2, options) {
|
|
|
740
701
|
if (typeof delay === "number") {
|
|
741
702
|
const value2 = store.get(atom2);
|
|
742
703
|
if (isPromiseLike2(value2)) {
|
|
743
|
-
attachPromiseMeta(
|
|
744
|
-
createContinuablePromise(value2, () => store.get(atom2))
|
|
745
|
-
);
|
|
704
|
+
attachPromiseMeta(createContinuablePromise(value2));
|
|
746
705
|
}
|
|
747
706
|
setTimeout(rerender, delay);
|
|
748
707
|
return;
|
|
@@ -754,7 +713,7 @@ function useAtomValue(atom2, options) {
|
|
|
754
713
|
}, [store, atom2, delay]);
|
|
755
714
|
useDebugValue(value);
|
|
756
715
|
if (isPromiseLike2(value)) {
|
|
757
|
-
const promise = createContinuablePromise(value
|
|
716
|
+
const promise = createContinuablePromise(value);
|
|
758
717
|
return use(promise);
|
|
759
718
|
}
|
|
760
719
|
return value;
|