atom.io 0.25.6 → 0.27.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.
Files changed (108) hide show
  1. package/data/dist/index.d.ts +3 -3
  2. package/data/dist/index.js +33 -25
  3. package/data/package.json +1 -4
  4. package/data/src/dict.ts +3 -3
  5. package/dist/chunk-AK23DRMD.js +21 -0
  6. package/dist/{chunk-HYXKCFVY.js → chunk-IBTHB2PI.js} +59 -60
  7. package/dist/{chunk-MR5NETHW.js → chunk-IW6WYRS7.js} +4 -5
  8. package/dist/chunk-XWL6SNVU.js +7 -0
  9. package/dist/index.d.ts +32 -54
  10. package/dist/index.js +33 -21
  11. package/ephemeral/dist/index.d.ts +7 -7
  12. package/ephemeral/dist/index.js +1 -1
  13. package/ephemeral/package.json +1 -4
  14. package/ephemeral/src/find-state.ts +7 -7
  15. package/eslint-plugin/dist/index.js +7 -8
  16. package/eslint-plugin/package.json +1 -4
  17. package/immortal/dist/index.d.ts +7 -7
  18. package/immortal/dist/index.js +1 -1
  19. package/immortal/package.json +1 -4
  20. package/immortal/src/seek-state.ts +8 -8
  21. package/internal/dist/index.d.ts +56 -59
  22. package/internal/dist/index.js +178 -170
  23. package/internal/package.json +1 -4
  24. package/internal/src/families/create-atom-family.ts +4 -4
  25. package/internal/src/families/create-readonly-selector-family.ts +2 -2
  26. package/internal/src/families/create-regular-atom-family.ts +2 -2
  27. package/internal/src/families/create-selector-family.ts +4 -4
  28. package/internal/src/families/create-writable-selector-family.ts +2 -2
  29. package/internal/src/families/dispose-from-store.ts +3 -7
  30. package/internal/src/families/find-in-store.ts +9 -9
  31. package/internal/src/families/init-family-member.ts +25 -37
  32. package/internal/src/families/seek-in-store.ts +11 -10
  33. package/internal/src/get-state/get-from-store.ts +3 -3
  34. package/internal/src/molecule/grow-molecule-in-store.ts +9 -9
  35. package/internal/src/mutable/index.ts +0 -1
  36. package/internal/src/mutable/tracker-family.ts +2 -2
  37. package/internal/src/set-state/set-into-store.ts +4 -4
  38. package/internal/src/store/deposit.ts +3 -3
  39. package/internal/src/store/withdraw.ts +10 -9
  40. package/introspection/dist/index.js +32 -30
  41. package/introspection/package.json +1 -4
  42. package/json/dist/index.d.ts +10 -27
  43. package/json/dist/index.js +3 -3
  44. package/json/package.json +1 -4
  45. package/json/src/index.ts +8 -3
  46. package/json/src/select-json-family.ts +4 -4
  47. package/package.json +36 -65
  48. package/react/dist/index.d.ts +4 -4
  49. package/react/dist/index.js +2 -2
  50. package/react/package.json +1 -4
  51. package/react/src/parse-state-overloads.ts +4 -4
  52. package/react/src/use-i.ts +3 -3
  53. package/react/src/use-json.ts +3 -3
  54. package/react/src/use-o.ts +3 -3
  55. package/react-devtools/dist/index.d.ts +1 -1
  56. package/react-devtools/dist/index.js +90 -72
  57. package/react-devtools/package.json +1 -4
  58. package/react-devtools/src/StateIndex.tsx +5 -4
  59. package/realtime/dist/index.d.ts +3 -3
  60. package/realtime/dist/index.js +8 -9
  61. package/realtime/package.json +1 -4
  62. package/realtime/src/realtime-continuity.ts +2 -2
  63. package/realtime-client/dist/index.js +6 -6
  64. package/realtime-client/package.json +1 -4
  65. package/realtime-react/dist/index.d.ts +4 -4
  66. package/realtime-react/dist/index.js +9 -11
  67. package/realtime-react/package.json +1 -4
  68. package/realtime-react/src/use-pull-atom-family-member.ts +2 -2
  69. package/realtime-react/src/use-pull-mutable-family-member.ts +2 -2
  70. package/realtime-react/src/use-pull-selector-family-member.ts +2 -2
  71. package/realtime-server/dist/index.d.ts +9 -9
  72. package/realtime-server/dist/index.js +59 -54
  73. package/realtime-server/package.json +1 -4
  74. package/realtime-server/src/ipc-sockets/custom-socket.ts +2 -2
  75. package/realtime-server/src/realtime-family-provider.ts +3 -2
  76. package/realtime-server/src/realtime-mutable-family-provider.ts +2 -2
  77. package/realtime-testing/dist/index.js +3 -3
  78. package/realtime-testing/package.json +1 -4
  79. package/src/atom.ts +15 -42
  80. package/src/dispose-state.ts +2 -2
  81. package/src/get-state.ts +4 -4
  82. package/src/index.ts +5 -5
  83. package/src/molecule.ts +4 -3
  84. package/src/selector.ts +17 -39
  85. package/src/set-state.ts +3 -2
  86. package/src/silo.ts +4 -4
  87. package/transceivers/set-rtx/dist/index.js +11 -11
  88. package/transceivers/set-rtx/package.json +1 -4
  89. package/transceivers/set-rtx/src/set-rtx.ts +5 -5
  90. package/data/dist/index.cjs +0 -953
  91. package/dist/chunk-BF4MVQF6.js +0 -44
  92. package/dist/chunk-S4N6XNPH.js +0 -38
  93. package/dist/index.cjs +0 -215
  94. package/ephemeral/dist/index.cjs +0 -11
  95. package/eslint-plugin/dist/index.cjs +0 -388
  96. package/immortal/dist/index.cjs +0 -14
  97. package/internal/dist/index.cjs +0 -3405
  98. package/internal/src/mutable/is-mutable.ts +0 -16
  99. package/introspection/dist/index.cjs +0 -449
  100. package/json/dist/index.cjs +0 -128
  101. package/react/dist/index.cjs +0 -118
  102. package/react-devtools/dist/index.cjs +0 -2191
  103. package/realtime/dist/index.cjs +0 -120
  104. package/realtime-client/dist/index.cjs +0 -569
  105. package/realtime-react/dist/index.cjs +0 -189
  106. package/realtime-server/dist/index.cjs +0 -965
  107. package/realtime-testing/dist/index.cjs +0 -201
  108. package/transceivers/set-rtx/dist/index.cjs +0 -215
@@ -1,44 +0,0 @@
1
- // ../anvl/src/json/json-interface.ts
2
- var stringSetJsonInterface = {
3
- toJson: (stringSet) => Array.from(stringSet),
4
- fromJson: (json) => new Set(json)
5
- };
6
-
7
- // ../anvl/src/json/index.ts
8
- var parseJson = (str) => JSON.parse(str);
9
- var stringifyJson = (json) => JSON.stringify(json);
10
- var JSON_TYPE_NAMES = [
11
- `array`,
12
- `boolean`,
13
- `null`,
14
- `number`,
15
- `object`,
16
- `string`
17
- ];
18
- var JSON_DEFAULTS = {
19
- array: [],
20
- boolean: false,
21
- null: null,
22
- number: 0,
23
- object: {},
24
- string: ``
25
- };
26
-
27
- // ../anvl/src/primitive/index.ts
28
- var isString = (input) => {
29
- return typeof input === `string`;
30
- };
31
- var isNumber = (input) => {
32
- return typeof input === `number`;
33
- };
34
- var isBoolean = (input) => {
35
- return typeof input === `boolean`;
36
- };
37
- var isNull = (input) => {
38
- return input === null;
39
- };
40
- var isPrimitive = (input) => {
41
- return isString(input) || isNumber(input) || isBoolean(input) || isNull(input);
42
- };
43
-
44
- export { JSON_DEFAULTS, JSON_TYPE_NAMES, isBoolean, isNull, isNumber, isPrimitive, isString, parseJson, stringSetJsonInterface, stringifyJson };
@@ -1,38 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defProps = Object.defineProperties;
3
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
4
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
7
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
8
- var __spreadValues = (a, b) => {
9
- for (var prop in b || (b = {}))
10
- if (__hasOwnProp.call(b, prop))
11
- __defNormalProp(a, prop, b[prop]);
12
- if (__getOwnPropSymbols)
13
- for (var prop of __getOwnPropSymbols(b)) {
14
- if (__propIsEnum.call(b, prop))
15
- __defNormalProp(a, prop, b[prop]);
16
- }
17
- return a;
18
- };
19
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
- var __restKey = (key) => typeof key === "symbol" ? key : key + "";
21
- var __objRest = (source, exclude) => {
22
- var target = {};
23
- for (var prop in source)
24
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
25
- target[prop] = source[prop];
26
- if (source != null && __getOwnPropSymbols)
27
- for (var prop of __getOwnPropSymbols(source)) {
28
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
29
- target[prop] = source[prop];
30
- }
31
- return target;
32
- };
33
- var __export = (target, all) => {
34
- for (var name in all)
35
- __defProp(target, name, { get: all[name], enumerable: true });
36
- };
37
-
38
- export { __export, __objRest, __restKey, __spreadProps, __spreadValues };
package/dist/index.cjs DELETED
@@ -1,215 +0,0 @@
1
- 'use strict';
2
-
3
- var Internal = require('atom.io/internal');
4
- var json = require('atom.io/json');
5
-
6
- function _interopNamespace(e) {
7
- if (e && e.__esModule) return e;
8
- var n = Object.create(null);
9
- if (e) {
10
- Object.keys(e).forEach(function (k) {
11
- if (k !== 'default') {
12
- var d = Object.getOwnPropertyDescriptor(e, k);
13
- Object.defineProperty(n, k, d.get ? d : {
14
- enumerable: true,
15
- get: function () { return e[k]; }
16
- });
17
- }
18
- });
19
- }
20
- n.default = e;
21
- return Object.freeze(n);
22
- }
23
-
24
- var Internal__namespace = /*#__PURE__*/_interopNamespace(Internal);
25
-
26
- // src/atom.ts
27
- function atom(options) {
28
- return Internal.createStandaloneAtom(options, Internal.IMPLICIT.STORE);
29
- }
30
- function atomFamily(options) {
31
- return Internal.createAtomFamily(options, Internal.IMPLICIT.STORE);
32
- }
33
- function disposeState(token, key) {
34
- if (key) {
35
- Internal__namespace.disposeFromStore(token, key, Internal__namespace.IMPLICIT.STORE);
36
- } else {
37
- Internal__namespace.disposeFromStore(token, Internal__namespace.IMPLICIT.STORE);
38
- }
39
- }
40
- function getState(token, key) {
41
- if (key) {
42
- return Internal__namespace.getFromStore(
43
- token,
44
- key,
45
- Internal__namespace.IMPLICIT.STORE
46
- );
47
- }
48
- return Internal__namespace.getFromStore(token, Internal__namespace.IMPLICIT.STORE);
49
- }
50
-
51
- // src/logger.ts
52
- var LOG_LEVELS = [`info`, `warn`, `error`];
53
- var simpleLog = (logLevel) => (icon, denomination, tokenKey, message, ...rest) => {
54
- console[logLevel](
55
- `${icon} ${denomination} "${tokenKey}" ${message}`,
56
- ...rest
57
- );
58
- };
59
- var simpleLogger = {
60
- error: simpleLog(`error`),
61
- info: simpleLog(`info`),
62
- warn: simpleLog(`warn`)
63
- };
64
- var AtomIOLogger = class {
65
- constructor(logLevel, filter, logger = simpleLogger) {
66
- this.logLevel = logLevel;
67
- this.filter = filter;
68
- this.logger = logger;
69
- this.error = (...args) => {
70
- var _a, _b;
71
- if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel !== null) {
72
- this.logger.error(...args);
73
- }
74
- };
75
- this.info = (...args) => {
76
- var _a, _b;
77
- if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel === `info`) {
78
- this.logger.info(...args);
79
- }
80
- };
81
- this.warn = (...args) => {
82
- var _a, _b;
83
- if (((_b = (_a = this.filter) == null ? void 0 : _a.call(this, ...args)) != null ? _b : true) && this.logLevel !== `error` && this.logLevel !== null) {
84
- this.logger.warn(...args);
85
- }
86
- };
87
- }
88
- };
89
- function moleculeFamily(options) {
90
- return Internal.createMoleculeFamily(options, Internal.IMPLICIT.STORE);
91
- }
92
- function makeMolecule(context, family, key, ...params) {
93
- return Internal.makeMoleculeInStore(Internal.IMPLICIT.STORE, context, family, key, ...params);
94
- }
95
- function makeRootMolecule(key, store = Internal.IMPLICIT.STORE) {
96
- const molecule = new Internal.Molecule(void 0, key);
97
- store.molecules.set(json.stringifyJson(key), molecule);
98
- return {
99
- key,
100
- type: `molecule`
101
- };
102
- }
103
- function selector(options) {
104
- return Internal.createStandaloneSelector(options, Internal.IMPLICIT.STORE);
105
- }
106
- function selectorFamily(options) {
107
- return Internal.createSelectorFamily(options, Internal.IMPLICIT.STORE);
108
- }
109
- function setState(token, p1, p2) {
110
- if (p2) {
111
- Internal__namespace.setIntoStore(token, p1, p2, Internal__namespace.IMPLICIT.STORE);
112
- } else {
113
- Internal__namespace.setIntoStore(token, p1, Internal__namespace.IMPLICIT.STORE);
114
- }
115
- }
116
- var Silo = class {
117
- constructor(config, fromStore = null) {
118
- const s = new Internal.Store(config, fromStore);
119
- function _atom(options) {
120
- return Internal.createStandaloneAtom(options, s);
121
- }
122
- function _atomFamily(options) {
123
- return Internal.createAtomFamily(options, s);
124
- }
125
- this.store = s;
126
- this.atom = _atom;
127
- this.atomFamily = _atomFamily;
128
- this.selector = (options) => Internal.createStandaloneSelector(options, s);
129
- this.selectorFamily = (options) => Internal.createSelectorFamily(options, s);
130
- this.transaction = (options) => Internal.createTransaction(options, s);
131
- this.timeline = (options) => Internal.createTimeline(options, s);
132
- this.findState = (token, key) => Internal.findInStore(token, key, s);
133
- this.getState = (...params) => Internal.getFromStore(...params, s);
134
- this.setState = (...params) => {
135
- Internal.setIntoStore(...params, s);
136
- };
137
- this.disposeState = (...params) => {
138
- Internal.disposeFromStore(...params, s);
139
- };
140
- this.subscribe = (token, handler, key) => subscribe(token, handler, key, s);
141
- this.undo = (token) => {
142
- Internal.timeTravel(`undo`, token, s);
143
- };
144
- this.redo = (token) => {
145
- Internal.timeTravel(`redo`, token, s);
146
- };
147
- this.moleculeFamily = (...params) => {
148
- return Internal.createMoleculeFamily(...params, s);
149
- };
150
- this.makeMolecule = (...params) => {
151
- return Internal.makeMoleculeInStore(s, ...params);
152
- };
153
- }
154
- };
155
- function subscribe(token, handleUpdate, key = Internal.arbitrary(), store = Internal.IMPLICIT.STORE) {
156
- switch (token.type) {
157
- case `atom`:
158
- case `mutable_atom`:
159
- case `readonly_selector`:
160
- case `selector`:
161
- return Internal.subscribeToState(token, handleUpdate, key, store);
162
- case `transaction`:
163
- return Internal.subscribeToTransaction(token, handleUpdate, key, store);
164
- case `timeline`:
165
- return Internal.subscribeToTimeline(token, handleUpdate, key, store);
166
- }
167
- }
168
- var timeline = (options) => {
169
- return Internal.createTimeline(options, Internal.IMPLICIT.STORE);
170
- };
171
- var redo = (tl) => {
172
- Internal.timeTravel(`redo`, tl, Internal.IMPLICIT.STORE);
173
- };
174
- var undo = (tl) => {
175
- Internal.timeTravel(`undo`, tl, Internal.IMPLICIT.STORE);
176
- };
177
- function transaction(options) {
178
- return Internal.createTransaction(options, Internal.IMPLICIT.STORE);
179
- }
180
- function runTransaction(token, id = Internal.arbitrary()) {
181
- return Internal.actUponStore(token, id, Internal.IMPLICIT.STORE);
182
- }
183
-
184
- // src/validators.ts
185
- function isToken(knownToken, unknownToken) {
186
- return knownToken.key === unknownToken.key;
187
- }
188
- function belongsTo(family, unknownToken) {
189
- var _a;
190
- return family.key === ((_a = unknownToken.family) == null ? void 0 : _a.key);
191
- }
192
-
193
- exports.AtomIOLogger = AtomIOLogger;
194
- exports.LOG_LEVELS = LOG_LEVELS;
195
- exports.Silo = Silo;
196
- exports.atom = atom;
197
- exports.atomFamily = atomFamily;
198
- exports.belongsTo = belongsTo;
199
- exports.disposeState = disposeState;
200
- exports.getState = getState;
201
- exports.isToken = isToken;
202
- exports.makeMolecule = makeMolecule;
203
- exports.makeRootMolecule = makeRootMolecule;
204
- exports.moleculeFamily = moleculeFamily;
205
- exports.redo = redo;
206
- exports.runTransaction = runTransaction;
207
- exports.selector = selector;
208
- exports.selectorFamily = selectorFamily;
209
- exports.setState = setState;
210
- exports.simpleLog = simpleLog;
211
- exports.simpleLogger = simpleLogger;
212
- exports.subscribe = subscribe;
213
- exports.timeline = timeline;
214
- exports.transaction = transaction;
215
- exports.undo = undo;
@@ -1,11 +0,0 @@
1
- 'use strict';
2
-
3
- var internal = require('atom.io/internal');
4
-
5
- // ephemeral/src/find-state.ts
6
- function findState(token, key) {
7
- const state = internal.findInStore(token, key, internal.IMPLICIT.STORE);
8
- return state;
9
- }
10
-
11
- exports.findState = findState;
@@ -1,388 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var utils = require('@typescript-eslint/utils');
6
-
7
- var __defProp = Object.defineProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
-
13
- // eslint-plugin/src/rules/index.ts
14
- var rules_exports = {};
15
- __export(rules_exports, {
16
- explicitStateTypes: () => explicitStateTypes,
17
- lifespan: () => lifespan,
18
- synchronousSelectorDependencies: () => synchronousSelectorDependencies
19
- });
20
- var createRule = utils.ESLintUtils.RuleCreator(
21
- (name) => `https://atom.io.fyi/docs/eslint-plugin#${name}`
22
- );
23
- var STATE_FUNCTIONS = [`atom`, `atomFamily`, `selector`, `selectorFamily`];
24
- var explicitStateTypes = createRule({
25
- name: `explicit-state-types`,
26
- meta: {
27
- type: `problem`,
28
- docs: {
29
- description: `State declarations must have generic type arguments directly passed to them`
30
- },
31
- messages: {
32
- noTypeArgument: `State declarations must have generic type arguments directly passed to them.`
33
- },
34
- schema: []
35
- // no options
36
- },
37
- defaultOptions: [],
38
- create(context) {
39
- return {
40
- CallExpression(node) {
41
- const { callee } = node;
42
- switch (callee.type) {
43
- case `Identifier`: {
44
- if (STATE_FUNCTIONS.includes(callee.name)) {
45
- if (!node.typeArguments) {
46
- context.report({
47
- node,
48
- messageId: `noTypeArgument`
49
- });
50
- }
51
- }
52
- break;
53
- }
54
- case `MemberExpression`: {
55
- if (callee.property.type === `Identifier` && STATE_FUNCTIONS.includes(callee.property.name)) {
56
- if (!node.typeArguments) {
57
- context.report({
58
- node,
59
- messageId: `noTypeArgument`
60
- });
61
- }
62
- }
63
- }
64
- }
65
- }
66
- };
67
- }
68
- });
69
-
70
- // eslint-plugin/src/walk.ts
71
- function walk(node, callback, depth = 0) {
72
- callback(node, depth);
73
- switch (node.type) {
74
- case `FunctionDeclaration`:
75
- case `FunctionExpression`:
76
- case `ArrowFunctionExpression`:
77
- for (const param of node.params) {
78
- walk(param, callback, depth + 1);
79
- }
80
- walk(node.body, callback, depth + 1);
81
- break;
82
- case `BlockStatement`:
83
- for (const statement of node.body) {
84
- walk(statement, callback, depth + 1);
85
- }
86
- break;
87
- case `IfStatement`:
88
- walk(node.test, callback, depth);
89
- walk(node.consequent, callback, depth);
90
- if (node.alternate) {
91
- walk(node.alternate, callback, depth);
92
- }
93
- break;
94
- case `SwitchStatement`:
95
- walk(node.discriminant, callback, depth + 1);
96
- for (const caseOrDefault of node.cases) {
97
- walk(caseOrDefault, callback, depth);
98
- }
99
- break;
100
- case `ReturnStatement`:
101
- if (node.argument) {
102
- walk(node.argument, callback, depth);
103
- }
104
- break;
105
- case `SwitchCase`:
106
- if (node.test) {
107
- walk(node.test, callback, depth);
108
- }
109
- for (const statement of node.consequent) {
110
- walk(statement, callback, depth);
111
- }
112
- break;
113
- case `VariableDeclaration`:
114
- for (const declaration of node.declarations) {
115
- walk(declaration, callback, depth);
116
- if (declaration.init) {
117
- walk(declaration.init, callback, depth);
118
- }
119
- }
120
- break;
121
- case `BinaryExpression`:
122
- walk(node.left, callback, depth);
123
- walk(node.right, callback, depth);
124
- break;
125
- case `MemberExpression`:
126
- walk(node.object, callback, depth);
127
- walk(node.property, callback, depth);
128
- break;
129
- case `CallExpression`:
130
- walk(node.callee, callback, depth);
131
- for (const argument of node.arguments) {
132
- walk(argument, callback, depth);
133
- }
134
- break;
135
- }
136
- }
137
-
138
- // eslint-plugin/src/rules/lifespan.ts
139
- var lifespan = {
140
- meta: {
141
- type: `problem`,
142
- docs: {
143
- 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.`,
144
- category: `Possible Errors`,
145
- recommended: false,
146
- url: ``
147
- // URL to documentation page for this rule
148
- },
149
- schema: [
150
- {
151
- type: `string`,
152
- enum: [`ephemeral`, `immortal`],
153
- default: `ephemeral`
154
- }
155
- ]
156
- },
157
- create(context) {
158
- var _a;
159
- const storeLifespan = (_a = context.options[0]) != null ? _a : `ephemeral`;
160
- return {
161
- ImportDeclaration(node) {
162
- const importSource = node.source.value;
163
- if (!importSource.startsWith(`atom.io/`)) {
164
- return;
165
- }
166
- const [_, subPackageName] = importSource.split(`/`);
167
- if (storeLifespan === `immortal` && subPackageName === `ephemeral`) {
168
- context.report({
169
- node,
170
- message: `do not import from "${importSource}" in an ${storeLifespan} store`
171
- });
172
- }
173
- },
174
- CallExpression(node) {
175
- if (storeLifespan === `ephemeral`) {
176
- return;
177
- }
178
- const functionCallee = node.callee.type === `Identifier` ? node.callee : void 0;
179
- const methodCallee = node.callee.type === `MemberExpression` && node.callee.property.type === `Identifier` ? node.callee.property : void 0;
180
- const callee = functionCallee != null ? functionCallee : methodCallee;
181
- if (callee === void 0) {
182
- return;
183
- }
184
- if (callee.name === `findState`) {
185
- context.report({
186
- node,
187
- message: `do not use findState in an ${storeLifespan} store`
188
- });
189
- }
190
- const storeProcedures = [];
191
- if (callee.name === `selector` || callee.name === `selectorFamily` || callee.name === `transaction`) {
192
- if (node.arguments[0].type === `ObjectExpression`) {
193
- const argProperties = node.arguments[0].properties;
194
- switch (callee.name) {
195
- case `selector`:
196
- case `selectorFamily`:
197
- {
198
- const getAndSetProps = argProperties.filter(
199
- (prop) => {
200
- return `key` in prop && `name` in prop.key && (prop.key.name === `get` || prop.key.name === `set`);
201
- }
202
- );
203
- switch (callee.name) {
204
- case `selector`:
205
- {
206
- for (const prop of getAndSetProps) {
207
- if (prop.value.type === `FunctionExpression` || prop.value.type === `ArrowFunctionExpression`) {
208
- storeProcedures.push(prop.value);
209
- }
210
- }
211
- }
212
- break;
213
- case `selectorFamily`:
214
- {
215
- for (const prop of getAndSetProps) {
216
- const { value } = prop;
217
- if (value.type === `FunctionExpression` || value.type === `ArrowFunctionExpression`) {
218
- if (value.body.type === `BlockStatement`) {
219
- for (const statement of value.body.body) {
220
- if (statement.type === `ReturnStatement` && statement.argument && (statement.argument.type === `FunctionExpression` || statement.argument.type === `ArrowFunctionExpression`)) {
221
- storeProcedures.push(statement.argument);
222
- }
223
- }
224
- } else if (value.body.type === `FunctionExpression` || value.body.type === `ArrowFunctionExpression`) {
225
- storeProcedures.push(value.body);
226
- }
227
- }
228
- }
229
- }
230
- break;
231
- }
232
- }
233
- break;
234
- case `transaction`:
235
- {
236
- const doProp = argProperties.find(
237
- (prop) => {
238
- return `key` in prop && `name` in prop.key && prop.key.name === `do`;
239
- }
240
- );
241
- if (doProp) {
242
- if (doProp.value.type === `FunctionExpression` || doProp.value.type === `ArrowFunctionExpression`) {
243
- storeProcedures.push(doProp.value);
244
- }
245
- }
246
- }
247
- break;
248
- }
249
- }
250
- }
251
- for (const storeProcedure of storeProcedures) {
252
- const transactorsParam = storeProcedure.params[0];
253
- const nonDestructuredTransactorsName = transactorsParam && `name` in transactorsParam ? transactorsParam.name : void 0;
254
- walk(storeProcedure.body, (n) => {
255
- if (n.type === `CallExpression`) {
256
- let willReport = false;
257
- switch (n.callee.type) {
258
- case `MemberExpression`:
259
- if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `find`) {
260
- willReport = true;
261
- }
262
- break;
263
- case `Identifier`:
264
- if (n.callee.name === `find`) {
265
- willReport = true;
266
- }
267
- break;
268
- }
269
- if (willReport) {
270
- context.report({
271
- node: n,
272
- message: `Using find in a transactor is not allowed in an immortal store.`
273
- });
274
- }
275
- }
276
- });
277
- }
278
- }
279
- };
280
- }
281
- };
282
-
283
- // eslint-plugin/src/rules/synchronous-selector-dependencies.ts
284
- var synchronousSelectorDependencies = {
285
- meta: {
286
- type: `problem`,
287
- docs: {
288
- description: `disallow await before calling get on the parameter's get method inside selector`,
289
- category: `Possible Errors`,
290
- recommended: false,
291
- url: ``
292
- // URL to documentation page for this rule
293
- },
294
- schema: []
295
- // no options
296
- },
297
- create(context) {
298
- return {
299
- CallExpression(node) {
300
- let selectorComputation;
301
- if (`name` in node.callee && node.callee.name === `selectorFamily`) {
302
- if (node.arguments[0].type === `ObjectExpression`) {
303
- const selectorLookupProperty = node.arguments[0].properties.find(
304
- (prop) => {
305
- return `key` in prop && `name` in prop.key && prop.key.name === `get`;
306
- }
307
- );
308
- const selectorLookup = selectorLookupProperty == null ? void 0 : selectorLookupProperty.value;
309
- if ((selectorLookup == null ? void 0 : selectorLookup.type) === `FunctionExpression` || (selectorLookup == null ? void 0 : selectorLookup.type) === `ArrowFunctionExpression`) {
310
- if (selectorLookup.body.type === `BlockStatement`) {
311
- for (const statement of selectorLookup.body.body) {
312
- if (statement.type === `ReturnStatement` && statement.argument) {
313
- selectorComputation = statement.argument;
314
- }
315
- }
316
- } else if (selectorLookup.body.type === `FunctionExpression` || selectorLookup.body.type === `ArrowFunctionExpression`) {
317
- selectorComputation = selectorLookup.body;
318
- }
319
- }
320
- }
321
- }
322
- if (`name` in node.callee && node.callee.name === `selector`) {
323
- if (node.arguments[0].type === `ObjectExpression`) {
324
- const selectorComputationProperty = node.arguments[0].properties.find(
325
- (prop) => {
326
- return `key` in prop && `name` in prop.key && prop.key.name === `get`;
327
- }
328
- );
329
- selectorComputation = selectorComputationProperty == null ? void 0 : selectorComputationProperty.value;
330
- }
331
- }
332
- if ((selectorComputation == null ? void 0 : selectorComputation.type) === `FunctionExpression` || (selectorComputation == null ? void 0 : selectorComputation.type) === `ArrowFunctionExpression`) {
333
- const nonDestructuredTransactorsName = selectorComputation.params[0] && `name` in selectorComputation.params[0] ? selectorComputation.params[0].name : void 0;
334
- let awaited;
335
- let awaitNode;
336
- walk(selectorComputation, (n, depth) => {
337
- if (typeof awaited === `number`) {
338
- if (awaited > depth) {
339
- awaited = void 0;
340
- awaitNode = void 0;
341
- }
342
- }
343
- switch (n.type) {
344
- case `AwaitExpression`:
345
- awaited = depth;
346
- awaitNode = n;
347
- break;
348
- case `CallExpression`:
349
- if (awaitNode) {
350
- let willReport = false;
351
- switch (n.callee.type) {
352
- case `MemberExpression`:
353
- if (n.callee.object.type === `Identifier` && n.callee.object.name === nonDestructuredTransactorsName && n.callee.property.type === `Identifier` && n.callee.property.name === `get`) {
354
- willReport = true;
355
- }
356
- break;
357
- case `Identifier`:
358
- if (n.callee.name === `get`) {
359
- willReport = true;
360
- }
361
- break;
362
- }
363
- if (willReport) {
364
- context.report({
365
- node: awaitNode,
366
- message: `Using await before calling the 'get' transactor is not allowed.`
367
- });
368
- }
369
- }
370
- }
371
- });
372
- }
373
- }
374
- };
375
- }
376
- };
377
-
378
- // eslint-plugin/src/index.ts
379
- var src_default = {
380
- rules: {
381
- "explicit-state-types": explicitStateTypes,
382
- lifespan,
383
- "synchronous-selector-dependencies": synchronousSelectorDependencies
384
- }
385
- };
386
-
387
- exports.Rules = rules_exports;
388
- exports.default = src_default;