atom.io 0.31.1 → 0.32.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.d.ts +3 -154
- package/data/dist/index.js +11 -559
- package/data/src/index.ts +0 -2
- package/data/src/struct-family.ts +1 -1
- package/data/src/struct.ts +1 -2
- package/dist/chunk-3PQTWLQQ.js +83 -0
- package/dist/chunk-3ZFTRSNG.js +523 -0
- package/dist/chunk-4LWKCEW3.js +14 -0
- package/dist/chunk-KVI5OBF2.js +153 -0
- package/dist/{chunk-Y5MBNTVU.js → chunk-UQEYZ3OI.js} +1814 -721
- package/dist/chunk-UYYKOGZQ.js +1034 -0
- package/dist/chunk-VRJP2PCU.js +631 -0
- package/dist/chunk-X7SD2NXU.js +108 -0
- package/dist/index.d.ts +137 -12
- package/dist/index.js +1 -228
- package/eslint-plugin/dist/index.d.ts +1 -30
- package/eslint-plugin/dist/index.js +3 -149
- package/eslint-plugin/src/index.ts +0 -1
- package/eslint-plugin/src/rules/explicit-state-types.ts +1 -0
- package/eslint-plugin/src/rules/index.ts +0 -1
- package/eslint-plugin/src/rules/synchronous-selector-dependencies.ts +1 -0
- package/eslint-plugin/src/walk.ts +1 -0
- package/internal/dist/index.d.ts +129 -58
- package/internal/dist/index.js +1 -1
- package/internal/src/atom/create-regular-atom.ts +3 -3
- package/internal/src/atom/dispose-atom.ts +4 -13
- package/internal/src/atom/is-default.ts +3 -3
- package/internal/src/caching.ts +5 -5
- package/internal/src/capitalize.ts +3 -0
- package/internal/src/families/create-readonly-selector-family.ts +5 -6
- package/internal/src/families/create-writable-selector-family.ts +1 -4
- package/internal/src/families/dispose-from-store.ts +3 -13
- package/internal/src/get-state/get-from-store.ts +2 -2
- package/internal/src/get-state/read-or-compute-value.ts +1 -1
- package/internal/src/index.ts +2 -0
- package/internal/src/install-into-store.ts +1 -1
- package/internal/src/join/edit-relations-in-store.ts +32 -0
- package/internal/src/join/find-relations-in-store.ts +124 -0
- package/internal/src/join/get-internal-relations-from-store.ts +14 -0
- package/internal/src/join/get-join.ts +31 -0
- package/internal/src/join/index.ts +5 -0
- package/{data/src/join.ts → internal/src/join/join-internal.ts} +21 -430
- package/internal/src/junction.ts +7 -4
- package/internal/src/keys.ts +7 -7
- package/internal/src/mutable/create-mutable-atom-family.ts +1 -1
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-json-token.ts +1 -1
- package/internal/src/mutable/tracker-family.ts +19 -17
- package/internal/src/mutable/tracker.ts +8 -8
- package/internal/src/pretty-print.ts +1 -1
- package/internal/src/selector/create-readonly-selector.ts +3 -7
- package/internal/src/selector/create-writable-selector.ts +4 -4
- package/internal/src/selector/dispose-selector.ts +20 -11
- package/internal/src/selector/get-selector-dependency-keys.ts +1 -1
- package/internal/src/selector/register-selector.ts +6 -9
- package/internal/src/selector/trace-selector-atoms.ts +2 -2
- package/internal/src/set-state/copy-mutable-if-needed.ts +1 -1
- package/internal/src/set-state/emit-update.ts +4 -2
- package/internal/src/set-state/evict-downstream.ts +1 -1
- package/internal/src/set-state/set-atom-or-selector.ts +1 -1
- package/internal/src/set-state/set-atom.ts +10 -10
- package/internal/src/set-state/set-into-store.ts +2 -2
- package/internal/src/set-state/stow-update.ts +1 -1
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw.ts +22 -22
- package/internal/src/subscribe/recall-state.ts +1 -1
- package/internal/src/subscribe/subscribe-in-store.ts +3 -3
- package/internal/src/subscribe/subscribe-to-root-atoms.ts +3 -3
- package/internal/src/subscribe/subscribe-to-state.ts +5 -5
- package/internal/src/subscribe/subscribe-to-timeline.ts +3 -3
- package/internal/src/subscribe/subscribe-to-transaction.ts +3 -3
- package/internal/src/timeline/create-timeline.ts +19 -38
- package/internal/src/timeline/time-travel.ts +2 -1
- package/internal/src/transaction/act-upon-store.ts +2 -2
- package/internal/src/transaction/apply-transaction.ts +5 -5
- package/internal/src/transaction/assign-transaction-to-continuity.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +5 -8
- package/internal/src/transaction/create-transaction.ts +3 -3
- package/internal/src/transaction/get-epoch-number.ts +3 -3
- package/internal/src/transaction/set-epoch-number.ts +2 -2
- package/introspection/dist/index.js +2 -620
- package/json/dist/index.d.ts +2 -2
- package/json/dist/index.js +1 -80
- package/json/src/select-json-family.ts +3 -14
- package/package.json +31 -49
- package/react/dist/index.js +2 -82
- package/react/src/use-o.ts +1 -1
- package/react/src/use-tl.ts +2 -2
- package/react-devtools/dist/index.css +16 -14
- package/react-devtools/dist/index.js +31 -18
- package/react-devtools/src/Updates.tsx +12 -0
- package/react-devtools/src/devtools.scss +16 -14
- package/react-devtools/src/json-editor/editors-by-type/utilities/cast-to-json.ts +2 -1
- package/realtime/dist/index.d.ts +1 -2
- package/realtime/dist/index.js +2 -107
- package/realtime/src/realtime-continuity.ts +3 -2
- package/realtime/src/shared-room-store.ts +1 -2
- package/realtime-client/dist/index.d.ts +9 -9
- package/realtime-client/dist/index.js +3 -509
- package/realtime-client/src/continuity/register-and-attempt-confirmed-update.ts +3 -3
- package/realtime-client/src/continuity/use-conceal-state.ts +1 -1
- package/realtime-client/src/pull-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-atom.ts +2 -2
- package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
- package/realtime-client/src/pull-mutable-atom.ts +2 -2
- package/realtime-client/src/pull-selector-family-member.ts +4 -4
- package/realtime-client/src/pull-selector.ts +4 -4
- package/realtime-client/src/push-state.ts +5 -10
- package/realtime-client/src/server-action.ts +4 -4
- package/realtime-client/src/sync-continuity.ts +6 -6
- package/realtime-react/dist/index.js +5 -154
- package/realtime-react/src/use-pull-atom-family-member.ts +1 -1
- package/realtime-react/src/use-pull-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-atom.ts +1 -1
- package/realtime-react/src/use-pull-mutable-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector-family-member.ts +1 -1
- package/realtime-react/src/use-pull-selector.ts +1 -1
- package/realtime-react/src/use-push.ts +1 -1
- package/realtime-react/src/use-server-action.ts +2 -2
- package/realtime-react/src/use-sync-continuity.ts +1 -1
- package/realtime-server/dist/index.d.ts +2 -4
- package/realtime-server/dist/index.js +3 -1001
- package/realtime-server/src/continuity/prepare-to-serve-transaction-request.ts +1 -1
- package/realtime-server/src/continuity/prepare-to-sync-realtime-continuity.ts +3 -3
- package/realtime-server/src/continuity/subscribe-to-continuity-actions.ts +2 -2
- package/realtime-server/src/continuity/subscribe-to-continuity-perpectives.ts +2 -2
- package/realtime-server/src/ipc-sockets/child-socket.ts +2 -0
- package/realtime-server/src/realtime-action-receiver.ts +1 -1
- package/realtime-server/src/realtime-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +2 -1
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-sync-store.ts +10 -2
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +1 -2
- package/realtime-server/src/realtime-state-provider.ts +2 -2
- package/realtime-testing/dist/index.js +20 -22
- package/realtime-testing/src/setup-realtime-test.tsx +2 -1
- package/src/index.ts +4 -0
- package/src/join.ts +218 -0
- package/src/silo.ts +4 -4
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +4 -8
- package/transceivers/set-rtx/dist/index.d.ts +4 -3
- package/transceivers/set-rtx/dist/index.js +1 -215
- package/transceivers/set-rtx/src/set-rtx.ts +4 -7
- package/web/dist/index.js +1 -15
- package/data/src/until.ts +0 -15
- package/ephemeral/dist/index.d.ts +0 -67
- package/ephemeral/dist/index.js +0 -9
- package/ephemeral/package.json +0 -13
- package/ephemeral/src/index.ts +0 -1
- package/eslint-plugin/src/rules/lifespan.ts +0 -203
- package/immortal/dist/index.d.ts +0 -12
- package/immortal/dist/index.js +0 -9
- package/immortal/package.json +0 -13
- package/immortal/src/index.ts +0 -1
- package/immortal/src/seek-state.ts +0 -60
- package/react-devtools/src/json-editor/assets/Untitled-1.ai +2 -1436
- package/react-devtools/src/json-editor/assets/data-vis.ai +1 -1548
- package/react-devtools/src/json-editor/comp/json-editor-sketches.ai +5 -1449
- /package/{ephemeral/src → src}/find-state.ts +0 -0
|
@@ -5,7 +5,6 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
5
5
|
var rules_exports = {};
|
|
6
6
|
__export(rules_exports, {
|
|
7
7
|
explicitStateTypes: () => explicitStateTypes,
|
|
8
|
-
lifespan: () => lifespan,
|
|
9
8
|
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
10
9
|
});
|
|
11
10
|
var createRule = ESLintUtils.RuleCreator(
|
|
@@ -133,150 +132,6 @@ function walk(node, callback, depth = 0) {
|
|
|
133
132
|
}
|
|
134
133
|
}
|
|
135
134
|
|
|
136
|
-
// eslint-plugin/src/rules/lifespan.ts
|
|
137
|
-
var lifespan = {
|
|
138
|
-
meta: {
|
|
139
|
-
type: `problem`,
|
|
140
|
-
docs: {
|
|
141
|
-
description: `atom.io provides tools for short-lived (ephemeral) and long-lived (immortal) stores. This rule allows you to guard against unsafe usage of tools for the other type of store.`,
|
|
142
|
-
category: `Possible Errors`,
|
|
143
|
-
recommended: false,
|
|
144
|
-
url: ``
|
|
145
|
-
// URL to documentation page for this rule
|
|
146
|
-
},
|
|
147
|
-
schema: [
|
|
148
|
-
{
|
|
149
|
-
type: `string`,
|
|
150
|
-
enum: [`ephemeral`, `immortal`],
|
|
151
|
-
default: `ephemeral`
|
|
152
|
-
}
|
|
153
|
-
]
|
|
154
|
-
},
|
|
155
|
-
create(context) {
|
|
156
|
-
const storeLifespan = context.options[0] ?? `ephemeral`;
|
|
157
|
-
return {
|
|
158
|
-
ImportDeclaration(node) {
|
|
159
|
-
const importSource = node.source.value;
|
|
160
|
-
if (!importSource.startsWith(`atom.io/`)) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
const [_, subPackageName] = importSource.split(`/`);
|
|
164
|
-
if (storeLifespan === `immortal` && subPackageName === `ephemeral`) {
|
|
165
|
-
context.report({
|
|
166
|
-
node,
|
|
167
|
-
message: `do not import from "${importSource}" in an ${storeLifespan} store`
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
CallExpression(node) {
|
|
172
|
-
if (storeLifespan === `ephemeral`) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const functionCallee = node.callee.type === `Identifier` ? node.callee : undefined;
|
|
176
|
-
const methodCallee = node.callee.type === `MemberExpression` && node.callee.property.type === `Identifier` ? node.callee.property : undefined;
|
|
177
|
-
const callee = functionCallee ?? methodCallee;
|
|
178
|
-
if (callee === undefined) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
if (callee.name === `findState`) {
|
|
182
|
-
context.report({
|
|
183
|
-
node,
|
|
184
|
-
message: `do not use findState in an ${storeLifespan} store`
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
const storeProcedures = [];
|
|
188
|
-
if (callee.name === `selector` || callee.name === `selectorFamily` || callee.name === `transaction`) {
|
|
189
|
-
if (node.arguments[0].type === `ObjectExpression`) {
|
|
190
|
-
const argProperties = node.arguments[0].properties;
|
|
191
|
-
switch (callee.name) {
|
|
192
|
-
case `selector`:
|
|
193
|
-
case `selectorFamily`:
|
|
194
|
-
{
|
|
195
|
-
const getAndSetProps = argProperties.filter(
|
|
196
|
-
(prop) => {
|
|
197
|
-
return `key` in prop && `name` in prop.key && (prop.key.name === `get` || prop.key.name === `set`);
|
|
198
|
-
}
|
|
199
|
-
);
|
|
200
|
-
switch (callee.name) {
|
|
201
|
-
case `selector`:
|
|
202
|
-
{
|
|
203
|
-
for (const prop of getAndSetProps) {
|
|
204
|
-
if (prop.value.type === `FunctionExpression` || prop.value.type === `ArrowFunctionExpression`) {
|
|
205
|
-
storeProcedures.push(prop.value);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
break;
|
|
210
|
-
case `selectorFamily`:
|
|
211
|
-
{
|
|
212
|
-
for (const prop of getAndSetProps) {
|
|
213
|
-
const { value } = prop;
|
|
214
|
-
if (value.type === `FunctionExpression` || value.type === `ArrowFunctionExpression`) {
|
|
215
|
-
if (value.body.type === `BlockStatement`) {
|
|
216
|
-
for (const statement of value.body.body) {
|
|
217
|
-
if (statement.type === `ReturnStatement` && statement.argument && (statement.argument.type === `FunctionExpression` || statement.argument.type === `ArrowFunctionExpression`)) {
|
|
218
|
-
storeProcedures.push(statement.argument);
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
} else if (value.body.type === `FunctionExpression` || value.body.type === `ArrowFunctionExpression`) {
|
|
222
|
-
storeProcedures.push(value.body);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
break;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
break;
|
|
231
|
-
case `transaction`:
|
|
232
|
-
{
|
|
233
|
-
const doProp = argProperties.find(
|
|
234
|
-
(prop) => {
|
|
235
|
-
return `key` in prop && `name` in prop.key && prop.key.name === `do`;
|
|
236
|
-
}
|
|
237
|
-
);
|
|
238
|
-
if (doProp) {
|
|
239
|
-
if (doProp.value.type === `FunctionExpression` || doProp.value.type === `ArrowFunctionExpression`) {
|
|
240
|
-
storeProcedures.push(doProp.value);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
for (const storeProcedure of storeProcedures) {
|
|
249
|
-
const transactorsParam = storeProcedure.params[0];
|
|
250
|
-
const nonDestructuredTransactorsName = transactorsParam && `name` in transactorsParam ? transactorsParam.name : undefined;
|
|
251
|
-
walk(storeProcedure.body, (n) => {
|
|
252
|
-
if (n.type === `CallExpression`) {
|
|
253
|
-
let willReport = false;
|
|
254
|
-
switch (n.callee.type) {
|
|
255
|
-
case `MemberExpression`:
|
|
256
|
-
if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `find`) {
|
|
257
|
-
willReport = true;
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
case `Identifier`:
|
|
261
|
-
if (n.callee.name === `find`) {
|
|
262
|
-
willReport = true;
|
|
263
|
-
}
|
|
264
|
-
break;
|
|
265
|
-
}
|
|
266
|
-
if (willReport) {
|
|
267
|
-
context.report({
|
|
268
|
-
node: n,
|
|
269
|
-
message: `Using find in a transactor is not allowed in an immortal store.`
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
}
|
|
278
|
-
};
|
|
279
|
-
|
|
280
135
|
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
281
136
|
var synchronousSelectorDependencies = {
|
|
282
137
|
meta: {
|
|
@@ -327,14 +182,14 @@ var synchronousSelectorDependencies = {
|
|
|
327
182
|
}
|
|
328
183
|
}
|
|
329
184
|
if (selectorComputation?.type === `FunctionExpression` || selectorComputation?.type === `ArrowFunctionExpression`) {
|
|
330
|
-
const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name :
|
|
185
|
+
const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
|
|
331
186
|
let awaited;
|
|
332
187
|
let awaitNode;
|
|
333
188
|
walk(selectorComputation, (n, depth) => {
|
|
334
189
|
if (typeof awaited === `number`) {
|
|
335
190
|
if (awaited > depth) {
|
|
336
|
-
awaited =
|
|
337
|
-
awaitNode =
|
|
191
|
+
awaited = void 0;
|
|
192
|
+
awaitNode = void 0;
|
|
338
193
|
}
|
|
339
194
|
}
|
|
340
195
|
switch (n.type) {
|
|
@@ -376,7 +231,6 @@ var synchronousSelectorDependencies = {
|
|
|
376
231
|
var src_default = {
|
|
377
232
|
rules: {
|
|
378
233
|
"explicit-state-types": explicitStateTypes,
|
|
379
|
-
lifespan,
|
|
380
234
|
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
381
235
|
}
|
|
382
236
|
};
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, AtomFamilyToken, AtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, SelectorFamilyToken, SelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken, TransactionToken, TransactionUpdate, TransactionOptions, ActorToolkit, TimelineManageable, TimelineToken, AtomIOToken, Hierarchy, Vassal, Above, Claim, CompoundFrom, CompoundTypedKey, SingularTypedKey, StateUpdate, TokenType, FamilyMetadata, StateCreation, StateDisposal, MoleculeCreation, MoleculeDisposal,
|
|
1
|
+
import { MutableAtomFamilyToken, MutableAtomToken, RegularAtomFamilyToken, RegularAtomToken, AtomFamilyToken, AtomToken, WritableSelectorFamilyToken, WritableSelectorToken, ReadonlySelectorFamilyToken, ReadonlySelectorToken, SelectorFamilyToken, SelectorToken, WritableFamilyToken, WritableToken, ReadableFamilyToken, ReadableToken, TransactionToken, TransactionUpdate, TransactionOptions, ActorToolkit, TimelineManageable, TimelineToken, AtomIOToken, JoinToken, JoinStates, Hierarchy, Vassal, Above, Claim, CompoundFrom, CompoundTypedKey, SingularTypedKey, JoinOptions, SetterToolkit, Anarchy, TimelineUpdate, StateUpdate, TokenType, FamilyMetadata, StateCreation, StateDisposal, MoleculeCreation, MoleculeDisposal, TimelineOptions, AtomIOLogger, Logger, MutableAtomOptions, MutableAtomFamilyOptions, RegularAtomOptions, RegularAtomFamilyOptions, ReadonlySelectorFamilyOptions, WritableSelectorFamilyOptions, KeyedStateUpdate, MoleculeTransfer, ReadonlySelectorOptions, WritableSelectorOptions, UpdateHandler, TransactionUpdateHandler } from 'atom.io';
|
|
2
2
|
import { Json, Canonical, stringified, JsonInterface } from 'atom.io/json';
|
|
3
|
-
import {
|
|
3
|
+
import { SetRTX, SetRTXJson } from 'atom.io/transceivers/set-rtx';
|
|
4
4
|
import { Store as Store$1, Func as Func$1 } from 'atom.io/internal';
|
|
5
5
|
|
|
6
6
|
declare class CircularBuffer<T> {
|
|
@@ -142,11 +142,11 @@ declare class Junction<const ASide extends string, const AType extends string, c
|
|
|
142
142
|
|
|
143
143
|
declare const abortTransaction: (store: Store) => void;
|
|
144
144
|
|
|
145
|
-
declare function actUponStore<F extends Func>(token: TransactionToken<F>, id: string
|
|
145
|
+
declare function actUponStore<F extends Func>(store: Store, token: TransactionToken<F>, id: string): (...parameters: Parameters<F>) => ReturnType<F>;
|
|
146
146
|
|
|
147
147
|
declare const applyTransaction: <F extends Func>(output: ReturnType<F>, store: Store) => void;
|
|
148
148
|
|
|
149
|
-
declare function assignTransactionToContinuity(
|
|
149
|
+
declare function assignTransactionToContinuity(store: Store, continuityKey: string, transactionKey: string): void;
|
|
150
150
|
|
|
151
151
|
interface RootStore extends Store {
|
|
152
152
|
transactionMeta: TransactionEpoch;
|
|
@@ -161,7 +161,7 @@ interface ChildStore extends Store {
|
|
|
161
161
|
declare function isRootStore(store: Store): store is RootStore;
|
|
162
162
|
declare function isChildStore(store: Store): store is ChildStore;
|
|
163
163
|
|
|
164
|
-
declare const buildTransaction: (key: string, params: any[],
|
|
164
|
+
declare const buildTransaction: (store: Store, key: string, params: any[], id: string) => ChildStore;
|
|
165
165
|
|
|
166
166
|
declare class Subject<T> {
|
|
167
167
|
Subscriber: (value: T) => void;
|
|
@@ -183,14 +183,14 @@ type Transaction<F extends Func> = {
|
|
|
183
183
|
subject: Subject<TransactionUpdate<F>>;
|
|
184
184
|
run: (parameters: Parameters<F>, id?: string) => ReturnType<F>;
|
|
185
185
|
};
|
|
186
|
-
declare function createTransaction<F extends Func>(options: TransactionOptions<F
|
|
186
|
+
declare function createTransaction<F extends Func>(store: Store, options: TransactionOptions<F>): TransactionToken<F>;
|
|
187
187
|
|
|
188
|
-
declare function getContinuityKey(
|
|
189
|
-
declare function getEpochNumberOfContinuity(
|
|
190
|
-
declare function getEpochNumberOfAction(
|
|
188
|
+
declare function getContinuityKey(store: Store, transactionKey: string): string | undefined;
|
|
189
|
+
declare function getEpochNumberOfContinuity(store: Store, continuityKey: string): number | undefined;
|
|
190
|
+
declare function getEpochNumberOfAction(store: Store, transactionKey: string): number | undefined;
|
|
191
191
|
|
|
192
|
-
declare function setEpochNumberOfContinuity(continuityKey: string, newEpoch: number
|
|
193
|
-
declare function setEpochNumberOfAction(transactionKey: string, newEpoch: number
|
|
192
|
+
declare function setEpochNumberOfContinuity(store: Store, continuityKey: string, newEpoch: number): void;
|
|
193
|
+
declare function setEpochNumberOfAction(store: Store, transactionKey: string, newEpoch: number): void;
|
|
194
194
|
|
|
195
195
|
declare const TRANSACTION_PHASES: readonly ["idle", "building", "applying"];
|
|
196
196
|
type TransactionPhase = (typeof TRANSACTION_PHASES)[number];
|
|
@@ -224,11 +224,11 @@ declare function deposit<T extends Func>(state: Transaction<T>): TransactionToke
|
|
|
224
224
|
declare function deposit<M extends TimelineManageable>(state: Timeline<M>): TimelineToken<M>;
|
|
225
225
|
declare function deposit(resource: AtomIOInternalResource): AtomIOToken;
|
|
226
226
|
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
declare function
|
|
227
|
+
declare function editRelationsInStore<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, change: (relations: Junction<ASide, AType, BSide, BType, Content>) => void, store: Store): void;
|
|
228
|
+
|
|
229
|
+
declare function findRelationsInStore<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, key: AType | BType, store: Store): JoinStates<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
230
|
+
|
|
231
|
+
declare function getInternalRelationsFromStore(token: JoinToken<any, any, any, any, any, any>, store: Store): MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
232
232
|
|
|
233
233
|
type Molecule<K extends Canonical> = {
|
|
234
234
|
readonly key: K;
|
|
@@ -241,6 +241,74 @@ declare function fuseWithinStore<H extends Hierarchy, C extends CompoundFrom<H>,
|
|
|
241
241
|
declare function deallocateFromStore<H extends Hierarchy, V extends Vassal<H>>(store: Store, claim: Claim<V>): void;
|
|
242
242
|
declare function claimWithinStore<H extends Hierarchy, V extends Exclude<Vassal<H>, CompoundTypedKey>, A extends Above<V, H>>(store: Store, newProvenance: A, claim: Claim<V>, exclusive?: `exclusive`): Claim<V>;
|
|
243
243
|
|
|
244
|
+
type JoinStateFamilies<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null> = Cardinality extends `1:1` ? (Content extends Json.Object ? {
|
|
245
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
246
|
+
AType,
|
|
247
|
+
Content
|
|
248
|
+
] | null, BType>;
|
|
249
|
+
} & {
|
|
250
|
+
readonly [B in BSide as `${B}EntryOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
251
|
+
BType,
|
|
252
|
+
Content
|
|
253
|
+
] | null, AType>;
|
|
254
|
+
} : {}) & {
|
|
255
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
|
|
256
|
+
} & {
|
|
257
|
+
readonly [B in BSide as `${B}KeyOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType | null, AType>;
|
|
258
|
+
} : Cardinality extends `1:n` ? (Content extends Json.Object ? {
|
|
259
|
+
readonly [A in ASide as `${A}EntryOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
260
|
+
AType,
|
|
261
|
+
Content
|
|
262
|
+
] | null, BType>;
|
|
263
|
+
} & {
|
|
264
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
265
|
+
BType,
|
|
266
|
+
Content
|
|
267
|
+
][], AType>;
|
|
268
|
+
} : {}) & {
|
|
269
|
+
readonly [A in ASide as `${A}KeyOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType | null, BType>;
|
|
270
|
+
} & {
|
|
271
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
|
|
272
|
+
} : Cardinality extends `n:n` ? (Content extends Json.Object ? {
|
|
273
|
+
readonly [A in ASide as `${A}EntriesOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<[
|
|
274
|
+
AType,
|
|
275
|
+
Content
|
|
276
|
+
][], BType>;
|
|
277
|
+
} & {
|
|
278
|
+
readonly [B in BSide as `${B}EntriesOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<[
|
|
279
|
+
BType,
|
|
280
|
+
Content
|
|
281
|
+
][], AType>;
|
|
282
|
+
} : {}) & {
|
|
283
|
+
readonly [A in ASide as `${A}KeysOf${Capitalize<BSide>}`]: ReadonlySelectorFamilyToken<AType[], BType>;
|
|
284
|
+
} & {
|
|
285
|
+
readonly [B in BSide as `${B}KeysOf${Capitalize<ASide>}`]: ReadonlySelectorFamilyToken<BType[], AType>;
|
|
286
|
+
} : never;
|
|
287
|
+
declare class Join<const ASide extends string, const AType extends string, const BSide extends string, const BType extends string, const Cardinality extends `1:1` | `1:n` | `n:n`, const Content extends Json.Object | null = null, const ContentKey extends CompoundTypedKey<`content`, ASide, BSide> = CompoundTypedKey<`content`, ASide, BSide>> {
|
|
288
|
+
private toolkit;
|
|
289
|
+
options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
290
|
+
defaultContent: Content | undefined;
|
|
291
|
+
molecules: Map<string, Molecule<any>>;
|
|
292
|
+
relations: Junction<ASide, AType, BSide, BType, Content>;
|
|
293
|
+
states: JoinStateFamilies<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
294
|
+
core: {
|
|
295
|
+
relatedKeysAtoms: MutableAtomFamilyToken<SetRTX<string>, SetRTXJson<string>, string>;
|
|
296
|
+
};
|
|
297
|
+
transact(toolkit: SetterToolkit, run: (join: Join<ASide, AType, BSide, BType, Cardinality, Content>) => void): void;
|
|
298
|
+
store: Store;
|
|
299
|
+
realm: Anarchy;
|
|
300
|
+
[Symbol.dispose](): void;
|
|
301
|
+
constructor(options: JoinOptions<ASide, AType, BSide, BType, Cardinality, Content>, defaultContent: Content | undefined, store?: Store);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
declare function getJoin<ASide extends string, AType extends string, BSide extends string, BType extends string, Cardinality extends `1:1` | `1:n` | `n:n`, Content extends Json.Object | null>(token: JoinToken<ASide, AType, BSide, BType, Cardinality, Content>, store: Store): Join<ASide, AType, BSide, BType, Cardinality, Content>;
|
|
305
|
+
|
|
306
|
+
interface Lineage {
|
|
307
|
+
parent: typeof this | null;
|
|
308
|
+
child: typeof this | null;
|
|
309
|
+
}
|
|
310
|
+
declare function newest<T extends Lineage>(scion: T): T;
|
|
311
|
+
|
|
244
312
|
type OperationProgress = {
|
|
245
313
|
open: false;
|
|
246
314
|
} | {
|
|
@@ -297,7 +365,7 @@ type Timeline<ManagedAtom extends TimelineManageable> = {
|
|
|
297
365
|
subject: Subject<TimelineUpdate<ManagedAtom> | `redo` | `undo`>;
|
|
298
366
|
subscriptions: Map<string, () => void>;
|
|
299
367
|
};
|
|
300
|
-
declare function createTimeline<ManagedAtom extends TimelineManageable>(options: TimelineOptions<ManagedAtom>,
|
|
368
|
+
declare function createTimeline<ManagedAtom extends TimelineManageable>(store: Store, options: TimelineOptions<ManagedAtom>, data?: Timeline<ManagedAtom>): TimelineToken<ManagedAtom>;
|
|
301
369
|
|
|
302
370
|
declare const timeTravel: (store: Store, action: `redo` | `undo`, token: TimelineToken<any>) => void;
|
|
303
371
|
|
|
@@ -360,27 +428,27 @@ declare const IMPLICIT: {
|
|
|
360
428
|
};
|
|
361
429
|
declare const clearStore: (store: Store) => void;
|
|
362
430
|
|
|
363
|
-
declare function withdraw<T>(token: RegularAtomToken<T
|
|
364
|
-
declare function withdraw<T extends Transceiver<any>>(token: MutableAtomToken<T, any
|
|
365
|
-
declare function withdraw<T>(token: AtomToken<T
|
|
366
|
-
declare function withdraw<T>(token: WritableSelectorToken<T
|
|
367
|
-
declare function withdraw<T>(token: ReadonlySelectorToken<T
|
|
368
|
-
declare function withdraw<T>(token: SelectorToken<T
|
|
369
|
-
declare function withdraw<T>(token: WritableToken<T
|
|
370
|
-
declare function withdraw<T>(token: ReadableToken<T
|
|
371
|
-
declare function withdraw<T, K extends Canonical>(token: RegularAtomFamilyToken<T, K
|
|
372
|
-
declare function withdraw<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(token: MutableAtomFamilyToken<T, J, K
|
|
373
|
-
declare function withdraw<T, K extends Canonical>(token: AtomFamilyToken<T
|
|
374
|
-
declare function withdraw<T, K extends Canonical>(token: ReadonlySelectorFamilyToken<T, K
|
|
375
|
-
declare function withdraw<T, K extends Canonical>(token: WritableSelectorFamilyToken<T, K
|
|
376
|
-
declare function withdraw<T, K extends Canonical>(token: SelectorFamilyToken<T, K
|
|
377
|
-
declare function withdraw<T, K extends Canonical>(token: ReadableFamilyToken<T, K
|
|
378
|
-
declare function withdraw<T, K extends Canonical>(token: WritableFamilyToken<T, K
|
|
379
|
-
declare function withdraw<T extends Func>(token: TransactionToken<T
|
|
380
|
-
declare function withdraw<T>(token: TimelineToken<T
|
|
381
|
-
declare function withdraw<T>(token: WritableToken<T
|
|
382
|
-
declare function withdraw<T>(token: ReadableToken<T
|
|
383
|
-
declare function withdraw(
|
|
431
|
+
declare function withdraw<T>(store: Store, token: RegularAtomToken<T>): RegularAtom<T>;
|
|
432
|
+
declare function withdraw<T extends Transceiver<any>>(store: Store, token: MutableAtomToken<T, any>): MutableAtom<T, any>;
|
|
433
|
+
declare function withdraw<T>(store: Store, token: AtomToken<T>): Atom<T>;
|
|
434
|
+
declare function withdraw<T>(store: Store, token: WritableSelectorToken<T>): WritableSelector<T>;
|
|
435
|
+
declare function withdraw<T>(store: Store, token: ReadonlySelectorToken<T>): ReadonlySelector<T>;
|
|
436
|
+
declare function withdraw<T>(store: Store, token: SelectorToken<T>): Selector<T>;
|
|
437
|
+
declare function withdraw<T>(store: Store, token: WritableToken<T>): WritableState<T>;
|
|
438
|
+
declare function withdraw<T>(store: Store, token: ReadableToken<T>): ReadableState<T>;
|
|
439
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: RegularAtomFamilyToken<T, K>): RegularAtomFamily<T, K>;
|
|
440
|
+
declare function withdraw<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(store: Store, token: MutableAtomFamilyToken<T, J, K>): MutableAtomFamily<T, J, K>;
|
|
441
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: AtomFamilyToken<T>): AtomFamily<T, any>;
|
|
442
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: ReadonlySelectorFamilyToken<T, K>): ReadonlySelectorFamily<T, any>;
|
|
443
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: WritableSelectorFamilyToken<T, K>): WritableSelectorFamily<T, any>;
|
|
444
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: SelectorFamilyToken<T, K>): SelectorFamily<T, any>;
|
|
445
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: ReadableFamilyToken<T, K>): ReadableFamily<T, any>;
|
|
446
|
+
declare function withdraw<T, K extends Canonical>(store: Store, token: WritableFamilyToken<T, K>): WritableFamily<T, any>;
|
|
447
|
+
declare function withdraw<T extends Func>(store: Store, token: TransactionToken<T>): Transaction<T extends Func ? T : never>;
|
|
448
|
+
declare function withdraw<T>(store: Store, token: TimelineToken<T>): Timeline<T extends TimelineManageable ? T : never>;
|
|
449
|
+
declare function withdraw<T>(store: Store, token: WritableToken<T>): WritableState<T>;
|
|
450
|
+
declare function withdraw<T>(store: Store, token: ReadableToken<T>): ReadableState<T>;
|
|
451
|
+
declare function withdraw(store: Store, token: AtomIOToken): AtomIOInternalResource;
|
|
384
452
|
|
|
385
453
|
interface Transceiver<S extends Json.Serializable> {
|
|
386
454
|
do: (update: S) => number | `OUT_OF_RANGE` | null;
|
|
@@ -419,11 +487,12 @@ declare class Tracker<Mutable extends Transceiver<any>> {
|
|
|
419
487
|
private updateCore;
|
|
420
488
|
mutableState: MutableAtomToken<Mutable, Json.Serializable>;
|
|
421
489
|
latestUpdateState: RegularAtomToken<typeof this.Update | null>;
|
|
422
|
-
dispose: () => void;
|
|
490
|
+
[Symbol.dispose]: () => void;
|
|
423
491
|
constructor(mutableState: MutableAtomToken<Mutable, Json.Serializable>, store: Store);
|
|
424
492
|
}
|
|
425
493
|
|
|
426
494
|
declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey extends Canonical> {
|
|
495
|
+
private trackers;
|
|
427
496
|
private readonly Update;
|
|
428
497
|
readonly latestUpdateAtoms: RegularAtomFamily<typeof this.Update | null, FamilyMemberKey>;
|
|
429
498
|
readonly mutableAtoms: MutableAtomFamily<Core, any, FamilyMemberKey>;
|
|
@@ -437,11 +506,11 @@ declare function createRegularAtom<T>(store: Store, options: RegularAtomOptions<
|
|
|
437
506
|
declare function createStandaloneAtom<T>(store: Store, options: RegularAtomOptions<T>): RegularAtomToken<T>;
|
|
438
507
|
declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(store: Store, options: MutableAtomOptions<T, J>): MutableAtomToken<T, J>;
|
|
439
508
|
|
|
440
|
-
declare function disposeAtom(atomToken: AtomToken<unknown
|
|
509
|
+
declare function disposeAtom(store: Store, atomToken: AtomToken<unknown>): void;
|
|
441
510
|
|
|
442
|
-
declare const isAtomDefault: (
|
|
443
|
-
declare const markAtomAsDefault: (
|
|
444
|
-
declare const markAtomAsNotDefault: (
|
|
511
|
+
declare const isAtomDefault: (store: Store, key: string) => boolean;
|
|
512
|
+
declare const markAtomAsDefault: (store: Store, key: string) => void;
|
|
513
|
+
declare const markAtomAsNotDefault: (store: Store, key: string) => void;
|
|
445
514
|
|
|
446
515
|
/**
|
|
447
516
|
* A Promise whose incoming value can be hot swapped.
|
|
@@ -463,11 +532,13 @@ declare class Future<T> extends Promise<T> {
|
|
|
463
532
|
use(value: Promise<T> | T): void;
|
|
464
533
|
}
|
|
465
534
|
|
|
466
|
-
declare function cacheValue<T>(key: string, value: T, subject: Subject<StateUpdate<unknown
|
|
467
|
-
declare function cacheValue<T extends Promise<any>>(key: string, value: T, subject: Subject<StateUpdate<unknown
|
|
535
|
+
declare function cacheValue<T>(store: Store, key: string, value: T, subject: Subject<StateUpdate<unknown>>): T;
|
|
536
|
+
declare function cacheValue<T extends Promise<any>>(store: Store, key: string, value: T, subject: Subject<StateUpdate<unknown>>): Future<T>;
|
|
468
537
|
declare const readCachedValue: <T>(token: ReadableState<any>, target: Store) => T;
|
|
469
538
|
declare const evictCachedValue: (key: string, target: Store) => void;
|
|
470
539
|
|
|
540
|
+
declare function capitalize<S extends string>(string: S): Capitalize<S>;
|
|
541
|
+
|
|
471
542
|
declare function createAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Canonical>(store: Store, options: MutableAtomFamilyOptions<T, J, K>): MutableAtomFamilyToken<T, J, K>;
|
|
472
543
|
declare function createAtomFamily<T, K extends Canonical>(store: Store, options: RegularAtomFamilyOptions<T, K>): RegularAtomFamilyToken<T, K>;
|
|
473
544
|
|
|
@@ -516,7 +587,7 @@ declare function getEnvironmentData(store: Store): EnvironmentData;
|
|
|
516
587
|
declare function getFromStore<T>(store: Store, token: ReadableToken<T>): T;
|
|
517
588
|
declare function getFromStore<T, K extends Canonical>(store: Store, token: ReadableFamilyToken<T, K>, key: K): T;
|
|
518
589
|
|
|
519
|
-
declare const readOrComputeValue: <T>(state: ReadableState<T
|
|
590
|
+
declare const readOrComputeValue: <T>(target: Store, state: ReadableState<T>) => T;
|
|
520
591
|
|
|
521
592
|
declare function getTrace(error: Error): string;
|
|
522
593
|
|
|
@@ -544,11 +615,11 @@ type ReadonlySelectorKey<T> = string & {
|
|
|
544
615
|
__readonlySelectorKey?: never;
|
|
545
616
|
__brand?: T;
|
|
546
617
|
};
|
|
547
|
-
declare const isAtomKey: (
|
|
548
|
-
declare const isSelectorKey: (
|
|
549
|
-
declare const isReadonlySelectorKey: (
|
|
618
|
+
declare const isAtomKey: (store: Store, key: string) => key is AtomKey<unknown>;
|
|
619
|
+
declare const isSelectorKey: (store: Store, key: string) => key is SelectorKey<unknown>;
|
|
620
|
+
declare const isReadonlySelectorKey: (store: Store, key: string) => key is ReadonlySelectorKey<unknown>;
|
|
550
621
|
type StateKey<T> = AtomKey<T> | ReadonlySelectorKey<T> | SelectorKey<T>;
|
|
551
|
-
declare const isStateKey: (
|
|
622
|
+
declare const isStateKey: (store: Store, key: string) => key is StateKey<unknown>;
|
|
552
623
|
|
|
553
624
|
declare class LazyMap<K, V> extends Map<K, V> {
|
|
554
625
|
protected readonly source: Map<K, V>;
|
|
@@ -574,7 +645,7 @@ declare function createStandaloneSelector<T>(store: Store, options: ReadonlySele
|
|
|
574
645
|
|
|
575
646
|
declare const createWritableSelector: <T>(store: Store, options: WritableSelectorOptions<T>, family: FamilyMetadata | undefined) => WritableSelectorToken<T>;
|
|
576
647
|
|
|
577
|
-
declare function disposeSelector(selectorToken:
|
|
648
|
+
declare function disposeSelector(store: Store, selectorToken: SelectorToken<unknown>): void;
|
|
578
649
|
|
|
579
650
|
declare const getSelectorDependencyKeys: (key: string, store: Store) => (AtomKey<unknown> | ReadonlySelectorKey<unknown> | SelectorKey<unknown>)[];
|
|
580
651
|
|
|
@@ -588,25 +659,25 @@ declare const updateSelectorAtoms: (selectorKey: string, dependency: ReadonlySel
|
|
|
588
659
|
type Modify<T> = (thing: T) => T;
|
|
589
660
|
declare const become: <T>(nextVersionOfThing: Modify<T> | T) => (originalThing: T) => T;
|
|
590
661
|
|
|
591
|
-
declare const setAtomOrSelector: <T>(state: WritableState<T>, value: T | ((oldValue: T) => T)
|
|
662
|
+
declare const setAtomOrSelector: <T>(store: Store, state: WritableState<T>, value: T | ((oldValue: T) => T)) => void;
|
|
592
663
|
|
|
593
664
|
declare function setIntoStore<T, New extends T>(store: Store, token: WritableToken<T>, value: New | ((oldValue: T) => New)): void;
|
|
594
665
|
declare function setIntoStore<T, K extends Canonical, New extends T>(store: Store, token: WritableFamilyToken<T, K>, key: K, value: New | ((oldValue: T) => New)): void;
|
|
595
666
|
|
|
596
|
-
declare const recallState: <T>(state: ReadableState<T
|
|
667
|
+
declare const recallState: <T>(store: Store, state: ReadableState<T>) => T;
|
|
597
668
|
|
|
598
669
|
declare function subscribeInStore<T>(store: Store$1, token: ReadableToken<T>, handleUpdate: UpdateHandler<T>, key?: string): () => void;
|
|
599
670
|
declare function subscribeInStore<F extends Func$1>(store: Store$1, token: TransactionToken<F>, handleUpdate: TransactionUpdateHandler<F>, key?: string): () => void;
|
|
600
671
|
declare function subscribeInStore<M extends TimelineManageable>(store: Store$1, token: TimelineToken<M>, handleUpdate: (update: TimelineUpdate<M> | `redo` | `undo`) => void, key?: string): () => void;
|
|
601
672
|
declare function subscribeInStore<M extends TimelineManageable>(store: Store$1, token: ReadableToken<any> | TimelineToken<M> | TransactionToken<any>, handleUpdate: TransactionUpdateHandler<any> | UpdateHandler<any> | ((update: TimelineUpdate<M> | `redo` | `undo`) => void), key?: string): () => void;
|
|
602
673
|
|
|
603
|
-
declare const subscribeToRootAtoms: <T>(selector: Selector<T
|
|
674
|
+
declare const subscribeToRootAtoms: <T>(store: Store, selector: Selector<T>) => (() => void)[];
|
|
604
675
|
|
|
605
|
-
declare function subscribeToState<T>(
|
|
676
|
+
declare function subscribeToState<T>(store: Store, token: ReadableToken<T>, key: string, handleUpdate: UpdateHandler<T>): () => void;
|
|
606
677
|
|
|
607
|
-
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(token: TimelineToken<ManagedAtom>, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void
|
|
678
|
+
declare const subscribeToTimeline: <ManagedAtom extends TimelineManageable>(store: Store, token: TimelineToken<ManagedAtom>, key: string, handleUpdate: (update: TimelineUpdate<any> | `redo` | `undo`) => void) => (() => void);
|
|
608
679
|
|
|
609
|
-
declare const subscribeToTransaction: <F extends Func>(
|
|
680
|
+
declare const subscribeToTransaction: <F extends Func>(store: Store, token: TransactionToken<F>, key: string, handleUpdate: TransactionUpdateHandler<F>) => (() => void);
|
|
610
681
|
|
|
611
682
|
type AtomIOState = {
|
|
612
683
|
key: string;
|
|
@@ -670,4 +741,4 @@ type WritableFamily<T, K extends Canonical> = AtomFamily<T, K> | WritableSelecto
|
|
|
670
741
|
type ReadableFamily<T, K extends Canonical> = AtomFamily<T, K> | SelectorFamily<T, K>;
|
|
671
742
|
type AtomIOInternalResource = ReadableFamily<any, any> | ReadableState<any> | Timeline<any> | Transaction<any>;
|
|
672
743
|
|
|
673
|
-
export { type Atom, type AtomFamily, type AtomIOInternalResource, type AtomIOState, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, CircularBuffer, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionEntriesBase, type JunctionJSON, type JunctionSchema, type JunctionSchemaBase, LazyMap, type Lineage, type Modify, type Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type Refinement, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, claimWithinStore, clearStore, closeOperation, counterfeit, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, evictCachedValue, findInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|
|
744
|
+
export { type Atom, type AtomFamily, type AtomIOInternalResource, type AtomIOState, type AtomKey, type BaseExternalStoreConfiguration, type ChildStore, CircularBuffer, type Count, type Each, type Empty, type EnvironmentData, type ExternalStoreConfiguration, type ExternalStoreWithContentConfiguration, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, type Flat, type Func, Future, IMPLICIT, Join, type JoinStateFamilies, Junction, type JunctionAdvancedConfiguration, type JunctionEntries, type JunctionEntriesBase, type JunctionJSON, type JunctionSchema, type JunctionSchemaBase, LazyMap, type Lineage, type Modify, type Molecule, type MutableAtom, type MutableAtomFamily, NotFoundError, type OperationProgress, type ReadableFamily, type ReadableState, type ReadonlySelector, type ReadonlySelectorFamily, type ReadonlySelectorKey, type Refinement, type RegularAtom, type RegularAtomFamily, type RootStore, type Selector, type SelectorFamily, type SelectorKey, type Signal, type StateKey, StatefulSubject, Store, Subject, TRANSACTION_PHASES, type Timeline, type TimelineAtomUpdate, type TimelineMoleculeCreation, type TimelineMoleculeDisposal, type TimelineSelectorUpdate, type TimelineStateCreation, type TimelineStateDisposal, type TimelineTransactionUpdate, Tracker, type Transaction, type TransactionEpoch, type TransactionPhase, type TransactionProgress, type Transceiver, type TransceiverMode, type WritableFamily, type WritableSelector, type WritableSelectorFamily, type WritableState, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, capitalize, claimWithinStore, clearStore, closeOperation, counterfeit, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, evictCachedValue, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw };
|
package/internal/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { CircularBuffer, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Junction, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, claimWithinStore, clearStore, closeOperation, counterfeit, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, evictCachedValue, findInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-
|
|
1
|
+
export { CircularBuffer, FAMILY_MEMBER_TOKEN_TYPES, FamilyTracker, Future, IMPLICIT, Join, Junction, LazyMap, NotFoundError, StatefulSubject, Store, Subject, TRANSACTION_PHASES, Tracker, abortTransaction, actUponStore, allocateIntoStore, applyTransaction, arbitrary, assignTransactionToContinuity, become, buildTransaction, cacheValue, capitalize, claimWithinStore, clearStore, closeOperation, counterfeit, createAtomFamily, createMutableAtom, createMutableAtomFamily, createReadonlySelector, createReadonlySelectorFamily, createRegularAtom, createRegularAtomFamily, createSelectorFamily, createStandaloneAtom, createStandaloneSelector, createTimeline, createTransaction, createWritableSelector, deallocateFromStore, deposit, disposeAtom, disposeFromStore, disposeSelector, editRelationsInStore, evictCachedValue, findInStore, findRelationsInStore, fuseWithinStore, getContinuityKey, getEnvironmentData, getEpochNumberOfAction, getEpochNumberOfContinuity, getFromStore, getInternalRelationsFromStore, getJoin, getJsonFamily, getJsonToken, getSelectorDependencyKeys, getTrace, getUpdateFamily, getUpdateToken, ingestAtomUpdate, ingestCreationEvent, ingestDisposalEvent, ingestMoleculeCreationEvent, ingestMoleculeDisposalEvent, ingestMoleculeTransferEvent, ingestSelectorUpdate, ingestTransactionUpdate, initFamilyMemberInStore, isAtomDefault, isAtomKey, isChildStore, isDone, isReadonlySelectorKey, isRootStore, isSelectorKey, isStateKey, isTransceiver, makeRootMoleculeInStore, markAtomAsDefault, markAtomAsNotDefault, markDone, newest, openOperation, prettyPrintTokenType, readCachedValue, readOrComputeValue, recallState, registerSelector, seekInStore, setAtomOrSelector, setEpochNumberOfAction, setEpochNumberOfContinuity, setIntoStore, subscribeInStore, subscribeToRootAtoms, subscribeToState, subscribeToTimeline, subscribeToTransaction, timeTravel, traceAllSelectorAtoms, traceSelectorAtoms, updateSelectorAtoms, withdraw } from '../../dist/chunk-UQEYZ3OI.js';
|
|
2
2
|
import '../../dist/chunk-XWL6SNVU.js';
|
|
@@ -59,8 +59,8 @@ export function createRegularAtom<T>(
|
|
|
59
59
|
initialValue = options.default()
|
|
60
60
|
}
|
|
61
61
|
target.atoms.set(newAtom.key, newAtom)
|
|
62
|
-
markAtomAsDefault(options.key
|
|
63
|
-
cacheValue(options.key, initialValue, subject
|
|
62
|
+
markAtomAsDefault(store, options.key)
|
|
63
|
+
cacheValue(target, options.key, initialValue, subject)
|
|
64
64
|
const token = deposit(newAtom)
|
|
65
65
|
if (options.effects) {
|
|
66
66
|
let effectIndex = 0
|
|
@@ -71,7 +71,7 @@ export function createRegularAtom<T>(
|
|
|
71
71
|
setIntoStore(store, token, next)
|
|
72
72
|
},
|
|
73
73
|
onSet: (handle: UpdateHandler<T>) =>
|
|
74
|
-
subscribeToState(
|
|
74
|
+
subscribeToState(store, token, `effect[${effectIndex}]`, handle),
|
|
75
75
|
})
|
|
76
76
|
if (cleanup) {
|
|
77
77
|
cleanupFunctions.push(cleanup)
|
|
@@ -3,16 +3,16 @@ import type { AtomDisposal, AtomToken } from "atom.io"
|
|
|
3
3
|
import type { Store } from ".."
|
|
4
4
|
import { getUpdateToken, isChildStore, newest, withdraw } from ".."
|
|
5
5
|
|
|
6
|
-
export function disposeAtom(atomToken: AtomToken<unknown
|
|
6
|
+
export function disposeAtom(store: Store, atomToken: AtomToken<unknown>): void {
|
|
7
7
|
const target = newest(store)
|
|
8
8
|
const { key, family } = atomToken
|
|
9
|
-
const atom = withdraw(
|
|
9
|
+
const atom = withdraw(target, atomToken)
|
|
10
10
|
if (!family) {
|
|
11
11
|
store.logger.error(`❌`, `atom`, key, `Standalone atoms cannot be disposed.`)
|
|
12
12
|
} else {
|
|
13
13
|
atom.cleanup?.()
|
|
14
14
|
const lastValue = store.valueMap.get(atom.key)
|
|
15
|
-
const atomFamily = withdraw({ key: family.key, type: `atom_family` }
|
|
15
|
+
const atomFamily = withdraw(store, { key: family.key, type: `atom_family` })
|
|
16
16
|
|
|
17
17
|
const disposal: AtomDisposal<AtomToken<unknown>> = {
|
|
18
18
|
type: `state_disposal`,
|
|
@@ -24,15 +24,6 @@ export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
|
|
|
24
24
|
atomFamily.subject.next(disposal)
|
|
25
25
|
|
|
26
26
|
const isChild = isChildStore(target)
|
|
27
|
-
// let molecule = target.molecules.get(family.subKey)
|
|
28
|
-
// if (molecule && isChild) {
|
|
29
|
-
// const parentMolecule = target.parent.molecules.get(family.subKey)
|
|
30
|
-
// if (parentMolecule === molecule) {
|
|
31
|
-
// molecule = parentMolecule.copy()
|
|
32
|
-
// target.molecules.set(family.subKey, molecule)
|
|
33
|
-
// }
|
|
34
|
-
// }
|
|
35
|
-
// molecule?.tokens.delete(family.key)
|
|
36
27
|
|
|
37
28
|
target.atoms.delete(key)
|
|
38
29
|
target.valueMap.delete(key)
|
|
@@ -42,7 +33,7 @@ export function disposeAtom(atomToken: AtomToken<unknown>, store: Store): void {
|
|
|
42
33
|
|
|
43
34
|
if (atomToken.type === `mutable_atom`) {
|
|
44
35
|
const updateToken = getUpdateToken(atomToken)
|
|
45
|
-
disposeAtom(
|
|
36
|
+
disposeAtom(store, updateToken)
|
|
46
37
|
store.trackers.delete(key)
|
|
47
38
|
}
|
|
48
39
|
store.logger.info(`🔥`, `atom`, key, `deleted`)
|