eslint-plugin-react-hooks-extra 1.5.3 → 1.5.4-beta.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/dist/index.js +983 -665
- package/dist/index.mjs +983 -665
- package/package.json +10 -10
- package/dist/index.cjs +0 -1036
package/dist/index.js
CHANGED
|
@@ -1,116 +1,93 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var core = require('@eslint-react/core');
|
|
4
|
+
require('string-ts');
|
|
4
5
|
var shared = require('@eslint-react/shared');
|
|
5
6
|
var ast = require('@eslint-react/ast');
|
|
6
7
|
var jsx = require('@eslint-react/jsx');
|
|
7
8
|
var _var = require('@eslint-react/var');
|
|
8
9
|
|
|
9
|
-
var
|
|
10
|
-
var
|
|
10
|
+
var __defProp = Object.defineProperty;
|
|
11
|
+
var __export = (target, all2) => {
|
|
12
|
+
for (var name2 in all2)
|
|
13
|
+
__defProp(target, name2, { get: all2[name2], enumerable: true });
|
|
14
|
+
};
|
|
11
15
|
|
|
12
|
-
|
|
16
|
+
// package.json
|
|
17
|
+
var name = "eslint-plugin-react-hooks-extra";
|
|
18
|
+
var version = "1.5.4-beta.1";
|
|
19
|
+
var createRule = shared.createRuleForPlugin("hooks-extra");
|
|
13
20
|
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
schema: [],
|
|
24
|
-
messages: {
|
|
25
|
-
ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS: "Custom hooks {{name}} should use other hooks"
|
|
26
|
-
}
|
|
21
|
+
// src/rules/ensure-custom-hooks-using-other-hooks.ts
|
|
22
|
+
var RULE_NAME = "ensure-custom-hooks-using-other-hooks";
|
|
23
|
+
var ensure_custom_hooks_using_other_hooks_default = createRule({
|
|
24
|
+
name: RULE_NAME,
|
|
25
|
+
meta: {
|
|
26
|
+
type: "problem",
|
|
27
|
+
docs: {
|
|
28
|
+
description: "enforce custom hooks using other hooks",
|
|
29
|
+
requiresTypeChecking: false
|
|
27
30
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return {
|
|
32
|
-
...listeners,
|
|
33
|
-
"Program:exit" (node) {
|
|
34
|
-
const allHooks = ctx.getAllHooks(node);
|
|
35
|
-
for (const { name, hookCalls, node } of allHooks.values()){
|
|
36
|
-
if (hookCalls.length > 0) continue;
|
|
37
|
-
context.report({
|
|
38
|
-
data: {
|
|
39
|
-
name: name.value
|
|
40
|
-
},
|
|
41
|
-
messageId: "ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS",
|
|
42
|
-
node
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
};
|
|
31
|
+
schema: [],
|
|
32
|
+
messages: {
|
|
33
|
+
ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS: "Custom hooks {{name}} should use other hooks"
|
|
47
34
|
}
|
|
35
|
+
},
|
|
36
|
+
defaultOptions: [],
|
|
37
|
+
create(context) {
|
|
38
|
+
const { ctx, listeners } = core.useHookCollector();
|
|
39
|
+
return {
|
|
40
|
+
...listeners,
|
|
41
|
+
"Program:exit"(node) {
|
|
42
|
+
const allHooks = ctx.getAllHooks(node);
|
|
43
|
+
for (const { name: name2, hookCalls, node: node2 } of allHooks.values()) {
|
|
44
|
+
if (hookCalls.length > 0)
|
|
45
|
+
continue;
|
|
46
|
+
context.report({
|
|
47
|
+
data: {
|
|
48
|
+
name: name2.value
|
|
49
|
+
},
|
|
50
|
+
messageId: "ENSURE_CUSTOM_HOOKS_USING_OTHER_HOOKS",
|
|
51
|
+
node: node2
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
48
57
|
});
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
* function is being used in a data-first or data-last style.
|
|
77
|
-
*
|
|
78
|
-
* @param arity - Either the arity of the uncurried function or a predicate
|
|
79
|
-
* which determines if the function is being used in a data-first
|
|
80
|
-
* or data-last style.
|
|
81
|
-
* @param body - The definition of the uncurried function.
|
|
82
|
-
*
|
|
83
|
-
* @example
|
|
84
|
-
* import { dual, pipe } from "effect/Function"
|
|
85
|
-
*
|
|
86
|
-
* // Exampe using arity to determine data-first or data-last style
|
|
87
|
-
* const sum: {
|
|
88
|
-
* (that: number): (self: number) => number
|
|
89
|
-
* (self: number, that: number): number
|
|
90
|
-
* } = dual(2, (self: number, that: number): number => self + that)
|
|
91
|
-
*
|
|
92
|
-
* assert.deepStrictEqual(sum(2, 3), 5)
|
|
93
|
-
* assert.deepStrictEqual(pipe(2, sum(3)), 5)
|
|
94
|
-
*
|
|
95
|
-
* // Example using a predicate to determine data-first or data-last style
|
|
96
|
-
* const sum2: {
|
|
97
|
-
* (that: number): (self: number) => number
|
|
98
|
-
* (self: number, that: number): number
|
|
99
|
-
* } = dual((args) => args.length === 1, (self: number, that: number): number => self + that)
|
|
100
|
-
*
|
|
101
|
-
* assert.deepStrictEqual(sum(2, 3), 5)
|
|
102
|
-
* assert.deepStrictEqual(pipe(2, sum(3)), 5)
|
|
103
|
-
*
|
|
104
|
-
* @since 2.0.0
|
|
105
|
-
*/
|
|
106
|
-
const dual = function (arity, body) {
|
|
59
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Function.js
|
|
60
|
+
var Function_exports = {};
|
|
61
|
+
__export(Function_exports, {
|
|
62
|
+
SK: () => SK,
|
|
63
|
+
absurd: () => absurd,
|
|
64
|
+
apply: () => apply,
|
|
65
|
+
compose: () => compose,
|
|
66
|
+
constFalse: () => constFalse,
|
|
67
|
+
constNull: () => constNull,
|
|
68
|
+
constTrue: () => constTrue,
|
|
69
|
+
constUndefined: () => constUndefined,
|
|
70
|
+
constVoid: () => constVoid,
|
|
71
|
+
constant: () => constant,
|
|
72
|
+
dual: () => dual,
|
|
73
|
+
flip: () => flip,
|
|
74
|
+
flow: () => flow,
|
|
75
|
+
hole: () => hole,
|
|
76
|
+
identity: () => identity,
|
|
77
|
+
isFunction: () => isFunction,
|
|
78
|
+
pipe: () => pipe,
|
|
79
|
+
tupled: () => tupled,
|
|
80
|
+
unsafeCoerce: () => unsafeCoerce,
|
|
81
|
+
untupled: () => untupled
|
|
82
|
+
});
|
|
83
|
+
var isFunction = (input) => typeof input === "function";
|
|
84
|
+
var dual = function(arity, body) {
|
|
107
85
|
if (typeof arity === "function") {
|
|
108
|
-
return function
|
|
86
|
+
return function() {
|
|
109
87
|
if (arity(arguments)) {
|
|
110
|
-
// @ts-expect-error
|
|
111
88
|
return body.apply(this, arguments);
|
|
112
89
|
}
|
|
113
|
-
return self => body(self, ...arguments);
|
|
90
|
+
return (self) => body(self, ...arguments);
|
|
114
91
|
};
|
|
115
92
|
}
|
|
116
93
|
switch (arity) {
|
|
@@ -118,69 +95,69 @@ const dual = function (arity, body) {
|
|
|
118
95
|
case 1:
|
|
119
96
|
throw new RangeError(`Invalid arity ${arity}`);
|
|
120
97
|
case 2:
|
|
121
|
-
return function
|
|
98
|
+
return function(a, b2) {
|
|
122
99
|
if (arguments.length >= 2) {
|
|
123
|
-
return body(a,
|
|
100
|
+
return body(a, b2);
|
|
124
101
|
}
|
|
125
|
-
return function
|
|
102
|
+
return function(self) {
|
|
126
103
|
return body(self, a);
|
|
127
104
|
};
|
|
128
105
|
};
|
|
129
106
|
case 3:
|
|
130
|
-
return function
|
|
107
|
+
return function(a, b2, c2) {
|
|
131
108
|
if (arguments.length >= 3) {
|
|
132
|
-
return body(a,
|
|
109
|
+
return body(a, b2, c2);
|
|
133
110
|
}
|
|
134
|
-
return function
|
|
135
|
-
return body(self, a,
|
|
111
|
+
return function(self) {
|
|
112
|
+
return body(self, a, b2);
|
|
136
113
|
};
|
|
137
114
|
};
|
|
138
115
|
case 4:
|
|
139
|
-
return function
|
|
116
|
+
return function(a, b2, c2, d2) {
|
|
140
117
|
if (arguments.length >= 4) {
|
|
141
|
-
return body(a,
|
|
118
|
+
return body(a, b2, c2, d2);
|
|
142
119
|
}
|
|
143
|
-
return function
|
|
144
|
-
return body(self, a,
|
|
120
|
+
return function(self) {
|
|
121
|
+
return body(self, a, b2, c2);
|
|
145
122
|
};
|
|
146
123
|
};
|
|
147
124
|
case 5:
|
|
148
|
-
return function
|
|
125
|
+
return function(a, b2, c2, d2, e2) {
|
|
149
126
|
if (arguments.length >= 5) {
|
|
150
|
-
return body(a,
|
|
127
|
+
return body(a, b2, c2, d2, e2);
|
|
151
128
|
}
|
|
152
|
-
return function
|
|
153
|
-
return body(self, a,
|
|
129
|
+
return function(self) {
|
|
130
|
+
return body(self, a, b2, c2, d2);
|
|
154
131
|
};
|
|
155
132
|
};
|
|
156
133
|
default:
|
|
157
|
-
return function
|
|
134
|
+
return function() {
|
|
158
135
|
if (arguments.length >= arity) {
|
|
159
|
-
// @ts-expect-error
|
|
160
136
|
return body.apply(this, arguments);
|
|
161
137
|
}
|
|
162
138
|
const args = arguments;
|
|
163
|
-
return function
|
|
139
|
+
return function(self) {
|
|
164
140
|
return body(self, ...args);
|
|
165
141
|
};
|
|
166
142
|
};
|
|
167
143
|
}
|
|
168
144
|
};
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
145
|
+
var apply = (a) => (self) => self(a);
|
|
146
|
+
var identity = (a) => a;
|
|
147
|
+
var unsafeCoerce = identity;
|
|
148
|
+
var constant = (value) => () => value;
|
|
149
|
+
var constTrue = /* @__PURE__ */ constant(true);
|
|
150
|
+
var constFalse = /* @__PURE__ */ constant(false);
|
|
151
|
+
var constNull = /* @__PURE__ */ constant(null);
|
|
152
|
+
var constUndefined = /* @__PURE__ */ constant(void 0);
|
|
153
|
+
var constVoid = constUndefined;
|
|
154
|
+
var flip = (f) => (...b2) => (...a) => f(...a)(...b2);
|
|
155
|
+
var compose = /* @__PURE__ */ dual(2, (ab, bc) => (a) => bc(ab(a)));
|
|
156
|
+
var absurd = (_) => {
|
|
157
|
+
throw new Error("Called `absurd` function which should be uncallable");
|
|
158
|
+
};
|
|
159
|
+
var tupled = (f) => (a) => f(...a);
|
|
160
|
+
var untupled = (f) => (...a) => f(a);
|
|
184
161
|
function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
185
162
|
switch (arguments.length) {
|
|
186
163
|
case 1:
|
|
@@ -201,126 +178,183 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
|
|
|
201
178
|
return gh(fg(ef(de(cd(bc(ab(a)))))));
|
|
202
179
|
case 9:
|
|
203
180
|
return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
|
|
204
|
-
default:
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
ret = arguments[i](ret);
|
|
209
|
-
}
|
|
210
|
-
return ret;
|
|
181
|
+
default: {
|
|
182
|
+
let ret = arguments[0];
|
|
183
|
+
for (let i2 = 1; i2 < arguments.length; i2++) {
|
|
184
|
+
ret = arguments[i2](ret);
|
|
211
185
|
}
|
|
186
|
+
return ret;
|
|
187
|
+
}
|
|
212
188
|
}
|
|
213
189
|
}
|
|
190
|
+
function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
|
|
191
|
+
switch (arguments.length) {
|
|
192
|
+
case 1:
|
|
193
|
+
return ab;
|
|
194
|
+
case 2:
|
|
195
|
+
return function() {
|
|
196
|
+
return bc(ab.apply(this, arguments));
|
|
197
|
+
};
|
|
198
|
+
case 3:
|
|
199
|
+
return function() {
|
|
200
|
+
return cd(bc(ab.apply(this, arguments)));
|
|
201
|
+
};
|
|
202
|
+
case 4:
|
|
203
|
+
return function() {
|
|
204
|
+
return de(cd(bc(ab.apply(this, arguments))));
|
|
205
|
+
};
|
|
206
|
+
case 5:
|
|
207
|
+
return function() {
|
|
208
|
+
return ef(de(cd(bc(ab.apply(this, arguments)))));
|
|
209
|
+
};
|
|
210
|
+
case 6:
|
|
211
|
+
return function() {
|
|
212
|
+
return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
|
|
213
|
+
};
|
|
214
|
+
case 7:
|
|
215
|
+
return function() {
|
|
216
|
+
return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
|
|
217
|
+
};
|
|
218
|
+
case 8:
|
|
219
|
+
return function() {
|
|
220
|
+
return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
|
|
221
|
+
};
|
|
222
|
+
case 9:
|
|
223
|
+
return function() {
|
|
224
|
+
return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
var hole = /* @__PURE__ */ unsafeCoerce(absurd);
|
|
230
|
+
var SK = (_, b2) => b2;
|
|
214
231
|
|
|
215
|
-
|
|
232
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/internal/version.js
|
|
233
|
+
var moduleVersion = "2.3.3";
|
|
216
234
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
*/
|
|
220
|
-
const globalStoreId = /*#__PURE__*/Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
|
|
235
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/GlobalValue.js
|
|
236
|
+
var globalStoreId = /* @__PURE__ */ Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
|
|
221
237
|
if (!(globalStoreId in globalThis)) {
|
|
222
|
-
globalThis[globalStoreId] =
|
|
238
|
+
globalThis[globalStoreId] = /* @__PURE__ */ new Map();
|
|
223
239
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
* @since 2.0.0
|
|
227
|
-
*/
|
|
228
|
-
const globalValue = (id, compute) => {
|
|
240
|
+
var globalStore = globalThis[globalStoreId];
|
|
241
|
+
var globalValue = (id, compute) => {
|
|
229
242
|
if (!globalStore.has(id)) {
|
|
230
243
|
globalStore.set(id, compute());
|
|
231
244
|
}
|
|
232
245
|
return globalStore.get(id);
|
|
233
246
|
};
|
|
234
247
|
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
* @param input - The value to test.
|
|
242
|
-
*
|
|
243
|
-
* @example
|
|
244
|
-
* import { isFunction } from "effect/Predicate"
|
|
245
|
-
*
|
|
246
|
-
* assert.deepStrictEqual(isFunction(isFunction), true)
|
|
247
|
-
*
|
|
248
|
-
* assert.deepStrictEqual(isFunction("function"), false)
|
|
249
|
-
*
|
|
250
|
-
* @category guards
|
|
251
|
-
* @since 2.0.0
|
|
252
|
-
*/
|
|
253
|
-
const isFunction = isFunction$1;
|
|
254
|
-
const isRecordOrArray = input => typeof input === "object" && input !== null;
|
|
255
|
-
/**
|
|
256
|
-
* Tests if a value is an `object`.
|
|
257
|
-
*
|
|
258
|
-
* @param input - The value to test.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* import { isObject } from "effect/Predicate"
|
|
262
|
-
*
|
|
263
|
-
* assert.deepStrictEqual(isObject({}), true)
|
|
264
|
-
* assert.deepStrictEqual(isObject([]), true)
|
|
265
|
-
*
|
|
266
|
-
* assert.deepStrictEqual(isObject(null), false)
|
|
267
|
-
* assert.deepStrictEqual(isObject(undefined), false)
|
|
268
|
-
*
|
|
269
|
-
* @category guards
|
|
270
|
-
* @since 2.0.0
|
|
271
|
-
*/
|
|
272
|
-
const isObject = input => isRecordOrArray(input) || isFunction(input);
|
|
273
|
-
/**
|
|
274
|
-
* Checks whether a value is an `object` containing a specified property key.
|
|
275
|
-
*
|
|
276
|
-
* @param property - The field to check within the object.
|
|
277
|
-
* @param self - The value to examine.
|
|
278
|
-
*
|
|
279
|
-
* @category guards
|
|
280
|
-
* @since 2.0.0
|
|
281
|
-
*/
|
|
282
|
-
const hasProperty = /*#__PURE__*/dual(2, (self, property) => isObject(self) && property in self);
|
|
283
|
-
/**
|
|
284
|
-
* A guard that succeeds when the input is `null` or `undefined`.
|
|
285
|
-
*
|
|
286
|
-
* @param input - The value to test.
|
|
287
|
-
*
|
|
288
|
-
* @example
|
|
289
|
-
* import { isNullable } from "effect/Predicate"
|
|
290
|
-
*
|
|
291
|
-
* assert.deepStrictEqual(isNullable(null), true)
|
|
292
|
-
* assert.deepStrictEqual(isNullable(undefined), true)
|
|
293
|
-
*
|
|
294
|
-
* assert.deepStrictEqual(isNullable({}), false)
|
|
295
|
-
* assert.deepStrictEqual(isNullable([]), false)
|
|
296
|
-
*
|
|
297
|
-
* @category guards
|
|
298
|
-
* @since 2.0.0
|
|
299
|
-
*/
|
|
300
|
-
const isNullable = input => input === null || input === undefined;
|
|
248
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Predicate.js
|
|
249
|
+
var isFunction2 = isFunction;
|
|
250
|
+
var isRecordOrArray = (input) => typeof input === "object" && input !== null;
|
|
251
|
+
var isObject = (input) => isRecordOrArray(input) || isFunction2(input);
|
|
252
|
+
var hasProperty = /* @__PURE__ */ dual(2, (self, property) => isObject(self) && property in self);
|
|
253
|
+
var isNullable = (input) => input === null || input === void 0;
|
|
301
254
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
255
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Utils.js
|
|
256
|
+
var GenKindTypeId = /* @__PURE__ */ Symbol.for("effect/Gen/GenKind");
|
|
257
|
+
var GenKindImpl = class {
|
|
258
|
+
value;
|
|
259
|
+
constructor(value) {
|
|
260
|
+
this.value = value;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* @since 2.0.0
|
|
264
|
+
*/
|
|
265
|
+
get _F() {
|
|
266
|
+
return identity;
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* @since 2.0.0
|
|
270
|
+
*/
|
|
271
|
+
get _R() {
|
|
272
|
+
return (_) => _;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* @since 2.0.0
|
|
276
|
+
*/
|
|
277
|
+
get _O() {
|
|
278
|
+
return (_) => _;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* @since 2.0.0
|
|
282
|
+
*/
|
|
283
|
+
get _E() {
|
|
284
|
+
return (_) => _;
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* @since 2.0.0
|
|
288
|
+
*/
|
|
289
|
+
[GenKindTypeId] = GenKindTypeId;
|
|
290
|
+
/**
|
|
291
|
+
* @since 2.0.0
|
|
292
|
+
*/
|
|
293
|
+
[Symbol.iterator]() {
|
|
294
|
+
return new SingleShotGen(this);
|
|
295
|
+
}
|
|
296
|
+
};
|
|
297
|
+
var SingleShotGen = class _SingleShotGen {
|
|
298
|
+
self;
|
|
299
|
+
called = false;
|
|
300
|
+
constructor(self) {
|
|
301
|
+
this.self = self;
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* @since 2.0.0
|
|
305
|
+
*/
|
|
306
|
+
next(a) {
|
|
307
|
+
return this.called ? {
|
|
308
|
+
value: a,
|
|
309
|
+
done: true
|
|
310
|
+
} : (this.called = true, {
|
|
311
|
+
value: this.self,
|
|
312
|
+
done: false
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* @since 2.0.0
|
|
317
|
+
*/
|
|
318
|
+
return(a) {
|
|
319
|
+
return {
|
|
320
|
+
value: a,
|
|
321
|
+
done: true
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* @since 2.0.0
|
|
326
|
+
*/
|
|
327
|
+
throw(e2) {
|
|
328
|
+
throw e2;
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* @since 2.0.0
|
|
332
|
+
*/
|
|
333
|
+
[Symbol.iterator]() {
|
|
334
|
+
return new _SingleShotGen(this.self);
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
var adapter = () => (
|
|
338
|
+
// @ts-expect-error
|
|
339
|
+
function() {
|
|
340
|
+
let x2 = arguments[0];
|
|
341
|
+
for (let i2 = 1; i2 < arguments.length; i2++) {
|
|
342
|
+
x2 = arguments[i2](x2);
|
|
343
|
+
}
|
|
344
|
+
return new GenKindImpl(x2);
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
var defaultIncHi = 335903614;
|
|
348
|
+
var defaultIncLo = 4150755663;
|
|
349
|
+
var MUL_HI = 1481765933 >>> 0;
|
|
350
|
+
var MUL_LO = 1284865837 >>> 0;
|
|
351
|
+
var BIT_53 = 9007199254740992;
|
|
352
|
+
var BIT_27 = 134217728;
|
|
353
|
+
var PCGRandom = class {
|
|
320
354
|
_state;
|
|
321
355
|
constructor(seedHi, seedLo, incHi, incLo) {
|
|
322
356
|
if (isNullable(seedLo) && isNullable(seedHi)) {
|
|
323
|
-
seedLo = Math.random() *
|
|
357
|
+
seedLo = Math.random() * 4294967295 >>> 0;
|
|
324
358
|
seedHi = 0;
|
|
325
359
|
} else if (isNullable(seedLo)) {
|
|
326
360
|
seedLo = seedHi;
|
|
@@ -372,13 +406,11 @@ class PCGRandom {
|
|
|
372
406
|
}
|
|
373
407
|
max = max >>> 0;
|
|
374
408
|
if ((max & max - 1) === 0) {
|
|
375
|
-
return this._next() & max - 1;
|
|
409
|
+
return this._next() & max - 1;
|
|
376
410
|
}
|
|
377
411
|
let num = 0;
|
|
378
412
|
const skew = (-max >>> 0) % max >>> 0;
|
|
379
413
|
for (num = this._next(); num < skew; num = this._next()) {
|
|
380
|
-
// this loop will rarely execute more than twice,
|
|
381
|
-
// and is intentionally empty
|
|
382
414
|
}
|
|
383
415
|
return num % max;
|
|
384
416
|
}
|
|
@@ -390,35 +422,30 @@ class PCGRandom {
|
|
|
390
422
|
* @since 2.0.0
|
|
391
423
|
*/
|
|
392
424
|
number() {
|
|
393
|
-
const hi = (this._next() &
|
|
394
|
-
const lo = (this._next() &
|
|
425
|
+
const hi = (this._next() & 67108863) * 1;
|
|
426
|
+
const lo = (this._next() & 134217727) * 1;
|
|
395
427
|
return (hi * BIT_27 + lo) / BIT_53;
|
|
396
428
|
}
|
|
397
429
|
/** @internal */
|
|
398
430
|
_next() {
|
|
399
|
-
// save current state (what we'll use for this number)
|
|
400
431
|
const oldHi = this._state[0] >>> 0;
|
|
401
432
|
const oldLo = this._state[1] >>> 0;
|
|
402
|
-
// churn LCG.
|
|
403
433
|
mul64(this._state, oldHi, oldLo, MUL_HI, MUL_LO);
|
|
404
434
|
add64(this._state, this._state[0], this._state[1], this._state[2], this._state[3]);
|
|
405
|
-
// get least sig. 32 bits of ((oldstate >> 18) ^ oldstate) >> 27
|
|
406
435
|
let xsHi = oldHi >>> 18;
|
|
407
436
|
let xsLo = (oldLo >>> 18 | oldHi << 14) >>> 0;
|
|
408
437
|
xsHi = (xsHi ^ oldHi) >>> 0;
|
|
409
438
|
xsLo = (xsLo ^ oldLo) >>> 0;
|
|
410
439
|
const xorshifted = (xsLo >>> 27 | xsHi << 5) >>> 0;
|
|
411
|
-
// rotate xorshifted right a random amount, based on the most sig. 5 bits
|
|
412
|
-
// bits of the old state.
|
|
413
440
|
const rot = oldHi >>> 27;
|
|
414
441
|
const rot2 = (-rot >>> 0 & 31) >>> 0;
|
|
415
442
|
return (xorshifted >>> rot | xorshifted << rot2) >>> 0;
|
|
416
443
|
}
|
|
417
|
-
}
|
|
444
|
+
};
|
|
418
445
|
function mul64(out, aHi, aLo, bHi, bLo) {
|
|
419
|
-
let c1 = (aLo >>> 16) * (bLo &
|
|
420
|
-
let c0 = (aLo &
|
|
421
|
-
let lo = (aLo &
|
|
446
|
+
let c1 = (aLo >>> 16) * (bLo & 65535) >>> 0;
|
|
447
|
+
let c0 = (aLo & 65535) * (bLo >>> 16) >>> 0;
|
|
448
|
+
let lo = (aLo & 65535) * (bLo & 65535) >>> 0;
|
|
422
449
|
let hi = (aLo >>> 16) * (bLo >>> 16) + ((c0 >>> 16) + (c1 >>> 16)) >>> 0;
|
|
423
450
|
c0 = c0 << 16 >>> 0;
|
|
424
451
|
lo = lo + c0 >>> 0;
|
|
@@ -435,7 +462,6 @@ function mul64(out, aHi, aLo, bHi, bLo) {
|
|
|
435
462
|
out[0] = hi;
|
|
436
463
|
out[1] = lo;
|
|
437
464
|
}
|
|
438
|
-
// add two 64 bit numbers (given in parts), and store the result in `out`.
|
|
439
465
|
function add64(out, aHi, aLo, bHi, bLo) {
|
|
440
466
|
let hi = aHi + bHi >>> 0;
|
|
441
467
|
const lo = aLo + bLo >>> 0;
|
|
@@ -446,23 +472,11 @@ function add64(out, aHi, aLo, bHi, bLo) {
|
|
|
446
472
|
out[1] = lo;
|
|
447
473
|
}
|
|
448
474
|
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
*/
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
/** @internal */
|
|
455
|
-
const pcgr = /*#__PURE__*/globalValue( /*#__PURE__*/Symbol.for("effect/Hash/pcgr"), () => new PCGRandom());
|
|
456
|
-
/**
|
|
457
|
-
* @since 2.0.0
|
|
458
|
-
* @category symbols
|
|
459
|
-
*/
|
|
460
|
-
const symbol$1 = /*#__PURE__*/Symbol.for("effect/Hash");
|
|
461
|
-
/**
|
|
462
|
-
* @since 2.0.0
|
|
463
|
-
* @category hashing
|
|
464
|
-
*/
|
|
465
|
-
const hash = self => {
|
|
475
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Hash.js
|
|
476
|
+
var randomHashCache = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/randomHashCache"), () => /* @__PURE__ */ new WeakMap());
|
|
477
|
+
var pcgr = /* @__PURE__ */ globalValue(/* @__PURE__ */ Symbol.for("effect/Hash/pcgr"), () => new PCGRandom());
|
|
478
|
+
var symbol = /* @__PURE__ */ Symbol.for("effect/Hash");
|
|
479
|
+
var hash = (self) => {
|
|
466
480
|
switch (typeof self) {
|
|
467
481
|
case "number":
|
|
468
482
|
return number(self);
|
|
@@ -477,84 +491,55 @@ const hash = self => {
|
|
|
477
491
|
case "undefined":
|
|
478
492
|
return string("undefined");
|
|
479
493
|
case "function":
|
|
480
|
-
case "object":
|
|
481
|
-
{
|
|
482
|
-
|
|
483
|
-
return string("null");
|
|
484
|
-
}
|
|
485
|
-
if (isHash(self)) {
|
|
486
|
-
return self[symbol$1]();
|
|
487
|
-
} else {
|
|
488
|
-
return random(self);
|
|
489
|
-
}
|
|
494
|
+
case "object": {
|
|
495
|
+
if (self === null) {
|
|
496
|
+
return string("null");
|
|
490
497
|
}
|
|
498
|
+
if (isHash(self)) {
|
|
499
|
+
return self[symbol]();
|
|
500
|
+
} else {
|
|
501
|
+
return random(self);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
491
504
|
default:
|
|
492
505
|
throw new Error(`BUG: unhandled typeof ${typeof self} - please report an issue at https://github.com/Effect-TS/effect/issues`);
|
|
493
506
|
}
|
|
494
507
|
};
|
|
495
|
-
|
|
496
|
-
* @since 2.0.0
|
|
497
|
-
* @category hashing
|
|
498
|
-
*/
|
|
499
|
-
const random = self => {
|
|
508
|
+
var random = (self) => {
|
|
500
509
|
if (!randomHashCache.has(self)) {
|
|
501
510
|
randomHashCache.set(self, number(pcgr.integer(Number.MAX_SAFE_INTEGER)));
|
|
502
511
|
}
|
|
503
512
|
return randomHashCache.get(self);
|
|
504
513
|
};
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
/**
|
|
511
|
-
* @since 2.0.0
|
|
512
|
-
* @category hashing
|
|
513
|
-
*/
|
|
514
|
-
const optimize = n => n & 0xbfffffff | n >>> 1 & 0x40000000;
|
|
515
|
-
/**
|
|
516
|
-
* @since 2.0.0
|
|
517
|
-
* @category guards
|
|
518
|
-
*/
|
|
519
|
-
const isHash = u => hasProperty(u, symbol$1);
|
|
520
|
-
/**
|
|
521
|
-
* @since 2.0.0
|
|
522
|
-
* @category hashing
|
|
523
|
-
*/
|
|
524
|
-
const number = n => {
|
|
525
|
-
if (n !== n || n === Infinity) {
|
|
514
|
+
var combine = (b2) => (self) => self * 53 ^ b2;
|
|
515
|
+
var optimize = (n2) => n2 & 3221225471 | n2 >>> 1 & 1073741824;
|
|
516
|
+
var isHash = (u2) => hasProperty(u2, symbol);
|
|
517
|
+
var number = (n2) => {
|
|
518
|
+
if (n2 !== n2 || n2 === Infinity) {
|
|
526
519
|
return 0;
|
|
527
520
|
}
|
|
528
|
-
let h =
|
|
529
|
-
if (h !==
|
|
530
|
-
h ^=
|
|
521
|
+
let h = n2 | 0;
|
|
522
|
+
if (h !== n2) {
|
|
523
|
+
h ^= n2 * 4294967295;
|
|
531
524
|
}
|
|
532
|
-
while (
|
|
533
|
-
h ^=
|
|
525
|
+
while (n2 > 4294967295) {
|
|
526
|
+
h ^= n2 /= 4294967295;
|
|
534
527
|
}
|
|
535
|
-
return optimize(
|
|
528
|
+
return optimize(n2);
|
|
536
529
|
};
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
const string = str => {
|
|
542
|
-
let h = 5381,
|
|
543
|
-
i = str.length;
|
|
544
|
-
while (i) {
|
|
545
|
-
h = h * 33 ^ str.charCodeAt(--i);
|
|
530
|
+
var string = (str) => {
|
|
531
|
+
let h = 5381, i2 = str.length;
|
|
532
|
+
while (i2) {
|
|
533
|
+
h = h * 33 ^ str.charCodeAt(--i2);
|
|
546
534
|
}
|
|
547
535
|
return optimize(h);
|
|
548
536
|
};
|
|
549
537
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
* @category symbols
|
|
553
|
-
*/
|
|
554
|
-
const symbol = /*#__PURE__*/Symbol.for("effect/Equal");
|
|
538
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Equal.js
|
|
539
|
+
var symbol2 = /* @__PURE__ */ Symbol.for("effect/Equal");
|
|
555
540
|
function equals() {
|
|
556
541
|
if (arguments.length === 1) {
|
|
557
|
-
return self => compareBoth(self, arguments[0]);
|
|
542
|
+
return (self) => compareBoth(self, arguments[0]);
|
|
558
543
|
}
|
|
559
544
|
return compareBoth(arguments[0], arguments[1]);
|
|
560
545
|
}
|
|
@@ -568,48 +553,93 @@ function compareBoth(self, that) {
|
|
|
568
553
|
}
|
|
569
554
|
if ((selfType === "object" || selfType === "function") && self !== null && that !== null) {
|
|
570
555
|
if (isEqual(self) && isEqual(that)) {
|
|
571
|
-
return hash(self) === hash(that) && self[
|
|
556
|
+
return hash(self) === hash(that) && self[symbol2](that);
|
|
572
557
|
}
|
|
573
558
|
}
|
|
574
559
|
return false;
|
|
575
560
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
561
|
+
var isEqual = (u2) => hasProperty(u2, symbol2);
|
|
562
|
+
var equivalence = () => (self, that) => equals(self, that);
|
|
563
|
+
|
|
564
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Equivalence.js
|
|
565
|
+
var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
|
|
581
566
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
* @since 2.0.0
|
|
592
|
-
*/
|
|
593
|
-
const toJSON = x => {
|
|
594
|
-
if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) {
|
|
595
|
-
return x.toJSON();
|
|
596
|
-
} else if (Array.isArray(x)) {
|
|
597
|
-
return x.map(toJSON);
|
|
598
|
-
}
|
|
599
|
-
return x;
|
|
567
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Inspectable.js
|
|
568
|
+
var NodeInspectSymbol = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
|
|
569
|
+
var toJSON = (x2) => {
|
|
570
|
+
if (hasProperty(x2, "toJSON") && isFunction2(x2["toJSON"]) && x2["toJSON"].length === 0) {
|
|
571
|
+
return x2.toJSON();
|
|
572
|
+
} else if (Array.isArray(x2)) {
|
|
573
|
+
return x2.map(toJSON);
|
|
574
|
+
}
|
|
575
|
+
return x2;
|
|
600
576
|
};
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
577
|
+
var format = (x2) => JSON.stringify(x2, null, 2);
|
|
578
|
+
|
|
579
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Option.js
|
|
580
|
+
var Option_exports = {};
|
|
581
|
+
__export(Option_exports, {
|
|
582
|
+
Do: () => Do,
|
|
583
|
+
TypeId: () => TypeId3,
|
|
584
|
+
all: () => all,
|
|
585
|
+
andThen: () => andThen,
|
|
586
|
+
ap: () => ap,
|
|
587
|
+
as: () => as,
|
|
588
|
+
asUnit: () => asUnit,
|
|
589
|
+
bind: () => bind,
|
|
590
|
+
bindTo: () => bindTo,
|
|
591
|
+
composeK: () => composeK,
|
|
592
|
+
contains: () => contains,
|
|
593
|
+
containsWith: () => containsWith,
|
|
594
|
+
exists: () => exists,
|
|
595
|
+
filter: () => filter,
|
|
596
|
+
filterMap: () => filterMap,
|
|
597
|
+
firstSomeOf: () => firstSomeOf,
|
|
598
|
+
flatMap: () => flatMap,
|
|
599
|
+
flatMapNullable: () => flatMapNullable,
|
|
600
|
+
flatten: () => flatten,
|
|
601
|
+
fromIterable: () => fromIterable,
|
|
602
|
+
fromNullable: () => fromNullable,
|
|
603
|
+
gen: () => gen,
|
|
604
|
+
getEquivalence: () => getEquivalence,
|
|
605
|
+
getLeft: () => getLeft2,
|
|
606
|
+
getOrElse: () => getOrElse,
|
|
607
|
+
getOrNull: () => getOrNull,
|
|
608
|
+
getOrThrow: () => getOrThrow,
|
|
609
|
+
getOrThrowWith: () => getOrThrowWith,
|
|
610
|
+
getOrUndefined: () => getOrUndefined,
|
|
611
|
+
getOrder: () => getOrder,
|
|
612
|
+
getRight: () => getRight2,
|
|
613
|
+
isNone: () => isNone2,
|
|
614
|
+
isOption: () => isOption2,
|
|
615
|
+
isSome: () => isSome2,
|
|
616
|
+
let: () => let_,
|
|
617
|
+
lift2: () => lift2,
|
|
618
|
+
liftNullable: () => liftNullable,
|
|
619
|
+
liftPredicate: () => liftPredicate,
|
|
620
|
+
liftThrowable: () => liftThrowable,
|
|
621
|
+
map: () => map,
|
|
622
|
+
match: () => match,
|
|
623
|
+
none: () => none2,
|
|
624
|
+
orElse: () => orElse,
|
|
625
|
+
orElseEither: () => orElseEither,
|
|
626
|
+
orElseSome: () => orElseSome,
|
|
627
|
+
partitionMap: () => partitionMap,
|
|
628
|
+
product: () => product,
|
|
629
|
+
productMany: () => productMany,
|
|
630
|
+
reduceCompact: () => reduceCompact,
|
|
631
|
+
some: () => some2,
|
|
632
|
+
tap: () => tap,
|
|
633
|
+
toArray: () => toArray,
|
|
634
|
+
toRefinement: () => toRefinement,
|
|
635
|
+
unit: () => unit,
|
|
636
|
+
zipLeft: () => zipLeft,
|
|
637
|
+
zipRight: () => zipRight,
|
|
638
|
+
zipWith: () => zipWith
|
|
639
|
+
});
|
|
605
640
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
*/
|
|
609
|
-
/**
|
|
610
|
-
* @since 2.0.0
|
|
611
|
-
*/
|
|
612
|
-
const pipeArguments = (self, args) => {
|
|
641
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Pipeable.js
|
|
642
|
+
var pipeArguments = (self, args) => {
|
|
613
643
|
switch (args.length) {
|
|
614
644
|
case 1:
|
|
615
645
|
return args[0](self);
|
|
@@ -629,73 +659,67 @@ const pipeArguments = (self, args) => {
|
|
|
629
659
|
return args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self))))))));
|
|
630
660
|
case 9:
|
|
631
661
|
return args[8](args[7](args[6](args[5](args[4](args[3](args[2](args[1](args[0](self)))))))));
|
|
632
|
-
default:
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
ret = args[i](ret);
|
|
637
|
-
}
|
|
638
|
-
return ret;
|
|
662
|
+
default: {
|
|
663
|
+
let ret = self;
|
|
664
|
+
for (let i2 = 0, len = args.length; i2 < len; i2++) {
|
|
665
|
+
ret = args[i2](ret);
|
|
639
666
|
}
|
|
667
|
+
return ret;
|
|
668
|
+
}
|
|
640
669
|
}
|
|
641
670
|
};
|
|
642
671
|
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
/** @internal */
|
|
650
|
-
const ChannelTypeId = /*#__PURE__*/Symbol.for("effect/Channel");
|
|
651
|
-
/** @internal */
|
|
652
|
-
const effectVariance = {
|
|
672
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/internal/effectable.js
|
|
673
|
+
var EffectTypeId = /* @__PURE__ */ Symbol.for("effect/Effect");
|
|
674
|
+
var StreamTypeId = /* @__PURE__ */ Symbol.for("effect/Stream");
|
|
675
|
+
var SinkTypeId = /* @__PURE__ */ Symbol.for("effect/Sink");
|
|
676
|
+
var ChannelTypeId = /* @__PURE__ */ Symbol.for("effect/Channel");
|
|
677
|
+
var effectVariance = {
|
|
653
678
|
/* c8 ignore next */
|
|
654
|
-
_R: _ => _,
|
|
679
|
+
_R: (_) => _,
|
|
655
680
|
/* c8 ignore next */
|
|
656
|
-
_E: _ => _,
|
|
681
|
+
_E: (_) => _,
|
|
657
682
|
/* c8 ignore next */
|
|
658
|
-
_A: _ => _,
|
|
683
|
+
_A: (_) => _,
|
|
659
684
|
_V: moduleVersion
|
|
660
685
|
};
|
|
661
|
-
|
|
686
|
+
var sinkVariance = {
|
|
662
687
|
/* c8 ignore next */
|
|
663
|
-
_A: _ => _,
|
|
688
|
+
_A: (_) => _,
|
|
664
689
|
/* c8 ignore next */
|
|
665
|
-
_In: _ => _,
|
|
690
|
+
_In: (_) => _,
|
|
666
691
|
/* c8 ignore next */
|
|
667
|
-
_L: _ => _,
|
|
692
|
+
_L: (_) => _,
|
|
668
693
|
/* c8 ignore next */
|
|
669
|
-
_E: _ => _,
|
|
694
|
+
_E: (_) => _,
|
|
670
695
|
/* c8 ignore next */
|
|
671
|
-
_R: _ => _
|
|
696
|
+
_R: (_) => _
|
|
672
697
|
};
|
|
673
|
-
|
|
698
|
+
var channelVariance = {
|
|
674
699
|
/* c8 ignore next */
|
|
675
|
-
_Env: _ => _,
|
|
700
|
+
_Env: (_) => _,
|
|
676
701
|
/* c8 ignore next */
|
|
677
|
-
_InErr: _ => _,
|
|
702
|
+
_InErr: (_) => _,
|
|
678
703
|
/* c8 ignore next */
|
|
679
|
-
_InElem: _ => _,
|
|
704
|
+
_InElem: (_) => _,
|
|
680
705
|
/* c8 ignore next */
|
|
681
|
-
_InDone: _ => _,
|
|
706
|
+
_InDone: (_) => _,
|
|
682
707
|
/* c8 ignore next */
|
|
683
|
-
_OutErr: _ => _,
|
|
708
|
+
_OutErr: (_) => _,
|
|
684
709
|
/* c8 ignore next */
|
|
685
|
-
_OutElem: _ => _,
|
|
710
|
+
_OutElem: (_) => _,
|
|
686
711
|
/* c8 ignore next */
|
|
687
|
-
_OutDone: _ => _
|
|
712
|
+
_OutDone: (_) => _
|
|
688
713
|
};
|
|
689
|
-
|
|
690
|
-
const EffectPrototype = {
|
|
714
|
+
var EffectPrototype = {
|
|
691
715
|
[EffectTypeId]: effectVariance,
|
|
692
716
|
[StreamTypeId]: effectVariance,
|
|
693
717
|
[SinkTypeId]: sinkVariance,
|
|
694
718
|
[ChannelTypeId]: channelVariance,
|
|
695
|
-
[
|
|
719
|
+
[symbol2](that) {
|
|
696
720
|
return this === that;
|
|
697
721
|
},
|
|
698
|
-
[symbol
|
|
722
|
+
[symbol]() {
|
|
699
723
|
return random(this);
|
|
700
724
|
},
|
|
701
725
|
pipe() {
|
|
@@ -703,14 +727,12 @@ const EffectPrototype = {
|
|
|
703
727
|
}
|
|
704
728
|
};
|
|
705
729
|
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
const TypeId = /*#__PURE__*/Symbol.for("effect/Option");
|
|
710
|
-
const CommonProto = {
|
|
730
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/internal/option.js
|
|
731
|
+
var TypeId = /* @__PURE__ */ Symbol.for("effect/Option");
|
|
732
|
+
var CommonProto = {
|
|
711
733
|
...EffectPrototype,
|
|
712
734
|
[TypeId]: {
|
|
713
|
-
_A: _ => _
|
|
735
|
+
_A: (_) => _
|
|
714
736
|
},
|
|
715
737
|
[NodeInspectSymbol]() {
|
|
716
738
|
return this.toJSON();
|
|
@@ -719,13 +741,13 @@ const CommonProto = {
|
|
|
719
741
|
return format(this.toJSON());
|
|
720
742
|
}
|
|
721
743
|
};
|
|
722
|
-
|
|
744
|
+
var SomeProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), {
|
|
723
745
|
_tag: "Some",
|
|
724
746
|
_op: "Some",
|
|
725
|
-
[
|
|
747
|
+
[symbol2](that) {
|
|
726
748
|
return isOption(that) && isSome(that) && equals(that.value, this.value);
|
|
727
749
|
},
|
|
728
|
-
[symbol
|
|
750
|
+
[symbol]() {
|
|
729
751
|
return combine(hash(this._tag))(hash(this.value));
|
|
730
752
|
},
|
|
731
753
|
toJSON() {
|
|
@@ -736,13 +758,13 @@ const SomeProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonP
|
|
|
736
758
|
};
|
|
737
759
|
}
|
|
738
760
|
});
|
|
739
|
-
|
|
761
|
+
var NoneProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto), {
|
|
740
762
|
_tag: "None",
|
|
741
763
|
_op: "None",
|
|
742
|
-
[
|
|
743
|
-
return isOption(that) && isNone
|
|
764
|
+
[symbol2](that) {
|
|
765
|
+
return isOption(that) && isNone(that);
|
|
744
766
|
},
|
|
745
|
-
[symbol
|
|
767
|
+
[symbol]() {
|
|
746
768
|
return combine(hash(this._tag));
|
|
747
769
|
},
|
|
748
770
|
toJSON() {
|
|
@@ -752,284 +774,580 @@ const NoneProto = /*#__PURE__*/Object.assign( /*#__PURE__*/Object.create(CommonP
|
|
|
752
774
|
};
|
|
753
775
|
}
|
|
754
776
|
});
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
const isSome = fa => fa._tag === "Some";
|
|
761
|
-
/** @internal */
|
|
762
|
-
const none$1 = /*#__PURE__*/Object.create(NoneProto);
|
|
763
|
-
/** @internal */
|
|
764
|
-
const some$1 = value => {
|
|
777
|
+
var isOption = (input) => hasProperty(input, TypeId);
|
|
778
|
+
var isNone = (fa) => fa._tag === "None";
|
|
779
|
+
var isSome = (fa) => fa._tag === "Some";
|
|
780
|
+
var none = /* @__PURE__ */ Object.create(NoneProto);
|
|
781
|
+
var some = (value) => {
|
|
765
782
|
const a = Object.create(SomeProto);
|
|
766
783
|
a.value = value;
|
|
767
784
|
return a;
|
|
768
785
|
};
|
|
769
786
|
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
*/
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
* assert.deepStrictEqual(O.filterMap(O.some(2), evenNumber), O.some(2))
|
|
834
|
-
*
|
|
835
|
-
* @category filtering
|
|
836
|
-
* @since 2.0.0
|
|
837
|
-
*/
|
|
838
|
-
const filterMap = /*#__PURE__*/dual(2, (self, f) => isNone(self) ? none() : f(self.value));
|
|
839
|
-
/**
|
|
840
|
-
* Filters an `Option` using a predicate. If the predicate is not satisfied or the `Option` is `None` returns `None`.
|
|
841
|
-
*
|
|
842
|
-
* If you need to change the type of the `Option` in addition to filtering, see `filterMap`.
|
|
843
|
-
*
|
|
844
|
-
* @param predicate - A predicate function to apply to the `Option` value.
|
|
845
|
-
* @param fb - The `Option` to filter.
|
|
846
|
-
*
|
|
847
|
-
* @example
|
|
848
|
-
* import * as O from "effect/Option"
|
|
849
|
-
*
|
|
850
|
-
* // predicate
|
|
851
|
-
* const isEven = (n: number) => n % 2 === 0
|
|
852
|
-
*
|
|
853
|
-
* assert.deepStrictEqual(O.filter(O.none(), isEven), O.none())
|
|
854
|
-
* assert.deepStrictEqual(O.filter(O.some(3), isEven), O.none())
|
|
855
|
-
* assert.deepStrictEqual(O.filter(O.some(2), isEven), O.some(2))
|
|
856
|
-
*
|
|
857
|
-
* // refinement
|
|
858
|
-
* const isNumber = (v: unknown): v is number => typeof v === "number"
|
|
859
|
-
*
|
|
860
|
-
* assert.deepStrictEqual(O.filter(O.none(), isNumber), O.none())
|
|
861
|
-
* assert.deepStrictEqual(O.filter(O.some('hello'), isNumber), O.none())
|
|
862
|
-
* assert.deepStrictEqual(O.filter(O.some(2), isNumber), O.some(2))
|
|
863
|
-
*
|
|
864
|
-
* @category filtering
|
|
865
|
-
* @since 2.0.0
|
|
866
|
-
*/
|
|
867
|
-
const filter = /*#__PURE__*/dual(2, (self, predicate) => filterMap(self, b => predicate(b) ? some$1(b) : none$1));
|
|
868
|
-
|
|
869
|
-
/**
|
|
870
|
-
* Bun currently has a bug where `setTimeout` doesn't behave correctly with a 0ms delay.
|
|
871
|
-
*
|
|
872
|
-
* @see https://github.com/oven-sh/bun/issues/3333
|
|
873
|
-
*/
|
|
874
|
-
/** @internal */
|
|
875
|
-
typeof process === "undefined" ? false : !!process?.isBun;
|
|
787
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/internal/either.js
|
|
788
|
+
var TypeId2 = /* @__PURE__ */ Symbol.for("effect/Either");
|
|
789
|
+
var CommonProto2 = {
|
|
790
|
+
...EffectPrototype,
|
|
791
|
+
[TypeId2]: {
|
|
792
|
+
_A: (_) => _
|
|
793
|
+
},
|
|
794
|
+
[NodeInspectSymbol]() {
|
|
795
|
+
return this.toJSON();
|
|
796
|
+
},
|
|
797
|
+
toString() {
|
|
798
|
+
return format(this.toJSON());
|
|
799
|
+
}
|
|
800
|
+
};
|
|
801
|
+
var RightProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
|
|
802
|
+
_tag: "Right",
|
|
803
|
+
_op: "Right",
|
|
804
|
+
[symbol2](that) {
|
|
805
|
+
return isEither(that) && isRight(that) && equals(that.right, this.right);
|
|
806
|
+
},
|
|
807
|
+
[symbol]() {
|
|
808
|
+
return combine(hash(this._tag))(hash(this.right));
|
|
809
|
+
},
|
|
810
|
+
toJSON() {
|
|
811
|
+
return {
|
|
812
|
+
_id: "Either",
|
|
813
|
+
_tag: this._tag,
|
|
814
|
+
right: toJSON(this.right)
|
|
815
|
+
};
|
|
816
|
+
}
|
|
817
|
+
});
|
|
818
|
+
var LeftProto = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(CommonProto2), {
|
|
819
|
+
_tag: "Left",
|
|
820
|
+
_op: "Left",
|
|
821
|
+
[symbol2](that) {
|
|
822
|
+
return isEither(that) && isLeft(that) && equals(that.left, this.left);
|
|
823
|
+
},
|
|
824
|
+
[symbol]() {
|
|
825
|
+
return combine(hash(this._tag))(hash(this.left));
|
|
826
|
+
},
|
|
827
|
+
toJSON() {
|
|
828
|
+
return {
|
|
829
|
+
_id: "Either",
|
|
830
|
+
_tag: this._tag,
|
|
831
|
+
left: toJSON(this.left)
|
|
832
|
+
};
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
var isEither = (input) => hasProperty(input, TypeId2);
|
|
836
|
+
var isLeft = (ma) => ma._tag === "Left";
|
|
837
|
+
var isRight = (ma) => ma._tag === "Right";
|
|
838
|
+
var left = (left2) => {
|
|
839
|
+
const a = Object.create(LeftProto);
|
|
840
|
+
a.left = left2;
|
|
841
|
+
return a;
|
|
842
|
+
};
|
|
843
|
+
var right = (right2) => {
|
|
844
|
+
const a = Object.create(RightProto);
|
|
845
|
+
a.right = right2;
|
|
846
|
+
return a;
|
|
847
|
+
};
|
|
848
|
+
var getLeft = (self) => isRight(self) ? none : some(self.left);
|
|
849
|
+
var getRight = (self) => isLeft(self) ? none : some(self.right);
|
|
876
850
|
|
|
877
|
-
|
|
878
|
-
|
|
851
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Order.js
|
|
852
|
+
var make2 = (compare) => (self, that) => self === that ? 0 : compare(self, that);
|
|
879
853
|
|
|
880
|
-
|
|
881
|
-
var
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
node
|
|
910
|
-
});
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
const maybeDescriptor = pipe(match(deps).with({
|
|
914
|
-
type: ast.NodeType.ArrayExpression
|
|
915
|
-
}, some).with({
|
|
916
|
-
type: ast.NodeType.Identifier
|
|
917
|
-
}, (n)=>{
|
|
918
|
-
return pipe(_var.findVariable(n.name, initialScope), flatMap(_var.getVariableInit(0)), filter(ast.is(ast.NodeType.ArrayExpression)));
|
|
919
|
-
}).otherwise(none), filter((x)=>x.elements.length === 0), map(()=>({
|
|
920
|
-
node,
|
|
921
|
-
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS"
|
|
922
|
-
})));
|
|
923
|
-
map(maybeDescriptor, context.report);
|
|
924
|
-
}
|
|
925
|
-
};
|
|
854
|
+
// ../../../node_modules/.pnpm/effect@2.3.3/node_modules/effect/dist/esm/Option.js
|
|
855
|
+
var TypeId3 = /* @__PURE__ */ Symbol.for("effect/Option");
|
|
856
|
+
var none2 = () => none;
|
|
857
|
+
var some2 = some;
|
|
858
|
+
var isOption2 = isOption;
|
|
859
|
+
var isNone2 = isNone;
|
|
860
|
+
var isSome2 = isSome;
|
|
861
|
+
var match = /* @__PURE__ */ dual(2, (self, {
|
|
862
|
+
onNone,
|
|
863
|
+
onSome
|
|
864
|
+
}) => isNone2(self) ? onNone() : onSome(self.value));
|
|
865
|
+
var toRefinement = (f) => (a) => isSome2(f(a));
|
|
866
|
+
var fromIterable = (collection) => {
|
|
867
|
+
for (const a of collection) {
|
|
868
|
+
return some2(a);
|
|
869
|
+
}
|
|
870
|
+
return none2();
|
|
871
|
+
};
|
|
872
|
+
var getRight2 = getRight;
|
|
873
|
+
var getLeft2 = getLeft;
|
|
874
|
+
var getOrElse = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? onNone() : self.value);
|
|
875
|
+
var orElse = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? that() : self);
|
|
876
|
+
var orElseSome = /* @__PURE__ */ dual(2, (self, onNone) => isNone2(self) ? some2(onNone()) : self);
|
|
877
|
+
var orElseEither = /* @__PURE__ */ dual(2, (self, that) => isNone2(self) ? map(that(), right) : map(self, left));
|
|
878
|
+
var firstSomeOf = (collection) => {
|
|
879
|
+
let out = none2();
|
|
880
|
+
for (out of collection) {
|
|
881
|
+
if (isSome2(out)) {
|
|
882
|
+
return out;
|
|
926
883
|
}
|
|
884
|
+
}
|
|
885
|
+
return out;
|
|
886
|
+
};
|
|
887
|
+
var fromNullable = (nullableValue) => nullableValue == null ? none2() : some2(nullableValue);
|
|
888
|
+
var liftNullable = (f) => (...a) => fromNullable(f(...a));
|
|
889
|
+
var getOrNull = /* @__PURE__ */ getOrElse(constNull);
|
|
890
|
+
var getOrUndefined = /* @__PURE__ */ getOrElse(constUndefined);
|
|
891
|
+
var liftThrowable = (f) => (...a) => {
|
|
892
|
+
try {
|
|
893
|
+
return some2(f(...a));
|
|
894
|
+
} catch (e2) {
|
|
895
|
+
return none2();
|
|
896
|
+
}
|
|
897
|
+
};
|
|
898
|
+
var getOrThrowWith = /* @__PURE__ */ dual(2, (self, onNone) => {
|
|
899
|
+
if (isSome2(self)) {
|
|
900
|
+
return self.value;
|
|
901
|
+
}
|
|
902
|
+
throw onNone();
|
|
927
903
|
});
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
var
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
904
|
+
var getOrThrow = /* @__PURE__ */ getOrThrowWith(() => new Error("getOrThrow called on a None"));
|
|
905
|
+
var map = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : some2(f(self.value)));
|
|
906
|
+
var as = /* @__PURE__ */ dual(2, (self, b2) => map(self, () => b2));
|
|
907
|
+
var asUnit = /* @__PURE__ */ as(void 0);
|
|
908
|
+
var unit = /* @__PURE__ */ some2(void 0);
|
|
909
|
+
var flatMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value));
|
|
910
|
+
var andThen = /* @__PURE__ */ dual(2, (self, f) => flatMap(self, (a) => {
|
|
911
|
+
const b2 = isFunction(f) ? f(a) : f;
|
|
912
|
+
return isOption2(b2) ? b2 : some2(b2);
|
|
913
|
+
}));
|
|
914
|
+
var flatMapNullable = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : fromNullable(f(self.value)));
|
|
915
|
+
var flatten = /* @__PURE__ */ flatMap(identity);
|
|
916
|
+
var zipRight = /* @__PURE__ */ dual(2, (self, that) => flatMap(self, () => that));
|
|
917
|
+
var composeK = /* @__PURE__ */ dual(2, (afb, bfc) => (a) => flatMap(afb(a), bfc));
|
|
918
|
+
var zipLeft = /* @__PURE__ */ dual(2, (self, that) => tap(self, () => that));
|
|
919
|
+
var tap = /* @__PURE__ */ dual(2, (self, f) => flatMap(self, (a) => map(f(a), () => a)));
|
|
920
|
+
var product = (self, that) => isSome2(self) && isSome2(that) ? some2([self.value, that.value]) : none2();
|
|
921
|
+
var productMany = (self, collection) => {
|
|
922
|
+
if (isNone2(self)) {
|
|
923
|
+
return none2();
|
|
924
|
+
}
|
|
925
|
+
const out = [self.value];
|
|
926
|
+
for (const o2 of collection) {
|
|
927
|
+
if (isNone2(o2)) {
|
|
928
|
+
return none2();
|
|
929
|
+
}
|
|
930
|
+
out.push(o2.value);
|
|
931
|
+
}
|
|
932
|
+
return some2(out);
|
|
933
|
+
};
|
|
934
|
+
var all = (input) => {
|
|
935
|
+
if (Symbol.iterator in input) {
|
|
936
|
+
const out2 = [];
|
|
937
|
+
for (const o2 of input) {
|
|
938
|
+
if (isNone2(o2)) {
|
|
939
|
+
return none2();
|
|
940
|
+
}
|
|
941
|
+
out2.push(o2.value);
|
|
942
|
+
}
|
|
943
|
+
return some2(out2);
|
|
944
|
+
}
|
|
945
|
+
const out = {};
|
|
946
|
+
for (const key of Object.keys(input)) {
|
|
947
|
+
const o2 = input[key];
|
|
948
|
+
if (isNone2(o2)) {
|
|
949
|
+
return none2();
|
|
950
|
+
}
|
|
951
|
+
out[key] = o2.value;
|
|
952
|
+
}
|
|
953
|
+
return some2(out);
|
|
954
|
+
};
|
|
955
|
+
var zipWith = /* @__PURE__ */ dual(3, (self, that, f) => map(product(self, that), ([a, b2]) => f(a, b2)));
|
|
956
|
+
var ap = /* @__PURE__ */ dual(2, (self, that) => zipWith(self, that, (f, a) => f(a)));
|
|
957
|
+
var reduceCompact = /* @__PURE__ */ dual(3, (self, b2, f) => {
|
|
958
|
+
let out = b2;
|
|
959
|
+
for (const oa of self) {
|
|
960
|
+
if (isSome2(oa)) {
|
|
961
|
+
out = f(out, oa.value);
|
|
962
|
+
}
|
|
963
|
+
}
|
|
964
|
+
return out;
|
|
965
|
+
});
|
|
966
|
+
var toArray = (self) => isNone2(self) ? [] : [self.value];
|
|
967
|
+
var partitionMap = /* @__PURE__ */ dual(2, (self, f) => {
|
|
968
|
+
if (isNone2(self)) {
|
|
969
|
+
return [none2(), none2()];
|
|
970
|
+
}
|
|
971
|
+
const e2 = f(self.value);
|
|
972
|
+
return isLeft(e2) ? [some2(e2.left), none2()] : [none2(), some2(e2.right)];
|
|
973
|
+
});
|
|
974
|
+
var filterMap = /* @__PURE__ */ dual(2, (self, f) => isNone2(self) ? none2() : f(self.value));
|
|
975
|
+
var filter = /* @__PURE__ */ dual(2, (self, predicate) => filterMap(self, (b2) => predicate(b2) ? some(b2) : none));
|
|
976
|
+
var getEquivalence = (isEquivalent) => make((x2, y2) => x2 === y2 || (isNone2(x2) ? isNone2(y2) : isNone2(y2) ? false : isEquivalent(x2.value, y2.value)));
|
|
977
|
+
var getOrder = (O) => make2((self, that) => isSome2(self) ? isSome2(that) ? O(self.value, that.value) : 1 : -1);
|
|
978
|
+
var lift2 = (f) => dual(2, (self, that) => zipWith(self, that, f));
|
|
979
|
+
var liftPredicate = (predicate) => (b2) => predicate(b2) ? some2(b2) : none2();
|
|
980
|
+
var containsWith = (isEquivalent) => dual(2, (self, a) => isNone2(self) ? false : isEquivalent(self.value, a));
|
|
981
|
+
var _equivalence = /* @__PURE__ */ equivalence();
|
|
982
|
+
var contains = /* @__PURE__ */ containsWith(_equivalence);
|
|
983
|
+
var exists = /* @__PURE__ */ dual(2, (self, refinement) => isNone2(self) ? false : refinement(self.value));
|
|
984
|
+
var bindTo = /* @__PURE__ */ dual(2, (self, name2) => map(self, (a) => ({
|
|
985
|
+
[name2]: a
|
|
986
|
+
})));
|
|
987
|
+
var let_ = /* @__PURE__ */ dual(3, (self, name2, f) => map(self, (a) => Object.assign({}, a, {
|
|
988
|
+
[name2]: f(a)
|
|
989
|
+
})));
|
|
990
|
+
var bind = /* @__PURE__ */ dual(3, (self, name2, f) => flatMap(self, (a) => map(f(a), (b2) => Object.assign({}, a, {
|
|
991
|
+
[name2]: b2
|
|
992
|
+
}))));
|
|
993
|
+
var Do = /* @__PURE__ */ some2({});
|
|
994
|
+
var adapter2 = /* @__PURE__ */ adapter();
|
|
995
|
+
var gen = (f) => {
|
|
996
|
+
const iterator = f(adapter2);
|
|
997
|
+
let state = iterator.next();
|
|
998
|
+
if (state.done) {
|
|
999
|
+
return some2(state.value);
|
|
1000
|
+
} else {
|
|
1001
|
+
let current = state.value.value;
|
|
1002
|
+
if (isNone2(current)) {
|
|
1003
|
+
return current;
|
|
1004
|
+
}
|
|
1005
|
+
while (!state.done) {
|
|
1006
|
+
state = iterator.next(current.value);
|
|
1007
|
+
if (!state.done) {
|
|
1008
|
+
current = state.value.value;
|
|
1009
|
+
if (isNone2(current)) {
|
|
1010
|
+
return current;
|
|
941
1011
|
}
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
return some2(state.value);
|
|
1015
|
+
}
|
|
1016
|
+
};
|
|
1017
|
+
|
|
1018
|
+
// ../../../node_modules/.pnpm/ts-pattern@5.0.6/node_modules/ts-pattern/dist/index.js
|
|
1019
|
+
var t = Symbol.for("@ts-pattern/matcher");
|
|
1020
|
+
var e = Symbol.for("@ts-pattern/isVariadic");
|
|
1021
|
+
var n = "@ts-pattern/anonymous-select-key";
|
|
1022
|
+
var r = (t2) => Boolean(t2 && "object" == typeof t2);
|
|
1023
|
+
var i = (e2) => e2 && !!e2[t];
|
|
1024
|
+
var s = (n2, o2, c2) => {
|
|
1025
|
+
if (i(n2)) {
|
|
1026
|
+
const e2 = n2[t](), { matched: r2, selections: i2 } = e2.match(o2);
|
|
1027
|
+
return r2 && i2 && Object.keys(i2).forEach((t2) => c2(t2, i2[t2])), r2;
|
|
1028
|
+
}
|
|
1029
|
+
if (r(n2)) {
|
|
1030
|
+
if (!r(o2))
|
|
1031
|
+
return false;
|
|
1032
|
+
if (Array.isArray(n2)) {
|
|
1033
|
+
if (!Array.isArray(o2))
|
|
1034
|
+
return false;
|
|
1035
|
+
let t2 = [], r2 = [], a = [];
|
|
1036
|
+
for (const s2 of n2.keys()) {
|
|
1037
|
+
const o3 = n2[s2];
|
|
1038
|
+
i(o3) && o3[e] ? a.push(o3) : a.length ? r2.push(o3) : t2.push(o3);
|
|
1039
|
+
}
|
|
1040
|
+
if (a.length) {
|
|
1041
|
+
if (a.length > 1)
|
|
1042
|
+
throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
|
|
1043
|
+
if (o2.length < t2.length + r2.length)
|
|
1044
|
+
return false;
|
|
1045
|
+
const e2 = o2.slice(0, t2.length), n3 = 0 === r2.length ? [] : o2.slice(-r2.length), i2 = o2.slice(t2.length, 0 === r2.length ? Infinity : -r2.length);
|
|
1046
|
+
return t2.every((t3, n4) => s(t3, e2[n4], c2)) && r2.every((t3, e3) => s(t3, n3[e3], c2)) && (0 === a.length || s(a[0], i2, c2));
|
|
1047
|
+
}
|
|
1048
|
+
return n2.length === o2.length && n2.every((t3, e2) => s(t3, o2[e2], c2));
|
|
1049
|
+
}
|
|
1050
|
+
return Object.keys(n2).every((e2) => {
|
|
1051
|
+
const r2 = n2[e2];
|
|
1052
|
+
return (e2 in o2 || i(a = r2) && "optional" === a[t]().matcherType) && s(r2, o2[e2], c2);
|
|
1053
|
+
var a;
|
|
1054
|
+
});
|
|
1055
|
+
}
|
|
1056
|
+
return Object.is(o2, n2);
|
|
1057
|
+
};
|
|
1058
|
+
var o = (e2) => {
|
|
1059
|
+
var n2, s2, a;
|
|
1060
|
+
return r(e2) ? i(e2) ? null != (n2 = null == (s2 = (a = e2[t]()).getSelectionKeys) ? void 0 : s2.call(a)) ? n2 : [] : Array.isArray(e2) ? c(e2, o) : c(Object.values(e2), o) : [];
|
|
1061
|
+
};
|
|
1062
|
+
var c = (t2, e2) => t2.reduce((t3, n2) => t3.concat(e2(n2)), []);
|
|
1063
|
+
function u(t2) {
|
|
1064
|
+
return Object.assign(t2, { optional: () => l(t2), and: (e2) => m(t2, e2), or: (e2) => y(t2, e2), select: (e2) => void 0 === e2 ? p(t2) : p(e2, t2) });
|
|
1065
|
+
}
|
|
1066
|
+
function l(e2) {
|
|
1067
|
+
return u({ [t]: () => ({ match: (t2) => {
|
|
1068
|
+
let n2 = {};
|
|
1069
|
+
const r2 = (t3, e3) => {
|
|
1070
|
+
n2[t3] = e3;
|
|
1071
|
+
};
|
|
1072
|
+
return void 0 === t2 ? (o(e2).forEach((t3) => r2(t3, void 0)), { matched: true, selections: n2 }) : { matched: s(e2, t2, r2), selections: n2 };
|
|
1073
|
+
}, getSelectionKeys: () => o(e2), matcherType: "optional" }) });
|
|
1074
|
+
}
|
|
1075
|
+
function m(...e2) {
|
|
1076
|
+
return u({ [t]: () => ({ match: (t2) => {
|
|
1077
|
+
let n2 = {};
|
|
1078
|
+
const r2 = (t3, e3) => {
|
|
1079
|
+
n2[t3] = e3;
|
|
1080
|
+
};
|
|
1081
|
+
return { matched: e2.every((e3) => s(e3, t2, r2)), selections: n2 };
|
|
1082
|
+
}, getSelectionKeys: () => c(e2, o), matcherType: "and" }) });
|
|
1083
|
+
}
|
|
1084
|
+
function y(...e2) {
|
|
1085
|
+
return u({ [t]: () => ({ match: (t2) => {
|
|
1086
|
+
let n2 = {};
|
|
1087
|
+
const r2 = (t3, e3) => {
|
|
1088
|
+
n2[t3] = e3;
|
|
1089
|
+
};
|
|
1090
|
+
return c(e2, o).forEach((t3) => r2(t3, void 0)), { matched: e2.some((e3) => s(e3, t2, r2)), selections: n2 };
|
|
1091
|
+
}, getSelectionKeys: () => c(e2, o), matcherType: "or" }) });
|
|
1092
|
+
}
|
|
1093
|
+
function d(e2) {
|
|
1094
|
+
return { [t]: () => ({ match: (t2) => ({ matched: Boolean(e2(t2)) }) }) };
|
|
1095
|
+
}
|
|
1096
|
+
function p(...e2) {
|
|
1097
|
+
const r2 = "string" == typeof e2[0] ? e2[0] : void 0, i2 = 2 === e2.length ? e2[1] : "string" == typeof e2[0] ? void 0 : e2[0];
|
|
1098
|
+
return u({ [t]: () => ({ match: (t2) => {
|
|
1099
|
+
let e3 = { [null != r2 ? r2 : n]: t2 };
|
|
1100
|
+
return { matched: void 0 === i2 || s(i2, t2, (t3, n2) => {
|
|
1101
|
+
e3[t3] = n2;
|
|
1102
|
+
}), selections: e3 };
|
|
1103
|
+
}, getSelectionKeys: () => [null != r2 ? r2 : n].concat(void 0 === i2 ? [] : o(i2)) }) });
|
|
1104
|
+
}
|
|
1105
|
+
function v(t2) {
|
|
1106
|
+
return "number" == typeof t2;
|
|
1107
|
+
}
|
|
1108
|
+
function b(t2) {
|
|
1109
|
+
return "string" == typeof t2;
|
|
1110
|
+
}
|
|
1111
|
+
function w(t2) {
|
|
1112
|
+
return "bigint" == typeof t2;
|
|
1113
|
+
}
|
|
1114
|
+
u(d(function(t2) {
|
|
1115
|
+
return true;
|
|
1116
|
+
}));
|
|
1117
|
+
var j = (t2) => Object.assign(u(t2), { startsWith: (e2) => {
|
|
1118
|
+
return j(m(t2, (n2 = e2, d((t3) => b(t3) && t3.startsWith(n2)))));
|
|
1119
|
+
var n2;
|
|
1120
|
+
}, endsWith: (e2) => {
|
|
1121
|
+
return j(m(t2, (n2 = e2, d((t3) => b(t3) && t3.endsWith(n2)))));
|
|
1122
|
+
var n2;
|
|
1123
|
+
}, minLength: (e2) => j(m(t2, ((t3) => d((e3) => b(e3) && e3.length >= t3))(e2))), maxLength: (e2) => j(m(t2, ((t3) => d((e3) => b(e3) && e3.length <= t3))(e2))), includes: (e2) => {
|
|
1124
|
+
return j(m(t2, (n2 = e2, d((t3) => b(t3) && t3.includes(n2)))));
|
|
1125
|
+
var n2;
|
|
1126
|
+
}, regex: (e2) => {
|
|
1127
|
+
return j(m(t2, (n2 = e2, d((t3) => b(t3) && Boolean(t3.match(n2))))));
|
|
1128
|
+
var n2;
|
|
1129
|
+
} });
|
|
1130
|
+
j(d(b));
|
|
1131
|
+
var K = (t2) => Object.assign(u(t2), { between: (e2, n2) => K(m(t2, ((t3, e3) => d((n3) => v(n3) && t3 <= n3 && e3 >= n3))(e2, n2))), lt: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 < t3))(e2))), gt: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 > t3))(e2))), lte: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 <= t3))(e2))), gte: (e2) => K(m(t2, ((t3) => d((e3) => v(e3) && e3 >= t3))(e2))), int: () => K(m(t2, d((t3) => v(t3) && Number.isInteger(t3)))), finite: () => K(m(t2, d((t3) => v(t3) && Number.isFinite(t3)))), positive: () => K(m(t2, d((t3) => v(t3) && t3 > 0))), negative: () => K(m(t2, d((t3) => v(t3) && t3 < 0))) });
|
|
1132
|
+
K(d(v));
|
|
1133
|
+
var x = (t2) => Object.assign(u(t2), { between: (e2, n2) => x(m(t2, ((t3, e3) => d((n3) => w(n3) && t3 <= n3 && e3 >= n3))(e2, n2))), lt: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 < t3))(e2))), gt: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 > t3))(e2))), lte: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 <= t3))(e2))), gte: (e2) => x(m(t2, ((t3) => d((e3) => w(e3) && e3 >= t3))(e2))), positive: () => x(m(t2, d((t3) => w(t3) && t3 > 0))), negative: () => x(m(t2, d((t3) => w(t3) && t3 < 0))) });
|
|
1134
|
+
x(d(w));
|
|
1135
|
+
u(d(function(t2) {
|
|
1136
|
+
return "boolean" == typeof t2;
|
|
1137
|
+
}));
|
|
1138
|
+
u(d(function(t2) {
|
|
1139
|
+
return "symbol" == typeof t2;
|
|
1140
|
+
}));
|
|
1141
|
+
u(d(function(t2) {
|
|
1142
|
+
return null == t2;
|
|
1143
|
+
}));
|
|
1144
|
+
var W = { matched: false, value: void 0 };
|
|
1145
|
+
function N(t2) {
|
|
1146
|
+
return new $(t2, W);
|
|
1147
|
+
}
|
|
1148
|
+
var $ = class _$ {
|
|
1149
|
+
constructor(t2, e2) {
|
|
1150
|
+
this.input = void 0, this.state = void 0, this.input = t2, this.state = e2;
|
|
1151
|
+
}
|
|
1152
|
+
with(...t2) {
|
|
1153
|
+
if (this.state.matched)
|
|
1154
|
+
return this;
|
|
1155
|
+
const e2 = t2[t2.length - 1], r2 = [t2[0]];
|
|
1156
|
+
let i2;
|
|
1157
|
+
3 === t2.length && "function" == typeof t2[1] ? i2 = t2[1] : t2.length > 2 && r2.push(...t2.slice(1, t2.length - 1));
|
|
1158
|
+
let o2 = false, c2 = {};
|
|
1159
|
+
const a = (t3, e3) => {
|
|
1160
|
+
o2 = true, c2[t3] = e3;
|
|
1161
|
+
}, u2 = !r2.some((t3) => s(t3, this.input, a)) || i2 && !Boolean(i2(this.input)) ? W : { matched: true, value: e2(o2 ? n in c2 ? c2[n] : c2 : this.input, this.input) };
|
|
1162
|
+
return new _$(this.input, u2);
|
|
1163
|
+
}
|
|
1164
|
+
when(t2, e2) {
|
|
1165
|
+
if (this.state.matched)
|
|
1166
|
+
return this;
|
|
1167
|
+
const n2 = Boolean(t2(this.input));
|
|
1168
|
+
return new _$(this.input, n2 ? { matched: true, value: e2(this.input, this.input) } : W);
|
|
1169
|
+
}
|
|
1170
|
+
otherwise(t2) {
|
|
1171
|
+
return this.state.matched ? this.state.value : t2(this.input);
|
|
1172
|
+
}
|
|
1173
|
+
exhaustive() {
|
|
1174
|
+
if (this.state.matched)
|
|
1175
|
+
return this.state.value;
|
|
1176
|
+
let t2;
|
|
1177
|
+
try {
|
|
1178
|
+
t2 = JSON.stringify(this.input);
|
|
1179
|
+
} catch (e2) {
|
|
1180
|
+
t2 = this.input;
|
|
1181
|
+
}
|
|
1182
|
+
throw new Error(`Pattern matching error: no pattern matches value ${t2}`);
|
|
1183
|
+
}
|
|
1184
|
+
run() {
|
|
1185
|
+
return this.exhaustive();
|
|
1186
|
+
}
|
|
1187
|
+
returnType() {
|
|
1188
|
+
return this;
|
|
1189
|
+
}
|
|
1190
|
+
};
|
|
1191
|
+
|
|
1192
|
+
// src/rules/ensure-use-callback-has-non-empty-deps.ts
|
|
1193
|
+
var RULE_NAME2 = "ensure-use-callback-has-non-empty-deps";
|
|
1194
|
+
var ensure_use_callback_has_non_empty_deps_default = createRule({
|
|
1195
|
+
name: RULE_NAME2,
|
|
1196
|
+
meta: {
|
|
1197
|
+
type: "problem",
|
|
1198
|
+
docs: {
|
|
1199
|
+
description: "enforce 'useCallback' has non-empty dependencies array",
|
|
1200
|
+
requiresTypeChecking: false
|
|
942
1201
|
},
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
const pragma = jsx.getPragmaFromContext(context);
|
|
947
|
-
return {
|
|
948
|
-
CallExpression (node) {
|
|
949
|
-
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope();
|
|
950
|
-
if (!core.isReactHookCall(node)) return;
|
|
951
|
-
if (!core.isUseMemoCall(node, context, pragma) && !alias.some(flip(core.isReactHookCallWithNameLoose)(node))) return;
|
|
952
|
-
const [_, deps] = node.arguments;
|
|
953
|
-
if (!deps) {
|
|
954
|
-
context.report({
|
|
955
|
-
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS",
|
|
956
|
-
node
|
|
957
|
-
});
|
|
958
|
-
return;
|
|
959
|
-
}
|
|
960
|
-
const maybeDescriptor = pipe(match(deps).with({
|
|
961
|
-
type: ast.NodeType.ArrayExpression
|
|
962
|
-
}, some).with({
|
|
963
|
-
type: ast.NodeType.Identifier
|
|
964
|
-
}, (n)=>{
|
|
965
|
-
return pipe(_var.findVariable(n.name, initialScope), flatMap(_var.getVariableInit(0)), filter(ast.is(ast.NodeType.ArrayExpression)));
|
|
966
|
-
}).otherwise(none), filter((x)=>x.elements.length === 0), map(()=>({
|
|
967
|
-
node,
|
|
968
|
-
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS"
|
|
969
|
-
})));
|
|
970
|
-
map(maybeDescriptor, context.report);
|
|
971
|
-
}
|
|
972
|
-
};
|
|
1202
|
+
schema: [],
|
|
1203
|
+
messages: {
|
|
1204
|
+
ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS: "useCallback should have a non-empty dependencies array"
|
|
973
1205
|
}
|
|
1206
|
+
},
|
|
1207
|
+
defaultOptions: [],
|
|
1208
|
+
create(context) {
|
|
1209
|
+
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useCallback ?? [];
|
|
1210
|
+
const pragma = jsx.getPragmaFromContext(context);
|
|
1211
|
+
return {
|
|
1212
|
+
CallExpression(node) {
|
|
1213
|
+
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope();
|
|
1214
|
+
if (!core.isReactHookCall(node))
|
|
1215
|
+
return;
|
|
1216
|
+
if (!core.isUseCallbackCall(node, context, pragma) && !alias.some(Function_exports.flip(core.isReactHookCallWithNameLoose)(node))) {
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
const [_, deps] = node.arguments;
|
|
1220
|
+
if (!deps) {
|
|
1221
|
+
context.report({
|
|
1222
|
+
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS",
|
|
1223
|
+
node
|
|
1224
|
+
});
|
|
1225
|
+
return;
|
|
1226
|
+
}
|
|
1227
|
+
const maybeDescriptor = Function_exports.pipe(
|
|
1228
|
+
N(deps).with({ type: ast.NodeType.ArrayExpression }, Option_exports.some).with({ type: ast.NodeType.Identifier }, (n2) => {
|
|
1229
|
+
return Function_exports.pipe(
|
|
1230
|
+
_var.findVariable(n2.name, initialScope),
|
|
1231
|
+
Option_exports.flatMap(_var.getVariableInit(0)),
|
|
1232
|
+
Option_exports.filter(ast.is(ast.NodeType.ArrayExpression))
|
|
1233
|
+
);
|
|
1234
|
+
}).otherwise(Option_exports.none),
|
|
1235
|
+
Option_exports.filter((x2) => x2.elements.length === 0),
|
|
1236
|
+
Option_exports.map(() => ({
|
|
1237
|
+
node,
|
|
1238
|
+
messageId: "ENSURE_USE_CALLBACK_HAS_NON_EMPTY_DEPS"
|
|
1239
|
+
}))
|
|
1240
|
+
);
|
|
1241
|
+
Option_exports.map(maybeDescriptor, context.report);
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
}
|
|
974
1245
|
});
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
1246
|
+
var RULE_NAME3 = "ensure-use-memo-has-non-empty-deps";
|
|
1247
|
+
var ensure_use_memo_has_non_empty_deps_default = createRule({
|
|
1248
|
+
name: RULE_NAME3,
|
|
1249
|
+
meta: {
|
|
1250
|
+
type: "problem",
|
|
1251
|
+
docs: {
|
|
1252
|
+
description: "enforce 'useMemo' has non-empty dependencies array",
|
|
1253
|
+
requiresTypeChecking: false
|
|
1254
|
+
},
|
|
1255
|
+
schema: [],
|
|
1256
|
+
messages: {
|
|
1257
|
+
ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS: "useMemo should have a non-empty dependencies array"
|
|
1258
|
+
}
|
|
1259
|
+
},
|
|
1260
|
+
defaultOptions: [],
|
|
1261
|
+
create(context) {
|
|
1262
|
+
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useMemo ?? [];
|
|
1263
|
+
const pragma = jsx.getPragmaFromContext(context);
|
|
1264
|
+
return {
|
|
1265
|
+
CallExpression(node) {
|
|
1266
|
+
const initialScope = context.sourceCode.getScope?.(node) ?? context.getScope();
|
|
1267
|
+
if (!core.isReactHookCall(node))
|
|
1268
|
+
return;
|
|
1269
|
+
if (!core.isUseMemoCall(node, context, pragma) && !alias.some(Function_exports.flip(core.isReactHookCallWithNameLoose)(node)))
|
|
1270
|
+
return;
|
|
1271
|
+
const [_, deps] = node.arguments;
|
|
1272
|
+
if (!deps) {
|
|
1273
|
+
context.report({
|
|
1274
|
+
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS",
|
|
1275
|
+
node
|
|
1276
|
+
});
|
|
1277
|
+
return;
|
|
996
1278
|
}
|
|
1279
|
+
const maybeDescriptor = Function_exports.pipe(
|
|
1280
|
+
N(deps).with({ type: ast.NodeType.ArrayExpression }, Option_exports.some).with({ type: ast.NodeType.Identifier }, (n2) => {
|
|
1281
|
+
return Function_exports.pipe(
|
|
1282
|
+
_var.findVariable(n2.name, initialScope),
|
|
1283
|
+
Option_exports.flatMap(_var.getVariableInit(0)),
|
|
1284
|
+
Option_exports.filter(ast.is(ast.NodeType.ArrayExpression))
|
|
1285
|
+
);
|
|
1286
|
+
}).otherwise(Option_exports.none),
|
|
1287
|
+
Option_exports.filter((x2) => x2.elements.length === 0),
|
|
1288
|
+
Option_exports.map(() => ({
|
|
1289
|
+
node,
|
|
1290
|
+
messageId: "ENSURE_USE_MEMO_HAS_NON_EMPTY_DEPS"
|
|
1291
|
+
}))
|
|
1292
|
+
);
|
|
1293
|
+
Option_exports.map(maybeDescriptor, context.report);
|
|
1294
|
+
}
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
});
|
|
1298
|
+
var RULE_NAME4 = "prefer-use-state-lazy-initialization";
|
|
1299
|
+
var ALLOW_LIST = Object.freeze(["Boolean", "String", "Number"]);
|
|
1300
|
+
var prefer_use_state_lazy_initialization_default = createRule({
|
|
1301
|
+
name: RULE_NAME4,
|
|
1302
|
+
meta: {
|
|
1303
|
+
type: "problem",
|
|
1304
|
+
docs: {
|
|
1305
|
+
description: "disallow function calls in 'useState' that aren't wrapped in an initializer function",
|
|
1306
|
+
requiresTypeChecking: false
|
|
997
1307
|
},
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
const pragma = jsx.getPragmaFromContext(context);
|
|
1002
|
-
return {
|
|
1003
|
-
CallExpression (node) {
|
|
1004
|
-
if (!core.isReactHookCall(node)) return;
|
|
1005
|
-
if (!core.isUseStateCall(node, context, pragma) && !alias.some(flip(core.isReactHookCallWithNameLoose)(node))) return;
|
|
1006
|
-
const [useStateInput] = node.arguments;
|
|
1007
|
-
if (!useStateInput) return;
|
|
1008
|
-
const nestedCallExpressions = ast.getNestedCallExpressions(useStateInput);
|
|
1009
|
-
const hasFunctionCall = nestedCallExpressions.some((n)=>{
|
|
1010
|
-
return "name" in n.callee && !ALLOW_LIST.includes(n.callee.name);
|
|
1011
|
-
});
|
|
1012
|
-
if (!hasFunctionCall) return;
|
|
1013
|
-
context.report({
|
|
1014
|
-
node: useStateInput,
|
|
1015
|
-
messageId: "PREFER_USE_STATE_LAZY_INITIALIZATION"
|
|
1016
|
-
});
|
|
1017
|
-
}
|
|
1018
|
-
};
|
|
1308
|
+
schema: [],
|
|
1309
|
+
messages: {
|
|
1310
|
+
PREFER_USE_STATE_LAZY_INITIALIZATION: "To prevent re-computation, consider using lazy initial state for useState calls that involve function calls. Ex: 'useState(() => getValue())'"
|
|
1019
1311
|
}
|
|
1312
|
+
},
|
|
1313
|
+
defaultOptions: [],
|
|
1314
|
+
create(context) {
|
|
1315
|
+
const alias = shared.parseSchema(shared.ESLintSettingsSchema, context.settings).reactOptions?.additionalHooks?.useState ?? [];
|
|
1316
|
+
const pragma = jsx.getPragmaFromContext(context);
|
|
1317
|
+
return {
|
|
1318
|
+
CallExpression(node) {
|
|
1319
|
+
if (!core.isReactHookCall(node))
|
|
1320
|
+
return;
|
|
1321
|
+
if (!core.isUseStateCall(node, context, pragma) && !alias.some(Function_exports.flip(core.isReactHookCallWithNameLoose)(node)))
|
|
1322
|
+
return;
|
|
1323
|
+
const [useStateInput] = node.arguments;
|
|
1324
|
+
if (!useStateInput)
|
|
1325
|
+
return;
|
|
1326
|
+
const nestedCallExpressions = ast.getNestedCallExpressions(useStateInput);
|
|
1327
|
+
const hasFunctionCall = nestedCallExpressions.some((n2) => {
|
|
1328
|
+
return "name" in n2.callee && !ALLOW_LIST.includes(n2.callee.name);
|
|
1329
|
+
});
|
|
1330
|
+
if (!hasFunctionCall)
|
|
1331
|
+
return;
|
|
1332
|
+
context.report({
|
|
1333
|
+
node: useStateInput,
|
|
1334
|
+
messageId: "PREFER_USE_STATE_LAZY_INITIALIZATION"
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
};
|
|
1338
|
+
}
|
|
1020
1339
|
});
|
|
1021
1340
|
|
|
1022
|
-
//
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
version
|
|
1341
|
+
// src/index.ts
|
|
1342
|
+
var meta = {
|
|
1343
|
+
name,
|
|
1344
|
+
version
|
|
1027
1345
|
};
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1346
|
+
var rules = {
|
|
1347
|
+
"ensure-custom-hooks-using-other-hooks": ensure_custom_hooks_using_other_hooks_default,
|
|
1348
|
+
"ensure-use-callback-has-non-empty-deps": ensure_use_callback_has_non_empty_deps_default,
|
|
1349
|
+
"ensure-use-memo-has-non-empty-deps": ensure_use_memo_has_non_empty_deps_default,
|
|
1350
|
+
"prefer-use-state-lazy-initialization": prefer_use_state_lazy_initialization_default
|
|
1033
1351
|
};
|
|
1034
1352
|
|
|
1035
1353
|
exports.meta = meta;
|