atom.io 0.14.0 → 0.14.1
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/data/dist/index.cjs +1473 -52
- package/data/dist/index.cjs.map +1 -1
- package/data/dist/index.d.cts +315 -16
- package/data/dist/index.js +10 -267
- package/data/dist/index.js.map +1 -1
- package/data/package.json +5 -5
- package/data/src/join.ts +3 -3
- package/dist/chunk-5VJ77LZE.js +176 -0
- package/dist/chunk-5VJ77LZE.js.map +1 -0
- package/dist/chunk-CK7GNCU5.js +309 -0
- package/dist/chunk-CK7GNCU5.js.map +1 -0
- package/dist/chunk-KW7RA7IM.js +67 -0
- package/dist/chunk-KW7RA7IM.js.map +1 -0
- package/dist/chunk-LFXB7Y6M.js +68 -0
- package/dist/chunk-LFXB7Y6M.js.map +1 -0
- package/dist/chunk-NYCVSXQB.js +181 -0
- package/dist/chunk-NYCVSXQB.js.map +1 -0
- package/dist/chunk-TE3ZSTQ6.js +2516 -0
- package/dist/chunk-TE3ZSTQ6.js.map +1 -0
- package/dist/index.cjs +2244 -55
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +268 -21
- package/dist/index.js +1 -152
- package/dist/index.js.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/internal/dist/index.cjs +208 -79
- package/internal/dist/index.cjs.map +1 -1
- package/internal/dist/index.d.cts +226 -27
- package/internal/dist/index.js +1 -2240
- package/internal/dist/index.js.map +1 -1
- package/internal/package.json +5 -5
- package/introspection/dist/index.cjs +1618 -46
- package/introspection/dist/index.cjs.map +1 -1
- package/introspection/dist/index.d.cts +374 -4
- package/introspection/dist/index.js +2 -316
- package/introspection/dist/index.js.map +1 -1
- package/introspection/package.json +5 -5
- package/json/dist/index.cjs +1560 -8
- package/json/dist/index.cjs.map +1 -1
- package/json/dist/index.d.cts +371 -7
- package/json/dist/index.js +1 -76
- package/json/dist/index.js.map +1 -1
- package/json/package.json +5 -5
- package/package.json +5 -4
- package/react/dist/index.cjs +1604 -14
- package/react/dist/index.cjs.map +1 -1
- package/react/dist/index.d.cts +375 -4
- package/react/dist/index.js +2 -68
- package/react/dist/index.js.map +1 -1
- package/react/package.json +5 -5
- package/react-devtools/dist/index.cjs +2268 -198
- package/react-devtools/dist/index.cjs.map +1 -1
- package/react-devtools/dist/index.css +2 -2
- package/react-devtools/dist/index.d.cts +148 -24
- package/react-devtools/dist/index.js +57 -297
- package/react-devtools/dist/index.js.map +1 -1
- package/react-devtools/package.json +5 -5
- package/realtime-client/dist/index.cjs +1585 -35
- package/realtime-client/dist/index.cjs.map +1 -1
- package/realtime-client/dist/index.d.cts +382 -12
- package/realtime-client/dist/index.js +2 -165
- package/realtime-client/dist/index.js.map +1 -1
- package/realtime-client/package.json +5 -5
- package/realtime-react/dist/index.cjs +1782 -35
- package/realtime-react/dist/index.cjs.map +1 -1
- package/realtime-react/dist/index.d.cts +49 -9
- package/realtime-react/dist/index.js +4 -66
- package/realtime-react/dist/index.js.map +1 -1
- package/realtime-react/package.json +5 -5
- package/realtime-server/dist/index.cjs +1604 -58
- package/realtime-server/dist/index.cjs.map +1 -1
- package/realtime-server/dist/index.d.cts +391 -11
- package/realtime-server/dist/index.js +27 -21
- package/realtime-server/dist/index.js.map +1 -1
- package/realtime-server/package.json +6 -6
- package/realtime-testing/dist/index.cjs +2352 -16
- package/realtime-testing/dist/index.cjs.map +1 -1
- package/realtime-testing/dist/index.d.cts +486 -3
- package/realtime-testing/dist/index.js +10 -31
- package/realtime-testing/dist/index.js.map +1 -1
- package/realtime-testing/package.json +5 -5
- package/transceivers/set-rtx/dist/index.cjs +31 -10
- package/transceivers/set-rtx/dist/index.cjs.map +1 -1
- package/transceivers/set-rtx/dist/index.d.cts +29 -3
- package/transceivers/set-rtx/dist/index.js +2 -3
- package/transceivers/set-rtx/dist/index.js.map +1 -1
- package/transceivers/set-rtx/package.json +6 -6
- package/data/dist/index.d.ts +0 -158
- package/data/dist/metafile-cjs.json +0 -1
- package/data/dist/metafile-esm.json +0 -1
- package/dist/index.d.ts +0 -243
- package/dist/metafile-esm.json +0 -1
- package/internal/dist/index.d.ts +0 -421
- package/internal/dist/metafile-cjs.json +0 -1
- package/internal/dist/metafile-esm.json +0 -1
- package/introspection/dist/index.d.ts +0 -24
- package/introspection/dist/metafile-cjs.json +0 -1
- package/introspection/dist/metafile-esm.json +0 -1
- package/json/dist/index.d.ts +0 -51
- package/json/dist/metafile-cjs.json +0 -1
- package/json/dist/metafile-esm.json +0 -1
- package/react/dist/index.d.ts +0 -23
- package/react/dist/metafile-cjs.json +0 -1
- package/react/dist/metafile-esm.json +0 -1
- package/react-devtools/dist/index.d.ts +0 -341
- package/react-devtools/dist/metafile-cjs.json +0 -1
- package/react-devtools/dist/metafile-esm.json +0 -1
- package/realtime-client/dist/index.d.ts +0 -22
- package/realtime-client/dist/metafile-cjs.json +0 -1
- package/realtime-client/dist/metafile-esm.json +0 -1
- package/realtime-react/dist/index.d.ts +0 -27
- package/realtime-react/dist/metafile-cjs.json +0 -1
- package/realtime-react/dist/metafile-esm.json +0 -1
- package/realtime-server/dist/index.d.ts +0 -25
- package/realtime-server/dist/metafile-cjs.json +0 -1
- package/realtime-server/dist/metafile-esm.json +0 -1
- package/realtime-testing/dist/index.d.ts +0 -49
- package/realtime-testing/dist/metafile-cjs.json +0 -1
- package/realtime-testing/dist/metafile-esm.json +0 -1
- package/transceivers/set-rtx/dist/index.d.ts +0 -40
- package/transceivers/set-rtx/dist/metafile-cjs.json +0 -1
- package/transceivers/set-rtx/dist/metafile-esm.json +0 -1
|
@@ -1,67 +1,2149 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var introspection = require('atom.io/introspection');
|
|
5
|
-
var react = require('atom.io/react');
|
|
6
|
-
var framerMotion = require('framer-motion');
|
|
7
|
-
var React = require('react');
|
|
3
|
+
var React2 = require('react');
|
|
8
4
|
var jsxRuntime = require('react/jsx-runtime');
|
|
9
|
-
var
|
|
5
|
+
var framerMotion = require('framer-motion');
|
|
6
|
+
var react = require('@floating-ui/react');
|
|
7
|
+
|
|
8
|
+
function _interopNamespace(e) {
|
|
9
|
+
if (e && e.__esModule) return e;
|
|
10
|
+
var n = Object.create(null);
|
|
11
|
+
if (e) {
|
|
12
|
+
Object.keys(e).forEach(function (k) {
|
|
13
|
+
if (k !== 'default') {
|
|
14
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
15
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return e[k]; }
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
n.default = e;
|
|
23
|
+
return Object.freeze(n);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var React2__namespace = /*#__PURE__*/_interopNamespace(React2);
|
|
27
|
+
|
|
28
|
+
var __defProp = Object.defineProperty;
|
|
29
|
+
var __defProps = Object.defineProperties;
|
|
30
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
31
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
32
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
33
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
34
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
35
|
+
var __spreadValues = (a2, b2) => {
|
|
36
|
+
for (var prop in b2 || (b2 = {}))
|
|
37
|
+
if (__hasOwnProp.call(b2, prop))
|
|
38
|
+
__defNormalProp(a2, prop, b2[prop]);
|
|
39
|
+
if (__getOwnPropSymbols)
|
|
40
|
+
for (var prop of __getOwnPropSymbols(b2)) {
|
|
41
|
+
if (__propIsEnum.call(b2, prop))
|
|
42
|
+
__defNormalProp(a2, prop, b2[prop]);
|
|
43
|
+
}
|
|
44
|
+
return a2;
|
|
45
|
+
};
|
|
46
|
+
var __spreadProps = (a2, b2) => __defProps(a2, __getOwnPropDescs(b2));
|
|
47
|
+
var __restKey = (key) => typeof key === "symbol" ? key : key + "";
|
|
48
|
+
var __objRest = (source, exclude) => {
|
|
49
|
+
var target = {};
|
|
50
|
+
for (var prop in source)
|
|
51
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
52
|
+
target[prop] = source[prop];
|
|
53
|
+
if (source != null && __getOwnPropSymbols)
|
|
54
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
55
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
56
|
+
target[prop] = source[prop];
|
|
57
|
+
}
|
|
58
|
+
return target;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
// internal/src/future.ts
|
|
62
|
+
var Future = class extends Promise {
|
|
63
|
+
constructor(executor) {
|
|
64
|
+
super((resolve, reject) => {
|
|
65
|
+
const pass2 = (value) => this.isCanceled ? reject(`canceled`) : resolve(value);
|
|
66
|
+
const fail = (reason) => this.isCanceled ? reject(`canceled`) : reject(reason);
|
|
67
|
+
if (typeof executor === `function`) {
|
|
68
|
+
executor(pass2, fail);
|
|
69
|
+
} else {
|
|
70
|
+
executor.then(pass2, fail);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.isCanceled = false;
|
|
74
|
+
}
|
|
75
|
+
cancel() {
|
|
76
|
+
this.isCanceled = true;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// internal/src/lineage.ts
|
|
81
|
+
function newest(scion) {
|
|
82
|
+
while (scion.child !== null) {
|
|
83
|
+
scion = scion.child;
|
|
84
|
+
}
|
|
85
|
+
return scion;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// internal/src/caching.ts
|
|
89
|
+
function cacheValue(key, value, subject, store) {
|
|
90
|
+
const target = newest(store);
|
|
91
|
+
const currentValue = target.valueMap.get(key);
|
|
92
|
+
if (currentValue instanceof Future) {
|
|
93
|
+
currentValue.cancel();
|
|
94
|
+
}
|
|
95
|
+
if (value instanceof Promise) {
|
|
96
|
+
const future = new Future(value);
|
|
97
|
+
newest(store).valueMap.set(key, future);
|
|
98
|
+
future.then((resolved) => {
|
|
99
|
+
if (future.isCanceled) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
cacheValue(key, resolved, subject, store);
|
|
103
|
+
subject.next({ newValue: resolved, oldValue: future });
|
|
104
|
+
}).catch((thrown) => {
|
|
105
|
+
if (thrown !== `canceled`) {
|
|
106
|
+
store.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
return future;
|
|
110
|
+
}
|
|
111
|
+
target.valueMap.set(key, value);
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
var readCachedValue = (key, store) => {
|
|
115
|
+
return newest(store).valueMap.get(key);
|
|
116
|
+
};
|
|
117
|
+
var isValueCached = (key, store) => {
|
|
118
|
+
return newest(store).valueMap.has(key);
|
|
119
|
+
};
|
|
120
|
+
var evictCachedValue = (key, store) => {
|
|
121
|
+
const core = newest(store);
|
|
122
|
+
const currentValue = core.valueMap.get(key);
|
|
123
|
+
if (currentValue instanceof Future) {
|
|
124
|
+
currentValue.cancel();
|
|
125
|
+
}
|
|
126
|
+
if (core.operation.open) {
|
|
127
|
+
core.operation.prev.set(key, currentValue);
|
|
128
|
+
}
|
|
129
|
+
core.valueMap.delete(key);
|
|
130
|
+
store.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
// ../anvl/src/json/index.ts
|
|
134
|
+
var parseJson = (str) => JSON.parse(str);
|
|
135
|
+
var stringifyJson = (json) => JSON.stringify(json);
|
|
136
|
+
var JSON_TYPE_NAMES = [
|
|
137
|
+
`array`,
|
|
138
|
+
`boolean`,
|
|
139
|
+
`null`,
|
|
140
|
+
`number`,
|
|
141
|
+
`object`,
|
|
142
|
+
`string`
|
|
143
|
+
];
|
|
144
|
+
var JSON_DEFAULTS = {
|
|
145
|
+
array: [],
|
|
146
|
+
boolean: false,
|
|
147
|
+
null: null,
|
|
148
|
+
number: 0,
|
|
149
|
+
object: {},
|
|
150
|
+
string: ``
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
// ../anvl/src/primitive/index.ts
|
|
154
|
+
var isString = (input) => {
|
|
155
|
+
return typeof input === `string`;
|
|
156
|
+
};
|
|
157
|
+
var isNumber = (input) => {
|
|
158
|
+
return typeof input === `number`;
|
|
159
|
+
};
|
|
160
|
+
var isBoolean = (input) => {
|
|
161
|
+
return typeof input === `boolean`;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// json/src/select-json.ts
|
|
165
|
+
var selectJson = (atom2, transform, store = IMPLICIT.STORE) => {
|
|
166
|
+
return createSelector(
|
|
167
|
+
{
|
|
168
|
+
key: `${atom2.key}:JSON`,
|
|
169
|
+
get: ({ get }) => transform.toJson(get(atom2)),
|
|
170
|
+
set: ({ set }, newValue) => set(atom2, transform.fromJson(newValue))
|
|
171
|
+
},
|
|
172
|
+
void 0,
|
|
173
|
+
store
|
|
174
|
+
);
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
// json/src/select-json-family.ts
|
|
178
|
+
var selectJsonFamily = (atomFamily2, transform, store = IMPLICIT.STORE) => {
|
|
179
|
+
const jsonFamily = createSelectorFamily(
|
|
180
|
+
{
|
|
181
|
+
key: `${atomFamily2.key}:JSON`,
|
|
182
|
+
get: (key) => ({ get }) => transform.toJson(get(atomFamily2(key))),
|
|
183
|
+
set: (key) => ({ set }, newValue) => set(atomFamily2(key), transform.fromJson(newValue))
|
|
184
|
+
},
|
|
185
|
+
store
|
|
186
|
+
);
|
|
187
|
+
atomFamily2.subject.subscribe(
|
|
188
|
+
`store=${store.config.name}::json-selector-family`,
|
|
189
|
+
(token) => {
|
|
190
|
+
if (token.family) {
|
|
191
|
+
jsonFamily(parseJson(token.family.subKey));
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
);
|
|
195
|
+
return jsonFamily;
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
// internal/src/read-or-compute-value.ts
|
|
199
|
+
var readOrComputeValue = (state, store) => {
|
|
200
|
+
if (isValueCached(state.key, store)) {
|
|
201
|
+
store.logger.info(`\u{1F4D6}`, state.type, state.key, `reading cached value`);
|
|
202
|
+
return readCachedValue(state.key, store);
|
|
203
|
+
}
|
|
204
|
+
if (state.type !== `atom`) {
|
|
205
|
+
store.logger.info(`\u{1F9EE}`, state.type, state.key, `computing value`);
|
|
206
|
+
return state.get();
|
|
207
|
+
}
|
|
208
|
+
const fallback2 = state.default instanceof Function ? state.default() : state.default;
|
|
209
|
+
store.logger.info(
|
|
210
|
+
`\u{1F481}`,
|
|
211
|
+
`atom`,
|
|
212
|
+
state.key,
|
|
213
|
+
`could not find cached value; using default`,
|
|
214
|
+
fallback2
|
|
215
|
+
);
|
|
216
|
+
return state.default instanceof Function ? state.default() : state.default;
|
|
217
|
+
};
|
|
218
|
+
|
|
219
|
+
// internal/src/operation.ts
|
|
220
|
+
var openOperation = (token, store) => {
|
|
221
|
+
const target = newest(store);
|
|
222
|
+
if (target.operation.open) {
|
|
223
|
+
store.logger.error(
|
|
224
|
+
`\u274C`,
|
|
225
|
+
token.type,
|
|
226
|
+
token.key,
|
|
227
|
+
`failed to setState during a setState for "${target.operation.token.key}"`
|
|
228
|
+
);
|
|
229
|
+
return `rejection`;
|
|
230
|
+
}
|
|
231
|
+
target.operation = {
|
|
232
|
+
open: true,
|
|
233
|
+
done: /* @__PURE__ */ new Set(),
|
|
234
|
+
prev: /* @__PURE__ */ new Map(),
|
|
235
|
+
time: Date.now(),
|
|
236
|
+
token
|
|
237
|
+
};
|
|
238
|
+
store.logger.info(
|
|
239
|
+
`\u2B55`,
|
|
240
|
+
token.type,
|
|
241
|
+
token.key,
|
|
242
|
+
`operation start in store "${store.config.name}"${target.transactionMeta === null ? `` : ` ${target.transactionMeta.phase} "${target.transactionMeta.update.key}"`}`
|
|
243
|
+
);
|
|
244
|
+
};
|
|
245
|
+
var closeOperation = (store) => {
|
|
246
|
+
const target = newest(store);
|
|
247
|
+
if (target.operation.open) {
|
|
248
|
+
store.logger.info(
|
|
249
|
+
`\u{1F534}`,
|
|
250
|
+
target.operation.token.type,
|
|
251
|
+
target.operation.token.key,
|
|
252
|
+
`operation done in store "${store.config.name}"`
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
target.operation = { open: false };
|
|
256
|
+
store.subject.operationStatus.next(target.operation);
|
|
257
|
+
};
|
|
258
|
+
var isDone = (key, store) => {
|
|
259
|
+
const target = newest(store);
|
|
260
|
+
if (!target.operation.open) {
|
|
261
|
+
store.logger.warn(
|
|
262
|
+
`\u{1F41E}`,
|
|
263
|
+
`unknown`,
|
|
264
|
+
key,
|
|
265
|
+
`isDone called outside of an operation. This is probably a bug.`
|
|
266
|
+
);
|
|
267
|
+
return true;
|
|
268
|
+
}
|
|
269
|
+
return target.operation.done.has(key);
|
|
270
|
+
};
|
|
271
|
+
var markDone = (key, store) => {
|
|
272
|
+
const target = newest(store);
|
|
273
|
+
if (!target.operation.open) {
|
|
274
|
+
store.logger.warn(
|
|
275
|
+
`\u{1F41E}`,
|
|
276
|
+
`unknown`,
|
|
277
|
+
key,
|
|
278
|
+
`markDone called outside of an operation. This is probably a bug.`
|
|
279
|
+
);
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
target.operation.done.add(key);
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
// internal/src/set-state/become.ts
|
|
286
|
+
var become = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
|
|
287
|
+
originalThing instanceof Function ? originalThing() : originalThing
|
|
288
|
+
) : nextVersionOfThing;
|
|
289
|
+
|
|
290
|
+
// internal/src/subject.ts
|
|
291
|
+
var Subject = class {
|
|
292
|
+
constructor() {
|
|
293
|
+
this.subscribers = /* @__PURE__ */ new Map();
|
|
294
|
+
}
|
|
295
|
+
subscribe(key, subscriber) {
|
|
296
|
+
this.subscribers.set(key, subscriber);
|
|
297
|
+
const unsubscribe = () => this.unsubscribe(key);
|
|
298
|
+
return unsubscribe;
|
|
299
|
+
}
|
|
300
|
+
unsubscribe(key) {
|
|
301
|
+
this.subscribers.delete(key);
|
|
302
|
+
}
|
|
303
|
+
next(value) {
|
|
304
|
+
for (const subscriber of this.subscribers.values()) {
|
|
305
|
+
subscriber(value);
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
};
|
|
309
|
+
var StatefulSubject = class extends Subject {
|
|
310
|
+
constructor(initialState) {
|
|
311
|
+
super();
|
|
312
|
+
this.state = initialState;
|
|
313
|
+
}
|
|
314
|
+
next(value) {
|
|
315
|
+
this.state = value;
|
|
316
|
+
super.next(value);
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
321
|
+
function copyMutableIfNeeded(atom2, transform, origin, target) {
|
|
322
|
+
const originValue = origin.valueMap.get(atom2.key);
|
|
323
|
+
const targetValue = target.valueMap.get(atom2.key);
|
|
324
|
+
if (originValue === targetValue) {
|
|
325
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, `${atom2.key}`, `copying`);
|
|
326
|
+
const jsonValue = transform.toJson(originValue);
|
|
327
|
+
const copiedValue = transform.fromJson(jsonValue);
|
|
328
|
+
target.valueMap.set(atom2.key, copiedValue);
|
|
329
|
+
new Tracker(atom2, origin);
|
|
330
|
+
return copiedValue;
|
|
331
|
+
}
|
|
332
|
+
return targetValue;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// internal/src/set-state/copy-mutable-in-transaction.ts
|
|
336
|
+
function copyMutableIfWithinTransaction(oldValue, atom2, store) {
|
|
337
|
+
const target = newest(store);
|
|
338
|
+
const parent = target.parent;
|
|
339
|
+
if (parent !== null) {
|
|
340
|
+
if (`toJson` in atom2 && `fromJson` in atom2) {
|
|
341
|
+
const copiedValue = copyMutableIfNeeded(atom2, atom2, parent, target);
|
|
342
|
+
return copiedValue;
|
|
343
|
+
}
|
|
344
|
+
if (`family` in atom2) {
|
|
345
|
+
const family = parent.families.get(atom2.family.key);
|
|
346
|
+
if (family && family.type === `atom_family`) {
|
|
347
|
+
const result = copyMutableFamilyMemberWithinTransaction(
|
|
348
|
+
atom2,
|
|
349
|
+
family,
|
|
350
|
+
parent,
|
|
351
|
+
target
|
|
352
|
+
);
|
|
353
|
+
if (result) {
|
|
354
|
+
return result;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return oldValue;
|
|
360
|
+
}
|
|
361
|
+
function copyMutableFamilyMemberWithinTransaction(atom2, family, origin, target) {
|
|
362
|
+
if (`toJson` in family && `fromJson` in family) {
|
|
363
|
+
const copyCreated = copyMutableIfNeeded(atom2, family, origin, target);
|
|
364
|
+
return copyCreated;
|
|
365
|
+
}
|
|
366
|
+
return null;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
// internal/src/set-state/emit-update.ts
|
|
370
|
+
var emitUpdate = (state, update, store) => {
|
|
371
|
+
store.logger.info(
|
|
372
|
+
`\u{1F4E2}`,
|
|
373
|
+
state.type,
|
|
374
|
+
state.key,
|
|
375
|
+
`went (`,
|
|
376
|
+
update.oldValue,
|
|
377
|
+
`->`,
|
|
378
|
+
update.newValue,
|
|
379
|
+
`) subscribers:`,
|
|
380
|
+
state.subject.subscribers
|
|
381
|
+
);
|
|
382
|
+
state.subject.next(update);
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
// internal/src/set-state/evict-downstream.ts
|
|
386
|
+
var evictDownStream = (atom2, store) => {
|
|
387
|
+
const target = newest(store);
|
|
388
|
+
const downstreamKeys = target.selectorAtoms.getRelatedKeys(atom2.key);
|
|
389
|
+
store.logger.info(
|
|
390
|
+
`\u{1F9F9}`,
|
|
391
|
+
atom2.type,
|
|
392
|
+
atom2.key,
|
|
393
|
+
downstreamKeys ? `evicting ${downstreamKeys.size} states downstream:` : `no downstream states`,
|
|
394
|
+
downstreamKeys != null ? downstreamKeys : `to evict`
|
|
395
|
+
);
|
|
396
|
+
if (downstreamKeys) {
|
|
397
|
+
if (target.operation.open) {
|
|
398
|
+
store.logger.info(
|
|
399
|
+
`\u{1F9F9}`,
|
|
400
|
+
atom2.type,
|
|
401
|
+
atom2.key,
|
|
402
|
+
`[ ${[...target.operation.done].join(`, `)} ] already done`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
for (const key of downstreamKeys) {
|
|
406
|
+
if (isDone(key, store)) {
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
evictCachedValue(key, store);
|
|
410
|
+
markDone(key, store);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
// internal/src/set-state/stow-update.ts
|
|
416
|
+
function shouldUpdateBeStowed(key, update) {
|
|
417
|
+
if (isTransceiver(update.newValue)) {
|
|
418
|
+
return false;
|
|
419
|
+
}
|
|
420
|
+
if (key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
421
|
+
return false;
|
|
422
|
+
}
|
|
423
|
+
return true;
|
|
424
|
+
}
|
|
425
|
+
var stowUpdate = (state, update, store) => {
|
|
426
|
+
const { key } = state;
|
|
427
|
+
const target = newest(store);
|
|
428
|
+
if (target.transactionMeta === null || target.transactionMeta.phase !== `building`) {
|
|
429
|
+
store.logger.error(
|
|
430
|
+
`\u{1F41E}`,
|
|
431
|
+
`atom`,
|
|
432
|
+
key,
|
|
433
|
+
`stowUpdate called outside of a transaction. This is probably a bug.`
|
|
434
|
+
);
|
|
435
|
+
return;
|
|
436
|
+
}
|
|
437
|
+
const shouldStow = shouldUpdateBeStowed(key, update);
|
|
438
|
+
if (!shouldStow) {
|
|
439
|
+
return;
|
|
440
|
+
}
|
|
441
|
+
const atomUpdate = __spreadValues({ key }, update);
|
|
442
|
+
if (state.family) {
|
|
443
|
+
atomUpdate.family = state.family;
|
|
444
|
+
}
|
|
445
|
+
target.transactionMeta.update.updates.push(atomUpdate);
|
|
446
|
+
store.logger.info(
|
|
447
|
+
`\u{1F4C1}`,
|
|
448
|
+
`atom`,
|
|
449
|
+
key,
|
|
450
|
+
`stowed (`,
|
|
451
|
+
update.oldValue,
|
|
452
|
+
`->`,
|
|
453
|
+
update.newValue,
|
|
454
|
+
`)`
|
|
455
|
+
);
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
// internal/src/set-state/set-atom.ts
|
|
459
|
+
var setAtom = (atom2, next, store) => {
|
|
460
|
+
const target = newest(store);
|
|
461
|
+
const oldValue = readOrComputeValue(atom2, store);
|
|
462
|
+
let newValue = copyMutableIfWithinTransaction(oldValue, atom2, store);
|
|
463
|
+
newValue = become(next)(newValue);
|
|
464
|
+
store.logger.info(`\u{1F4DD}`, `atom`, atom2.key, `set to`, newValue);
|
|
465
|
+
newValue = cacheValue(atom2.key, newValue, atom2.subject, store);
|
|
466
|
+
if (isAtomDefault(atom2.key, store)) {
|
|
467
|
+
markAtomAsNotDefault(atom2.key, store);
|
|
468
|
+
}
|
|
469
|
+
markDone(atom2.key, store);
|
|
470
|
+
evictDownStream(atom2, store);
|
|
471
|
+
const update = { oldValue, newValue };
|
|
472
|
+
if (target.transactionMeta === null || target.transactionMeta.phase === `applying`) {
|
|
473
|
+
emitUpdate(atom2, update, store);
|
|
474
|
+
} else {
|
|
475
|
+
stowUpdate(atom2, update, store);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
// internal/src/set-state/set-atom-or-selector.ts
|
|
480
|
+
var setAtomOrSelector = (state, value, store) => {
|
|
481
|
+
if (state.type === `selector`) {
|
|
482
|
+
state.set(value);
|
|
483
|
+
} else {
|
|
484
|
+
setAtom(state, value, store);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
// internal/src/store/deposit.ts
|
|
489
|
+
function deposit(state) {
|
|
490
|
+
const token = {
|
|
491
|
+
key: state.key,
|
|
492
|
+
type: state.type
|
|
493
|
+
};
|
|
494
|
+
if (`family` in state) {
|
|
495
|
+
token.family = state.family;
|
|
496
|
+
}
|
|
497
|
+
return token;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
// ../rel8/junction/src/junction.ts
|
|
501
|
+
var Junction = class {
|
|
502
|
+
constructor(data, config) {
|
|
503
|
+
this.relations = /* @__PURE__ */ new Map();
|
|
504
|
+
this.contents = /* @__PURE__ */ new Map();
|
|
505
|
+
this.makeContentKey = (a2, b2) => `${a2}:${b2}`;
|
|
506
|
+
var _a2, _b, _c, _d;
|
|
507
|
+
this.a = data.between[0];
|
|
508
|
+
this.b = data.between[1];
|
|
509
|
+
this.cardinality = data.cardinality;
|
|
510
|
+
if (!(config == null ? void 0 : config.externalStore)) {
|
|
511
|
+
this.relations = new Map((_a2 = data.relations) == null ? void 0 : _a2.map(([a2, b2]) => [a2, new Set(b2)]));
|
|
512
|
+
this.contents = new Map(data.contents);
|
|
513
|
+
}
|
|
514
|
+
this.isContent = (_b = config == null ? void 0 : config.isContent) != null ? _b : null;
|
|
515
|
+
if (config == null ? void 0 : config.makeContentKey) {
|
|
516
|
+
this.makeContentKey = config.makeContentKey;
|
|
517
|
+
}
|
|
518
|
+
if (config == null ? void 0 : config.externalStore) {
|
|
519
|
+
const externalStore = config.externalStore;
|
|
520
|
+
this.has = (a2, b2) => externalStore.has(a2, b2);
|
|
521
|
+
this.addRelation = (a2, b2) => {
|
|
522
|
+
externalStore.addRelation(a2, b2);
|
|
523
|
+
};
|
|
524
|
+
this.deleteRelation = (a2, b2) => {
|
|
525
|
+
externalStore.deleteRelation(a2, b2);
|
|
526
|
+
};
|
|
527
|
+
this.replaceRelationsSafely = (a2, bs) => {
|
|
528
|
+
externalStore.replaceRelationsSafely(a2, bs);
|
|
529
|
+
};
|
|
530
|
+
this.replaceRelationsUnsafely = (a2, bs) => {
|
|
531
|
+
externalStore.replaceRelationsUnsafely(a2, bs);
|
|
532
|
+
};
|
|
533
|
+
this.getRelatedKeys = (key) => externalStore.getRelatedKeys(key);
|
|
534
|
+
if (externalStore.getContent) {
|
|
535
|
+
this.getContentInternal = (contentKey) => {
|
|
536
|
+
return externalStore.getContent(contentKey);
|
|
537
|
+
};
|
|
538
|
+
this.setContent = (contentKey, content) => {
|
|
539
|
+
externalStore.setContent(contentKey, content);
|
|
540
|
+
};
|
|
541
|
+
this.deleteContent = (contentKey) => {
|
|
542
|
+
externalStore.deleteContent(contentKey);
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
for (const [x, ys] of (_c = data.relations) != null ? _c : []) {
|
|
546
|
+
for (const y of ys)
|
|
547
|
+
this.addRelation(x, y);
|
|
548
|
+
}
|
|
549
|
+
for (const [contentKey, content] of (_d = data.contents) != null ? _d : []) {
|
|
550
|
+
this.setContent(contentKey, content);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
getRelatedKeys(key) {
|
|
555
|
+
return this.relations.get(key);
|
|
556
|
+
}
|
|
557
|
+
addRelation(a2, b2) {
|
|
558
|
+
let aRelations = this.relations.get(a2);
|
|
559
|
+
let bRelations = this.relations.get(b2);
|
|
560
|
+
if (aRelations) {
|
|
561
|
+
aRelations.add(b2);
|
|
562
|
+
} else {
|
|
563
|
+
aRelations = /* @__PURE__ */ new Set([b2]);
|
|
564
|
+
this.relations.set(a2, aRelations);
|
|
565
|
+
}
|
|
566
|
+
if (bRelations) {
|
|
567
|
+
bRelations.add(a2);
|
|
568
|
+
} else {
|
|
569
|
+
bRelations = /* @__PURE__ */ new Set([a2]);
|
|
570
|
+
this.relations.set(b2, bRelations);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
deleteRelation(a2, b2) {
|
|
574
|
+
const aRelations = this.relations.get(a2);
|
|
575
|
+
if (aRelations) {
|
|
576
|
+
aRelations.delete(b2);
|
|
577
|
+
if (aRelations.size === 0) {
|
|
578
|
+
this.relations.delete(a2);
|
|
579
|
+
}
|
|
580
|
+
const bRelations = this.relations.get(b2);
|
|
581
|
+
if (bRelations) {
|
|
582
|
+
bRelations.delete(a2);
|
|
583
|
+
if (bRelations.size === 0) {
|
|
584
|
+
this.relations.delete(b2);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
replaceRelationsUnsafely(a2, bs) {
|
|
590
|
+
this.relations.set(a2, new Set(bs));
|
|
591
|
+
for (const b2 of bs) {
|
|
592
|
+
const bRelations = /* @__PURE__ */ new Set([a2]);
|
|
593
|
+
this.relations.set(b2, bRelations);
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
replaceRelationsSafely(a2, bs) {
|
|
597
|
+
const aRelationsPrev = this.relations.get(a2);
|
|
598
|
+
if (aRelationsPrev) {
|
|
599
|
+
for (const b2 of aRelationsPrev) {
|
|
600
|
+
const bRelations = this.relations.get(b2);
|
|
601
|
+
if (bRelations) {
|
|
602
|
+
if (bRelations.size === 1) {
|
|
603
|
+
this.relations.delete(b2);
|
|
604
|
+
} else {
|
|
605
|
+
bRelations.delete(a2);
|
|
606
|
+
}
|
|
607
|
+
this.contents.delete(this.makeContentKey(a2, b2));
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
this.relations.set(a2, new Set(bs));
|
|
612
|
+
for (const b2 of bs) {
|
|
613
|
+
let bRelations = this.relations.get(b2);
|
|
614
|
+
if (bRelations) {
|
|
615
|
+
bRelations.add(a2);
|
|
616
|
+
} else {
|
|
617
|
+
bRelations = /* @__PURE__ */ new Set([a2]);
|
|
618
|
+
this.relations.set(b2, bRelations);
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
getContentInternal(contentKey) {
|
|
623
|
+
return this.contents.get(contentKey);
|
|
624
|
+
}
|
|
625
|
+
setContent(contentKey, content) {
|
|
626
|
+
this.contents.set(contentKey, content);
|
|
627
|
+
}
|
|
628
|
+
deleteContent(contentKey) {
|
|
629
|
+
this.contents.delete(contentKey);
|
|
630
|
+
}
|
|
631
|
+
toJSON() {
|
|
632
|
+
return {
|
|
633
|
+
between: [this.a, this.b],
|
|
634
|
+
cardinality: this.cardinality,
|
|
635
|
+
relations: [...this.relations.entries()].map(([a2, b2]) => [a2, [...b2]]),
|
|
636
|
+
contents: [...this.contents.entries()]
|
|
637
|
+
};
|
|
638
|
+
}
|
|
639
|
+
set(a2, ...rest) {
|
|
640
|
+
var _a2;
|
|
641
|
+
const b2 = typeof rest[0] === `string` ? rest[0] : a2[this.b];
|
|
642
|
+
const content = ((_a2 = rest[1]) != null ? _a2 : typeof rest[0] === `string`) ? void 0 : rest[0];
|
|
643
|
+
a2 = typeof a2 === `string` ? a2 : a2[this.a];
|
|
644
|
+
switch (this.cardinality) {
|
|
645
|
+
case `1:1`: {
|
|
646
|
+
const bPrev = this.getRelatedKey(a2);
|
|
647
|
+
if (bPrev && bPrev !== b2)
|
|
648
|
+
this.delete(bPrev, a2);
|
|
649
|
+
}
|
|
650
|
+
case `1:n`: {
|
|
651
|
+
const aPrev = this.getRelatedKey(b2);
|
|
652
|
+
if (aPrev && aPrev !== a2)
|
|
653
|
+
this.delete(aPrev, b2);
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
if (content) {
|
|
657
|
+
const contentKey = this.makeContentKey(a2, b2);
|
|
658
|
+
this.setContent(contentKey, content);
|
|
659
|
+
}
|
|
660
|
+
this.addRelation(a2, b2);
|
|
661
|
+
return this;
|
|
662
|
+
}
|
|
663
|
+
delete(x, b2) {
|
|
664
|
+
b2 = typeof b2 === `string` ? b2 : x[this.b];
|
|
665
|
+
const a2 = typeof x === `string` ? x : x[this.a];
|
|
666
|
+
if (a2 === void 0 && typeof b2 === `string`) {
|
|
667
|
+
const bRelations = this.getRelatedKeys(b2);
|
|
668
|
+
if (bRelations) {
|
|
669
|
+
for (const a3 of bRelations) {
|
|
670
|
+
this.delete(a3, b2);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
if (typeof a2 === `string` && b2 === void 0) {
|
|
675
|
+
const aRelations = this.getRelatedKeys(a2);
|
|
676
|
+
if (aRelations) {
|
|
677
|
+
for (const b3 of aRelations) {
|
|
678
|
+
this.delete(a2, b3);
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
if (typeof a2 === `string` && typeof b2 === `string`) {
|
|
683
|
+
this.deleteRelation(a2, b2);
|
|
684
|
+
const contentKey = this.makeContentKey(a2, b2);
|
|
685
|
+
this.deleteContent(contentKey);
|
|
686
|
+
}
|
|
687
|
+
return this;
|
|
688
|
+
}
|
|
689
|
+
getRelatedKey(key) {
|
|
690
|
+
const relations = this.getRelatedKeys(key);
|
|
691
|
+
if (relations) {
|
|
692
|
+
if (relations.size > 1) {
|
|
693
|
+
console.warn(
|
|
694
|
+
`${relations.size} related keys were found for key "${key}": (${[
|
|
695
|
+
...relations
|
|
696
|
+
].map((k) => `"${k}"`).join(`, `)}). Only one related key was expected.`
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
for (const relation of relations) {
|
|
700
|
+
return relation;
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
replaceRelations(a2, relations, config) {
|
|
705
|
+
const hasContent = !Array.isArray(relations);
|
|
706
|
+
const bs = hasContent ? Object.keys(relations) : relations;
|
|
707
|
+
if (config == null ? void 0 : config.reckless) {
|
|
708
|
+
this.replaceRelationsUnsafely(a2, bs);
|
|
709
|
+
} else {
|
|
710
|
+
this.replaceRelationsSafely(a2, bs);
|
|
711
|
+
}
|
|
712
|
+
if (hasContent) {
|
|
713
|
+
for (const b2 of bs) {
|
|
714
|
+
const contentKey = this.makeContentKey(a2, b2);
|
|
715
|
+
const content = relations[b2];
|
|
716
|
+
this.setContent(contentKey, content);
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
return this;
|
|
720
|
+
}
|
|
721
|
+
getContent(a2, b2) {
|
|
722
|
+
const contentKey = this.makeContentKey(a2, b2);
|
|
723
|
+
return this.getContentInternal(contentKey);
|
|
724
|
+
}
|
|
725
|
+
getRelationEntries(input) {
|
|
726
|
+
const a2 = input[this.a];
|
|
727
|
+
const b2 = input[this.b];
|
|
728
|
+
if (a2 !== void 0 && b2 === void 0) {
|
|
729
|
+
const aRelations = this.getRelatedKeys(a2);
|
|
730
|
+
if (aRelations) {
|
|
731
|
+
return [...aRelations].map((b3) => {
|
|
732
|
+
var _a2;
|
|
733
|
+
return [b3, (_a2 = this.getContent(a2, b3)) != null ? _a2 : null];
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
if (a2 === void 0 && b2 !== void 0) {
|
|
738
|
+
const bRelations = this.getRelatedKeys(b2);
|
|
739
|
+
if (bRelations) {
|
|
740
|
+
return [...bRelations].map((a3) => {
|
|
741
|
+
var _a2;
|
|
742
|
+
return [a3, (_a2 = this.getContent(a3, b2)) != null ? _a2 : null];
|
|
743
|
+
});
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
return [];
|
|
747
|
+
}
|
|
748
|
+
has(a2, b2) {
|
|
749
|
+
var _a2;
|
|
750
|
+
if (b2) {
|
|
751
|
+
const setA = this.getRelatedKeys(a2);
|
|
752
|
+
return (_a2 = setA == null ? void 0 : setA.has(b2)) != null ? _a2 : false;
|
|
753
|
+
}
|
|
754
|
+
return this.relations.has(a2);
|
|
755
|
+
}
|
|
756
|
+
};
|
|
757
|
+
|
|
758
|
+
// internal/src/store/store.ts
|
|
759
|
+
var Store = class {
|
|
760
|
+
constructor(name, store = null) {
|
|
761
|
+
this.parent = null;
|
|
762
|
+
this.child = null;
|
|
763
|
+
this.valueMap = /* @__PURE__ */ new Map();
|
|
764
|
+
this.atoms = /* @__PURE__ */ new Map();
|
|
765
|
+
this.selectors = /* @__PURE__ */ new Map();
|
|
766
|
+
this.readonlySelectors = /* @__PURE__ */ new Map();
|
|
767
|
+
this.trackers = /* @__PURE__ */ new Map();
|
|
768
|
+
this.families = /* @__PURE__ */ new Map();
|
|
769
|
+
this.timelines = /* @__PURE__ */ new Map();
|
|
770
|
+
this.transactions = /* @__PURE__ */ new Map();
|
|
771
|
+
this.atomsThatAreDefault = /* @__PURE__ */ new Set();
|
|
772
|
+
this.timelineAtoms = new Junction({
|
|
773
|
+
between: [`timelineKey`, `atomKey`],
|
|
774
|
+
cardinality: `1:n`
|
|
775
|
+
});
|
|
776
|
+
this.selectorAtoms = new Junction({
|
|
777
|
+
between: [`selectorKey`, `atomKey`],
|
|
778
|
+
cardinality: `n:n`
|
|
779
|
+
});
|
|
780
|
+
this.selectorGraph = new Junction(
|
|
781
|
+
{
|
|
782
|
+
between: [`upstreamSelectorKey`, `downstreamSelectorKey`],
|
|
783
|
+
cardinality: `n:n`
|
|
784
|
+
},
|
|
785
|
+
{
|
|
786
|
+
makeContentKey: (...keys) => keys.sort().join(`:`)
|
|
787
|
+
}
|
|
788
|
+
);
|
|
789
|
+
this.subject = {
|
|
790
|
+
atomCreation: new Subject(),
|
|
791
|
+
selectorCreation: new Subject(),
|
|
792
|
+
transactionCreation: new Subject(),
|
|
793
|
+
timelineCreation: new Subject(),
|
|
794
|
+
transactionApplying: new StatefulSubject(null),
|
|
795
|
+
operationStatus: new Subject()
|
|
796
|
+
};
|
|
797
|
+
this.operation = { open: false };
|
|
798
|
+
this.transactionMeta = null;
|
|
799
|
+
this.config = {
|
|
800
|
+
name: `IMPLICIT_STORE`
|
|
801
|
+
};
|
|
802
|
+
this.loggers = [
|
|
803
|
+
new AtomIOLogger(`warn`, (_, __, key) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`))
|
|
804
|
+
];
|
|
805
|
+
this.logger = {
|
|
806
|
+
error: (...messages) => {
|
|
807
|
+
for (const logger of this.loggers)
|
|
808
|
+
logger.error(...messages);
|
|
809
|
+
},
|
|
810
|
+
info: (...messages) => {
|
|
811
|
+
for (const logger of this.loggers)
|
|
812
|
+
logger.info(...messages);
|
|
813
|
+
},
|
|
814
|
+
warn: (...messages) => {
|
|
815
|
+
for (const logger of this.loggers)
|
|
816
|
+
logger.warn(...messages);
|
|
817
|
+
}
|
|
818
|
+
};
|
|
819
|
+
if (store !== null) {
|
|
820
|
+
this.valueMap = new Map(store == null ? void 0 : store.valueMap);
|
|
821
|
+
this.operation = __spreadValues({}, store == null ? void 0 : store.operation);
|
|
822
|
+
this.transactionMeta = (store == null ? void 0 : store.transactionMeta) ? __spreadValues({}, store == null ? void 0 : store.transactionMeta) : null;
|
|
823
|
+
this.config = __spreadProps(__spreadValues({}, store == null ? void 0 : store.config), {
|
|
824
|
+
name
|
|
825
|
+
});
|
|
826
|
+
for (const [, atom2] of store.atoms) {
|
|
827
|
+
atom2.install(this);
|
|
828
|
+
}
|
|
829
|
+
for (const [, selector] of store.readonlySelectors) {
|
|
830
|
+
selector.install(this);
|
|
831
|
+
}
|
|
832
|
+
for (const [, selector] of store.selectors) {
|
|
833
|
+
selector.install(this);
|
|
834
|
+
}
|
|
835
|
+
for (const [, tx] of store.transactions) {
|
|
836
|
+
tx.install(this);
|
|
837
|
+
}
|
|
838
|
+
for (const [, timeline] of store.timelines) {
|
|
839
|
+
timeline.install(this);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
};
|
|
844
|
+
var IMPLICIT = {
|
|
845
|
+
STORE_INTERNAL: void 0,
|
|
846
|
+
get STORE() {
|
|
847
|
+
var _a2;
|
|
848
|
+
return (_a2 = this.STORE_INTERNAL) != null ? _a2 : this.STORE_INTERNAL = new Store(`IMPLICIT_STORE`);
|
|
849
|
+
}
|
|
850
|
+
};
|
|
851
|
+
|
|
852
|
+
// internal/src/store/withdraw.ts
|
|
853
|
+
function withdraw(token, store) {
|
|
854
|
+
var _a2, _b, _c, _d;
|
|
855
|
+
const target = newest(store);
|
|
856
|
+
const state = (_d = (_c = (_b = (_a2 = target.atoms.get(token.key)) != null ? _a2 : target.selectors.get(token.key)) != null ? _b : target.readonlySelectors.get(token.key)) != null ? _c : target.transactions.get(token.key)) != null ? _d : target.timelines.get(token.key);
|
|
857
|
+
if (state) {
|
|
858
|
+
return state;
|
|
859
|
+
}
|
|
860
|
+
return void 0;
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
// internal/src/store/withdraw-new-family-member.ts
|
|
864
|
+
function withdrawNewFamilyMember(token, store) {
|
|
865
|
+
if (token.family) {
|
|
866
|
+
store.logger.info(
|
|
867
|
+
`\u{1F46A}`,
|
|
868
|
+
token.type,
|
|
869
|
+
token.key,
|
|
870
|
+
`creating new family member in store "${store.config.name}"`
|
|
871
|
+
);
|
|
872
|
+
const target = newest(store);
|
|
873
|
+
const family = target.families.get(token.family.key);
|
|
874
|
+
if (family) {
|
|
875
|
+
const jsonSubKey = JSON.parse(token.family.subKey);
|
|
876
|
+
family(jsonSubKey);
|
|
877
|
+
const state = withdraw(token, store);
|
|
878
|
+
return state;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
return void 0;
|
|
882
|
+
}
|
|
883
|
+
|
|
884
|
+
// internal/src/keys.ts
|
|
885
|
+
var isAtomKey = (key, store) => newest(store).atoms.has(key);
|
|
886
|
+
var isSelectorKey = (key, store) => newest(store).selectors.has(key);
|
|
887
|
+
var isReadonlySelectorKey = (key, store) => newest(store).readonlySelectors.has(key);
|
|
888
|
+
var isStateKey = (key, store) => isAtomKey(key, store) || isSelectorKey(key, store) || isReadonlySelectorKey(key, store);
|
|
889
|
+
|
|
890
|
+
// internal/src/selector/get-selector-dependency-keys.ts
|
|
891
|
+
var getSelectorDependencyKeys = (key, store) => {
|
|
892
|
+
const sources = newest(store).selectorGraph.getRelationEntries({ downstreamSelectorKey: key }).filter(([_, { source }]) => source !== key).map(([_, { source }]) => source).filter((source) => isStateKey(source, store));
|
|
893
|
+
return sources;
|
|
894
|
+
};
|
|
895
|
+
|
|
896
|
+
// internal/src/selector/trace-selector-atoms.ts
|
|
897
|
+
var traceSelectorAtoms = (selectorKey, directDependencyKey, store) => {
|
|
898
|
+
const rootKeys = [];
|
|
899
|
+
const indirectDependencyKeys = getSelectorDependencyKeys(
|
|
900
|
+
directDependencyKey,
|
|
901
|
+
store
|
|
902
|
+
);
|
|
903
|
+
let depth = 0;
|
|
904
|
+
while (indirectDependencyKeys.length > 0) {
|
|
905
|
+
const indirectDependencyKey = indirectDependencyKeys.shift();
|
|
906
|
+
++depth;
|
|
907
|
+
if (depth > 99999) {
|
|
908
|
+
throw new Error(
|
|
909
|
+
`Maximum selector dependency depth exceeded (> 99999) in selector "${selectorKey}". This is likely due to a circular dependency.`
|
|
910
|
+
);
|
|
911
|
+
}
|
|
912
|
+
if (!isAtomKey(indirectDependencyKey, store)) {
|
|
913
|
+
indirectDependencyKeys.push(
|
|
914
|
+
...getSelectorDependencyKeys(indirectDependencyKey, store)
|
|
915
|
+
);
|
|
916
|
+
} else if (!rootKeys.includes(indirectDependencyKey)) {
|
|
917
|
+
rootKeys.push(indirectDependencyKey);
|
|
918
|
+
}
|
|
919
|
+
}
|
|
920
|
+
return rootKeys;
|
|
921
|
+
};
|
|
922
|
+
var traceAllSelectorAtoms = (selectorKey, store) => {
|
|
923
|
+
const directDependencyKeys = getSelectorDependencyKeys(selectorKey, store);
|
|
924
|
+
return directDependencyKeys.flatMap(
|
|
925
|
+
(depKey) => isAtomKey(depKey, store) ? depKey : traceSelectorAtoms(selectorKey, depKey, store)
|
|
926
|
+
);
|
|
927
|
+
};
|
|
928
|
+
|
|
929
|
+
// internal/src/selector/update-selector-atoms.ts
|
|
930
|
+
var updateSelectorAtoms = (selectorKey, dependency, store) => {
|
|
931
|
+
const target = newest(store);
|
|
932
|
+
if (dependency.type === `atom`) {
|
|
933
|
+
target.selectorAtoms.set({
|
|
934
|
+
selectorKey,
|
|
935
|
+
atomKey: dependency.key
|
|
936
|
+
});
|
|
937
|
+
store.logger.info(
|
|
938
|
+
`\u{1F50D}`,
|
|
939
|
+
`selector`,
|
|
940
|
+
selectorKey,
|
|
941
|
+
`discovers root atom "${dependency.key}"`
|
|
942
|
+
);
|
|
943
|
+
} else {
|
|
944
|
+
const rootKeys = traceSelectorAtoms(selectorKey, dependency.key, store);
|
|
945
|
+
store.logger.info(
|
|
946
|
+
`\u{1F50D}`,
|
|
947
|
+
`selector`,
|
|
948
|
+
selectorKey,
|
|
949
|
+
`discovers root atoms: [ ${rootKeys.map((key) => `"${key}"`).join(`, `)} ]`
|
|
950
|
+
);
|
|
951
|
+
for (const atomKey of rootKeys) {
|
|
952
|
+
target.selectorAtoms = target.selectorAtoms.set({
|
|
953
|
+
selectorKey,
|
|
954
|
+
atomKey
|
|
955
|
+
});
|
|
956
|
+
}
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
|
|
960
|
+
// internal/src/selector/register-selector.ts
|
|
961
|
+
var registerSelector = (selectorKey, store) => ({
|
|
962
|
+
get: (dependency) => {
|
|
963
|
+
const target = newest(store);
|
|
964
|
+
const alreadyRegistered = target.selectorGraph.getRelationEntries({ downstreamSelectorKey: selectorKey }).some(([_, { source }]) => source === dependency.key);
|
|
965
|
+
const dependencyState = withdraw(dependency, store);
|
|
966
|
+
if (dependencyState === void 0) {
|
|
967
|
+
throw new Error(
|
|
968
|
+
`State "${dependency.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
969
|
+
);
|
|
970
|
+
}
|
|
971
|
+
const dependencyValue = readOrComputeValue(dependencyState, store);
|
|
972
|
+
store.logger.info(
|
|
973
|
+
`\u{1F50C}`,
|
|
974
|
+
`selector`,
|
|
975
|
+
selectorKey,
|
|
976
|
+
`registers dependency ( "${dependency.key}" =`,
|
|
977
|
+
dependencyValue,
|
|
978
|
+
`)`
|
|
979
|
+
);
|
|
980
|
+
if (!alreadyRegistered) {
|
|
981
|
+
target.selectorGraph.set(
|
|
982
|
+
{
|
|
983
|
+
upstreamSelectorKey: dependency.key,
|
|
984
|
+
downstreamSelectorKey: selectorKey
|
|
985
|
+
},
|
|
986
|
+
{
|
|
987
|
+
source: dependency.key
|
|
988
|
+
}
|
|
989
|
+
);
|
|
990
|
+
}
|
|
991
|
+
updateSelectorAtoms(selectorKey, dependency, store);
|
|
992
|
+
return dependencyValue;
|
|
993
|
+
},
|
|
994
|
+
set: (stateToken, newValue) => {
|
|
995
|
+
const state = withdraw(stateToken, store);
|
|
996
|
+
if (state === void 0) {
|
|
997
|
+
throw new Error(
|
|
998
|
+
`State "${stateToken.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
999
|
+
);
|
|
1000
|
+
}
|
|
1001
|
+
setAtomOrSelector(state, newValue, store);
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
1004
|
+
|
|
1005
|
+
// internal/src/selector/create-read-write-selector.ts
|
|
1006
|
+
var createReadWriteSelector = (options, family, store) => {
|
|
1007
|
+
const target = newest(store);
|
|
1008
|
+
const subject = new Subject();
|
|
1009
|
+
const { get, set } = registerSelector(options.key, store);
|
|
1010
|
+
const getSelf = () => {
|
|
1011
|
+
const value = options.get({ get });
|
|
1012
|
+
cacheValue(options.key, value, subject, store);
|
|
1013
|
+
return value;
|
|
1014
|
+
};
|
|
1015
|
+
const setSelf = (next) => {
|
|
1016
|
+
const oldValue = getSelf();
|
|
1017
|
+
const newValue = become(next)(oldValue);
|
|
1018
|
+
store.logger.info(
|
|
1019
|
+
`\u{1F4DD}`,
|
|
1020
|
+
`selector`,
|
|
1021
|
+
options.key,
|
|
1022
|
+
`set (`,
|
|
1023
|
+
oldValue,
|
|
1024
|
+
`->`,
|
|
1025
|
+
newValue,
|
|
1026
|
+
`)`
|
|
1027
|
+
);
|
|
1028
|
+
cacheValue(options.key, newValue, subject, store);
|
|
1029
|
+
markDone(options.key, store);
|
|
1030
|
+
if (target.transactionMeta === null) {
|
|
1031
|
+
subject.next({ newValue, oldValue });
|
|
1032
|
+
}
|
|
1033
|
+
options.set({ get, set }, newValue);
|
|
1034
|
+
};
|
|
1035
|
+
const mySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
1036
|
+
subject,
|
|
1037
|
+
install: (s) => createSelector(options, family, s),
|
|
1038
|
+
get: getSelf,
|
|
1039
|
+
set: setSelf,
|
|
1040
|
+
type: `selector`
|
|
1041
|
+
}), family && { family });
|
|
1042
|
+
target.selectors.set(options.key, mySelector);
|
|
1043
|
+
const initialValue = getSelf();
|
|
1044
|
+
store.logger.info(`\u2728`, mySelector.type, mySelector.key, `=`, initialValue);
|
|
1045
|
+
const token = {
|
|
1046
|
+
key: options.key,
|
|
1047
|
+
type: `selector`
|
|
1048
|
+
};
|
|
1049
|
+
if (family) {
|
|
1050
|
+
token.family = family;
|
|
1051
|
+
}
|
|
1052
|
+
store.subject.selectorCreation.next(token);
|
|
1053
|
+
return token;
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
// internal/src/selector/create-readonly-selector.ts
|
|
1057
|
+
var createReadonlySelector = (options, family, store) => {
|
|
1058
|
+
const target = newest(store);
|
|
1059
|
+
const subject = new Subject();
|
|
1060
|
+
const { get } = registerSelector(options.key, store);
|
|
1061
|
+
const getSelf = () => {
|
|
1062
|
+
const value = options.get({ get });
|
|
1063
|
+
cacheValue(options.key, value, subject, store);
|
|
1064
|
+
return value;
|
|
1065
|
+
};
|
|
1066
|
+
const readonlySelector = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
1067
|
+
subject,
|
|
1068
|
+
install: (s) => createSelector(options, family, s),
|
|
1069
|
+
get: getSelf,
|
|
1070
|
+
type: `readonly_selector`
|
|
1071
|
+
}), family && { family });
|
|
1072
|
+
target.readonlySelectors.set(options.key, readonlySelector);
|
|
1073
|
+
const initialValue = getSelf();
|
|
1074
|
+
store.logger.info(
|
|
1075
|
+
`\u2728`,
|
|
1076
|
+
readonlySelector.type,
|
|
1077
|
+
readonlySelector.key,
|
|
1078
|
+
`=`,
|
|
1079
|
+
initialValue
|
|
1080
|
+
);
|
|
1081
|
+
const token = {
|
|
1082
|
+
key: options.key,
|
|
1083
|
+
type: `readonly_selector`
|
|
1084
|
+
};
|
|
1085
|
+
if (family) {
|
|
1086
|
+
token.family = family;
|
|
1087
|
+
}
|
|
1088
|
+
store.subject.selectorCreation.next(token);
|
|
1089
|
+
return token;
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
// internal/src/selector/create-selector.ts
|
|
1093
|
+
function createSelector(options, family, store) {
|
|
1094
|
+
const target = newest(store);
|
|
1095
|
+
const existingWritable = target.selectors.get(options.key);
|
|
1096
|
+
const existingReadonly = target.readonlySelectors.get(options.key);
|
|
1097
|
+
if (existingWritable || existingReadonly) {
|
|
1098
|
+
store.logger.error(
|
|
1099
|
+
`\u274C`,
|
|
1100
|
+
existingReadonly ? `readonly_selector` : `selector`,
|
|
1101
|
+
options.key,
|
|
1102
|
+
`Tried to create selector, but it already exists in the store. (Ignore if you are in development using hot module replacement.)`
|
|
1103
|
+
);
|
|
1104
|
+
}
|
|
1105
|
+
if (`set` in options) {
|
|
1106
|
+
return createReadWriteSelector(options, family, store);
|
|
1107
|
+
}
|
|
1108
|
+
return createReadonlySelector(options, family, store);
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// internal/src/selector/delete-selector.ts
|
|
1112
|
+
function deleteSelector(selectorToken, store) {
|
|
1113
|
+
const target = newest(store);
|
|
1114
|
+
const { key } = selectorToken;
|
|
1115
|
+
switch (selectorToken.type) {
|
|
1116
|
+
case `selector`:
|
|
1117
|
+
target.selectors.delete(key);
|
|
1118
|
+
break;
|
|
1119
|
+
case `readonly_selector`:
|
|
1120
|
+
target.readonlySelectors.delete(key);
|
|
1121
|
+
break;
|
|
1122
|
+
}
|
|
1123
|
+
target.valueMap.delete(key);
|
|
1124
|
+
target.selectorAtoms.delete(key);
|
|
1125
|
+
const downstreamTokens = target.selectorGraph.getRelationEntries({ upstreamSelectorKey: key }).filter(([_, { source }]) => source === key).map(
|
|
1126
|
+
([downstreamSelectorKey]) => {
|
|
1127
|
+
var _a2;
|
|
1128
|
+
return (_a2 = target.selectors.get(downstreamSelectorKey)) != null ? _a2 : target.readonlySelectors.get(downstreamSelectorKey);
|
|
1129
|
+
}
|
|
1130
|
+
);
|
|
1131
|
+
for (const downstreamToken of downstreamTokens) {
|
|
1132
|
+
if (downstreamToken) {
|
|
1133
|
+
deleteSelector(downstreamToken, store);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
target.selectorGraph.delete(key);
|
|
1137
|
+
store.logger.info(`\u{1F525}`, selectorToken.type, `${key}`, `deleted`);
|
|
1138
|
+
}
|
|
1139
|
+
|
|
1140
|
+
// internal/src/subscribe/recall-state.ts
|
|
1141
|
+
var recallState = (state, store) => {
|
|
1142
|
+
const target = newest(store);
|
|
1143
|
+
if (!target.operation.open) {
|
|
1144
|
+
return target.valueMap.get(state.key);
|
|
1145
|
+
}
|
|
1146
|
+
return target.operation.prev.get(state.key);
|
|
1147
|
+
};
|
|
1148
|
+
|
|
1149
|
+
// internal/src/subscribe/subscribe-to-root-atoms.ts
|
|
1150
|
+
var subscribeToRootAtoms = (state, store) => {
|
|
1151
|
+
const dependencySubscriptions = `default` in state ? null : traceAllSelectorAtoms(state.key, store).map((atomKey) => {
|
|
1152
|
+
const atom2 = store.atoms.get(atomKey);
|
|
1153
|
+
if (atom2 === void 0) {
|
|
1154
|
+
throw new Error(
|
|
1155
|
+
`Atom "${atomKey}", a dependency of selector "${state.key}", not found in store "${store.config.name}".`
|
|
1156
|
+
);
|
|
1157
|
+
}
|
|
1158
|
+
return atom2.subject.subscribe(
|
|
1159
|
+
`${state.type}:${state.key}`,
|
|
1160
|
+
(atomChange) => {
|
|
1161
|
+
store.logger.info(
|
|
1162
|
+
`\u{1F4E2}`,
|
|
1163
|
+
state.type,
|
|
1164
|
+
state.key,
|
|
1165
|
+
`root`,
|
|
1166
|
+
atomKey,
|
|
1167
|
+
`went`,
|
|
1168
|
+
atomChange.oldValue,
|
|
1169
|
+
`->`,
|
|
1170
|
+
atomChange.newValue
|
|
1171
|
+
);
|
|
1172
|
+
const oldValue = recallState(state, store);
|
|
1173
|
+
const newValue = readOrComputeValue(state, store);
|
|
1174
|
+
store.logger.info(
|
|
1175
|
+
`\u2728`,
|
|
1176
|
+
state.type,
|
|
1177
|
+
state.key,
|
|
1178
|
+
`went`,
|
|
1179
|
+
oldValue,
|
|
1180
|
+
`->`,
|
|
1181
|
+
newValue
|
|
1182
|
+
);
|
|
1183
|
+
state.subject.next({ newValue, oldValue });
|
|
1184
|
+
}
|
|
1185
|
+
);
|
|
1186
|
+
});
|
|
1187
|
+
return dependencySubscriptions;
|
|
1188
|
+
};
|
|
1189
|
+
|
|
1190
|
+
// internal/src/subscribe/subscribe-to-state.ts
|
|
1191
|
+
function subscribeToState(token, handleUpdate, key, store) {
|
|
1192
|
+
const state = withdraw(token, store);
|
|
1193
|
+
if (state === void 0) {
|
|
1194
|
+
throw new Error(
|
|
1195
|
+
`State "${token.key}" not found in this store. Did you forget to initialize with the "atom" or "selector" function?`
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1198
|
+
const unsubFunction = state.subject.subscribe(key, handleUpdate);
|
|
1199
|
+
store.logger.info(`\u{1F440}`, state.type, state.key, `Adding subscription "${key}"`);
|
|
1200
|
+
const dependencyUnsubFunctions = state.type !== `atom` ? subscribeToRootAtoms(state, store) : null;
|
|
1201
|
+
const unsubscribe = dependencyUnsubFunctions === null ? () => {
|
|
1202
|
+
store.logger.info(
|
|
1203
|
+
`\u{1F648}`,
|
|
1204
|
+
state.type,
|
|
1205
|
+
state.key,
|
|
1206
|
+
`Removing subscription "${key}"`
|
|
1207
|
+
);
|
|
1208
|
+
unsubFunction();
|
|
1209
|
+
} : () => {
|
|
1210
|
+
store.logger.info(
|
|
1211
|
+
`\u{1F648}`,
|
|
1212
|
+
state.type,
|
|
1213
|
+
state.key,
|
|
1214
|
+
`Removing subscription "${key}"`
|
|
1215
|
+
);
|
|
1216
|
+
unsubFunction();
|
|
1217
|
+
for (const unsubFromDependency of dependencyUnsubFunctions) {
|
|
1218
|
+
unsubFromDependency();
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
return unsubscribe;
|
|
1222
|
+
}
|
|
1223
|
+
|
|
1224
|
+
// internal/src/subscribe/subscribe-to-timeline.ts
|
|
1225
|
+
var subscribeToTimeline = (token, handleUpdate, key, store) => {
|
|
1226
|
+
const tl = withdraw(token, store);
|
|
1227
|
+
if (tl === void 0) {
|
|
1228
|
+
throw new Error(
|
|
1229
|
+
`Cannot subscribe to timeline "${token.key}": timeline not found in store "${store.config.name}".`
|
|
1230
|
+
);
|
|
1231
|
+
}
|
|
1232
|
+
store.logger.info(`\u{1F440}`, `timeline`, token.key, `Adding subscription "${key}"`);
|
|
1233
|
+
const unsubscribe = tl.subject.subscribe(key, handleUpdate);
|
|
1234
|
+
return () => {
|
|
1235
|
+
store.logger.info(
|
|
1236
|
+
`\u{1F648}`,
|
|
1237
|
+
`timeline`,
|
|
1238
|
+
token.key,
|
|
1239
|
+
`Removing subscription "${key}" from timeline`
|
|
1240
|
+
);
|
|
1241
|
+
unsubscribe();
|
|
1242
|
+
};
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1245
|
+
// internal/src/mutable/tracker.ts
|
|
1246
|
+
var Tracker = class {
|
|
1247
|
+
constructor(mutableState, store) {
|
|
1248
|
+
this.unsubscribeFromInnerValue = null;
|
|
1249
|
+
this.mutableState = mutableState;
|
|
1250
|
+
const target = newest(store);
|
|
1251
|
+
this.latestUpdateState = this.initializeState(mutableState, target);
|
|
1252
|
+
this.observeCore(mutableState, this.latestUpdateState, target);
|
|
1253
|
+
this.updateCore(mutableState, this.latestUpdateState, target);
|
|
1254
|
+
target.trackers.set(mutableState.key, this);
|
|
1255
|
+
}
|
|
1256
|
+
initializeState(mutableState, store) {
|
|
1257
|
+
const latestUpdateStateKey = `*${mutableState.key}`;
|
|
1258
|
+
deleteAtom({ type: `atom`, key: latestUpdateStateKey }, store);
|
|
1259
|
+
const familyMetaData = mutableState.family ? {
|
|
1260
|
+
key: `*${mutableState.family.key}`,
|
|
1261
|
+
subKey: mutableState.family.subKey
|
|
1262
|
+
} : void 0;
|
|
1263
|
+
const latestUpdateState = createAtom(
|
|
1264
|
+
{
|
|
1265
|
+
key: latestUpdateStateKey,
|
|
1266
|
+
default: null
|
|
1267
|
+
},
|
|
1268
|
+
familyMetaData,
|
|
1269
|
+
store
|
|
1270
|
+
);
|
|
1271
|
+
return latestUpdateState;
|
|
1272
|
+
}
|
|
1273
|
+
observeCore(mutableState, latestUpdateState, store) {
|
|
1274
|
+
const originalInnerValue = getState(mutableState, store);
|
|
1275
|
+
const target = newest(store);
|
|
1276
|
+
this.unsubscribeFromInnerValue = originalInnerValue.subscribe(
|
|
1277
|
+
`tracker:${store.config.name}:${target.transactionMeta === null ? `main` : target.transactionMeta.update.key}`,
|
|
1278
|
+
(update) => {
|
|
1279
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1280
|
+
mutableState.key,
|
|
1281
|
+
() => {
|
|
1282
|
+
unsubscribe();
|
|
1283
|
+
setState(latestUpdateState, update, store);
|
|
1284
|
+
}
|
|
1285
|
+
);
|
|
1286
|
+
}
|
|
1287
|
+
);
|
|
1288
|
+
subscribeToState(
|
|
1289
|
+
mutableState,
|
|
1290
|
+
(update) => {
|
|
1291
|
+
var _a2;
|
|
1292
|
+
if (update.newValue !== update.oldValue) {
|
|
1293
|
+
(_a2 = this.unsubscribeFromInnerValue) == null ? void 0 : _a2.call(this);
|
|
1294
|
+
const target2 = newest(store);
|
|
1295
|
+
this.unsubscribeFromInnerValue = update.newValue.subscribe(
|
|
1296
|
+
`tracker:${store.config.name}:${target2.transactionMeta === null ? `main` : target2.transactionMeta.update.key}`,
|
|
1297
|
+
(update2) => {
|
|
1298
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1299
|
+
mutableState.key,
|
|
1300
|
+
() => {
|
|
1301
|
+
unsubscribe();
|
|
1302
|
+
setState(latestUpdateState, update2, store);
|
|
1303
|
+
}
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
);
|
|
1307
|
+
}
|
|
1308
|
+
},
|
|
1309
|
+
`${store.config.name}: tracker observing inner value`,
|
|
1310
|
+
store
|
|
1311
|
+
);
|
|
1312
|
+
}
|
|
1313
|
+
updateCore(mutableState, latestUpdateState, store) {
|
|
1314
|
+
subscribeToState(
|
|
1315
|
+
latestUpdateState,
|
|
1316
|
+
({ newValue, oldValue }) => {
|
|
1317
|
+
const timelineId = store.timelineAtoms.getRelatedKey(
|
|
1318
|
+
latestUpdateState.key
|
|
1319
|
+
);
|
|
1320
|
+
if (timelineId) {
|
|
1321
|
+
const timelineData = store.timelines.get(timelineId);
|
|
1322
|
+
if (timelineData == null ? void 0 : timelineData.timeTraveling) {
|
|
1323
|
+
const unsubscribe2 = subscribeToTimeline(
|
|
1324
|
+
{ key: timelineId, type: `timeline` },
|
|
1325
|
+
(update) => {
|
|
1326
|
+
unsubscribe2();
|
|
1327
|
+
setState(
|
|
1328
|
+
mutableState,
|
|
1329
|
+
(transceiver) => {
|
|
1330
|
+
if (update === `redo` && newValue) {
|
|
1331
|
+
transceiver.do(newValue);
|
|
1332
|
+
} else if (update === `undo` && oldValue) {
|
|
1333
|
+
transceiver.undo(oldValue);
|
|
1334
|
+
}
|
|
1335
|
+
return transceiver;
|
|
1336
|
+
},
|
|
1337
|
+
store
|
|
1338
|
+
);
|
|
1339
|
+
},
|
|
1340
|
+
`${mutableState.key}: tracker observing timeline`,
|
|
1341
|
+
store
|
|
1342
|
+
);
|
|
1343
|
+
return;
|
|
1344
|
+
}
|
|
1345
|
+
}
|
|
1346
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1347
|
+
latestUpdateState.key,
|
|
1348
|
+
() => {
|
|
1349
|
+
unsubscribe();
|
|
1350
|
+
const mutable = getState(mutableState, store);
|
|
1351
|
+
const updateNumber = mutable.getUpdateNumber(newValue);
|
|
1352
|
+
const eventOffset = updateNumber - mutable.cacheUpdateNumber;
|
|
1353
|
+
if (newValue && eventOffset === 1) {
|
|
1354
|
+
setState(
|
|
1355
|
+
mutableState,
|
|
1356
|
+
(transceiver) => (transceiver.do(newValue), transceiver),
|
|
1357
|
+
store
|
|
1358
|
+
);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
);
|
|
1362
|
+
},
|
|
1363
|
+
`${store.config.name}: tracker observing latest update`,
|
|
1364
|
+
store
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
};
|
|
1368
|
+
|
|
1369
|
+
// internal/src/mutable/create-mutable-atom.ts
|
|
1370
|
+
function createMutableAtom(options, store) {
|
|
1371
|
+
store.logger.info(
|
|
1372
|
+
`\u{1F527}`,
|
|
1373
|
+
`atom`,
|
|
1374
|
+
options.key,
|
|
1375
|
+
`creating in store "${store.config.name}"`
|
|
1376
|
+
);
|
|
1377
|
+
const coreState = createAtom(options, void 0, store);
|
|
1378
|
+
new Tracker(coreState, store);
|
|
1379
|
+
const jsonState = selectJson(coreState, options, store);
|
|
1380
|
+
const target = newest(store);
|
|
1381
|
+
subscribeToState(
|
|
1382
|
+
jsonState,
|
|
1383
|
+
() => {
|
|
1384
|
+
const trackerHasBeenInitialized = newest(store).trackers.has(coreState.key);
|
|
1385
|
+
if (!trackerHasBeenInitialized) {
|
|
1386
|
+
new Tracker(coreState, store);
|
|
1387
|
+
}
|
|
1388
|
+
},
|
|
1389
|
+
`tracker-initializer:${store == null ? void 0 : store.config.name}:${target.transactionMeta === null ? `main` : `${target.transactionMeta.update.key}`}`,
|
|
1390
|
+
store
|
|
1391
|
+
);
|
|
1392
|
+
return coreState;
|
|
1393
|
+
}
|
|
1394
|
+
|
|
1395
|
+
// internal/src/families/create-atom-family.ts
|
|
1396
|
+
function createAtomFamily(options, store) {
|
|
1397
|
+
const subject = new Subject();
|
|
1398
|
+
const atomFamily2 = Object.assign(
|
|
1399
|
+
(key) => {
|
|
1400
|
+
const subKey = stringifyJson(key);
|
|
1401
|
+
const family = { key: options.key, subKey };
|
|
1402
|
+
const fullKey = `${options.key}(${subKey})`;
|
|
1403
|
+
const existing = withdraw({ key: fullKey, type: `atom` }, store);
|
|
1404
|
+
let token;
|
|
1405
|
+
if (existing) {
|
|
1406
|
+
token = deposit(existing);
|
|
1407
|
+
} else {
|
|
1408
|
+
const individualOptions = {
|
|
1409
|
+
key: fullKey,
|
|
1410
|
+
default: options.default instanceof Function ? options.default(key) : options.default
|
|
1411
|
+
};
|
|
1412
|
+
if (options.effects) {
|
|
1413
|
+
individualOptions.effects = options.effects(key);
|
|
1414
|
+
}
|
|
1415
|
+
token = createAtom(individualOptions, family, store);
|
|
1416
|
+
subject.next(token);
|
|
1417
|
+
}
|
|
1418
|
+
return token;
|
|
1419
|
+
},
|
|
1420
|
+
{
|
|
1421
|
+
key: options.key,
|
|
1422
|
+
type: `atom_family`,
|
|
1423
|
+
subject
|
|
1424
|
+
}
|
|
1425
|
+
);
|
|
1426
|
+
const target = newest(store);
|
|
1427
|
+
target.families.set(options.key, atomFamily2);
|
|
1428
|
+
return atomFamily2;
|
|
1429
|
+
}
|
|
1430
|
+
|
|
1431
|
+
// internal/src/families/create-readonly-selector-family.ts
|
|
1432
|
+
function createReadonlySelectorFamily(options, store) {
|
|
1433
|
+
const subject = new Subject();
|
|
1434
|
+
return Object.assign(
|
|
1435
|
+
(key) => {
|
|
1436
|
+
const target = newest(store);
|
|
1437
|
+
const subKey = stringifyJson(key);
|
|
1438
|
+
const family = { key: options.key, subKey };
|
|
1439
|
+
const fullKey = `${options.key}(${subKey})`;
|
|
1440
|
+
const existing = target.readonlySelectors.get(fullKey);
|
|
1441
|
+
if (existing) {
|
|
1442
|
+
return deposit(existing);
|
|
1443
|
+
}
|
|
1444
|
+
return createSelector(
|
|
1445
|
+
{
|
|
1446
|
+
key: fullKey,
|
|
1447
|
+
get: options.get(key)
|
|
1448
|
+
},
|
|
1449
|
+
family,
|
|
1450
|
+
store
|
|
1451
|
+
);
|
|
1452
|
+
},
|
|
1453
|
+
{
|
|
1454
|
+
key: options.key,
|
|
1455
|
+
type: `readonly_selector_family`,
|
|
1456
|
+
subject
|
|
1457
|
+
}
|
|
1458
|
+
);
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1461
|
+
// internal/src/families/create-selector-family.ts
|
|
1462
|
+
function createSelectorFamily(options, store) {
|
|
1463
|
+
const isReadonly = !(`set` in options);
|
|
1464
|
+
if (isReadonly) {
|
|
1465
|
+
return createReadonlySelectorFamily(options, store);
|
|
1466
|
+
}
|
|
1467
|
+
const target = newest(store);
|
|
1468
|
+
const subject = new Subject();
|
|
1469
|
+
const selectorFamily2 = Object.assign(
|
|
1470
|
+
(key) => {
|
|
1471
|
+
const subKey = stringifyJson(key);
|
|
1472
|
+
const family = { key: options.key, subKey };
|
|
1473
|
+
const fullKey = `${options.key}(${subKey})`;
|
|
1474
|
+
const existing = target.selectors.get(fullKey);
|
|
1475
|
+
if (existing) {
|
|
1476
|
+
return deposit(existing);
|
|
1477
|
+
}
|
|
1478
|
+
const token = createSelector(
|
|
1479
|
+
{
|
|
1480
|
+
key: fullKey,
|
|
1481
|
+
get: options.get(key),
|
|
1482
|
+
set: options.set(key)
|
|
1483
|
+
},
|
|
1484
|
+
family,
|
|
1485
|
+
store
|
|
1486
|
+
);
|
|
1487
|
+
subject.next(token);
|
|
1488
|
+
return token;
|
|
1489
|
+
},
|
|
1490
|
+
{
|
|
1491
|
+
key: options.key,
|
|
1492
|
+
type: `selector_family`
|
|
1493
|
+
}
|
|
1494
|
+
);
|
|
1495
|
+
target.families.set(options.key, selectorFamily2);
|
|
1496
|
+
return selectorFamily2;
|
|
1497
|
+
}
|
|
10
1498
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1499
|
+
// internal/src/mutable/tracker-family.ts
|
|
1500
|
+
var FamilyTracker = class {
|
|
1501
|
+
constructor(findMutableState, store) {
|
|
1502
|
+
this.findLatestUpdateState = createAtomFamily(
|
|
1503
|
+
{
|
|
1504
|
+
key: `*${findMutableState.key}`,
|
|
1505
|
+
default: null
|
|
1506
|
+
},
|
|
1507
|
+
store
|
|
1508
|
+
);
|
|
1509
|
+
this.findMutableState = findMutableState;
|
|
1510
|
+
this.findMutableState.subject.subscribe(
|
|
1511
|
+
`store=${store.config.name}::tracker-atom-family`,
|
|
1512
|
+
(atomToken) => {
|
|
1513
|
+
if (atomToken.family) {
|
|
1514
|
+
const key = parseJson(atomToken.family.subKey);
|
|
1515
|
+
this.findLatestUpdateState(key);
|
|
1516
|
+
new Tracker(atomToken, store);
|
|
1517
|
+
}
|
|
22
1518
|
}
|
|
23
|
-
|
|
1519
|
+
);
|
|
1520
|
+
this.findLatestUpdateState.subject.subscribe(
|
|
1521
|
+
`store=${store.config.name}::tracker-atom-family`,
|
|
1522
|
+
(atomToken) => {
|
|
1523
|
+
if (atomToken.family) {
|
|
1524
|
+
const key = parseJson(atomToken.family.subKey);
|
|
1525
|
+
const mutableAtomToken = this.findMutableState(key);
|
|
1526
|
+
new Tracker(mutableAtomToken, store);
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
);
|
|
24
1530
|
}
|
|
25
|
-
|
|
26
|
-
|
|
1531
|
+
};
|
|
1532
|
+
|
|
1533
|
+
// internal/src/mutable/create-mutable-atom-family.ts
|
|
1534
|
+
function createMutableAtomFamily(options, store) {
|
|
1535
|
+
const coreFamily = Object.assign(
|
|
1536
|
+
createAtomFamily(options, store),
|
|
1537
|
+
options
|
|
1538
|
+
);
|
|
1539
|
+
selectJsonFamily(coreFamily, options);
|
|
1540
|
+
new FamilyTracker(coreFamily, store);
|
|
1541
|
+
return coreFamily;
|
|
27
1542
|
}
|
|
28
1543
|
|
|
29
|
-
|
|
1544
|
+
// internal/src/mutable/transceiver.ts
|
|
1545
|
+
function isTransceiver(value) {
|
|
1546
|
+
return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
|
|
1547
|
+
}
|
|
30
1548
|
|
|
31
|
-
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
1549
|
+
// internal/src/atom/is-default.ts
|
|
1550
|
+
var isAtomDefault = (key, store) => {
|
|
1551
|
+
const core = newest(store);
|
|
1552
|
+
return core.atomsThatAreDefault.has(key);
|
|
1553
|
+
};
|
|
1554
|
+
var markAtomAsDefault = (key, store) => {
|
|
1555
|
+
const core = newest(store);
|
|
1556
|
+
core.atomsThatAreDefault = new Set(core.atomsThatAreDefault).add(key);
|
|
1557
|
+
};
|
|
1558
|
+
var markAtomAsNotDefault = (key, store) => {
|
|
1559
|
+
const core = newest(store);
|
|
1560
|
+
core.atomsThatAreDefault = new Set(newest(store).atomsThatAreDefault);
|
|
1561
|
+
core.atomsThatAreDefault.delete(key);
|
|
1562
|
+
};
|
|
1563
|
+
|
|
1564
|
+
// internal/src/atom/create-atom.ts
|
|
1565
|
+
function createAtom(options, family, store) {
|
|
1566
|
+
store.logger.info(
|
|
1567
|
+
`\u{1F528}`,
|
|
1568
|
+
`atom`,
|
|
1569
|
+
options.key,
|
|
1570
|
+
`creating in store "${store.config.name}"`
|
|
1571
|
+
);
|
|
1572
|
+
const target = newest(store);
|
|
1573
|
+
const existing = target.atoms.get(options.key);
|
|
1574
|
+
if (existing) {
|
|
1575
|
+
store.logger.error(
|
|
1576
|
+
`\u274C`,
|
|
1577
|
+
`atom`,
|
|
1578
|
+
options.key,
|
|
1579
|
+
`Tried to create atom, but it already exists in the store.`,
|
|
1580
|
+
`(Ignore if you are in development using hot module replacement.)`
|
|
1581
|
+
);
|
|
1582
|
+
return deposit(existing);
|
|
1583
|
+
}
|
|
1584
|
+
const subject = new Subject();
|
|
1585
|
+
const newAtom = __spreadValues(__spreadProps(__spreadValues({}, options), {
|
|
1586
|
+
type: `atom`,
|
|
1587
|
+
install: (store2) => {
|
|
1588
|
+
store2.logger.info(
|
|
1589
|
+
`\u{1F6E0}\uFE0F`,
|
|
1590
|
+
`atom`,
|
|
1591
|
+
options.key,
|
|
1592
|
+
`installing in store "${store2.config.name}"`
|
|
1593
|
+
);
|
|
1594
|
+
return `mutable` in options ? createMutableAtom(options, store2) : createAtom(options, void 0, store2);
|
|
1595
|
+
},
|
|
1596
|
+
subject
|
|
1597
|
+
}), family && { family });
|
|
1598
|
+
let initialValue = options.default;
|
|
1599
|
+
if (options.default instanceof Function) {
|
|
1600
|
+
initialValue = options.default();
|
|
1601
|
+
}
|
|
1602
|
+
target.atoms.set(newAtom.key, newAtom);
|
|
1603
|
+
markAtomAsDefault(options.key, store);
|
|
1604
|
+
cacheValue(options.key, initialValue, subject, store);
|
|
1605
|
+
const token = deposit(newAtom);
|
|
1606
|
+
if (options.effects) {
|
|
1607
|
+
let effectIndex = 0;
|
|
1608
|
+
const cleanupFunctions = [];
|
|
1609
|
+
for (const effect of options.effects) {
|
|
1610
|
+
const cleanup = effect({
|
|
1611
|
+
setSelf: (next) => setState(token, next, store),
|
|
1612
|
+
onSet: (handle) => subscribeToState(token, handle, `effect[${effectIndex}]`, store)
|
|
1613
|
+
});
|
|
1614
|
+
if (cleanup) {
|
|
1615
|
+
cleanupFunctions.push(cleanup);
|
|
1616
|
+
}
|
|
1617
|
+
++effectIndex;
|
|
46
1618
|
}
|
|
47
|
-
|
|
1619
|
+
newAtom.cleanup = () => {
|
|
1620
|
+
for (const cleanup of cleanupFunctions) {
|
|
1621
|
+
cleanup();
|
|
1622
|
+
}
|
|
1623
|
+
};
|
|
1624
|
+
}
|
|
1625
|
+
store.subject.atomCreation.next(token);
|
|
1626
|
+
return token;
|
|
1627
|
+
}
|
|
1628
|
+
|
|
1629
|
+
// internal/src/atom/delete-atom.ts
|
|
1630
|
+
function deleteAtom(atomToken, store) {
|
|
1631
|
+
var _a2, _b;
|
|
1632
|
+
const target = newest(store);
|
|
1633
|
+
const { key } = atomToken;
|
|
1634
|
+
const atom2 = target.atoms.get(key);
|
|
1635
|
+
if (!atom2) {
|
|
1636
|
+
store.logger.error(
|
|
1637
|
+
`\u274C`,
|
|
1638
|
+
`atom`,
|
|
1639
|
+
`${key}`,
|
|
1640
|
+
`Tried to delete atom, but it does not exist in the store.`
|
|
1641
|
+
);
|
|
1642
|
+
}
|
|
1643
|
+
(_a2 = atom2 == null ? void 0 : atom2.cleanup) == null ? void 0 : _a2.call(atom2);
|
|
1644
|
+
target.atoms.delete(key);
|
|
1645
|
+
target.valueMap.delete(key);
|
|
1646
|
+
const selectorKeys = target.selectorAtoms.getRelatedKeys(key);
|
|
1647
|
+
if (selectorKeys) {
|
|
1648
|
+
for (const selectorKey of selectorKeys) {
|
|
1649
|
+
const token = (_b = target.selectors.get(selectorKey)) != null ? _b : target.readonlySelectors.get(selectorKey);
|
|
1650
|
+
if (token) {
|
|
1651
|
+
deleteSelector(token, store);
|
|
1652
|
+
}
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
target.selectorAtoms.delete(key);
|
|
1656
|
+
target.atomsThatAreDefault.delete(key);
|
|
1657
|
+
target.timelineAtoms.delete(key);
|
|
1658
|
+
store.logger.info(`\u{1F525}`, `atom`, `${key}`, `deleted`);
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
// internal/src/not-found-error.ts
|
|
1662
|
+
var capitalize = (str) => str[0].toUpperCase() + str.slice(1);
|
|
1663
|
+
function prettyPrintTokenType(token) {
|
|
1664
|
+
if (token.type === `readonly_selector`) {
|
|
1665
|
+
return `Readonly Selector`;
|
|
1666
|
+
}
|
|
1667
|
+
return capitalize(token.type);
|
|
1668
|
+
}
|
|
1669
|
+
var NotFoundError = class extends Error {
|
|
1670
|
+
constructor(token, store) {
|
|
1671
|
+
super(
|
|
1672
|
+
`${prettyPrintTokenType(token)} "${token.key}" not found in store "${store.config.name}".`
|
|
1673
|
+
);
|
|
1674
|
+
}
|
|
48
1675
|
};
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
1676
|
+
|
|
1677
|
+
// internal/src/timeline/time-travel.ts
|
|
1678
|
+
var timeTravel = (direction, token, store) => {
|
|
1679
|
+
const action = direction === `forward` ? `redo` : `undo`;
|
|
1680
|
+
store.logger.info(
|
|
1681
|
+
direction === `forward` ? `\u23E9` : `\u23EA`,
|
|
1682
|
+
`timeline`,
|
|
1683
|
+
token.key,
|
|
1684
|
+
action
|
|
1685
|
+
);
|
|
1686
|
+
const timelineData = store.timelines.get(token.key);
|
|
1687
|
+
if (!timelineData) {
|
|
1688
|
+
store.logger.error(
|
|
1689
|
+
`\u{1F41E}`,
|
|
1690
|
+
`timeline`,
|
|
1691
|
+
token.key,
|
|
1692
|
+
`Failed to ${action}. This timeline has not been initialized.`
|
|
1693
|
+
);
|
|
1694
|
+
return;
|
|
1695
|
+
}
|
|
1696
|
+
if (direction === `forward` && timelineData.at === timelineData.history.length || direction === `backward` && timelineData.at === 0) {
|
|
1697
|
+
store.logger.warn(
|
|
1698
|
+
`\u{1F481}`,
|
|
1699
|
+
`timeline`,
|
|
1700
|
+
token.key,
|
|
1701
|
+
`Failed to ${action} at the ${direction === `forward` ? `end` : `beginning`} of timeline "${token.key}". There is nothing to ${action}.`
|
|
1702
|
+
);
|
|
1703
|
+
return;
|
|
1704
|
+
}
|
|
1705
|
+
timelineData.timeTraveling = direction === `forward` ? `into_future` : `into_past`;
|
|
1706
|
+
if (direction === `backward`) {
|
|
1707
|
+
--timelineData.at;
|
|
1708
|
+
}
|
|
1709
|
+
const update = timelineData.history[timelineData.at];
|
|
1710
|
+
const updateValues = (atomUpdate) => {
|
|
1711
|
+
const { key, newValue, oldValue } = atomUpdate;
|
|
1712
|
+
const value = direction === `forward` ? newValue : oldValue;
|
|
1713
|
+
setState({ key, type: `atom` }, value, store);
|
|
1714
|
+
};
|
|
1715
|
+
const updateValuesFromTransactionUpdate = (transactionUpdate) => {
|
|
1716
|
+
const updates = direction === `forward` ? transactionUpdate.updates : [...transactionUpdate.updates].reverse();
|
|
1717
|
+
for (const updateFromTransaction of updates) {
|
|
1718
|
+
if (`newValue` in updateFromTransaction) {
|
|
1719
|
+
updateValues(updateFromTransaction);
|
|
1720
|
+
} else {
|
|
1721
|
+
updateValuesFromTransactionUpdate(updateFromTransaction);
|
|
1722
|
+
}
|
|
60
1723
|
}
|
|
61
|
-
|
|
1724
|
+
};
|
|
1725
|
+
switch (update.type) {
|
|
1726
|
+
case `atom_update`: {
|
|
1727
|
+
updateValues(update);
|
|
1728
|
+
break;
|
|
1729
|
+
}
|
|
1730
|
+
case `selector_update`: {
|
|
1731
|
+
const updates = direction === `forward` ? update.atomUpdates : [...update.atomUpdates].reverse();
|
|
1732
|
+
for (const atomUpdate of updates) {
|
|
1733
|
+
updateValues(atomUpdate);
|
|
1734
|
+
}
|
|
1735
|
+
break;
|
|
1736
|
+
}
|
|
1737
|
+
case `transaction_update`: {
|
|
1738
|
+
updateValuesFromTransactionUpdate(update);
|
|
1739
|
+
break;
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
if (direction === `forward`) {
|
|
1743
|
+
++timelineData.at;
|
|
1744
|
+
}
|
|
1745
|
+
timelineData.subject.next(action);
|
|
1746
|
+
timelineData.timeTraveling = null;
|
|
1747
|
+
store.logger.info(
|
|
1748
|
+
`\u23F9\uFE0F`,
|
|
1749
|
+
`timeline`,
|
|
1750
|
+
token.key,
|
|
1751
|
+
`"${token.key}" is now at ${timelineData.at} / ${timelineData.history.length}`
|
|
1752
|
+
);
|
|
1753
|
+
};
|
|
1754
|
+
|
|
1755
|
+
// src/atom.ts
|
|
1756
|
+
function atom(options) {
|
|
1757
|
+
if (`mutable` in options) {
|
|
1758
|
+
return createMutableAtom(options, IMPLICIT.STORE);
|
|
1759
|
+
}
|
|
1760
|
+
return createAtom(options, void 0, IMPLICIT.STORE);
|
|
1761
|
+
}
|
|
1762
|
+
function atomFamily(options) {
|
|
1763
|
+
if (`mutable` in options) {
|
|
1764
|
+
return createMutableAtomFamily(options, IMPLICIT.STORE);
|
|
1765
|
+
}
|
|
1766
|
+
return createAtomFamily(options, IMPLICIT.STORE);
|
|
1767
|
+
}
|
|
1768
|
+
|
|
1769
|
+
// src/get-state.ts
|
|
1770
|
+
function getState(token, store = IMPLICIT.STORE) {
|
|
1771
|
+
var _a2;
|
|
1772
|
+
const state = (_a2 = withdraw(token, store)) != null ? _a2 : withdrawNewFamilyMember(token, store);
|
|
1773
|
+
if (state === void 0) {
|
|
1774
|
+
throw new NotFoundError(token, store);
|
|
1775
|
+
}
|
|
1776
|
+
return readOrComputeValue(state, store);
|
|
1777
|
+
}
|
|
1778
|
+
|
|
1779
|
+
// src/logger.ts
|
|
1780
|
+
var simpleLog = (logLevel) => (icon, tokenType, tokenKey, message, ...rest) => {
|
|
1781
|
+
console[logLevel](`${icon} ${tokenType} "${tokenKey}" ${message}`, ...rest);
|
|
1782
|
+
};
|
|
1783
|
+
var simpleLogger = {
|
|
1784
|
+
error: simpleLog(`error`),
|
|
1785
|
+
info: simpleLog(`info`),
|
|
1786
|
+
warn: simpleLog(`warn`)
|
|
1787
|
+
};
|
|
1788
|
+
var AtomIOLogger = class {
|
|
1789
|
+
constructor(logLevel, filter, logger = simpleLogger) {
|
|
1790
|
+
this.logLevel = logLevel;
|
|
1791
|
+
this.filter = filter;
|
|
1792
|
+
this.logger = logger;
|
|
1793
|
+
this.error = (...args) => {
|
|
1794
|
+
var _a2, _b;
|
|
1795
|
+
if (((_b = (_a2 = this.filter) == null ? void 0 : _a2.call(this, ...args)) != null ? _b : true) && this.logLevel !== null) {
|
|
1796
|
+
this.logger.error(...args);
|
|
1797
|
+
}
|
|
1798
|
+
};
|
|
1799
|
+
this.info = (...args) => {
|
|
1800
|
+
var _a2, _b;
|
|
1801
|
+
if (((_b = (_a2 = this.filter) == null ? void 0 : _a2.call(this, ...args)) != null ? _b : true) && this.logLevel === `info`) {
|
|
1802
|
+
this.logger.info(...args);
|
|
1803
|
+
}
|
|
1804
|
+
};
|
|
1805
|
+
this.warn = (...args) => {
|
|
1806
|
+
var _a2, _b;
|
|
1807
|
+
if (((_b = (_a2 = this.filter) == null ? void 0 : _a2.call(this, ...args)) != null ? _b : true) && this.logLevel !== `error` && this.logLevel !== null) {
|
|
1808
|
+
this.logger.warn(...args);
|
|
1809
|
+
}
|
|
1810
|
+
};
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
|
|
1814
|
+
// src/selector.ts
|
|
1815
|
+
function selectorFamily(options) {
|
|
1816
|
+
return createSelectorFamily(options, IMPLICIT.STORE);
|
|
1817
|
+
}
|
|
1818
|
+
|
|
1819
|
+
// src/set-state.ts
|
|
1820
|
+
function setState(token, value, store = IMPLICIT.STORE) {
|
|
1821
|
+
var _a2;
|
|
1822
|
+
const rejection = openOperation(token, store);
|
|
1823
|
+
if (rejection) {
|
|
1824
|
+
return;
|
|
1825
|
+
}
|
|
1826
|
+
const state = (_a2 = withdraw(token, store)) != null ? _a2 : withdrawNewFamilyMember(token, store);
|
|
1827
|
+
if (state === void 0) {
|
|
1828
|
+
throw new NotFoundError(token, store);
|
|
1829
|
+
}
|
|
1830
|
+
setAtomOrSelector(state, value, store);
|
|
1831
|
+
closeOperation(store);
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
// src/timeline.ts
|
|
1835
|
+
var redo = (timeline) => {
|
|
1836
|
+
timeTravel(`forward`, timeline, IMPLICIT.STORE);
|
|
1837
|
+
};
|
|
1838
|
+
var undo = (timeline) => {
|
|
1839
|
+
timeTravel(`backward`, timeline, IMPLICIT.STORE);
|
|
1840
|
+
};
|
|
1841
|
+
|
|
1842
|
+
// introspection/src/attach-atom-index.ts
|
|
1843
|
+
var attachAtomIndex = (store = IMPLICIT.STORE) => {
|
|
1844
|
+
const atomTokenIndexState__INTERNAL = createAtom(
|
|
1845
|
+
{
|
|
1846
|
+
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index (Internal)`,
|
|
1847
|
+
default: () => {
|
|
1848
|
+
const defaultAtomIndex = [...store.atoms].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
1849
|
+
acc[key] = { key, type: `atom` };
|
|
1850
|
+
return acc;
|
|
1851
|
+
}, {});
|
|
1852
|
+
return defaultAtomIndex;
|
|
1853
|
+
},
|
|
1854
|
+
effects: [
|
|
1855
|
+
({ setSelf }) => {
|
|
1856
|
+
store.subject.atomCreation.subscribe(`introspection`, (atomToken) => {
|
|
1857
|
+
if (atomToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
1858
|
+
return;
|
|
1859
|
+
}
|
|
1860
|
+
const set = () => setSelf((state) => {
|
|
1861
|
+
const { key, family } = atomToken;
|
|
1862
|
+
if (family) {
|
|
1863
|
+
const { key: familyKey, subKey } = family;
|
|
1864
|
+
const current = state[familyKey];
|
|
1865
|
+
if (current === void 0 || `familyMembers` in current) {
|
|
1866
|
+
const familyKeyState = current || {
|
|
1867
|
+
key: familyKey,
|
|
1868
|
+
familyMembers: {}
|
|
1869
|
+
};
|
|
1870
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
1871
|
+
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
1872
|
+
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
1873
|
+
[subKey]: atomToken
|
|
1874
|
+
})
|
|
1875
|
+
})
|
|
1876
|
+
});
|
|
1877
|
+
}
|
|
1878
|
+
}
|
|
1879
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
1880
|
+
[key]: atomToken
|
|
1881
|
+
});
|
|
1882
|
+
});
|
|
1883
|
+
if (newest(store).operation.open) {
|
|
1884
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1885
|
+
`introspection: waiting to update atom index`,
|
|
1886
|
+
() => {
|
|
1887
|
+
unsubscribe();
|
|
1888
|
+
set();
|
|
1889
|
+
}
|
|
1890
|
+
);
|
|
1891
|
+
} else {
|
|
1892
|
+
set();
|
|
1893
|
+
}
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
]
|
|
1897
|
+
},
|
|
1898
|
+
void 0,
|
|
1899
|
+
store
|
|
1900
|
+
);
|
|
1901
|
+
return createSelector(
|
|
1902
|
+
{
|
|
1903
|
+
key: `\u{1F441}\u200D\u{1F5E8} Atom Token Index`,
|
|
1904
|
+
get: ({ get }) => get(atomTokenIndexState__INTERNAL)
|
|
1905
|
+
},
|
|
1906
|
+
void 0,
|
|
1907
|
+
store
|
|
1908
|
+
);
|
|
1909
|
+
};
|
|
1910
|
+
|
|
1911
|
+
// introspection/src/attach-selector-index.ts
|
|
1912
|
+
var attachSelectorIndex = (store = IMPLICIT.STORE) => {
|
|
1913
|
+
const readonlySelectorTokenIndexState__INTERNAL = createAtom(
|
|
1914
|
+
{
|
|
1915
|
+
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index (Internal)`,
|
|
1916
|
+
default: () => Object.assign(
|
|
1917
|
+
[...store.readonlySelectors].filter(([key]) => !key.includes(`\u{1F441}\u200D\u{1F5E8}`)).reduce((acc, [key]) => {
|
|
1918
|
+
acc[key] = { key, type: `readonly_selector` };
|
|
1919
|
+
return acc;
|
|
1920
|
+
}, {}),
|
|
1921
|
+
[...store.selectors].reduce((acc, [key]) => {
|
|
1922
|
+
acc[key] = { key, type: `selector` };
|
|
1923
|
+
return acc;
|
|
1924
|
+
}, {})
|
|
1925
|
+
),
|
|
1926
|
+
effects: [
|
|
1927
|
+
({ setSelf }) => {
|
|
1928
|
+
store.subject.selectorCreation.subscribe(
|
|
1929
|
+
`introspection`,
|
|
1930
|
+
(selectorToken) => {
|
|
1931
|
+
if (selectorToken.key.includes(`\u{1F441}\u200D\u{1F5E8}`)) {
|
|
1932
|
+
return;
|
|
1933
|
+
}
|
|
1934
|
+
const set = () => setSelf((state) => {
|
|
1935
|
+
const { key, family } = selectorToken;
|
|
1936
|
+
if (family) {
|
|
1937
|
+
const { key: familyKey, subKey } = family;
|
|
1938
|
+
const current = state[familyKey];
|
|
1939
|
+
if (current === void 0 || `familyMembers` in current) {
|
|
1940
|
+
const familyKeyState = current || {
|
|
1941
|
+
key: familyKey,
|
|
1942
|
+
familyMembers: {}
|
|
1943
|
+
};
|
|
1944
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
1945
|
+
[familyKey]: __spreadProps(__spreadValues({}, familyKeyState), {
|
|
1946
|
+
familyMembers: __spreadProps(__spreadValues({}, familyKeyState.familyMembers), {
|
|
1947
|
+
[subKey]: selectorToken
|
|
1948
|
+
})
|
|
1949
|
+
})
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
return __spreadProps(__spreadValues({}, state), {
|
|
1954
|
+
[key]: selectorToken
|
|
1955
|
+
});
|
|
1956
|
+
});
|
|
1957
|
+
if (newest(store).operation.open) {
|
|
1958
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
1959
|
+
`introspection: waiting to update selector index`,
|
|
1960
|
+
() => {
|
|
1961
|
+
unsubscribe();
|
|
1962
|
+
set();
|
|
1963
|
+
}
|
|
1964
|
+
);
|
|
1965
|
+
} else {
|
|
1966
|
+
set();
|
|
1967
|
+
}
|
|
1968
|
+
}
|
|
1969
|
+
);
|
|
1970
|
+
}
|
|
1971
|
+
]
|
|
1972
|
+
},
|
|
1973
|
+
void 0,
|
|
1974
|
+
store
|
|
1975
|
+
);
|
|
1976
|
+
return createSelector(
|
|
1977
|
+
{
|
|
1978
|
+
key: `\u{1F441}\u200D\u{1F5E8} Selector Token Index`,
|
|
1979
|
+
get: ({ get }) => get(readonlySelectorTokenIndexState__INTERNAL)
|
|
1980
|
+
},
|
|
1981
|
+
void 0,
|
|
1982
|
+
IMPLICIT.STORE
|
|
1983
|
+
);
|
|
1984
|
+
};
|
|
1985
|
+
|
|
1986
|
+
// introspection/src/attach-timeline-family.ts
|
|
1987
|
+
var attachTimelineFamily = (store = IMPLICIT.STORE) => {
|
|
1988
|
+
const findTimelineLogState__INTERNAL = createAtomFamily(
|
|
1989
|
+
{
|
|
1990
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log (Internal)`,
|
|
1991
|
+
default: (key) => {
|
|
1992
|
+
var _a2;
|
|
1993
|
+
return (_a2 = store.timelines.get(key)) != null ? _a2 : {
|
|
1994
|
+
type: `timeline`,
|
|
1995
|
+
key: ``,
|
|
1996
|
+
at: 0,
|
|
1997
|
+
timeTraveling: null,
|
|
1998
|
+
history: [],
|
|
1999
|
+
selectorTime: null,
|
|
2000
|
+
transactionKey: null,
|
|
2001
|
+
install: () => {
|
|
2002
|
+
},
|
|
2003
|
+
subject: new Subject()
|
|
2004
|
+
};
|
|
2005
|
+
},
|
|
2006
|
+
effects: (key) => [
|
|
2007
|
+
({ setSelf }) => {
|
|
2008
|
+
const tl = store.timelines.get(key);
|
|
2009
|
+
tl == null ? void 0 : tl.subject.subscribe(`introspection`, (_) => {
|
|
2010
|
+
if (store.operation.open === true) {
|
|
2011
|
+
const unsubscribe = store.subject.operationStatus.subscribe(
|
|
2012
|
+
`introspection`,
|
|
2013
|
+
(operationStatus) => {
|
|
2014
|
+
if (operationStatus.open === false) {
|
|
2015
|
+
unsubscribe();
|
|
2016
|
+
setSelf(__spreadValues({}, tl));
|
|
2017
|
+
}
|
|
2018
|
+
}
|
|
2019
|
+
);
|
|
2020
|
+
} else {
|
|
2021
|
+
setSelf(__spreadValues({}, tl));
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
}
|
|
2025
|
+
]
|
|
2026
|
+
},
|
|
2027
|
+
store
|
|
2028
|
+
);
|
|
2029
|
+
const findTimelineLogState = createSelectorFamily(
|
|
2030
|
+
{
|
|
2031
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Update Log`,
|
|
2032
|
+
get: (key) => ({ get }) => get(findTimelineLogState__INTERNAL(key))
|
|
2033
|
+
},
|
|
2034
|
+
store
|
|
2035
|
+
);
|
|
2036
|
+
return findTimelineLogState;
|
|
2037
|
+
};
|
|
2038
|
+
|
|
2039
|
+
// introspection/src/attach-timeline-index.ts
|
|
2040
|
+
var attachTimelineIndex = (store = IMPLICIT.STORE) => {
|
|
2041
|
+
const timelineTokenIndexState__INTERNAL = createAtom(
|
|
2042
|
+
{
|
|
2043
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index (Internal)`,
|
|
2044
|
+
default: () => [...store.timelines].map(([key]) => {
|
|
2045
|
+
return { key, type: `timeline` };
|
|
2046
|
+
}),
|
|
2047
|
+
effects: [
|
|
2048
|
+
({ setSelf }) => {
|
|
2049
|
+
store.subject.timelineCreation.subscribe(
|
|
2050
|
+
`introspection`,
|
|
2051
|
+
(timelineToken) => {
|
|
2052
|
+
setSelf((state) => [...state, timelineToken]);
|
|
2053
|
+
}
|
|
2054
|
+
);
|
|
2055
|
+
}
|
|
2056
|
+
]
|
|
2057
|
+
},
|
|
2058
|
+
void 0,
|
|
2059
|
+
store
|
|
2060
|
+
);
|
|
2061
|
+
const timelineTokenIndex = createSelector(
|
|
2062
|
+
{
|
|
2063
|
+
key: `\u{1F441}\u200D\u{1F5E8} Timeline Token Index`,
|
|
2064
|
+
get: ({ get }) => get(timelineTokenIndexState__INTERNAL)
|
|
2065
|
+
},
|
|
2066
|
+
void 0,
|
|
2067
|
+
store
|
|
2068
|
+
);
|
|
2069
|
+
return timelineTokenIndex;
|
|
2070
|
+
};
|
|
2071
|
+
|
|
2072
|
+
// introspection/src/attach-transaction-index.ts
|
|
2073
|
+
var attachTransactionIndex = (store = IMPLICIT.STORE) => {
|
|
2074
|
+
const transactionTokenIndexState__INTERNAL = createAtom(
|
|
2075
|
+
{
|
|
2076
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index (Internal)`,
|
|
2077
|
+
default: () => [...store.transactions].map(([key]) => {
|
|
2078
|
+
return { key, type: `transaction` };
|
|
2079
|
+
}),
|
|
2080
|
+
effects: [
|
|
2081
|
+
({ setSelf }) => {
|
|
2082
|
+
store.subject.transactionCreation.subscribe(
|
|
2083
|
+
`introspection`,
|
|
2084
|
+
(transactionToken) => {
|
|
2085
|
+
setSelf((state) => [...state, transactionToken]);
|
|
2086
|
+
}
|
|
2087
|
+
);
|
|
2088
|
+
}
|
|
2089
|
+
]
|
|
2090
|
+
},
|
|
2091
|
+
void 0,
|
|
2092
|
+
store
|
|
2093
|
+
);
|
|
2094
|
+
const transactionTokenIndex = createSelector(
|
|
2095
|
+
{
|
|
2096
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Token Index`,
|
|
2097
|
+
get: ({ get }) => get(transactionTokenIndexState__INTERNAL)
|
|
2098
|
+
},
|
|
2099
|
+
void 0,
|
|
2100
|
+
store
|
|
2101
|
+
);
|
|
2102
|
+
return transactionTokenIndex;
|
|
62
2103
|
};
|
|
63
2104
|
|
|
64
|
-
//
|
|
2105
|
+
// introspection/src/attach-transaction-logs.ts
|
|
2106
|
+
var attachTransactionLogs = (store = IMPLICIT.STORE) => {
|
|
2107
|
+
const findTransactionUpdateLog = createAtomFamily(
|
|
2108
|
+
{
|
|
2109
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log (Internal)`,
|
|
2110
|
+
default: () => [],
|
|
2111
|
+
effects: (key) => [
|
|
2112
|
+
({ setSelf }) => {
|
|
2113
|
+
const tx = store.transactions.get(key);
|
|
2114
|
+
tx == null ? void 0 : tx.subject.subscribe(`introspection`, (transactionUpdate) => {
|
|
2115
|
+
if (transactionUpdate.key === key) {
|
|
2116
|
+
setSelf((state) => [...state, transactionUpdate]);
|
|
2117
|
+
}
|
|
2118
|
+
});
|
|
2119
|
+
}
|
|
2120
|
+
]
|
|
2121
|
+
},
|
|
2122
|
+
store
|
|
2123
|
+
);
|
|
2124
|
+
const findTransactionUpdateLogState = createSelectorFamily(
|
|
2125
|
+
{
|
|
2126
|
+
key: `\u{1F441}\u200D\u{1F5E8} Transaction Update Log`,
|
|
2127
|
+
get: (key) => ({ get }) => get(findTransactionUpdateLog(key))
|
|
2128
|
+
},
|
|
2129
|
+
store
|
|
2130
|
+
);
|
|
2131
|
+
return findTransactionUpdateLogState;
|
|
2132
|
+
};
|
|
2133
|
+
|
|
2134
|
+
// introspection/src/attach-introspection-states.ts
|
|
2135
|
+
var attachIntrospectionStates = (store = IMPLICIT.STORE) => {
|
|
2136
|
+
return {
|
|
2137
|
+
atomIndex: attachAtomIndex(store),
|
|
2138
|
+
selectorIndex: attachSelectorIndex(store),
|
|
2139
|
+
transactionIndex: attachTransactionIndex(store),
|
|
2140
|
+
findTransactionLogState: attachTransactionLogs(store),
|
|
2141
|
+
timelineIndex: attachTimelineIndex(store),
|
|
2142
|
+
findTimelineState: attachTimelineFamily(store)
|
|
2143
|
+
};
|
|
2144
|
+
};
|
|
2145
|
+
|
|
2146
|
+
// __unstable__/web-effects/src/storage.ts
|
|
65
2147
|
var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, onSet }) => {
|
|
66
2148
|
const savedValue = storage.getItem(key);
|
|
67
2149
|
if (savedValue != null)
|
|
@@ -76,7 +2158,7 @@ var persistAtom = (storage) => ({ stringify, parse }) => (key) => ({ setSelf, on
|
|
|
76
2158
|
};
|
|
77
2159
|
var lazyLocalStorageEffect = persistAtom(localStorage)(JSON);
|
|
78
2160
|
|
|
79
|
-
//
|
|
2161
|
+
// ../anvl/src/function/pipe.ts
|
|
80
2162
|
function pipe(a2, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
81
2163
|
switch (arguments.length) {
|
|
82
2164
|
case 1:
|
|
@@ -107,9 +2189,9 @@ function pipe(a2, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
107
2189
|
}
|
|
108
2190
|
}
|
|
109
2191
|
|
|
110
|
-
//
|
|
2192
|
+
// ../anvl/src/function/index.ts
|
|
111
2193
|
var doNothing = () => void 0;
|
|
112
|
-
var
|
|
2194
|
+
var become2 = (nextVersionOfThing) => (originalThing) => nextVersionOfThing instanceof Function ? nextVersionOfThing(
|
|
113
2195
|
originalThing instanceof Function ? originalThing() : originalThing
|
|
114
2196
|
) : nextVersionOfThing;
|
|
115
2197
|
var isModifier = (validate) => (sample) => {
|
|
@@ -136,7 +2218,7 @@ var fallback = (fn, fallbackValue) => {
|
|
|
136
2218
|
}
|
|
137
2219
|
};
|
|
138
2220
|
|
|
139
|
-
//
|
|
2221
|
+
// ../anvl/src/array/venn.ts
|
|
140
2222
|
var includesAll = (items) => (array) => {
|
|
141
2223
|
for (const item of items) {
|
|
142
2224
|
if (!array.includes(item))
|
|
@@ -146,7 +2228,7 @@ var includesAll = (items) => (array) => {
|
|
|
146
2228
|
};
|
|
147
2229
|
var comprises = (items) => (array) => includesAll(items)(array) && includesAll(array)(items);
|
|
148
2230
|
|
|
149
|
-
//
|
|
2231
|
+
// ../anvl/src/array/index.ts
|
|
150
2232
|
var isArray = (isType) => (input) => Array.isArray(input) && input.every((item) => isType(item));
|
|
151
2233
|
var map = (f) => (a2) => a2.map(f);
|
|
152
2234
|
var every = (f = Boolean) => (a2) => a2.every(f);
|
|
@@ -155,21 +2237,21 @@ var addTo = (a2) => (x) => a2.includes(x) ? a2 : [...a2, x];
|
|
|
155
2237
|
var isEmptyArray = (input) => Array.isArray(input) && input.length === 0;
|
|
156
2238
|
var isOneOf = (...args) => (input) => args.includes(input);
|
|
157
2239
|
|
|
158
|
-
//
|
|
2240
|
+
// ../anvl/src/nullish/index.ts
|
|
159
2241
|
var isUndefined = (input) => input === void 0;
|
|
160
2242
|
var ifDefined = (validate) => (input) => isUndefined(input) || validate(input);
|
|
161
2243
|
var ifNullish = (alt) => (input) => input != null ? input : alt;
|
|
162
2244
|
|
|
163
|
-
//
|
|
2245
|
+
// ../anvl/src/object/access.ts
|
|
164
2246
|
var access = (k) => Object.assign((obj) => obj[k], {
|
|
165
2247
|
in: (obj) => obj[k]
|
|
166
2248
|
});
|
|
167
2249
|
|
|
168
|
-
//
|
|
2250
|
+
// ../anvl/src/object/entries.ts
|
|
169
2251
|
var recordToEntries = (obj) => Object.entries(obj);
|
|
170
2252
|
var entriesToRecord = (entries) => Object.fromEntries(entries);
|
|
171
2253
|
|
|
172
|
-
//
|
|
2254
|
+
// ../anvl/src/object/mapObject.ts
|
|
173
2255
|
var mapObject = (obj, fn) => pipe(
|
|
174
2256
|
obj,
|
|
175
2257
|
recordToEntries,
|
|
@@ -178,7 +2260,7 @@ var mapObject = (obj, fn) => pipe(
|
|
|
178
2260
|
);
|
|
179
2261
|
var mob = (fn) => (obj) => mapObject(obj, fn);
|
|
180
2262
|
|
|
181
|
-
//
|
|
2263
|
+
// ../anvl/src/object/refinement.ts
|
|
182
2264
|
var isNonNullObject = (input) => typeof input === `object` && input !== null;
|
|
183
2265
|
var isPlainObject = (input) => isNonNullObject(input) && Object.getPrototypeOf(input) === Object.prototype;
|
|
184
2266
|
var isEmptyObject = (input) => isPlainObject(input) && Object.keys(input).length === 0;
|
|
@@ -213,7 +2295,7 @@ var doesExtend = (isValue) => hasProperties(isValue, ALLOW_EXTENSION);
|
|
|
213
2295
|
var DO_NOT_ALLOW_EXTENSION = { allowExtraProperties: false };
|
|
214
2296
|
var hasExactProperties = (isValue) => hasProperties(isValue, DO_NOT_ALLOW_EXTENSION);
|
|
215
2297
|
|
|
216
|
-
//
|
|
2298
|
+
// ../anvl/src/object/sprawl.ts
|
|
217
2299
|
var sprawl = (tree, inspector) => {
|
|
218
2300
|
const walk = (path, node) => {
|
|
219
2301
|
const inspect = (path2, node2) => {
|
|
@@ -238,7 +2320,7 @@ var sprawl = (tree, inspector) => {
|
|
|
238
2320
|
walk([], tree);
|
|
239
2321
|
};
|
|
240
2322
|
|
|
241
|
-
//
|
|
2323
|
+
// ../anvl/src/object/index.ts
|
|
242
2324
|
var treeShake = (shouldDiscard = isUndefined) => (obj) => {
|
|
243
2325
|
const newObj = {};
|
|
244
2326
|
const entries = Object.entries(obj);
|
|
@@ -254,7 +2336,7 @@ var delve = (obj, path) => {
|
|
|
254
2336
|
return found === void 0 ? new Error(`Not found`) : { found };
|
|
255
2337
|
};
|
|
256
2338
|
|
|
257
|
-
//
|
|
2339
|
+
// ../anvl/src/refinement/refinery.ts
|
|
258
2340
|
var Refinery = class {
|
|
259
2341
|
constructor(supported) {
|
|
260
2342
|
this.supported = supported;
|
|
@@ -299,7 +2381,7 @@ var discoverType = (input) => {
|
|
|
299
2381
|
return Object.getPrototypeOf(input).constructor.name;
|
|
300
2382
|
};
|
|
301
2383
|
|
|
302
|
-
//
|
|
2384
|
+
// ../anvl/src/tree/differ.ts
|
|
303
2385
|
function diffNumber(a2, b2) {
|
|
304
2386
|
const sign = a2 < b2 ? `+` : `-`;
|
|
305
2387
|
return {
|
|
@@ -416,38 +2498,26 @@ var Differ = class {
|
|
|
416
2498
|
};
|
|
417
2499
|
}
|
|
418
2500
|
};
|
|
2501
|
+
var StoreContext = React2__namespace.createContext(IMPLICIT.STORE);
|
|
2502
|
+
function useI(token) {
|
|
2503
|
+
const store = React2__namespace.useContext(StoreContext);
|
|
2504
|
+
const setter = React2__namespace.useRef(null);
|
|
2505
|
+
if (setter.current === null) {
|
|
2506
|
+
setter.current = (next) => setState(token, next, store);
|
|
2507
|
+
}
|
|
2508
|
+
return setter.current;
|
|
2509
|
+
}
|
|
2510
|
+
function useO(token) {
|
|
2511
|
+
const store = React2__namespace.useContext(StoreContext);
|
|
2512
|
+
const id = React2__namespace.useId();
|
|
2513
|
+
return React2__namespace.useSyncExternalStore(
|
|
2514
|
+
(dispatch) => subscribeToState(token, dispatch, `use-o:${id}`, store),
|
|
2515
|
+
() => getState(token, store),
|
|
2516
|
+
() => getState(token, store)
|
|
2517
|
+
);
|
|
2518
|
+
}
|
|
419
2519
|
|
|
420
|
-
//
|
|
421
|
-
var stringifyJson = (json) => JSON.stringify(json);
|
|
422
|
-
var JSON_TYPE_NAMES = [
|
|
423
|
-
`array`,
|
|
424
|
-
`boolean`,
|
|
425
|
-
`null`,
|
|
426
|
-
`number`,
|
|
427
|
-
`object`,
|
|
428
|
-
`string`
|
|
429
|
-
];
|
|
430
|
-
var JSON_DEFAULTS = {
|
|
431
|
-
array: [],
|
|
432
|
-
boolean: false,
|
|
433
|
-
null: null,
|
|
434
|
-
number: 0,
|
|
435
|
-
object: {},
|
|
436
|
-
string: ``
|
|
437
|
-
};
|
|
438
|
-
|
|
439
|
-
// ../../anvl/src/primitive/index.ts
|
|
440
|
-
var isString = (input) => {
|
|
441
|
-
return typeof input === `string`;
|
|
442
|
-
};
|
|
443
|
-
var isNumber = (input) => {
|
|
444
|
-
return typeof input === `number`;
|
|
445
|
-
};
|
|
446
|
-
var isBoolean = (input) => {
|
|
447
|
-
return typeof input === `boolean`;
|
|
448
|
-
};
|
|
449
|
-
|
|
450
|
-
// ../../anvl/src/refinement/refine-json.ts
|
|
2520
|
+
// ../anvl/src/refinement/refine-json.ts
|
|
451
2521
|
var JSON_PROTOTYPES = [
|
|
452
2522
|
`Array`,
|
|
453
2523
|
`Boolean`,
|
|
@@ -484,13 +2554,13 @@ var button = {
|
|
|
484
2554
|
OpenClose
|
|
485
2555
|
};
|
|
486
2556
|
|
|
487
|
-
//
|
|
2557
|
+
// ../anvl/src/refinement/can-exist.ts
|
|
488
2558
|
var canExist = (_) => true;
|
|
489
2559
|
|
|
490
|
-
//
|
|
2560
|
+
// ../anvl/src/refinement/cannot-exist.ts
|
|
491
2561
|
var cannotExist = (_) => false;
|
|
492
2562
|
|
|
493
|
-
//
|
|
2563
|
+
// ../anvl/src/refinement/is-union.ts
|
|
494
2564
|
var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isTypeA]) => {
|
|
495
2565
|
const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` | `)})`;
|
|
496
2566
|
const _ = {
|
|
@@ -514,7 +2584,7 @@ var mustSatisfyOneOfTheFollowing = (isTypeA, logging = false, refinements = [isT
|
|
|
514
2584
|
};
|
|
515
2585
|
var isUnion = mustSatisfyOneOfTheFollowing(cannotExist);
|
|
516
2586
|
|
|
517
|
-
//
|
|
2587
|
+
// ../anvl/src/refinement/is-intersection.ts
|
|
518
2588
|
function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [isTypeA]) {
|
|
519
2589
|
const name = `(${refinements.map((r) => (r == null ? void 0 : r.name) || `anon`).join(` & `)})`;
|
|
520
2590
|
const _ = {
|
|
@@ -538,11 +2608,11 @@ function mustSatisfyAllOfTheFollowing(isTypeA, logging = false, refinements = [i
|
|
|
538
2608
|
}
|
|
539
2609
|
var isIntersection = mustSatisfyAllOfTheFollowing(canExist);
|
|
540
2610
|
|
|
541
|
-
//
|
|
2611
|
+
// ../anvl/src/refinement/index.ts
|
|
542
2612
|
var isLiteral = (value) => (input) => input === value;
|
|
543
2613
|
var isWithin = (args) => (input) => args.includes(input);
|
|
544
2614
|
|
|
545
|
-
//
|
|
2615
|
+
// ../anvl/src/join/core-relation-data.ts
|
|
546
2616
|
var RELATION_TYPES = [`1:1`, `1:n`, `n:n`];
|
|
547
2617
|
var isRelationType = (x) => RELATION_TYPES.includes(x);
|
|
548
2618
|
var EMPTY_RELATION_DATA = {
|
|
@@ -566,7 +2636,7 @@ var isRelationData = ({
|
|
|
566
2636
|
})(input);
|
|
567
2637
|
};
|
|
568
2638
|
|
|
569
|
-
//
|
|
2639
|
+
// ../anvl/src/join/get-related-ids.ts
|
|
570
2640
|
var getRelatedIds = (relationMap, id) => {
|
|
571
2641
|
var _a2;
|
|
572
2642
|
return (_a2 = relationMap.relations[id]) != null ? _a2 : [];
|
|
@@ -581,7 +2651,7 @@ var getRelatedId = (relationMap, id) => {
|
|
|
581
2651
|
return relations[0];
|
|
582
2652
|
};
|
|
583
2653
|
|
|
584
|
-
//
|
|
2654
|
+
// ../anvl/src/join/make-json-interface.ts
|
|
585
2655
|
var makeJsonInterface = (join, ...params) => {
|
|
586
2656
|
const isContent = params[0];
|
|
587
2657
|
const { a: a2, b: b2 } = join;
|
|
@@ -596,17 +2666,17 @@ var makeJsonInterface = (join, ...params) => {
|
|
|
596
2666
|
};
|
|
597
2667
|
};
|
|
598
2668
|
|
|
599
|
-
//
|
|
2669
|
+
// ../anvl/src/join/relation-record.ts
|
|
600
2670
|
var getRelationEntries = (relationMap, idA) => getRelatedIds(relationMap, idA).map((idB) => [
|
|
601
2671
|
idB,
|
|
602
2672
|
getContent(relationMap, idA, idB)
|
|
603
2673
|
]);
|
|
604
2674
|
var getRelationRecord = (relationMap, id) => Object.fromEntries(getRelationEntries(relationMap, id));
|
|
605
2675
|
|
|
606
|
-
//
|
|
2676
|
+
// ../anvl/src/string/split.ts
|
|
607
2677
|
var split = (separator) => (str) => str.split(separator);
|
|
608
2678
|
|
|
609
|
-
//
|
|
2679
|
+
// ../anvl/src/join/remove-relation.ts
|
|
610
2680
|
var removeSpecific = (current, idA, idB) => {
|
|
611
2681
|
const isIdForRemoval = isOneOf(idA, idB);
|
|
612
2682
|
return __spreadProps(__spreadValues({}, current), {
|
|
@@ -655,7 +2725,7 @@ var removeRelation = (current, relation) => {
|
|
|
655
2725
|
return idB ? removeSpecific(current, idA, idB) : removeAll(current, idA);
|
|
656
2726
|
};
|
|
657
2727
|
|
|
658
|
-
//
|
|
2728
|
+
// ../anvl/src/join/set-relation.ts
|
|
659
2729
|
var setManyToMany = (map2, idA, idB, ...rest) => {
|
|
660
2730
|
var _a2, _b;
|
|
661
2731
|
const next = __spreadProps(__spreadValues({}, map2), {
|
|
@@ -709,7 +2779,7 @@ var setRelationWithContent = (current, relation, ...rest) => {
|
|
|
709
2779
|
}
|
|
710
2780
|
};
|
|
711
2781
|
|
|
712
|
-
//
|
|
2782
|
+
// ../anvl/src/join/relation-contents.ts
|
|
713
2783
|
var makeContentId = (idA, idB) => [idA, idB].sort().join(`/`);
|
|
714
2784
|
var getContent = (relationMap, idA, idB) => relationMap.contents[makeContentId(idA, idB)];
|
|
715
2785
|
var setContent = (map2, idA, idB, content) => __spreadProps(__spreadValues({}, map2), {
|
|
@@ -767,7 +2837,7 @@ var setRelations = (current, subject, relations) => {
|
|
|
767
2837
|
);
|
|
768
2838
|
};
|
|
769
2839
|
|
|
770
|
-
//
|
|
2840
|
+
// ../anvl/src/join/index.ts
|
|
771
2841
|
var Join = class _Join {
|
|
772
2842
|
constructor(json) {
|
|
773
2843
|
this.a = `from`;
|
|
@@ -836,12 +2906,12 @@ var Join = class _Join {
|
|
|
836
2906
|
);
|
|
837
2907
|
}
|
|
838
2908
|
};
|
|
839
|
-
var ElasticInput =
|
|
2909
|
+
var ElasticInput = React2.forwardRef(function ElasticInputFC(props, ref) {
|
|
840
2910
|
var _a2, _b, _c, _d;
|
|
841
|
-
const inputRef =
|
|
842
|
-
const spanRef =
|
|
843
|
-
const [inputWidth, setInputWidth] =
|
|
844
|
-
|
|
2911
|
+
const inputRef = React2.useRef(null);
|
|
2912
|
+
const spanRef = React2.useRef(null);
|
|
2913
|
+
const [inputWidth, setInputWidth] = React2.useState(`auto`);
|
|
2914
|
+
React2.useImperativeHandle(
|
|
845
2915
|
ref,
|
|
846
2916
|
() => ({
|
|
847
2917
|
focus: () => {
|
|
@@ -851,7 +2921,7 @@ var ElasticInput = React.forwardRef(function ElasticInputFC(props, ref) {
|
|
|
851
2921
|
})
|
|
852
2922
|
);
|
|
853
2923
|
const extraWidth = props.type === `number` ? 15 : 0;
|
|
854
|
-
|
|
2924
|
+
React2.useLayoutEffect(() => {
|
|
855
2925
|
if (spanRef.current) {
|
|
856
2926
|
setInputWidth(`${spanRef.current.offsetWidth + extraWidth}px`);
|
|
857
2927
|
const interval = setInterval(() => {
|
|
@@ -896,10 +2966,10 @@ var ElasticInput = React.forwardRef(function ElasticInputFC(props, ref) {
|
|
|
896
2966
|
] });
|
|
897
2967
|
});
|
|
898
2968
|
|
|
899
|
-
//
|
|
2969
|
+
// ../anvl/src/number/clamp.ts
|
|
900
2970
|
var clampInto = (min, max) => (value) => value < min ? min : value > max ? max : value;
|
|
901
2971
|
|
|
902
|
-
//
|
|
2972
|
+
// ../anvl/src/number/wrap.ts
|
|
903
2973
|
var wrapInto = (min, max) => (value) => value < min ? max - (min - value) % (max - min) : min + (value - min) % (max - min);
|
|
904
2974
|
function round(value, decimalPlaces) {
|
|
905
2975
|
if (decimalPlaces === void 0)
|
|
@@ -961,9 +3031,9 @@ var NumberInput = ({
|
|
|
961
3031
|
testId,
|
|
962
3032
|
value = null
|
|
963
3033
|
}) => {
|
|
964
|
-
const id =
|
|
965
|
-
const [temporaryEntry, setTemporaryEntry] =
|
|
966
|
-
const userHasMadeDeliberateChange =
|
|
3034
|
+
const id = React2.useId();
|
|
3035
|
+
const [temporaryEntry, setTemporaryEntry] = React2.useState(null);
|
|
3036
|
+
const userHasMadeDeliberateChange = React2.useRef(false);
|
|
967
3037
|
const refine = initRefinery({ max, min, decimalPlaces, nullable: true });
|
|
968
3038
|
const allowDecimal = decimalPlaces === void 0 || decimalPlaces > 0;
|
|
969
3039
|
const handleBlur = () => {
|
|
@@ -1133,11 +3203,11 @@ var JsonEditor_INTERNAL = ({
|
|
|
1133
3203
|
] }) });
|
|
1134
3204
|
};
|
|
1135
3205
|
|
|
1136
|
-
//
|
|
3206
|
+
// ../hamr/src/react-json-editor/editors-by-type/utilities/array-elements.ts
|
|
1137
3207
|
var makeElementSetters = (data, set) => data.map(
|
|
1138
3208
|
(value, index) => (newValue) => set(() => {
|
|
1139
3209
|
const newData = [...data];
|
|
1140
|
-
newData[index] =
|
|
3210
|
+
newData[index] = become2(newValue)(value);
|
|
1141
3211
|
return newData;
|
|
1142
3212
|
})
|
|
1143
3213
|
);
|
|
@@ -1167,7 +3237,7 @@ var ArrayEditor = ({
|
|
|
1167
3237
|
}) });
|
|
1168
3238
|
};
|
|
1169
3239
|
|
|
1170
|
-
//
|
|
3240
|
+
// ../anvl/src/json-schema/integer.ts
|
|
1171
3241
|
var isInteger = (input) => Number.isInteger(input);
|
|
1172
3242
|
var parseInteger = (input) => {
|
|
1173
3243
|
if (isInteger(input))
|
|
@@ -1228,7 +3298,7 @@ asNumber(new Fraction(1, 2));
|
|
|
1228
3298
|
asNumber([new Fraction(1, 2)]);
|
|
1229
3299
|
asNumber({ a: new Fraction(1, 2) });
|
|
1230
3300
|
|
|
1231
|
-
//
|
|
3301
|
+
// ../anvl/src/json-schema/refs.ts
|
|
1232
3302
|
function isJsonSchemaRef(input) {
|
|
1233
3303
|
return doesExtend({
|
|
1234
3304
|
$ref: isString
|
|
@@ -1281,7 +3351,7 @@ var retrieveRef = ({
|
|
|
1281
3351
|
throw new TypeError(`The refNode is not a JsonSchema`);
|
|
1282
3352
|
};
|
|
1283
3353
|
|
|
1284
|
-
//
|
|
3354
|
+
// ../anvl/src/json-schema/string-formats.ts
|
|
1285
3355
|
var JSON_SCHEMA_STRING_FORMATS = [
|
|
1286
3356
|
`date-time`,
|
|
1287
3357
|
`date`,
|
|
@@ -1297,7 +3367,7 @@ var JSON_SCHEMA_STRING_FORMATS = [
|
|
|
1297
3367
|
`uuid`
|
|
1298
3368
|
];
|
|
1299
3369
|
|
|
1300
|
-
//
|
|
3370
|
+
// ../anvl/src/json-schema/json-schema.ts
|
|
1301
3371
|
var JSON_SCHEMA_TYPE_NAMES = [...JSON_TYPE_NAMES, `integer`];
|
|
1302
3372
|
[
|
|
1303
3373
|
...JSON_SCHEMA_TYPE_NAMES,
|
|
@@ -1420,7 +3490,7 @@ function isJsonSchema(input) {
|
|
|
1420
3490
|
return mustSatisfyOneOfTheFollowing(isBoolean).or(isJsonSchemaObject).or(isJsonSchemaRef)(input);
|
|
1421
3491
|
}
|
|
1422
3492
|
|
|
1423
|
-
//
|
|
3493
|
+
// ../anvl/src/json-schema/path-into.ts
|
|
1424
3494
|
var expandPathForSchema = (path) => {
|
|
1425
3495
|
try {
|
|
1426
3496
|
return path.flatMap((key) => {
|
|
@@ -1448,7 +3518,7 @@ var expandPathForSchema = (path) => {
|
|
|
1448
3518
|
}
|
|
1449
3519
|
};
|
|
1450
3520
|
|
|
1451
|
-
//
|
|
3521
|
+
// ../anvl/src/json-schema/find-sub-schema.ts
|
|
1452
3522
|
var findSubSchema = (schema) => {
|
|
1453
3523
|
if (typeof schema === `boolean`) {
|
|
1454
3524
|
throw new Error(`The schema does not contain subSchemas`);
|
|
@@ -1479,7 +3549,7 @@ var findSubSchema = (schema) => {
|
|
|
1479
3549
|
};
|
|
1480
3550
|
};
|
|
1481
3551
|
|
|
1482
|
-
//
|
|
3552
|
+
// ../anvl/src/json/cast-json.ts
|
|
1483
3553
|
var stringToBoolean = (str) => str === `true`;
|
|
1484
3554
|
var stringToNumber = (str) => Number(str);
|
|
1485
3555
|
var stringToArray = (str) => str.split(`,`);
|
|
@@ -1525,7 +3595,7 @@ var nullToBoolean = () => false;
|
|
|
1525
3595
|
var nullToArray = () => [];
|
|
1526
3596
|
var nullToObject = () => ({});
|
|
1527
3597
|
|
|
1528
|
-
//
|
|
3598
|
+
// ../anvl/src/refinement/smart-cast-json.ts
|
|
1529
3599
|
var castToJson = (input) => {
|
|
1530
3600
|
const json = refineJsonType(input);
|
|
1531
3601
|
return {
|
|
@@ -1615,10 +3685,10 @@ var castToJson = (input) => {
|
|
|
1615
3685
|
};
|
|
1616
3686
|
};
|
|
1617
3687
|
|
|
1618
|
-
//
|
|
3688
|
+
// ../hamr/src/react-json-editor/editors-by-type/utilities/object-properties.ts
|
|
1619
3689
|
var makePropertySetters = (data, set) => mapObject(
|
|
1620
3690
|
data,
|
|
1621
|
-
(value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]:
|
|
3691
|
+
(value, key) => (newValue) => set(__spreadProps(__spreadValues({}, data), { [key]: become2(newValue)(value[key]) }))
|
|
1622
3692
|
);
|
|
1623
3693
|
var makePropertyRenamers = (data, set, stableKeyMapRef) => mapObject(
|
|
1624
3694
|
data,
|
|
@@ -1677,7 +3747,7 @@ var ObjectEditor = ({
|
|
|
1677
3747
|
}) => {
|
|
1678
3748
|
var _a2;
|
|
1679
3749
|
const disabled = isReadonly(path);
|
|
1680
|
-
const stableKeyMap =
|
|
3750
|
+
const stableKeyMap = React2.useRef(
|
|
1681
3751
|
Object.keys(data).reduce(
|
|
1682
3752
|
(acc, key) => {
|
|
1683
3753
|
acc[key] = key;
|
|
@@ -1843,7 +3913,7 @@ var DefaultFallback = ({ error, errorInfo }) => {
|
|
|
1843
3913
|
}
|
|
1844
3914
|
);
|
|
1845
3915
|
};
|
|
1846
|
-
var ErrorBoundary = class extends
|
|
3916
|
+
var ErrorBoundary = class extends React2.Component {
|
|
1847
3917
|
constructor(props) {
|
|
1848
3918
|
super(props);
|
|
1849
3919
|
this.state = {};
|
|
@@ -1941,7 +4011,7 @@ var JsonEditor = ({
|
|
|
1941
4011
|
);
|
|
1942
4012
|
};
|
|
1943
4013
|
|
|
1944
|
-
//
|
|
4014
|
+
// ../hamr/src/react-json-editor/index.ts
|
|
1945
4015
|
var SubEditors = {
|
|
1946
4016
|
array: ArrayEditor,
|
|
1947
4017
|
boolean: BooleanEditor,
|
|
@@ -1951,7 +4021,7 @@ var SubEditors = {
|
|
|
1951
4021
|
string: StringEditor
|
|
1952
4022
|
};
|
|
1953
4023
|
|
|
1954
|
-
//
|
|
4024
|
+
// ../anvl/src/string/string-to-color.ts
|
|
1955
4025
|
function stringToColor(input) {
|
|
1956
4026
|
let hash = 0;
|
|
1957
4027
|
for (let i = 0; i < input.length; i++) {
|
|
@@ -1966,20 +4036,20 @@ function stringToColor(input) {
|
|
|
1966
4036
|
return `#${hexColor}`;
|
|
1967
4037
|
}
|
|
1968
4038
|
|
|
1969
|
-
//
|
|
4039
|
+
// ../luum/src/constants/index.ts
|
|
1970
4040
|
var CHANNEL_SPECIFIC_LUM = {
|
|
1971
4041
|
R: 0.3,
|
|
1972
4042
|
G: 0.5,
|
|
1973
4043
|
B: 0.2
|
|
1974
4044
|
};
|
|
1975
4045
|
|
|
1976
|
-
//
|
|
4046
|
+
// ../luum/src/constants/filters.ts
|
|
1977
4047
|
var unfiltered = [
|
|
1978
4048
|
{ sat: 255, hue: 0 },
|
|
1979
4049
|
{ sat: 255, hue: 360 }
|
|
1980
4050
|
];
|
|
1981
4051
|
|
|
1982
|
-
//
|
|
4052
|
+
// ../luum/src/export/channelsToHex.ts
|
|
1983
4053
|
var channelsToHex = (channels) => `#${Object.values(channels).map((channel) => {
|
|
1984
4054
|
let channelHex = channel.toString(16);
|
|
1985
4055
|
if (channelHex.length === 1)
|
|
@@ -1988,7 +4058,7 @@ var channelsToHex = (channels) => `#${Object.values(channels).map((channel) => {
|
|
|
1988
4058
|
}).join(``)}`;
|
|
1989
4059
|
var channelsToHex_default = channelsToHex;
|
|
1990
4060
|
|
|
1991
|
-
//
|
|
4061
|
+
// ../luum/src/import/hueToRelativeChannels.ts
|
|
1992
4062
|
var hueToRelativeChannels_default = (hue) => {
|
|
1993
4063
|
const hueWrapped = wrapInto(0, 360)(hue);
|
|
1994
4064
|
const hueReduced = hueWrapped / 60;
|
|
@@ -2014,7 +4084,7 @@ var hueToRelativeChannels_default = (hue) => {
|
|
|
2014
4084
|
}
|
|
2015
4085
|
};
|
|
2016
4086
|
|
|
2017
|
-
//
|
|
4087
|
+
// ../luum/src/solveFor/hueFromChannels.ts
|
|
2018
4088
|
var hueFromChannels = ({ R, G, B }) => {
|
|
2019
4089
|
let hue = 0;
|
|
2020
4090
|
if (R > G && G >= B)
|
|
@@ -2033,14 +4103,14 @@ var hueFromChannels = ({ R, G, B }) => {
|
|
|
2033
4103
|
};
|
|
2034
4104
|
var hueFromChannels_default = hueFromChannels;
|
|
2035
4105
|
|
|
2036
|
-
//
|
|
4106
|
+
// ../luum/src/solveFor/lumFromChannels.ts
|
|
2037
4107
|
var lumFromChannels = ({ R, G, B }) => {
|
|
2038
4108
|
const lum = CHANNEL_SPECIFIC_LUM.R * R / 255 + CHANNEL_SPECIFIC_LUM.G * G / 255 + CHANNEL_SPECIFIC_LUM.B * B / 255;
|
|
2039
4109
|
return lum;
|
|
2040
4110
|
};
|
|
2041
4111
|
var lumFromChannels_default = lumFromChannels;
|
|
2042
4112
|
|
|
2043
|
-
//
|
|
4113
|
+
// ../luum/src/solveFor/maxSatForHueInFilter.ts
|
|
2044
4114
|
var maxSatForHueInFilter_default = (hue, filter) => {
|
|
2045
4115
|
let maxSat = 255;
|
|
2046
4116
|
const hueWrapped = wrapInto(0, 360)(hue);
|
|
@@ -2063,14 +4133,14 @@ var maxSatForHueInFilter_default = (hue, filter) => {
|
|
|
2063
4133
|
return maxSat;
|
|
2064
4134
|
};
|
|
2065
4135
|
|
|
2066
|
-
//
|
|
4136
|
+
// ../luum/src/solveFor/satFromChannels.ts
|
|
2067
4137
|
var satFromChannels = ({ R, G, B }) => {
|
|
2068
4138
|
const sat = Math.max(R, G, B) - Math.min(R, G, B);
|
|
2069
4139
|
return sat;
|
|
2070
4140
|
};
|
|
2071
4141
|
var satFromChannels_default = satFromChannels;
|
|
2072
4142
|
|
|
2073
|
-
//
|
|
4143
|
+
// ../luum/src/solveFor/specificLumFromHue.ts
|
|
2074
4144
|
var specificLumFromHue_default = (hue) => {
|
|
2075
4145
|
const [factorR, factorG, factorB] = hueToRelativeChannels_default(hue);
|
|
2076
4146
|
const lumR = CHANNEL_SPECIFIC_LUM.R * factorR;
|
|
@@ -2080,7 +4150,7 @@ var specificLumFromHue_default = (hue) => {
|
|
|
2080
4150
|
return specificLum;
|
|
2081
4151
|
};
|
|
2082
4152
|
|
|
2083
|
-
//
|
|
4153
|
+
// ../luum/src/export/specToChannelsFixLimit.ts
|
|
2084
4154
|
var minChannelsForSaturationFromHue = (hue) => {
|
|
2085
4155
|
const relativeChannels = hueToRelativeChannels_default(hue);
|
|
2086
4156
|
const channelSpreader = (trueSaturation) => {
|
|
@@ -2164,7 +4234,7 @@ var specToChannelsFixLimit = ({ hue, sat, lum, prefer = `lum` }, filter = unfilt
|
|
|
2164
4234
|
};
|
|
2165
4235
|
var specToChannelsFixLimit_default = specToChannelsFixLimit;
|
|
2166
4236
|
|
|
2167
|
-
//
|
|
4237
|
+
// ../luum/src/export/specToHexFixLimit.ts
|
|
2168
4238
|
var specToHexFixLimit = ({ hue, sat, lum, prefer }, filter) => {
|
|
2169
4239
|
const { channels, fix, limit } = specToChannelsFixLimit_default(
|
|
2170
4240
|
{
|
|
@@ -2181,14 +4251,14 @@ var specToHexFixLimit = ({ hue, sat, lum, prefer }, filter) => {
|
|
|
2181
4251
|
};
|
|
2182
4252
|
var specToHexFixLimit_default = specToHexFixLimit;
|
|
2183
4253
|
|
|
2184
|
-
//
|
|
4254
|
+
// ../luum/src/export/specToHex.ts
|
|
2185
4255
|
var specToHex = ({ hue, sat, lum, prefer }, filter) => {
|
|
2186
4256
|
const { hex } = specToHexFixLimit_default({ hue, sat, lum, prefer }, filter);
|
|
2187
4257
|
return hex;
|
|
2188
4258
|
};
|
|
2189
4259
|
var specToHex_default = specToHex;
|
|
2190
4260
|
|
|
2191
|
-
//
|
|
4261
|
+
// ../luum/src/import/channelsToSpec.ts
|
|
2192
4262
|
var channelsToSpec = ({ R, G, B }) => {
|
|
2193
4263
|
const hue = hueFromChannels_default({ R, G, B });
|
|
2194
4264
|
const sat = satFromChannels_default({ R, G, B });
|
|
@@ -2197,7 +4267,7 @@ var channelsToSpec = ({ R, G, B }) => {
|
|
|
2197
4267
|
};
|
|
2198
4268
|
var channelsToSpec_default = channelsToSpec;
|
|
2199
4269
|
|
|
2200
|
-
//
|
|
4270
|
+
// ../luum/src/import/normalizeHex.ts
|
|
2201
4271
|
var BASE_16_CHAR_SET = `[a-fA-F0-9]+`;
|
|
2202
4272
|
var miniHexToHex = (miniHex) => {
|
|
2203
4273
|
const miniHexArray = miniHex.split(``);
|
|
@@ -2219,7 +4289,7 @@ var normalizeHex = (maybeHex) => {
|
|
|
2219
4289
|
};
|
|
2220
4290
|
var normalizeHex_default = normalizeHex;
|
|
2221
4291
|
|
|
2222
|
-
//
|
|
4292
|
+
// ../luum/src/import/hexToChannels.ts
|
|
2223
4293
|
var hexToChannels_default = (maybeHex) => {
|
|
2224
4294
|
const hex = normalizeHex_default(maybeHex);
|
|
2225
4295
|
return {
|
|
@@ -2229,7 +4299,7 @@ var hexToChannels_default = (maybeHex) => {
|
|
|
2229
4299
|
};
|
|
2230
4300
|
};
|
|
2231
4301
|
|
|
2232
|
-
//
|
|
4302
|
+
// ../luum/src/import/hexToSpec.ts
|
|
2233
4303
|
var hexToSpec = (hex) => {
|
|
2234
4304
|
const { R, G, B } = hexToChannels_default(hex);
|
|
2235
4305
|
const { hue, sat, lum } = channelsToSpec_default({ R, G, B });
|
|
@@ -2237,7 +4307,7 @@ var hexToSpec = (hex) => {
|
|
|
2237
4307
|
};
|
|
2238
4308
|
var hexToSpec_default = hexToSpec;
|
|
2239
4309
|
|
|
2240
|
-
//
|
|
4310
|
+
// ../luum/src/mixers/contrast.ts
|
|
2241
4311
|
var contrastMax = (color) => __spreadProps(__spreadValues({}, color), {
|
|
2242
4312
|
lum: color.lum > 0.666 ? 0 : 1
|
|
2243
4313
|
});
|
|
@@ -2245,7 +4315,7 @@ var offset = (offsetAmount) => (color) => __spreadProps(__spreadValues({}, color
|
|
|
2245
4315
|
lum: color.lum > 0.666 ? color.lum - offsetAmount : color.lum + offsetAmount
|
|
2246
4316
|
});
|
|
2247
4317
|
|
|
2248
|
-
//
|
|
4318
|
+
// ../luum/src/constants/luum-spec.ts
|
|
2249
4319
|
var defaultSpec = {
|
|
2250
4320
|
hue: 0,
|
|
2251
4321
|
lum: 0,
|
|
@@ -2253,7 +4323,7 @@ var defaultSpec = {
|
|
|
2253
4323
|
prefer: `lum`
|
|
2254
4324
|
};
|
|
2255
4325
|
|
|
2256
|
-
//
|
|
4326
|
+
// ../luum/src/scheme/index.ts
|
|
2257
4327
|
var isLuumSpec = (input) => typeof input === `object` && input !== null && typeof input.hue === `number` && typeof input.sat === `number` && typeof input.lum === `number` && [`sat`, `lum`].includes(input.prefer);
|
|
2258
4328
|
isModifier(isLuumSpec)(defaultSpec);
|
|
2259
4329
|
var WAYFORGE_CORE_COLOR_NAMES = [
|
|
@@ -2283,14 +4353,14 @@ WAYFORGE_CORE_COLOR_NAMES.reduce(
|
|
|
2283
4353
|
{}
|
|
2284
4354
|
);
|
|
2285
4355
|
var Id = ({ id }) => {
|
|
2286
|
-
const [isOpen, setIsOpen] =
|
|
2287
|
-
const { refs, floatingStyles, context } = react
|
|
4356
|
+
const [isOpen, setIsOpen] = React2__namespace.useState(false);
|
|
4357
|
+
const { refs, floatingStyles, context } = react.useFloating({
|
|
2288
4358
|
open: isOpen,
|
|
2289
4359
|
onOpenChange: setIsOpen,
|
|
2290
4360
|
placement: `bottom-start`
|
|
2291
4361
|
});
|
|
2292
|
-
const click = react
|
|
2293
|
-
const { getReferenceProps, getFloatingProps } = react
|
|
4362
|
+
const click = react.useClick(context);
|
|
4363
|
+
const { getReferenceProps, getFloatingProps } = react.useInteractions([click]);
|
|
2294
4364
|
const bgColor = stringToColor(id);
|
|
2295
4365
|
const contrastColor = pipe(bgColor, hexToSpec_default, contrastMax, specToHex_default);
|
|
2296
4366
|
const offsetColor = pipe(bgColor, hexToSpec_default, offset(0.25), specToHex_default);
|
|
@@ -2318,7 +4388,7 @@ var Id = ({ id }) => {
|
|
|
2318
4388
|
children: id.substring(0, 3)
|
|
2319
4389
|
})
|
|
2320
4390
|
),
|
|
2321
|
-
isOpen && /* @__PURE__ */ jsxRuntime.jsx(react
|
|
4391
|
+
isOpen && /* @__PURE__ */ jsxRuntime.jsx(react.FloatingPortal, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2322
4392
|
"span",
|
|
2323
4393
|
__spreadProps(__spreadValues({
|
|
2324
4394
|
role: "popup",
|
|
@@ -2336,7 +4406,7 @@ var Id = ({ id }) => {
|
|
|
2336
4406
|
] });
|
|
2337
4407
|
};
|
|
2338
4408
|
|
|
2339
|
-
//
|
|
4409
|
+
// ../hamr/src/react-data-designer/RelationEditor.module.scss
|
|
2340
4410
|
var RelationEditor_module_default = {};
|
|
2341
4411
|
var RelationEditor = (props) => {
|
|
2342
4412
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -2356,8 +4426,8 @@ var RelationEditor = (props) => {
|
|
|
2356
4426
|
] })) });
|
|
2357
4427
|
};
|
|
2358
4428
|
var StateEditor = ({ token }) => {
|
|
2359
|
-
const set =
|
|
2360
|
-
const data =
|
|
4429
|
+
const set = useI(token);
|
|
4430
|
+
const data = useO(token);
|
|
2361
4431
|
return isJson(data) ? /* @__PURE__ */ jsxRuntime.jsx(JsonEditor, { data, set, schema: true }) : data instanceof Join ? /* @__PURE__ */ jsxRuntime.jsx(RelationEditor, { data, set }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "json_editor", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2362
4432
|
ElasticInput,
|
|
2363
4433
|
{
|
|
@@ -2367,7 +4437,7 @@ var StateEditor = ({ token }) => {
|
|
|
2367
4437
|
) });
|
|
2368
4438
|
};
|
|
2369
4439
|
var ReadonlySelectorViewer = ({ token }) => {
|
|
2370
|
-
const data =
|
|
4440
|
+
const data = useO(token);
|
|
2371
4441
|
return isJson(data) ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
2372
4442
|
JsonEditor,
|
|
2373
4443
|
{
|
|
@@ -2390,7 +4460,7 @@ var StoreEditor = ({ token }) => {
|
|
|
2390
4460
|
}
|
|
2391
4461
|
return /* @__PURE__ */ jsxRuntime.jsx(StateEditor, { token });
|
|
2392
4462
|
};
|
|
2393
|
-
var findStateTypeState =
|
|
4463
|
+
var findStateTypeState = selectorFamily({
|
|
2394
4464
|
key: `\u{1F441}\u200D\u{1F5E8} State Type`,
|
|
2395
4465
|
get: (token) => ({ get }) => {
|
|
2396
4466
|
let state;
|
|
@@ -2408,10 +4478,10 @@ var findStateTypeState = atom_io.selectorFamily({
|
|
|
2408
4478
|
});
|
|
2409
4479
|
var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
|
|
2410
4480
|
var _a2, _b;
|
|
2411
|
-
const setIsOpen =
|
|
2412
|
-
const isOpen =
|
|
2413
|
-
const state =
|
|
2414
|
-
const stateType =
|
|
4481
|
+
const setIsOpen = useI(isOpenState);
|
|
4482
|
+
const isOpen = useO(isOpenState);
|
|
4483
|
+
const state = useO(node);
|
|
4484
|
+
const stateType = useO(typeState);
|
|
2415
4485
|
const isPrimitive = Boolean(primitiveRefinery.refine(state));
|
|
2416
4486
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2417
4487
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
|
|
@@ -2426,8 +4496,8 @@ var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
|
|
|
2426
4496
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
2427
4497
|
"label",
|
|
2428
4498
|
{
|
|
2429
|
-
onClick: () => console.log(node,
|
|
2430
|
-
onKeyUp: () => console.log(node,
|
|
4499
|
+
onClick: () => console.log(node, getState(node)),
|
|
4500
|
+
onKeyUp: () => console.log(node, getState(node)),
|
|
2431
4501
|
children: [
|
|
2432
4502
|
/* @__PURE__ */ jsxRuntime.jsx("h2", { children: (_b = (_a2 = node.family) == null ? void 0 : _a2.subKey) != null ? _b : node.key }),
|
|
2433
4503
|
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "type detail", children: [
|
|
@@ -2444,8 +4514,8 @@ var StateIndexLeafNode = ({ node, isOpenState, typeState }) => {
|
|
|
2444
4514
|
] });
|
|
2445
4515
|
};
|
|
2446
4516
|
var StateIndexTreeNode = ({ node, isOpenState }) => {
|
|
2447
|
-
const setIsOpen =
|
|
2448
|
-
const isOpen =
|
|
4517
|
+
const setIsOpen = useI(isOpenState);
|
|
4518
|
+
const isOpen = useO(isOpenState);
|
|
2449
4519
|
for (const [key, childNode] of recordToEntries(node.familyMembers)) {
|
|
2450
4520
|
findViewIsOpenState(key);
|
|
2451
4521
|
findStateTypeState(childNode);
|
|
@@ -2483,7 +4553,7 @@ var StateIndexNode = ({ node, isOpenState, typeState }) => {
|
|
|
2483
4553
|
) : /* @__PURE__ */ jsxRuntime.jsx(StateIndexTreeNode, { node, isOpenState }) });
|
|
2484
4554
|
};
|
|
2485
4555
|
var StateIndex = ({ tokenIndex }) => {
|
|
2486
|
-
const tokenIds =
|
|
4556
|
+
const tokenIds = useO(tokenIndex);
|
|
2487
4557
|
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index state_index", children: Object.entries(tokenIds).filter(([key]) => !key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).sort().map(([key, node]) => {
|
|
2488
4558
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2489
4559
|
StateIndexNode,
|
|
@@ -2623,9 +4693,9 @@ var YouAreHere = () => {
|
|
|
2623
4693
|
return /* @__PURE__ */ jsxRuntime.jsx("span", { className: "you_are_here", children: "you are here" });
|
|
2624
4694
|
};
|
|
2625
4695
|
var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
2626
|
-
const timeline =
|
|
2627
|
-
const isOpen =
|
|
2628
|
-
const setIsOpen =
|
|
4696
|
+
const timeline = useO(timelineState);
|
|
4697
|
+
const isOpen = useO(isOpenState);
|
|
4698
|
+
const setIsOpen = useI(isOpenState);
|
|
2629
4699
|
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "node timeline_log", children: [
|
|
2630
4700
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
|
|
2631
4701
|
/* @__PURE__ */ jsxRuntime.jsx(button.OpenClose, { isOpen, setIsOpen }),
|
|
@@ -2644,7 +4714,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
2644
4714
|
"button",
|
|
2645
4715
|
{
|
|
2646
4716
|
type: "button",
|
|
2647
|
-
onClick: () =>
|
|
4717
|
+
onClick: () => undo(token),
|
|
2648
4718
|
disabled: timeline.at === 0,
|
|
2649
4719
|
children: "undo"
|
|
2650
4720
|
}
|
|
@@ -2653,7 +4723,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
2653
4723
|
"button",
|
|
2654
4724
|
{
|
|
2655
4725
|
type: "button",
|
|
2656
|
-
onClick: () =>
|
|
4726
|
+
onClick: () => redo(token),
|
|
2657
4727
|
disabled: timeline.at === timeline.history.length,
|
|
2658
4728
|
children: "redo"
|
|
2659
4729
|
}
|
|
@@ -2661,7 +4731,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
2661
4731
|
] })
|
|
2662
4732
|
] })
|
|
2663
4733
|
] }),
|
|
2664
|
-
isOpen ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: timeline.history.map((update, index) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
4734
|
+
isOpen ? /* @__PURE__ */ jsxRuntime.jsx("main", { children: timeline.history.map((update, index) => /* @__PURE__ */ jsxRuntime.jsxs(React2.Fragment, { children: [
|
|
2665
4735
|
index === timeline.at ? /* @__PURE__ */ jsxRuntime.jsx(YouAreHere, {}) : null,
|
|
2666
4736
|
/* @__PURE__ */ jsxRuntime.jsx(article.TimelineUpdate, { timelineUpdate: update }),
|
|
2667
4737
|
index === timeline.history.length - 1 && timeline.at === timeline.history.length ? /* @__PURE__ */ jsxRuntime.jsx(YouAreHere, {}) : null
|
|
@@ -2669,7 +4739,7 @@ var TimelineLog = ({ token, isOpenState, timelineState }) => {
|
|
|
2669
4739
|
] });
|
|
2670
4740
|
};
|
|
2671
4741
|
var TimelineIndex = () => {
|
|
2672
|
-
const tokenIds =
|
|
4742
|
+
const tokenIds = useO(timelineIndex);
|
|
2673
4743
|
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index timeline_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
|
|
2674
4744
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2675
4745
|
TimelineLog,
|
|
@@ -2683,9 +4753,9 @@ var TimelineIndex = () => {
|
|
|
2683
4753
|
}) });
|
|
2684
4754
|
};
|
|
2685
4755
|
var TransactionLog = ({ token, isOpenState, logState }) => {
|
|
2686
|
-
const log =
|
|
2687
|
-
const isOpen =
|
|
2688
|
-
const setIsOpen =
|
|
4756
|
+
const log = useO(logState);
|
|
4757
|
+
const isOpen = useO(isOpenState);
|
|
4758
|
+
const setIsOpen = useI(isOpenState);
|
|
2689
4759
|
return /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "node transaction_log", children: [
|
|
2690
4760
|
/* @__PURE__ */ jsxRuntime.jsxs("header", { children: [
|
|
2691
4761
|
/* @__PURE__ */ jsxRuntime.jsx(button.OpenClose, { isOpen, setIsOpen }),
|
|
@@ -2709,7 +4779,7 @@ var TransactionLog = ({ token, isOpenState, logState }) => {
|
|
|
2709
4779
|
] });
|
|
2710
4780
|
};
|
|
2711
4781
|
var TransactionIndex = () => {
|
|
2712
|
-
const tokenIds =
|
|
4782
|
+
const tokenIds = useO(transactionIndex);
|
|
2713
4783
|
return /* @__PURE__ */ jsxRuntime.jsx("article", { className: "index transaction_index", children: tokenIds.filter((token) => !token.key.startsWith(`\u{1F441}\u200D\u{1F5E8}`)).map((token) => {
|
|
2714
4784
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2715
4785
|
TransactionLog,
|
|
@@ -2723,13 +4793,13 @@ var TransactionIndex = () => {
|
|
|
2723
4793
|
}) });
|
|
2724
4794
|
};
|
|
2725
4795
|
var AtomIODevtools = () => {
|
|
2726
|
-
const constraintsRef =
|
|
2727
|
-
const setDevtoolsAreOpen =
|
|
2728
|
-
const devtoolsAreOpen =
|
|
2729
|
-
const setDevtoolsView =
|
|
2730
|
-
const devtoolsView =
|
|
2731
|
-
const devtoolsViewOptions =
|
|
2732
|
-
const mouseHasMoved =
|
|
4796
|
+
const constraintsRef = React2.useRef(null);
|
|
4797
|
+
const setDevtoolsAreOpen = useI(devtoolsAreOpenState);
|
|
4798
|
+
const devtoolsAreOpen = useO(devtoolsAreOpenState);
|
|
4799
|
+
const setDevtoolsView = useI(devtoolsViewSelectionState);
|
|
4800
|
+
const devtoolsView = useO(devtoolsViewSelectionState);
|
|
4801
|
+
const devtoolsViewOptions = useO(devtoolsViewOptionsState);
|
|
4802
|
+
const mouseHasMoved = React2.useRef(false);
|
|
2733
4803
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2734
4804
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2735
4805
|
framerMotion.motion.span,
|
|
@@ -2797,7 +4867,7 @@ var AtomIODevtools = () => {
|
|
|
2797
4867
|
] });
|
|
2798
4868
|
};
|
|
2799
4869
|
|
|
2800
|
-
// src/index.ts
|
|
4870
|
+
// react-devtools/src/index.ts
|
|
2801
4871
|
var {
|
|
2802
4872
|
atomIndex,
|
|
2803
4873
|
selectorIndex,
|
|
@@ -2805,23 +4875,23 @@ var {
|
|
|
2805
4875
|
findTransactionLogState,
|
|
2806
4876
|
timelineIndex,
|
|
2807
4877
|
findTimelineState
|
|
2808
|
-
} =
|
|
2809
|
-
var devtoolsAreOpenState =
|
|
4878
|
+
} = attachIntrospectionStates();
|
|
4879
|
+
var devtoolsAreOpenState = atom({
|
|
2810
4880
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools Are Open`,
|
|
2811
4881
|
default: true,
|
|
2812
4882
|
effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools Are Open`)]
|
|
2813
4883
|
});
|
|
2814
|
-
var devtoolsViewSelectionState =
|
|
4884
|
+
var devtoolsViewSelectionState = atom({
|
|
2815
4885
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools View Selection`,
|
|
2816
4886
|
default: `atoms`,
|
|
2817
4887
|
effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View`)]
|
|
2818
4888
|
});
|
|
2819
|
-
var devtoolsViewOptionsState =
|
|
4889
|
+
var devtoolsViewOptionsState = atom({
|
|
2820
4890
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools View Options`,
|
|
2821
4891
|
default: [`atoms`, `selectors`, `transactions`, `timelines`],
|
|
2822
4892
|
effects: [lazyLocalStorageEffect(`\u{1F441}\u200D\u{1F5E8} Devtools View Options`)]
|
|
2823
4893
|
});
|
|
2824
|
-
var findViewIsOpenState =
|
|
4894
|
+
var findViewIsOpenState = atomFamily({
|
|
2825
4895
|
key: `\u{1F441}\u200D\u{1F5E8} Devtools View Is Open`,
|
|
2826
4896
|
default: false,
|
|
2827
4897
|
effects: (key) => [lazyLocalStorageEffect(key + `:view-is-open`)]
|