atom.io 0.19.3 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/data/dist/index.js +1 -1
- package/data/src/dict.ts +1 -1
- package/data/src/join.ts +1 -1
- package/data/src/struct-family.ts +1 -1
- package/data/src/struct.ts +5 -3
- package/eslint-plugin/dist/index.cjs +53 -0
- package/eslint-plugin/dist/index.js +52 -0
- package/eslint-plugin/src/index.ts +1 -0
- package/eslint-plugin/src/rules/explicit-state-types.ts +55 -0
- package/eslint-plugin/src/rules/index.ts +1 -0
- package/internal/dist/index.cjs +127 -92
- package/internal/dist/index.d.ts +13 -9
- package/internal/dist/index.js +127 -92
- package/internal/src/atom/index.ts +1 -1
- package/internal/src/caching.ts +13 -9
- package/internal/src/families/create-atom-family.ts +1 -1
- package/internal/src/families/find-in-store.ts +2 -2
- package/internal/src/families/index.ts +1 -1
- package/internal/src/future.ts +52 -15
- package/internal/src/index.ts +2 -2
- package/internal/src/mutable/create-mutable-atom-family.ts +2 -3
- package/internal/src/mutable/create-mutable-atom.ts +3 -3
- package/internal/src/mutable/get-update-token.ts +1 -0
- package/internal/src/selector/delete-selector.ts +1 -1
- package/internal/src/selector/register-selector.ts +1 -1
- package/internal/src/store/deposit.ts +1 -1
- package/internal/src/store/store.ts +2 -2
- package/internal/src/store/withdraw-new-family-member.ts +1 -1
- package/internal/src/store/withdraw.ts +2 -3
- package/internal/src/subscribe/subscribe-to-state.ts +1 -0
- package/internal/src/subscribe/subscribe-to-timeline.ts +1 -0
- package/internal/src/subscribe/subscribe-to-transaction.ts +2 -1
- package/internal/src/timeline/add-atom-to-timeline.ts +2 -2
- package/internal/src/timeline/create-timeline.ts +1 -1
- package/internal/src/transaction/act-upon-store.ts +1 -1
- package/internal/src/transaction/apply-transaction.ts +1 -1
- package/internal/src/transaction/build-transaction.ts +2 -2
- package/internal/src/transaction/create-transaction.ts +2 -2
- package/internal/src/transaction/index.ts +1 -1
- package/internal/src/transaction/is-root-store.ts +1 -1
- package/introspection/src/attach-atom-index.ts +1 -1
- package/introspection/src/attach-introspection-states.ts +2 -2
- package/introspection/src/attach-selector-index.ts +1 -1
- package/introspection/src/attach-timeline-family.ts +2 -2
- package/introspection/src/attach-timeline-index.ts +1 -1
- package/introspection/src/attach-transaction-index.ts +2 -2
- package/introspection/src/attach-transaction-logs.ts +2 -2
- package/json/dist/index.cjs +35 -33
- package/json/dist/index.d.ts +5 -5
- package/json/dist/index.js +5 -5
- package/json/src/index.ts +2 -3
- package/json/src/select-json-family.ts +6 -6
- package/json/src/select-json.ts +1 -2
- package/package.json +18 -15
- package/react/src/use-tl.ts +1 -1
- package/react-devtools/dist/index.cjs +99 -99
- package/react-devtools/dist/index.css +0 -3
- package/react-devtools/dist/index.d.ts +2 -2
- package/react-devtools/dist/index.js +77 -77
- package/react-devtools/src/AtomIODevtools.tsx +2 -2
- package/react-devtools/src/TransactionIndex.tsx +2 -2
- package/react-devtools/src/Updates.tsx +1 -1
- package/react-devtools/src/devtools.scss +0 -3
- package/react-devtools/src/index.ts +1 -1
- package/realtime/src/realtime-continuity.ts +1 -1
- package/realtime/src/shared-room-store.ts +1 -1
- package/realtime-client/dist/index.js +1 -1
- package/realtime-client/src/pull-atom-family-member.ts +1 -1
- package/realtime-client/src/pull-atom.ts +1 -1
- package/realtime-client/src/pull-mutable-atom-family-member.ts +2 -2
- package/realtime-client/src/sync-continuity.ts +1 -1
- package/realtime-react/dist/index.js +1 -1
- package/realtime-react/src/use-realtime-service.ts +1 -0
- package/realtime-react/src/use-sync-continuity.ts +2 -1
- package/realtime-server/dist/index.cjs +98 -98
- package/realtime-server/dist/index.d.ts +17 -18
- package/realtime-server/dist/index.js +100 -100
- package/realtime-server/src/index.ts +5 -5
- package/realtime-server/src/ipc-sockets/parent-socket.ts +3 -3
- package/realtime-server/src/realtime-action-receiver.ts +1 -1
- package/realtime-server/src/realtime-continuity-synchronizer.ts +2 -3
- package/realtime-server/src/realtime-family-provider.ts +1 -1
- package/realtime-server/src/realtime-mutable-family-provider.ts +1 -1
- package/realtime-server/src/realtime-mutable-provider.ts +2 -2
- package/realtime-server/src/realtime-server-stores/realtime-continuity-store.ts +2 -2
- package/realtime-server/src/realtime-server-stores/server-room-external-actions.ts +1 -1
- package/realtime-server/src/realtime-server-stores/server-room-external-store.ts +1 -0
- package/realtime-server/src/realtime-server-stores/server-user-store.ts +3 -2
- package/realtime-server/src/realtime-state-provider.ts +1 -1
- package/realtime-server/src/realtime-state-synchronizer.ts +1 -1
- package/realtime-testing/dist/index.js +2 -2
- package/realtime-testing/src/setup-realtime-test.tsx +3 -2
- package/src/atom.ts +1 -1
- package/src/find-state.ts +1 -1
- package/src/index.ts +1 -0
- package/src/selector.ts +1 -1
- package/src/silo.ts +4 -4
- package/src/subscribe.ts +2 -2
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +3 -3
- package/transceivers/set-rtx/src/set-rtx.ts +1 -1
- package/dist/{chunk-ATKDGVTV.js → chunk-2AIFLP2B.js} +0 -0
- package/dist/{chunk-CC7IF7QF.js → chunk-3V3VWQ7X.js} +6 -6
- /package/dist/{chunk-MSCJWACE.js → chunk-SMZRGPN6.js} +0 -0
package/data/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-
|
|
1
|
+
export { Join, editRelations, editRelationsInStore, findRelations, findRelationsInStore, getInternalRelations, getInternalRelationsFromStore, getJoin, getJoinMap, join } from '../../dist/chunk-SMZRGPN6.js';
|
|
2
2
|
import '../../dist/chunk-FTONNX2R.js';
|
|
3
3
|
import '../../dist/chunk-F2X4B4VY.js';
|
|
4
4
|
import { createStandaloneSelector, findInStore, IMPLICIT, createRegularAtom, createRegularAtomFamily, createSelectorFamily } from 'atom.io/internal';
|
package/data/src/dict.ts
CHANGED
package/data/src/join.ts
CHANGED
|
@@ -13,13 +13,13 @@ import type {
|
|
|
13
13
|
import { dispose, findState, getState, setState } from "atom.io"
|
|
14
14
|
import type { Store } from "atom.io/internal"
|
|
15
15
|
import {
|
|
16
|
-
IMPLICIT,
|
|
17
16
|
createMutableAtomFamily,
|
|
18
17
|
createRegularAtomFamily,
|
|
19
18
|
createSelectorFamily,
|
|
20
19
|
findInStore,
|
|
21
20
|
getFromStore,
|
|
22
21
|
getJsonFamily,
|
|
22
|
+
IMPLICIT,
|
|
23
23
|
isChildStore,
|
|
24
24
|
newest,
|
|
25
25
|
setIntoStore,
|
package/data/src/struct.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type * as AtomIO from "atom.io"
|
|
2
2
|
import type { Store } from "atom.io/internal"
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import {
|
|
4
|
+
createRegularAtom,
|
|
5
|
+
createStandaloneSelector,
|
|
6
|
+
IMPLICIT,
|
|
7
|
+
} from "atom.io/internal"
|
|
6
8
|
|
|
7
9
|
const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1)
|
|
8
10
|
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var utils = require('@typescript-eslint/utils');
|
|
6
|
+
|
|
5
7
|
var __defProp = Object.defineProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -11,8 +13,58 @@ var __export = (target, all) => {
|
|
|
11
13
|
// eslint-plugin/src/rules/index.ts
|
|
12
14
|
var rules_exports = {};
|
|
13
15
|
__export(rules_exports, {
|
|
16
|
+
explicitStateTypes: () => explicitStateTypes,
|
|
14
17
|
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
15
18
|
});
|
|
19
|
+
var createRule = utils.ESLintUtils.RuleCreator(
|
|
20
|
+
(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
|
|
21
|
+
);
|
|
22
|
+
var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
|
|
23
|
+
var explicitStateTypes = createRule({
|
|
24
|
+
name: `explicit-state-types`,
|
|
25
|
+
meta: {
|
|
26
|
+
type: `problem`,
|
|
27
|
+
docs: {
|
|
28
|
+
description: `State declarations must have generic type arguments directly passed to them`
|
|
29
|
+
},
|
|
30
|
+
messages: {
|
|
31
|
+
noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
|
|
32
|
+
},
|
|
33
|
+
schema: []
|
|
34
|
+
// no options
|
|
35
|
+
},
|
|
36
|
+
defaultOptions: [],
|
|
37
|
+
create(context) {
|
|
38
|
+
return {
|
|
39
|
+
CallExpression(node) {
|
|
40
|
+
const { callee } = node;
|
|
41
|
+
switch (callee.type) {
|
|
42
|
+
case `Identifier`: {
|
|
43
|
+
if (STATE_FUNCTIONS.includes(callee.name)) {
|
|
44
|
+
if (!node.typeArguments) {
|
|
45
|
+
context.report({
|
|
46
|
+
node,
|
|
47
|
+
messageId: `noTypeArgument`
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
case `MemberExpression`: {
|
|
54
|
+
if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
|
|
55
|
+
if (!node.typeArguments) {
|
|
56
|
+
context.report({
|
|
57
|
+
node,
|
|
58
|
+
messageId: `noTypeArgument`
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
});
|
|
16
68
|
|
|
17
69
|
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
18
70
|
function walk(node, callback, depth = 0) {
|
|
@@ -172,6 +224,7 @@ var synchronousSelectorDependencies = {
|
|
|
172
224
|
// eslint-plugin/src/index.ts
|
|
173
225
|
var src_default = {
|
|
174
226
|
rules: {
|
|
227
|
+
"explicit-state-types": explicitStateTypes,
|
|
175
228
|
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
176
229
|
}
|
|
177
230
|
};
|
|
@@ -1,10 +1,61 @@
|
|
|
1
1
|
import { __export } from '../../dist/chunk-F2X4B4VY.js';
|
|
2
|
+
import { ESLintUtils } from '@typescript-eslint/utils';
|
|
2
3
|
|
|
3
4
|
// eslint-plugin/src/rules/index.ts
|
|
4
5
|
var rules_exports = {};
|
|
5
6
|
__export(rules_exports, {
|
|
7
|
+
explicitStateTypes: () => explicitStateTypes,
|
|
6
8
|
synchronousSelectorDependencies: () => synchronousSelectorDependencies
|
|
7
9
|
});
|
|
10
|
+
var createRule = ESLintUtils.RuleCreator(
|
|
11
|
+
(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
|
|
12
|
+
);
|
|
13
|
+
var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
|
|
14
|
+
var explicitStateTypes = createRule({
|
|
15
|
+
name: `explicit-state-types`,
|
|
16
|
+
meta: {
|
|
17
|
+
type: `problem`,
|
|
18
|
+
docs: {
|
|
19
|
+
description: `State declarations must have generic type arguments directly passed to them`
|
|
20
|
+
},
|
|
21
|
+
messages: {
|
|
22
|
+
noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
|
|
23
|
+
},
|
|
24
|
+
schema: []
|
|
25
|
+
// no options
|
|
26
|
+
},
|
|
27
|
+
defaultOptions: [],
|
|
28
|
+
create(context) {
|
|
29
|
+
return {
|
|
30
|
+
CallExpression(node) {
|
|
31
|
+
const { callee } = node;
|
|
32
|
+
switch (callee.type) {
|
|
33
|
+
case `Identifier`: {
|
|
34
|
+
if (STATE_FUNCTIONS.includes(callee.name)) {
|
|
35
|
+
if (!node.typeArguments) {
|
|
36
|
+
context.report({
|
|
37
|
+
node,
|
|
38
|
+
messageId: `noTypeArgument`
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
case `MemberExpression`: {
|
|
45
|
+
if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
|
|
46
|
+
if (!node.typeArguments) {
|
|
47
|
+
context.report({
|
|
48
|
+
node,
|
|
49
|
+
messageId: `noTypeArgument`
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
});
|
|
8
59
|
|
|
9
60
|
// eslint-plugin/src/rules/synchronous-selector-dependencies.ts
|
|
10
61
|
function walk(node, callback, depth = 0) {
|
|
@@ -164,6 +215,7 @@ var synchronousSelectorDependencies = {
|
|
|
164
215
|
// eslint-plugin/src/index.ts
|
|
165
216
|
var src_default = {
|
|
166
217
|
rules: {
|
|
218
|
+
"explicit-state-types": explicitStateTypes,
|
|
167
219
|
"synchronous-selector-dependencies": synchronousSelectorDependencies
|
|
168
220
|
}
|
|
169
221
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { ESLintUtils } from "@typescript-eslint/utils"
|
|
2
|
+
|
|
3
|
+
const createRule = ESLintUtils.RuleCreator(
|
|
4
|
+
(name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`,
|
|
5
|
+
)
|
|
6
|
+
|
|
7
|
+
const STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`]
|
|
8
|
+
|
|
9
|
+
export const explicitStateTypes = createRule({
|
|
10
|
+
name: `explicit-state-types`,
|
|
11
|
+
meta: {
|
|
12
|
+
type: `problem`,
|
|
13
|
+
docs: {
|
|
14
|
+
description: `State declarations must have generic type arguments directly passed to them`,
|
|
15
|
+
},
|
|
16
|
+
messages: {
|
|
17
|
+
noTypeArgument: `State declarations must have generic type arguments directly passed to them.`,
|
|
18
|
+
},
|
|
19
|
+
schema: [], // no options
|
|
20
|
+
},
|
|
21
|
+
defaultOptions: [],
|
|
22
|
+
create(context) {
|
|
23
|
+
return {
|
|
24
|
+
CallExpression(node) {
|
|
25
|
+
const { callee } = node
|
|
26
|
+
switch (callee.type) {
|
|
27
|
+
case `Identifier`: {
|
|
28
|
+
if (STATE_FUNCTIONS.includes(callee.name)) {
|
|
29
|
+
if (!node.typeArguments) {
|
|
30
|
+
context.report({
|
|
31
|
+
node,
|
|
32
|
+
messageId: `noTypeArgument`,
|
|
33
|
+
})
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
break
|
|
37
|
+
}
|
|
38
|
+
case `MemberExpression`: {
|
|
39
|
+
if (
|
|
40
|
+
callee.property.type === `Identifier` &&
|
|
41
|
+
STATE_FUNCTIONS.includes(callee.property.name)
|
|
42
|
+
) {
|
|
43
|
+
if (!node.typeArguments) {
|
|
44
|
+
context.report({
|
|
45
|
+
node,
|
|
46
|
+
messageId: `noTypeArgument`,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
})
|
package/internal/dist/index.cjs
CHANGED
|
@@ -23,6 +23,67 @@ var __spreadValues = (a, b) => {
|
|
|
23
23
|
};
|
|
24
24
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
25
25
|
|
|
26
|
+
// internal/src/arbitrary.ts
|
|
27
|
+
function arbitrary(random = Math.random) {
|
|
28
|
+
return random().toString(36).slice(2);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// internal/src/future.ts
|
|
32
|
+
var Future = class extends Promise {
|
|
33
|
+
constructor(executor) {
|
|
34
|
+
let promise;
|
|
35
|
+
let superResolve;
|
|
36
|
+
let superReject;
|
|
37
|
+
super((resolve, reject) => {
|
|
38
|
+
superResolve = resolve;
|
|
39
|
+
superReject = reject;
|
|
40
|
+
promise = executor instanceof Promise ? executor : new Promise(executor);
|
|
41
|
+
promise.then(
|
|
42
|
+
(value) => {
|
|
43
|
+
if (promise) {
|
|
44
|
+
this.pass(promise, value);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
(reason) => {
|
|
48
|
+
if (promise) {
|
|
49
|
+
this.fail(promise, reason);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
});
|
|
54
|
+
this.destiny = promise;
|
|
55
|
+
this.resolve = superResolve;
|
|
56
|
+
this.reject = superReject;
|
|
57
|
+
}
|
|
58
|
+
pass(promise, value) {
|
|
59
|
+
if (promise === this.destiny) {
|
|
60
|
+
this.resolve(value);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
fail(promise, reason) {
|
|
64
|
+
if (promise === this.destiny) {
|
|
65
|
+
this.reject(reason);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
use(value) {
|
|
69
|
+
if (value instanceof Promise) {
|
|
70
|
+
const promise = value;
|
|
71
|
+
this.destiny = promise;
|
|
72
|
+
promise.then(
|
|
73
|
+
(resolved) => {
|
|
74
|
+
this.pass(promise, resolved);
|
|
75
|
+
},
|
|
76
|
+
(reason) => {
|
|
77
|
+
this.fail(promise, reason);
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
} else {
|
|
81
|
+
this.resolve(value);
|
|
82
|
+
this.destiny = void 0;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
26
87
|
// internal/src/lineage.ts
|
|
27
88
|
function newest(scion) {
|
|
28
89
|
while (scion.child !== null) {
|
|
@@ -539,93 +600,6 @@ function withdrawOrCreate(token, store) {
|
|
|
539
600
|
}
|
|
540
601
|
}
|
|
541
602
|
|
|
542
|
-
// internal/src/future.ts
|
|
543
|
-
var Future = class extends Promise {
|
|
544
|
-
constructor(executor) {
|
|
545
|
-
super((resolve, reject) => {
|
|
546
|
-
const pass = (value) => {
|
|
547
|
-
this.isCanceled ? reject(`canceled`) : resolve(value);
|
|
548
|
-
};
|
|
549
|
-
const fail = (reason) => {
|
|
550
|
-
this.isCanceled ? reject(`canceled`) : reject(reason);
|
|
551
|
-
};
|
|
552
|
-
if (typeof executor === `function`) {
|
|
553
|
-
executor(pass, fail);
|
|
554
|
-
} else {
|
|
555
|
-
executor.then(pass, fail);
|
|
556
|
-
}
|
|
557
|
-
});
|
|
558
|
-
this.isCanceled = false;
|
|
559
|
-
}
|
|
560
|
-
cancel() {
|
|
561
|
-
this.isCanceled = true;
|
|
562
|
-
}
|
|
563
|
-
};
|
|
564
|
-
|
|
565
|
-
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
566
|
-
function copyMutableIfNeeded(atom, origin, target) {
|
|
567
|
-
const originValue = origin.valueMap.get(atom.key);
|
|
568
|
-
const targetValue = target.valueMap.get(atom.key);
|
|
569
|
-
if (originValue === targetValue) {
|
|
570
|
-
if (originValue === void 0) {
|
|
571
|
-
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
572
|
-
}
|
|
573
|
-
origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
|
|
574
|
-
const jsonValue = atom.toJson(originValue);
|
|
575
|
-
const copiedValue = atom.fromJson(jsonValue);
|
|
576
|
-
target.valueMap.set(atom.key, copiedValue);
|
|
577
|
-
new Tracker(atom, origin);
|
|
578
|
-
return copiedValue;
|
|
579
|
-
}
|
|
580
|
-
return targetValue;
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
// internal/src/caching.ts
|
|
584
|
-
function cacheValue(key, value, subject, target) {
|
|
585
|
-
const currentValue = target.valueMap.get(key);
|
|
586
|
-
if (currentValue instanceof Future) {
|
|
587
|
-
currentValue.cancel();
|
|
588
|
-
}
|
|
589
|
-
if (value instanceof Promise) {
|
|
590
|
-
const future = new Future(value);
|
|
591
|
-
target.valueMap.set(key, future);
|
|
592
|
-
future.then((resolved) => {
|
|
593
|
-
if (future.isCanceled) {
|
|
594
|
-
return;
|
|
595
|
-
}
|
|
596
|
-
cacheValue(key, resolved, subject, target);
|
|
597
|
-
subject.next({ newValue: resolved, oldValue: future });
|
|
598
|
-
}).catch((thrown) => {
|
|
599
|
-
if (thrown !== `canceled`) {
|
|
600
|
-
target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
601
|
-
}
|
|
602
|
-
});
|
|
603
|
-
return future;
|
|
604
|
-
}
|
|
605
|
-
target.valueMap.set(key, value);
|
|
606
|
-
return value;
|
|
607
|
-
}
|
|
608
|
-
var readCachedValue = (token, target) => {
|
|
609
|
-
let value = target.valueMap.get(token.key);
|
|
610
|
-
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
611
|
-
const { parent } = target;
|
|
612
|
-
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
613
|
-
value = copiedValue;
|
|
614
|
-
}
|
|
615
|
-
return value;
|
|
616
|
-
};
|
|
617
|
-
var evictCachedValue = (key, target) => {
|
|
618
|
-
const currentValue = target.valueMap.get(key);
|
|
619
|
-
if (currentValue instanceof Future) {
|
|
620
|
-
currentValue.cancel();
|
|
621
|
-
}
|
|
622
|
-
if (target.operation.open) {
|
|
623
|
-
target.operation.prev.set(key, currentValue);
|
|
624
|
-
}
|
|
625
|
-
target.valueMap.delete(key);
|
|
626
|
-
target.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
|
|
627
|
-
};
|
|
628
|
-
|
|
629
603
|
// internal/src/get-state/read-or-compute-value.ts
|
|
630
604
|
var readOrComputeValue = (state, target) => {
|
|
631
605
|
if (target.valueMap.has(state.key)) {
|
|
@@ -1727,6 +1701,72 @@ function isTransceiver(value) {
|
|
|
1727
1701
|
return typeof value === `object` && value !== null && `do` in value && `undo` in value && `subscribe` in value;
|
|
1728
1702
|
}
|
|
1729
1703
|
|
|
1704
|
+
// internal/src/set-state/copy-mutable-if-needed.ts
|
|
1705
|
+
function copyMutableIfNeeded(atom, origin, target) {
|
|
1706
|
+
const originValue = origin.valueMap.get(atom.key);
|
|
1707
|
+
const targetValue = target.valueMap.get(atom.key);
|
|
1708
|
+
if (originValue === targetValue) {
|
|
1709
|
+
if (originValue === void 0) {
|
|
1710
|
+
return typeof atom.default === `function` ? atom.default() : atom.default;
|
|
1711
|
+
}
|
|
1712
|
+
origin.logger.info(`\u{1F4C3}`, `atom`, atom.key, `copying`);
|
|
1713
|
+
const jsonValue = atom.toJson(originValue);
|
|
1714
|
+
const copiedValue = atom.fromJson(jsonValue);
|
|
1715
|
+
target.valueMap.set(atom.key, copiedValue);
|
|
1716
|
+
new Tracker(atom, origin);
|
|
1717
|
+
return copiedValue;
|
|
1718
|
+
}
|
|
1719
|
+
return targetValue;
|
|
1720
|
+
}
|
|
1721
|
+
|
|
1722
|
+
// internal/src/caching.ts
|
|
1723
|
+
function cacheValue(key, value, subject, target) {
|
|
1724
|
+
const currentValue = target.valueMap.get(key);
|
|
1725
|
+
if (currentValue instanceof Future) {
|
|
1726
|
+
const future = currentValue;
|
|
1727
|
+
future.use(value);
|
|
1728
|
+
}
|
|
1729
|
+
if (value instanceof Promise) {
|
|
1730
|
+
const future = new Future(value);
|
|
1731
|
+
target.valueMap.set(key, future);
|
|
1732
|
+
future.then((resolved) => {
|
|
1733
|
+
cacheValue(key, resolved, subject, target);
|
|
1734
|
+
subject.next({ newValue: resolved, oldValue: future });
|
|
1735
|
+
}).catch((thrown) => {
|
|
1736
|
+
target.logger.error(`\u{1F4A5}`, `state`, key, `rejected:`, thrown);
|
|
1737
|
+
});
|
|
1738
|
+
return future;
|
|
1739
|
+
}
|
|
1740
|
+
target.valueMap.set(key, value);
|
|
1741
|
+
return value;
|
|
1742
|
+
}
|
|
1743
|
+
var readCachedValue = (token, target) => {
|
|
1744
|
+
let value = target.valueMap.get(token.key);
|
|
1745
|
+
if (token.type === `mutable_atom` && isChildStore(target)) {
|
|
1746
|
+
const { parent } = target;
|
|
1747
|
+
const copiedValue = copyMutableIfNeeded(token, parent, target);
|
|
1748
|
+
value = copiedValue;
|
|
1749
|
+
}
|
|
1750
|
+
return value;
|
|
1751
|
+
};
|
|
1752
|
+
var evictCachedValue = (key, target) => {
|
|
1753
|
+
var _a;
|
|
1754
|
+
const currentValue = target.valueMap.get(key);
|
|
1755
|
+
if (currentValue instanceof Future) {
|
|
1756
|
+
const future = currentValue;
|
|
1757
|
+
const selector = (_a = target.selectors.get(key)) != null ? _a : target.readonlySelectors.get(key);
|
|
1758
|
+
if (selector) {
|
|
1759
|
+
future.use(selector.get());
|
|
1760
|
+
}
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1763
|
+
if (target.operation.open) {
|
|
1764
|
+
target.operation.prev.set(key, currentValue);
|
|
1765
|
+
}
|
|
1766
|
+
target.valueMap.delete(key);
|
|
1767
|
+
target.logger.info(`\u{1F5D1}`, `state`, key, `evicted`);
|
|
1768
|
+
};
|
|
1769
|
+
|
|
1730
1770
|
// internal/src/atom/is-default.ts
|
|
1731
1771
|
var isAtomDefault = (key, store) => {
|
|
1732
1772
|
const core = newest(store);
|
|
@@ -1856,11 +1896,6 @@ function deleteAtom(atomToken, store) {
|
|
|
1856
1896
|
store.logger.info(`\u{1F525}`, `atom`, key, `deleted`);
|
|
1857
1897
|
}
|
|
1858
1898
|
|
|
1859
|
-
// internal/src/arbitrary.ts
|
|
1860
|
-
function arbitrary(random = Math.random) {
|
|
1861
|
-
return random().toString(36).slice(2);
|
|
1862
|
-
}
|
|
1863
|
-
|
|
1864
1899
|
// internal/src/get-environment-data.ts
|
|
1865
1900
|
function getEnvironmentData(store) {
|
|
1866
1901
|
return {
|
package/internal/dist/index.d.ts
CHANGED
|
@@ -315,21 +315,21 @@ declare class FamilyTracker<Core extends Transceiver<any>, FamilyMemberKey exten
|
|
|
315
315
|
constructor(findMutableState: MutableAtomFamily<Core, any, FamilyMemberKey>, store: Store);
|
|
316
316
|
}
|
|
317
317
|
|
|
318
|
-
declare function
|
|
319
|
-
declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, store: Store): MutableAtomToken<T, J>;
|
|
318
|
+
declare function arbitrary(random?: () => number): string;
|
|
320
319
|
|
|
321
320
|
declare function createRegularAtom<T>(options: MutableAtomOptions<any, any> | RegularAtomOptions<T>, family: FamilyMetadata | undefined, store: Store): RegularAtomToken<T>;
|
|
322
321
|
|
|
322
|
+
declare function createStandaloneAtom<T>(options: RegularAtomOptions<T>, store: Store): RegularAtomToken<T>;
|
|
323
|
+
declare function createStandaloneAtom<T extends Transceiver<any>, J extends Json.Serializable>(options: MutableAtomOptions<T, J>, store: Store): MutableAtomToken<T, J>;
|
|
324
|
+
|
|
323
325
|
declare function deleteAtom(atomToken: AtomToken<unknown>, store: Store): void;
|
|
324
326
|
|
|
325
327
|
declare const isAtomDefault: (key: string, store: Store) => boolean;
|
|
326
328
|
declare const markAtomAsDefault: (key: string, store: Store) => void;
|
|
327
329
|
declare const markAtomAsNotDefault: (key: string, store: Store) => void;
|
|
328
330
|
|
|
329
|
-
declare function arbitrary(random?: () => number): string;
|
|
330
|
-
|
|
331
331
|
/**
|
|
332
|
-
* A Promise
|
|
332
|
+
* A Promise whose incoming value can be hot swapped.
|
|
333
333
|
* @internal
|
|
334
334
|
* @private
|
|
335
335
|
* @typeParam T The type of the value that the promise will resolve to.
|
|
@@ -338,9 +338,13 @@ declare function arbitrary(random?: () => number): string;
|
|
|
338
338
|
* Can be constructed like a Promise, or from an existing Promise.
|
|
339
339
|
*/
|
|
340
340
|
declare class Future<T> extends Promise<T> {
|
|
341
|
-
|
|
341
|
+
private destiny;
|
|
342
|
+
private resolve;
|
|
343
|
+
private reject;
|
|
342
344
|
constructor(executor: Promise<T> | ((resolve: (value: T) => void, reject: (reason?: any) => void) => void));
|
|
343
|
-
|
|
345
|
+
private pass;
|
|
346
|
+
private fail;
|
|
347
|
+
use(value: Promise<T> | T): void;
|
|
344
348
|
}
|
|
345
349
|
|
|
346
350
|
declare function cacheValue<T>(key: string, value: T, subject: Subject<StateUpdate<unknown>>, store: Store): T;
|
|
@@ -351,10 +355,10 @@ declare const evictCachedValue: (key: string, target: Store) => void;
|
|
|
351
355
|
declare function createAtomFamily<T extends Transceiver<any>, J extends Json.Serializable, K extends Json.Serializable>(options: MutableAtomFamilyOptions<T, J, K>, store: Store): MutableAtomFamily<T, J, K>;
|
|
352
356
|
declare function createAtomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>, store: Store): RegularAtomFamily<T, K>;
|
|
353
357
|
|
|
354
|
-
declare function createRegularAtomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>, store: Store): RegularAtomFamily<T, K>;
|
|
355
|
-
|
|
356
358
|
declare function createReadonlySelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
357
359
|
|
|
360
|
+
declare function createRegularAtomFamily<T, K extends Json.Serializable>(options: RegularAtomFamilyOptions<T, K>, store: Store): RegularAtomFamily<T, K>;
|
|
361
|
+
|
|
358
362
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: WritableSelectorFamilyOptions<T, K>, store: Store): WritableSelectorFamily<T, K>;
|
|
359
363
|
declare function createSelectorFamily<T, K extends Json.Serializable>(options: ReadonlySelectorFamilyOptions<T, K>, store: Store): ReadonlySelectorFamily<T, K>;
|
|
360
364
|
|