atom.io 0.31.0 → 0.32.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.d.ts +867 -101
- package/data/dist/index.js +10 -558
- 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-354XQWHH.js +153 -0
- package/dist/chunk-4LWKCEW3.js +14 -0
- package/dist/chunk-5F2V7S3B.js +83 -0
- package/dist/chunk-ECOMOMUN.js +631 -0
- package/dist/{chunk-42UH5F5Q.js → chunk-GY2XQYZY.js} +2051 -755
- package/dist/chunk-NF7FJKJD.js +107 -0
- package/dist/chunk-R3ZUK5EH.js +1024 -0
- package/dist/chunk-Z2UJW4NQ.js +523 -0
- package/dist/index.d.ts +855 -127
- package/dist/index.js +1 -143
- package/eslint-plugin/dist/index.d.ts +1 -30
- package/eslint-plugin/dist/index.js +0 -146
- package/eslint-plugin/src/index.ts +0 -1
- package/eslint-plugin/src/rules/index.ts +0 -1
- package/internal/dist/index.d.ts +794 -70
- package/internal/dist/index.js +1 -2
- 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/families/find-in-store.ts +1 -6
- 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 +19 -9
- package/internal/src/ingest-updates/ingest-creation-disposal.ts +2 -3
- package/internal/src/install-into-store.ts +48 -0
- 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} +20 -429
- package/internal/src/keys.ts +7 -7
- package/internal/src/molecule.ts +299 -0
- 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/not-found-error.ts +8 -30
- package/internal/src/pretty-print.ts +2 -13
- 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 +7 -17
- 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 +1 -1
- 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/deposit.ts +10 -8
- package/internal/src/store/store.ts +1 -1
- package/internal/src/store/withdraw.ts +34 -53
- 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 +17 -37
- 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.d.ts +922 -6
- package/introspection/dist/index.js +2 -620
- package/json/dist/index.d.ts +899 -5
- package/json/dist/index.js +1 -81
- package/json/src/select-json-family.ts +3 -14
- package/package.json +27 -45
- package/react/dist/index.d.ts +921 -3
- 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.d.ts +26 -1
- package/react-devtools/dist/index.js +6 -6
- package/react-devtools/src/devtools.scss +16 -14
- package/realtime/dist/index.d.ts +202 -8
- package/realtime/dist/index.js +2 -107
- package/realtime/src/realtime-continuity.ts +2 -2
- package/realtime/src/shared-room-store.ts +1 -2
- package/realtime-client/dist/index.d.ts +960 -22
- 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.d.ts +166 -12
- 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 +971 -28
- 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 +0 -1
- 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-user-store.ts +1 -2
- package/realtime-server/src/realtime-state-provider.ts +2 -2
- package/realtime-testing/dist/index.d.ts +1091 -3
- package/realtime-testing/dist/index.js +23 -26
- package/realtime-testing/src/setup-realtime-test.tsx +6 -5
- package/src/atom.ts +53 -29
- package/src/dispose-state.ts +12 -2
- package/{ephemeral/src → src}/find-state.ts +35 -25
- package/src/get-state.ts +16 -0
- package/src/index.ts +77 -3
- package/src/join.ts +218 -0
- package/src/realm.ts +169 -0
- package/src/selector.ts +20 -0
- package/src/set-state.ts +16 -8
- package/src/silo.ts +13 -7
- package/src/timeline.ts +1 -1
- package/src/transaction.ts +4 -8
- package/transceivers/set-rtx/dist/index.d.ts +37 -2
- package/transceivers/set-rtx/dist/index.js +1 -212
- package/transceivers/set-rtx/src/set-rtx.ts +4 -1
- package/web/dist/index.d.ts +30 -1
- package/web/dist/index.js +1 -15
- package/data/src/until.ts +0 -15
- package/dist/chunk-ICGFFQ3H.js +0 -272
- package/ephemeral/dist/index.d.ts +0 -57
- 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/src/allocate.ts +0 -443
- package/src/molecule.ts +0 -16
package/dist/index.js
CHANGED
|
@@ -1,144 +1,2 @@
|
|
|
1
|
-
export { $claim, Anarchy, Realm, T$,
|
|
1
|
+
export { $claim, Anarchy, AtomIOLogger, LOG_LEVELS, Realm, Silo, T$, atom, atomFamily, belongsTo, disposeState, editRelations, findRelations, findState, getInternalRelations, getState, isToken, join, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo } from './chunk-GY2XQYZY.js';
|
|
2
2
|
import './chunk-XWL6SNVU.js';
|
|
3
|
-
import * as Internal from 'atom.io/internal';
|
|
4
|
-
import { createStandaloneAtom, IMPLICIT, createAtomFamily, createStandaloneSelector, createSelectorFamily, Store, createTransaction, createTimeline, findInStore, getFromStore, setIntoStore, disposeFromStore, subscribeInStore, timeTravel, actUponStore, arbitrary } from 'atom.io/internal';
|
|
5
|
-
|
|
6
|
-
function atom(options) {
|
|
7
|
-
return createStandaloneAtom(IMPLICIT.STORE, options);
|
|
8
|
-
}
|
|
9
|
-
function atomFamily(options) {
|
|
10
|
-
return createAtomFamily(IMPLICIT.STORE, options);
|
|
11
|
-
}
|
|
12
|
-
function disposeState(...[token, key]) {
|
|
13
|
-
if (key) {
|
|
14
|
-
Internal.disposeFromStore(Internal.IMPLICIT.STORE, token, key);
|
|
15
|
-
} else {
|
|
16
|
-
Internal.disposeFromStore(Internal.IMPLICIT.STORE, token);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function getState(...params) {
|
|
20
|
-
if (params.length === 2) {
|
|
21
|
-
return Internal.getFromStore(Internal.IMPLICIT.STORE, ...params);
|
|
22
|
-
}
|
|
23
|
-
return Internal.getFromStore(Internal.IMPLICIT.STORE, ...params);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// src/logger.ts
|
|
27
|
-
var LOG_LEVELS = [`info`, `warn`, `error`];
|
|
28
|
-
var simpleLog = (logLevel) => (icon, denomination, tokenKey, message, ...rest) => {
|
|
29
|
-
console[logLevel](
|
|
30
|
-
`${icon} ${denomination} "${tokenKey}" ${message}`,
|
|
31
|
-
...rest
|
|
32
|
-
);
|
|
33
|
-
};
|
|
34
|
-
var simpleLogger = {
|
|
35
|
-
error: simpleLog(`error`),
|
|
36
|
-
info: simpleLog(`info`),
|
|
37
|
-
warn: simpleLog(`warn`)
|
|
38
|
-
};
|
|
39
|
-
var AtomIOLogger = class {
|
|
40
|
-
constructor(logLevel, filter, logger = simpleLogger) {
|
|
41
|
-
this.logLevel = logLevel;
|
|
42
|
-
this.filter = filter;
|
|
43
|
-
this.logger = logger;
|
|
44
|
-
}
|
|
45
|
-
error = (...args) => {
|
|
46
|
-
if ((this.filter?.(...args) ?? true) && this.logLevel !== null) {
|
|
47
|
-
this.logger.error(...args);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
info = (...args) => {
|
|
51
|
-
if ((this.filter?.(...args) ?? true) && this.logLevel === `info`) {
|
|
52
|
-
this.logger.info(...args);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
warn = (...args) => {
|
|
56
|
-
if ((this.filter?.(...args) ?? true) && this.logLevel !== `error` && this.logLevel !== null) {
|
|
57
|
-
this.logger.warn(...args);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
function selector(options) {
|
|
62
|
-
return createStandaloneSelector(IMPLICIT.STORE, options);
|
|
63
|
-
}
|
|
64
|
-
function selectorFamily(options) {
|
|
65
|
-
return createSelectorFamily(IMPLICIT.STORE, options);
|
|
66
|
-
}
|
|
67
|
-
function setState(...params) {
|
|
68
|
-
if (params.length === 2) {
|
|
69
|
-
Internal.setIntoStore(Internal.IMPLICIT.STORE, ...params);
|
|
70
|
-
} else {
|
|
71
|
-
Internal.setIntoStore(Internal.IMPLICIT.STORE, ...params);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
var Silo = class {
|
|
75
|
-
store;
|
|
76
|
-
atom;
|
|
77
|
-
atomFamily;
|
|
78
|
-
selector;
|
|
79
|
-
selectorFamily;
|
|
80
|
-
transaction;
|
|
81
|
-
timeline;
|
|
82
|
-
findState;
|
|
83
|
-
getState;
|
|
84
|
-
setState;
|
|
85
|
-
disposeState;
|
|
86
|
-
subscribe;
|
|
87
|
-
undo;
|
|
88
|
-
redo;
|
|
89
|
-
runTransaction;
|
|
90
|
-
constructor(config, fromStore = null) {
|
|
91
|
-
const s = new Store(config, fromStore);
|
|
92
|
-
this.store = s;
|
|
93
|
-
this.atom = (options) => createStandaloneAtom(s, options);
|
|
94
|
-
this.atomFamily = (options) => createAtomFamily(s, options);
|
|
95
|
-
this.selector = (options) => createStandaloneSelector(s, options);
|
|
96
|
-
this.selectorFamily = (options) => createSelectorFamily(s, options);
|
|
97
|
-
this.transaction = (options) => createTransaction(options, s);
|
|
98
|
-
this.timeline = (options) => createTimeline(options, s);
|
|
99
|
-
this.findState = (...params) => findInStore(s, ...params);
|
|
100
|
-
this.getState = (...params) => getFromStore(s, ...params);
|
|
101
|
-
this.setState = (...params) => {
|
|
102
|
-
setIntoStore(s, ...params);
|
|
103
|
-
};
|
|
104
|
-
this.disposeState = (...params) => {
|
|
105
|
-
disposeFromStore(s, ...params);
|
|
106
|
-
};
|
|
107
|
-
this.subscribe = (...params) => subscribeInStore(s, ...params);
|
|
108
|
-
this.undo = (token) => {
|
|
109
|
-
timeTravel(s, `undo`, token);
|
|
110
|
-
};
|
|
111
|
-
this.redo = (token) => {
|
|
112
|
-
timeTravel(s, `redo`, token);
|
|
113
|
-
};
|
|
114
|
-
this.runTransaction = (token, id = arbitrary()) => actUponStore(token, id, s);
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
function subscribe(token, handleUpdate, key = arbitrary()) {
|
|
118
|
-
return subscribeInStore(IMPLICIT.STORE, token, handleUpdate, key);
|
|
119
|
-
}
|
|
120
|
-
var timeline = (options) => {
|
|
121
|
-
return createTimeline(options, IMPLICIT.STORE);
|
|
122
|
-
};
|
|
123
|
-
var redo = (tl) => {
|
|
124
|
-
timeTravel(IMPLICIT.STORE, `redo`, tl);
|
|
125
|
-
};
|
|
126
|
-
var undo = (tl) => {
|
|
127
|
-
timeTravel(IMPLICIT.STORE, `undo`, tl);
|
|
128
|
-
};
|
|
129
|
-
function transaction(options) {
|
|
130
|
-
return createTransaction(options, IMPLICIT.STORE);
|
|
131
|
-
}
|
|
132
|
-
function runTransaction(token, id = arbitrary()) {
|
|
133
|
-
return actUponStore(token, id, IMPLICIT.STORE);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// src/validators.ts
|
|
137
|
-
function isToken(knownToken, unknownToken) {
|
|
138
|
-
return knownToken.key === unknownToken.key;
|
|
139
|
-
}
|
|
140
|
-
function belongsTo(family, unknownToken) {
|
|
141
|
-
return family.key === unknownToken.family?.key;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
export { AtomIOLogger, LOG_LEVELS, Silo, atom, atomFamily, belongsTo, disposeState, getState, isToken, redo, runTransaction, selector, selectorFamily, setState, simpleLog, simpleLogger, subscribe, timeline, transaction, undo };
|
|
@@ -6,33 +6,6 @@ import { ESLintUtils } from '@typescript-eslint/utils';
|
|
|
6
6
|
|
|
7
7
|
declare const explicitStateTypes: ESLintUtils.RuleModule<"noTypeArgument", [], unknown, ESLintUtils.RuleListener>;
|
|
8
8
|
|
|
9
|
-
declare const lifespan: {
|
|
10
|
-
meta: {
|
|
11
|
-
type: "problem";
|
|
12
|
-
docs: {
|
|
13
|
-
description: string;
|
|
14
|
-
category: string;
|
|
15
|
-
recommended: false;
|
|
16
|
-
url: string;
|
|
17
|
-
};
|
|
18
|
-
schema: {
|
|
19
|
-
type: "string";
|
|
20
|
-
enum: string[];
|
|
21
|
-
default: string;
|
|
22
|
-
}[];
|
|
23
|
-
};
|
|
24
|
-
create(context: _eslint_core.RuleContext<{
|
|
25
|
-
LangOptions: eslint.Linter.LanguageOptions;
|
|
26
|
-
Code: eslint.SourceCode;
|
|
27
|
-
RuleOptions: any[];
|
|
28
|
-
Node: ESTree.Node;
|
|
29
|
-
MessageIds: string;
|
|
30
|
-
}>): {
|
|
31
|
-
ImportDeclaration(node: ESTree.ImportDeclaration & Rule.NodeParentExtension): void;
|
|
32
|
-
CallExpression(node: ESTree.CallExpression & Rule.NodeParentExtension): void;
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
|
|
36
9
|
declare const synchronousSelectorDependencies: {
|
|
37
10
|
meta: {
|
|
38
11
|
type: "problem";
|
|
@@ -56,16 +29,14 @@ declare const synchronousSelectorDependencies: {
|
|
|
56
29
|
};
|
|
57
30
|
|
|
58
31
|
declare const index_explicitStateTypes: typeof explicitStateTypes;
|
|
59
|
-
declare const index_lifespan: typeof lifespan;
|
|
60
32
|
declare const index_synchronousSelectorDependencies: typeof synchronousSelectorDependencies;
|
|
61
33
|
declare namespace index {
|
|
62
|
-
export { index_explicitStateTypes as explicitStateTypes,
|
|
34
|
+
export { index_explicitStateTypes as explicitStateTypes, index_synchronousSelectorDependencies as synchronousSelectorDependencies };
|
|
63
35
|
}
|
|
64
36
|
|
|
65
37
|
declare const _default: {
|
|
66
38
|
rules: {
|
|
67
39
|
"explicit-state-types": any;
|
|
68
|
-
lifespan: any;
|
|
69
40
|
"synchronous-selector-dependencies": {
|
|
70
41
|
meta: {
|
|
71
42
|
type: "problem";
|
|
@@ -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: {
|
|
@@ -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
|
};
|