@eslint-react/jsx 0.6.0 → 0.6.2

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.mjs CHANGED
@@ -468,9 +468,10 @@ var effectFunction_esm = /*#__PURE__*/ Object.freeze({
468
468
  unsafeCoerce: unsafeCoerce,
469
469
  untupled: untupled
470
470
  });
471
+ const moduleVersion = "2.0.0-next.54";
471
472
  /**
472
473
  * @since 2.0.0
473
- */ const globalStoreId = /*#__PURE__*/ Symbol.for("effect/GlobalValue/globalStoreId");
474
+ */ const globalStoreId = /*#__PURE__*/ Symbol.for(`effect/GlobalValue/globalStoreId/${moduleVersion}`);
474
475
  if (!(globalStoreId in globalThis)) {
475
476
  globalThis[globalStoreId] = /*#__PURE__*/ new Map();
476
477
  }
@@ -514,7 +515,35 @@ const globalStore = globalThis[globalStoreId];
514
515
  *
515
516
  * @category guards
516
517
  * @since 2.0.0
517
- */ const isObject = (input)=>typeof input === "object" && input != null || isFunction(input);
518
+ */ const isObject = (input)=>typeof input === "object" && input !== null || isFunction(input);
519
+ /**
520
+ * Checks whether a value is an `object` containing a specified property key.
521
+ *
522
+ * @param property - The field to check within the object.
523
+ * @param self - The value to examine.
524
+ *
525
+ * @category guards
526
+ * @since 2.0.0
527
+ */ const hasProperty = /*#__PURE__*/ dual(2, (self, property)=>isObject(self) && property in self);
528
+ /**
529
+ * Tests if a value is an `object` with a property `_tag` that matches the given tag.
530
+ *
531
+ * @param input - The value to test.
532
+ * @param tag - The tag to test for.
533
+ *
534
+ * @example
535
+ * import { isTagged } from "effect/Predicate"
536
+ *
537
+ * assert.deepStrictEqual(isTagged(1, "a"), false)
538
+ * assert.deepStrictEqual(isTagged(null, "a"), false)
539
+ * assert.deepStrictEqual(isTagged({}, "a"), false)
540
+ * assert.deepStrictEqual(isTagged({ a: "a" }, "a"), false)
541
+ * assert.deepStrictEqual(isTagged({ _tag: "a" }, "a"), true)
542
+ * assert.deepStrictEqual(isTagged("a")({ _tag: "a" }), true)
543
+ *
544
+ * @category guards
545
+ * @since 2.0.0
546
+ */ const isTagged = /*#__PURE__*/ dual(2, (self, tag)=>hasProperty(self, "_tag") && self["_tag"] === tag);
518
547
  /**
519
548
  * A guard that succeeds when the input is `null` or `undefined`.
520
549
  *
@@ -893,7 +922,7 @@ function add64(out, aHi, aLo, bHi, bLo) {
893
922
  /**
894
923
  * @since 2.0.0
895
924
  * @category guards
896
- */ const isHash = (u)=>typeof u === "object" && u !== null && symbol$1 in u;
925
+ */ const isHash = (u)=>hasProperty(u, symbol$1);
897
926
  /**
898
927
  * @since 2.0.0
899
928
  * @category hashing
@@ -980,7 +1009,7 @@ function compareBoth(self, that) {
980
1009
  /**
981
1010
  * @since 2.0.0
982
1011
  * @category guards
983
- */ const isEqual = (u)=>typeof u === "object" && u !== null && symbol in u;
1012
+ */ const isEqual = (u)=>hasProperty(u, symbol);
984
1013
  /**
985
1014
  * @since 2.0.0
986
1015
  * @category instances
@@ -1016,7 +1045,7 @@ function compareBoth(self, that) {
1016
1045
  */ /**
1017
1046
  * @since 2.0.0
1018
1047
  */ const toJSON = (x)=>{
1019
- if (typeof x === "object" && x !== null && "toJSON" in x && typeof x["toJSON"] === "function" && x["toJSON"].length === 0) {
1048
+ if (hasProperty(x, "toJSON") && isFunction(x["toJSON"]) && x["toJSON"].length === 0) {
1020
1049
  return x.toJSON();
1021
1050
  } else if (Array.isArray(x)) {
1022
1051
  return x.map(toJSON);
@@ -1110,10 +1139,11 @@ function compareBoth(self, that) {
1110
1139
  /** @internal */ const StreamTypeId = /*#__PURE__*/ Symbol.for("effect/Stream");
1111
1140
  /** @internal */ const SinkTypeId = /*#__PURE__*/ Symbol.for("effect/Sink");
1112
1141
  /** @internal */ const ChannelTypeId = /*#__PURE__*/ Symbol.for("effect/Channel");
1113
- /** @internal */ const effectVariance$1 = {
1142
+ /** @internal */ const effectVariance = {
1114
1143
  _R: (_)=>_,
1115
1144
  _E: (_)=>_,
1116
- _A: (_)=>_
1145
+ _A: (_)=>_,
1146
+ _V: moduleVersion
1117
1147
  };
1118
1148
  /** @internal */ const sinkVariance = {
1119
1149
  _R: (_)=>_,
@@ -1132,8 +1162,8 @@ function compareBoth(self, that) {
1132
1162
  _OutDone: (_)=>_
1133
1163
  };
1134
1164
  /** @internal */ const EffectPrototype = {
1135
- [EffectTypeId$1]: effectVariance$1,
1136
- [StreamTypeId]: effectVariance$1,
1165
+ [EffectTypeId$1]: effectVariance,
1166
+ [StreamTypeId]: effectVariance,
1137
1167
  [SinkTypeId]: sinkVariance,
1138
1168
  [ChannelTypeId]: channelVariance,
1139
1169
  [symbol] (that) {
@@ -1202,7 +1232,7 @@ const NoneProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
1202
1232
  };
1203
1233
  }
1204
1234
  });
1205
- /** @internal */ const isOption$1 = (input)=>typeof input === "object" && input != null && TypeId$8 in input;
1235
+ /** @internal */ const isOption$1 = (input)=>hasProperty(input, TypeId$8);
1206
1236
  /** @internal */ const isNone$1 = (fa)=>fa._tag === "None";
1207
1237
  /** @internal */ const isSome$1 = (fa)=>fa._tag === "Some";
1208
1238
  /** @internal */ const none$1 = /*#__PURE__*/ Object.create(NoneProto);
@@ -1262,7 +1292,7 @@ const LeftProto = /*#__PURE__*/ Object.assign(/*#__PURE__*/ Object.create(Common
1262
1292
  };
1263
1293
  }
1264
1294
  });
1265
- /** @internal */ const isEither$1 = (input)=>typeof input === "object" && input != null && TypeId$7 in input;
1295
+ /** @internal */ const isEither$1 = (input)=>hasProperty(input, TypeId$7);
1266
1296
  /** @internal */ const isLeft$1 = (ma)=>ma._tag === "Left";
1267
1297
  /** @internal */ const isRight$1 = (ma)=>ma._tag === "Right";
1268
1298
  /** @internal */ const left$1 = (left)=>{
@@ -2289,7 +2319,7 @@ const emptyArray = [];
2289
2319
  *
2290
2320
  * @category equivalence
2291
2321
  * @since 2.0.0
2292
- */ const getEquivalence$1 = (isEquivalent)=>make$7((self, that)=>toReadonlyArray$1(self).every((value, i)=>isEquivalent(value, unsafeGet(that, i))));
2322
+ */ const getEquivalence$1 = (isEquivalent)=>make$7((self, that)=>self.length === that.length && toReadonlyArray$1(self).every((value, i)=>isEquivalent(value, unsafeGet(that, i))));
2293
2323
  const _equivalence$1 = /*#__PURE__*/ getEquivalence$1(equals);
2294
2324
  const ChunkProto = {
2295
2325
  [TypeId$4]: {
@@ -2385,7 +2415,7 @@ const makeChunk = (backing)=>{
2385
2415
  *
2386
2416
  * @category constructors
2387
2417
  * @since 2.0.0
2388
- */ const isChunk = (u)=>isObject(u) && TypeId$4 in u;
2418
+ */ const isChunk = (u)=>hasProperty(u, TypeId$4);
2389
2419
  const _empty$4 = /*#__PURE__*/ makeChunk({
2390
2420
  _tag: "IEmpty"
2391
2421
  });
@@ -2713,7 +2743,7 @@ const copyToArray = (self, array, initial)=>{
2713
2743
  ...EffectPrototype,
2714
2744
  _tag: "Tag",
2715
2745
  _op: "Tag",
2716
- [STMTypeId]: effectVariance$1,
2746
+ [STMTypeId]: effectVariance,
2717
2747
  [TagTypeId]: {
2718
2748
  _S: (_)=>_,
2719
2749
  _I: (_)=>_
@@ -2801,7 +2831,7 @@ const tagRegistry = /*#__PURE__*/ globalValue("effect/Context/Tag/tagRegistry",
2801
2831
  context.unsafeMap = unsafeMap;
2802
2832
  return context;
2803
2833
  };
2804
- /** @internal */ const isContext = (u)=>typeof u === "object" && u !== null && TypeId$3 in u;
2834
+ /** @internal */ const isContext = (u)=>hasProperty(u, TypeId$3);
2805
2835
  const _empty$3 = /*#__PURE__*/ makeContext(/*#__PURE__*/ new Map());
2806
2836
  /** @internal */ const empty$7 = ()=>_empty$3;
2807
2837
  /** @internal */ const make$4 = (tag, service)=>makeContext(new Map([
@@ -3089,7 +3119,7 @@ const makeUpdateService = (tag, update)=>{
3089
3119
  }
3090
3120
  }
3091
3121
  /** @internal */ function isEmptyNode(a) {
3092
- return typeof a === "object" && a !== null && "_tag" in a && a._tag === "EmptyNode";
3122
+ return isTagged(a, "EmptyNode");
3093
3123
  }
3094
3124
  /** @internal */ function isLeafNode(node) {
3095
3125
  return isEmptyNode(node) || node._tag === "LeafNode" || node._tag === "CollisionNode";
@@ -3440,7 +3470,7 @@ const visitLazyChildren = (len, children, i, f, cont)=>{
3440
3470
  };
3441
3471
  const _empty$1 = /*#__PURE__*/ makeImpl$1(false, 0, /*#__PURE__*/ new EmptyNode(), 0);
3442
3472
  /** @internal */ const empty$4 = ()=>_empty$1;
3443
- /** @internal */ const isHashMap = (u)=>isObject(u) && HashMapTypeId in u;
3473
+ /** @internal */ const isHashMap = (u)=>hasProperty(u, HashMapTypeId);
3444
3474
  /** @internal */ const getHash = /*#__PURE__*/ dual(3, (self, key, hash)=>{
3445
3475
  let node = self._root;
3446
3476
  let shift = 0;
@@ -3574,7 +3604,7 @@ const _empty$1 = /*#__PURE__*/ makeImpl$1(false, 0, /*#__PURE__*/ new EmptyNode(
3574
3604
  set._keyMap = keyMap;
3575
3605
  return set;
3576
3606
  };
3577
- /** @internal */ const isHashSet = (u)=>isObject(u) && HashSetTypeId in u;
3607
+ /** @internal */ const isHashSet = (u)=>hasProperty(u, HashSetTypeId);
3578
3608
  const _empty = /*#__PURE__*/ makeImpl(/*#__PURE__*/ empty$4());
3579
3609
  /** @internal */ const empty$3 = ()=>_empty;
3580
3610
  /** @internal */ const size$2 = (self)=>size$3(self._keyMap);
@@ -3905,7 +3935,7 @@ var effectMutableRef_esm = /*#__PURE__*/ Object.freeze({
3905
3935
  // -----------------------------------------------------------------------------
3906
3936
  // Refinements
3907
3937
  // -----------------------------------------------------------------------------
3908
- /** @internal */ const isCause = (u)=>typeof u === "object" && u != null && CauseTypeId in u;
3938
+ /** @internal */ const isCause = (u)=>hasProperty(u, CauseTypeId);
3909
3939
  /** @internal */ const isInterruptedOnly = (self)=>reduceWithContext(undefined, IsInterruptedOnlyCauseReducer)(self);
3910
3940
  /** @internal */ const causeEquals = (left, right)=>{
3911
3941
  let leftStack = of$1(left);
@@ -4275,7 +4305,7 @@ class PrettyError {
4275
4305
  return `Error: ${u}`;
4276
4306
  }
4277
4307
  // 2)
4278
- if (typeof u === "object" && u != null && "toString" in u && typeof u["toString"] === "function" && u["toString"] !== Object.prototype.toString) {
4308
+ if (hasProperty(u, "toString") && isFunction(u["toString"]) && u["toString"] !== Object.prototype.toString) {
4279
4309
  return u["toString"]();
4280
4310
  }
4281
4311
  // 3)
@@ -4283,8 +4313,8 @@ class PrettyError {
4283
4313
  };
4284
4314
  const spanSymbol$1 = /*#__PURE__*/ Symbol.for("effect/SpanAnnotation");
4285
4315
  const defaultRenderError = (error)=>{
4286
- const span = typeof error === "object" && error !== null && spanSymbol$1 in error && error[spanSymbol$1];
4287
- if (typeof error === "object" && error !== null && error instanceof Error) {
4316
+ const span = hasProperty(error, spanSymbol$1) && error[spanSymbol$1];
4317
+ if (error instanceof Error) {
4288
4318
  return new PrettyError(prettyErrorMessage(error), error.stack?.split("\n").filter((_)=>_.match(/at (.*)/)).join("\n"), span);
4289
4319
  }
4290
4320
  return new PrettyError(prettyErrorMessage(error), void 0, span);
@@ -4384,11 +4414,6 @@ const defaultRenderError = (error)=>{
4384
4414
  return this.toJSON();
4385
4415
  }
4386
4416
  }
4387
- /** @internal */ const effectVariance = {
4388
- _R: (_)=>_,
4389
- _E: (_)=>_,
4390
- _A: (_)=>_
4391
- };
4392
4417
  /* @internal */ const withFiberRuntime = (withRuntime)=>{
4393
4418
  const effect = new EffectPrimitive(OP_WITH_RUNTIME);
4394
4419
  effect.i0 = withRuntime;
@@ -4416,7 +4441,7 @@ const originalSymbol = /*#__PURE__*/ Symbol.for("effect/OriginalAnnotation");
4416
4441
  }
4417
4442
  return obj;
4418
4443
  };
4419
- /* @internal */ const fail$1 = (error)=>typeof error === "object" && error !== null && !(spanSymbol in error) ? withFiberRuntime((fiber)=>failCause(fail$2(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail$2(error));
4444
+ /* @internal */ const fail$1 = (error)=>isObject(error) && !(spanSymbol in error) ? withFiberRuntime((fiber)=>failCause(fail$2(capture(error, currentSpanFromFiber(fiber))))) : failCause(fail$2(error));
4420
4445
  /* @internal */ const failCause = (cause)=>{
4421
4446
  const effect = new EffectPrimitiveFailure(OP_FAILURE);
4422
4447
  effect.i0 = cause;
@@ -4462,14 +4487,14 @@ const originalSymbol = /*#__PURE__*/ Symbol.for("effect/OriginalAnnotation");
4462
4487
  *
4463
4488
  * @see https://github.com/oven-sh/bun/issues/3333
4464
4489
  */ /** @internal */ typeof process === "undefined" ? false : !!process?.isBun;
4465
- /**
4466
- * @since 2.0.0
4467
- * @category constructors
4468
- */ const fail = fail$1;
4469
4490
  /**
4470
4491
  * @since 2.0.0
4471
4492
  * @category prototypes
4472
4493
  */ const StructuralCommitPrototype = StructuralCommitPrototype$1;
4494
+ /**
4495
+ * @since 2.0.0
4496
+ * @category constructors
4497
+ */ const fail = fail$1;
4473
4498
  /**
4474
4499
  * @since 2.0.0
4475
4500
  */ /**
@@ -4754,350 +4779,14 @@ function isNil(x){
4754
4779
  return x === undefined || x === null
4755
4780
  }
4756
4781
 
4757
- /**
4758
- * Tests if a value is a `string`.
4759
- *
4760
- * @param input - The value to test.
4761
- *
4762
- * @example
4763
- * import { isString } from "effect/Predicate"
4764
- *
4765
- * assert.deepStrictEqual(isString("a"), true)
4766
- *
4767
- * assert.deepStrictEqual(isString(1), false)
4768
- *
4769
- * @category guards
4770
- * @since 2.0.0
4771
- */ const isString$1 = (input)=>typeof input === "string";
4772
- const t$1 = Symbol.for("@ts-pattern/matcher"), e$1 = Symbol.for("@ts-pattern/isVariadic"), n$1 = "@ts-pattern/anonymous-select-key", r$1 = (t)=>Boolean(t && "object" == typeof t), i$1 = (e)=>e && !!e[t$1], s$1 = (n, o, c)=>{
4773
- if (i$1(n)) {
4774
- const e = n[t$1](), { matched: r, selections: i } = e.match(o);
4775
- return r && i && Object.keys(i).forEach((t)=>c(t, i[t])), r;
4776
- }
4777
- if (r$1(n)) {
4778
- if (!r$1(o)) return !1;
4779
- if (Array.isArray(n)) {
4780
- if (!Array.isArray(o)) return !1;
4781
- let t = [], r = [], a = [];
4782
- for (const s of n.keys()){
4783
- const o = n[s];
4784
- i$1(o) && o[e$1] ? a.push(o) : a.length ? r.push(o) : t.push(o);
4785
- }
4786
- if (a.length) {
4787
- if (a.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
4788
- if (o.length < t.length + r.length) return !1;
4789
- const e = o.slice(0, t.length), n = 0 === r.length ? [] : o.slice(-r.length), i = o.slice(t.length, 0 === r.length ? Infinity : -r.length);
4790
- return t.every((t, n)=>s$1(t, e[n], c)) && r.every((t, e)=>s$1(t, n[e], c)) && (0 === a.length || s$1(a[0], i, c));
4791
- }
4792
- return n.length === o.length && n.every((t, e)=>s$1(t, o[e], c));
4793
- }
4794
- return Object.keys(n).every((e)=>{
4795
- const r = n[e];
4796
- return (e in o || i$1(a = r) && "optional" === a[t$1]().matcherType) && s$1(r, o[e], c);
4797
- var a;
4798
- });
4799
- }
4800
- return Object.is(o, n);
4801
- }, o$1 = (e)=>{
4802
- var n, s, a;
4803
- return r$1(e) ? i$1(e) ? null != (n = null == (s = (a = e[t$1]()).getSelectionKeys) ? void 0 : s.call(a)) ? n : [] : Array.isArray(e) ? c$1(e, o$1) : c$1(Object.values(e), o$1) : [];
4804
- }, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
4805
- function u$1(t) {
4806
- return Object.assign(t, {
4807
- optional: ()=>l$1(t),
4808
- and: (e)=>m$1(t, e),
4809
- or: (e)=>y$1(t, e),
4810
- select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
4811
- });
4812
- }
4813
- function l$1(e) {
4814
- return u$1({
4815
- [t$1]: ()=>({
4816
- match: (t)=>{
4817
- let n = {};
4818
- const r = (t, e)=>{
4819
- n[t] = e;
4820
- };
4821
- return void 0 === t ? (o$1(e).forEach((t)=>r(t, void 0)), {
4822
- matched: !0,
4823
- selections: n
4824
- }) : {
4825
- matched: s$1(e, t, r),
4826
- selections: n
4827
- };
4828
- },
4829
- getSelectionKeys: ()=>o$1(e),
4830
- matcherType: "optional"
4831
- })
4832
- });
4833
- }
4834
- function m$1(...e) {
4835
- return u$1({
4836
- [t$1]: ()=>({
4837
- match: (t)=>{
4838
- let n = {};
4839
- const r = (t, e)=>{
4840
- n[t] = e;
4841
- };
4842
- return {
4843
- matched: e.every((e)=>s$1(e, t, r)),
4844
- selections: n
4845
- };
4846
- },
4847
- getSelectionKeys: ()=>c$1(e, o$1),
4848
- matcherType: "and"
4849
- })
4850
- });
4851
- }
4852
- function y$1(...e) {
4853
- return u$1({
4854
- [t$1]: ()=>({
4855
- match: (t)=>{
4856
- let n = {};
4857
- const r = (t, e)=>{
4858
- n[t] = e;
4859
- };
4860
- return c$1(e, o$1).forEach((t)=>r(t, void 0)), {
4861
- matched: e.some((e)=>s$1(e, t, r)),
4862
- selections: n
4863
- };
4864
- },
4865
- getSelectionKeys: ()=>c$1(e, o$1),
4866
- matcherType: "or"
4867
- })
4868
- });
4869
- }
4870
- function d$1(e) {
4871
- return {
4872
- [t$1]: ()=>({
4873
- match: (t)=>({
4874
- matched: Boolean(e(t))
4875
- })
4876
- })
4877
- };
4878
- }
4879
- function p$1(...e) {
4880
- const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
4881
- return u$1({
4882
- [t$1]: ()=>({
4883
- match: (t)=>{
4884
- let e = {
4885
- [null != r ? r : n$1]: t
4886
- };
4887
- return {
4888
- matched: void 0 === i || s$1(i, t, (t, n)=>{
4889
- e[t] = n;
4890
- }),
4891
- selections: e
4892
- };
4893
- },
4894
- getSelectionKeys: ()=>[
4895
- null != r ? r : n$1
4896
- ].concat(void 0 === i ? [] : o$1(i))
4897
- })
4898
- });
4899
- }
4900
- function v$1(t) {
4901
- return "number" == typeof t;
4902
- }
4903
- function b$1(t) {
4904
- return "string" == typeof t;
4905
- }
4906
- function w$1(t) {
4907
- return "bigint" == typeof t;
4908
- }
4909
- u$1(d$1(function(t) {
4910
- return !0;
4911
- }));
4912
- const j$1 = (t)=>Object.assign(u$1(t), {
4913
- startsWith: (e)=>{
4914
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
4915
- var n;
4916
- },
4917
- endsWith: (e)=>{
4918
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.endsWith(n)))));
4919
- var n;
4920
- },
4921
- minLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length >= t))(e))),
4922
- maxLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length <= t))(e))),
4923
- includes: (e)=>{
4924
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.includes(n)))));
4925
- var n;
4926
- },
4927
- regex: (e)=>{
4928
- return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
4929
- var n;
4930
- }
4931
- });
4932
- j$1(d$1(b$1));
4933
- const K$1 = (t)=>Object.assign(u$1(t), {
4934
- between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
4935
- lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
4936
- gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
4937
- lte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e <= t))(e))),
4938
- gte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e >= t))(e))),
4939
- int: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isInteger(t)))),
4940
- finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
4941
- positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
4942
- negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
4943
- });
4944
- K$1(d$1(v$1));
4945
- const x$1 = (t)=>Object.assign(u$1(t), {
4946
- between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
4947
- lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
4948
- gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
4949
- lte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e <= t))(e))),
4950
- gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
4951
- positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
4952
- negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
4953
- });
4954
- x$1(d$1(w$1));
4955
- u$1(d$1(function(t) {
4956
- return "boolean" == typeof t;
4957
- }));
4958
- u$1(d$1(function(t) {
4959
- return "symbol" == typeof t;
4960
- }));
4961
- u$1(d$1(function(t) {
4962
- return null == t;
4963
- }));
4964
- const NodeType = AST_NODE_TYPES;
4965
- const is = ASTUtils.isNodeOfType;
4966
- const isOneOf = ASTUtils.isNodeOfTypes;
4967
- isOneOf([
4968
- NodeType.ArrowFunctionExpression,
4969
- NodeType.FunctionDeclaration,
4970
- NodeType.FunctionExpression
4971
- ]);
4972
- isOneOf([
4973
- NodeType.ArrowFunctionExpression,
4974
- NodeType.FunctionDeclaration,
4975
- NodeType.FunctionExpression,
4976
- NodeType.TSCallSignatureDeclaration,
4977
- NodeType.TSConstructSignatureDeclaration,
4978
- NodeType.TSDeclareFunction,
4979
- NodeType.TSEmptyBodyFunctionExpression,
4980
- NodeType.TSFunctionType,
4981
- NodeType.TSMethodSignature
4982
- ]);
4983
- isOneOf([
4984
- NodeType.ClassDeclaration,
4985
- NodeType.ClassExpression
4986
- ]);
4987
- isOneOf([
4988
- NodeType.DoWhileStatement,
4989
- NodeType.ForInStatement,
4990
- NodeType.ForOfStatement,
4991
- NodeType.ForStatement,
4992
- NodeType.WhileStatement
4993
- ]);
4994
- isOneOf([
4995
- NodeType.TSArrayType,
4996
- NodeType.TSTupleType
4997
- ]);
4998
- isOneOf([
4999
- NodeType.PropertyDefinition,
5000
- NodeType.TSIndexSignature,
5001
- NodeType.TSParameterProperty,
5002
- NodeType.TSPropertySignature
5003
- ]);
5004
- is(NodeType.JSXElement);
5005
- is(NodeType.JSXFragment);
5006
- isOneOf([
5007
- NodeType.JSXAttribute,
5008
- NodeType.JSXSpreadChild,
5009
- NodeType.JSXClosingElement,
5010
- NodeType.JSXClosingFragment,
5011
- NodeType.JSXElement,
5012
- NodeType.JSXEmptyExpression,
5013
- NodeType.JSXExpressionContainer,
5014
- NodeType.JSXFragment,
5015
- NodeType.JSXIdentifier,
5016
- NodeType.JSXMemberExpression,
5017
- NodeType.JSXNamespacedName,
5018
- NodeType.JSXOpeningElement,
5019
- NodeType.JSXOpeningFragment,
5020
- NodeType.JSXSpreadAttribute,
5021
- NodeType.JSXSpreadChild,
5022
- NodeType.JSXText
5023
- ]);
5024
- const isJSXTagNameExpression = isOneOf([
5025
- NodeType.JSXIdentifier,
5026
- NodeType.JSXMemberExpression,
5027
- NodeType.JSXNamespacedName
5028
- ]);
5029
- isOneOf([
5030
- NodeType.ArrayPattern,
5031
- NodeType.AssignmentPattern,
5032
- NodeType.ObjectPattern,
5033
- NodeType.RestElement
5034
- ]);
5035
- isOneOf([
5036
- NodeType.TSInterfaceDeclaration,
5037
- NodeType.TSTypeAliasDeclaration
5038
- ]);
5039
- isOneOf([
5040
- NodeType.ArrayExpression,
5041
- NodeType.ArrayPattern,
5042
- NodeType.ArrowFunctionExpression,
5043
- NodeType.CallExpression,
5044
- NodeType.ClassExpression,
5045
- NodeType.FunctionExpression,
5046
- NodeType.Identifier,
5047
- NodeType.JSXElement,
5048
- NodeType.JSXFragment,
5049
- NodeType.Literal,
5050
- NodeType.TemplateLiteral,
5051
- NodeType.MemberExpression,
5052
- NodeType.MetaProperty,
5053
- NodeType.ObjectExpression,
5054
- NodeType.ObjectPattern,
5055
- NodeType.SequenceExpression,
5056
- NodeType.Super,
5057
- NodeType.TaggedTemplateExpression,
5058
- NodeType.ThisExpression
5059
- ]);
5060
- isOneOf([
5061
- NodeType.ArrayExpression,
5062
- NodeType.ArrayPattern,
5063
- NodeType.ArrowFunctionExpression,
5064
- NodeType.CallExpression,
5065
- NodeType.ClassExpression,
5066
- NodeType.FunctionExpression,
5067
- NodeType.Identifier,
5068
- NodeType.JSXElement,
5069
- NodeType.JSXFragment,
5070
- NodeType.Literal,
5071
- NodeType.TemplateLiteral,
5072
- NodeType.MemberExpression,
5073
- NodeType.MetaProperty,
5074
- NodeType.ObjectExpression,
5075
- NodeType.ObjectPattern,
5076
- NodeType.SequenceExpression,
5077
- NodeType.Super,
5078
- NodeType.TaggedTemplateExpression,
5079
- NodeType.ThisExpression,
5080
- NodeType.TSAsExpression,
5081
- NodeType.TSNonNullExpression,
5082
- NodeType.TSTypeAssertion
5083
- ]);
5084
- const Construction = effectData_esm.taggedEnum();
5085
- Construction.None();
5086
- [
5087
- NodeType.JSXElement,
5088
- NodeType.ArrayExpression,
5089
- NodeType.ObjectExpression,
5090
- NodeType.FunctionExpression,
5091
- NodeType.ArrowFunctionExpression,
5092
- NodeType.ClassExpression,
5093
- NodeType.NewExpression,
5094
- NodeType.CallExpression
5095
- ];
5096
4782
  /**
5097
4783
  * @typedef {{ readonly [type: string]: ReadonlyArray<string> }} VisitorKeys
5098
- */ /**
4784
+ */
4785
+
4786
+ /**
5099
4787
  * @type {VisitorKeys}
5100
- */ const KEYS = {
4788
+ */
4789
+ const KEYS = {
5101
4790
  ArrayExpression: [
5102
4791
  "elements"
5103
4792
  ],
@@ -5394,187 +5083,232 @@ Construction.None();
5394
5083
  "argument"
5395
5084
  ]
5396
5085
  };
5086
+
5397
5087
  // Types.
5398
5088
  const NODE_TYPES = Object.keys(KEYS);
5089
+
5399
5090
  // Freeze the keys.
5400
- for (const type of NODE_TYPES){
5091
+ for (const type of NODE_TYPES) {
5401
5092
  Object.freeze(KEYS[type]);
5402
5093
  }
5403
5094
  Object.freeze(KEYS);
5095
+
5404
5096
  /**
5405
5097
  * @author Toru Nagashima <https://github.com/mysticatea>
5406
5098
  * See LICENSE file in root directory for full license.
5407
- */ /**
5099
+ */
5100
+
5101
+ /**
5408
5102
  * @typedef {import('./visitor-keys.js').VisitorKeys} VisitorKeys
5409
- */ // List to ignore keys.
5103
+ */
5104
+
5105
+ // List to ignore keys.
5410
5106
  const KEY_BLACKLIST = new Set([
5411
5107
  "parent",
5412
5108
  "leadingComments",
5413
5109
  "trailingComments"
5414
5110
  ]);
5111
+
5415
5112
  /**
5416
5113
  * Check whether a given key should be used or not.
5417
5114
  * @param {string} key The key to check.
5418
5115
  * @returns {boolean} `true` if the key should be used.
5419
- */ function filterKey(key) {
5116
+ */
5117
+ function filterKey(key) {
5420
5118
  return !KEY_BLACKLIST.has(key) && key[0] !== "_";
5421
5119
  }
5120
+
5422
5121
  /**
5423
5122
  * Get visitor keys of a given node.
5424
5123
  * @param {object} node The AST node to get keys.
5425
5124
  * @returns {readonly string[]} Visitor keys of the node.
5426
- */ function getKeys(node) {
5125
+ */
5126
+ function getKeys(node) {
5427
5127
  return Object.keys(node).filter(filterKey);
5428
5128
  }
5129
+
5429
5130
  /**
5430
5131
  * Get the innermost scope which contains a given location.
5431
5132
  * @param {Scope} initialScope The initial scope to search.
5432
5133
  * @param {Node} node The location to search.
5433
5134
  * @returns {Scope} The innermost scope.
5434
- */ function getInnermostScope(initialScope, node) {
5135
+ */
5136
+ function getInnermostScope(initialScope, node) {
5435
5137
  const location = node.range[0];
5138
+
5436
5139
  let scope = initialScope;
5437
5140
  let found = false;
5438
5141
  do {
5439
5142
  found = false;
5440
- for (const childScope of scope.childScopes){
5143
+ for (const childScope of scope.childScopes) {
5441
5144
  const range = childScope.block.range;
5145
+
5442
5146
  if (range[0] <= location && location < range[1]) {
5443
5147
  scope = childScope;
5444
5148
  found = true;
5445
- break;
5149
+ break
5446
5150
  }
5447
5151
  }
5448
- }while (found)
5449
- return scope;
5152
+ } while (found)
5153
+
5154
+ return scope
5450
5155
  }
5156
+
5451
5157
  /**
5452
5158
  * Find the variable of a given name.
5453
5159
  * @param {Scope} initialScope The scope to start finding.
5454
5160
  * @param {string|Node} nameOrNode The variable name to find. If this is a Node object then it should be an Identifier node.
5455
5161
  * @returns {Variable|null} The found variable or null.
5456
- */ function findVariable(initialScope, nameOrNode) {
5162
+ */
5163
+ function findVariable(initialScope, nameOrNode) {
5457
5164
  let name = "";
5458
5165
  let scope = initialScope;
5166
+
5459
5167
  if (typeof nameOrNode === "string") {
5460
5168
  name = nameOrNode;
5461
5169
  } else {
5462
5170
  name = nameOrNode.name;
5463
5171
  scope = getInnermostScope(scope, nameOrNode);
5464
5172
  }
5465
- while(scope != null){
5173
+
5174
+ while (scope != null) {
5466
5175
  const variable = scope.set.get(name);
5467
5176
  if (variable != null) {
5468
- return variable;
5177
+ return variable
5469
5178
  }
5470
5179
  scope = scope.upper;
5471
5180
  }
5472
- return null;
5181
+
5182
+ return null
5473
5183
  }
5184
+
5474
5185
  /**
5475
5186
  * Negate the result of `this` calling.
5476
5187
  * @param {Token} token The token to check.
5477
5188
  * @returns {boolean} `true` if the result of `this(token)` is `false`.
5478
- */ function negate0(token) {
5189
+ */
5190
+ function negate0(token) {
5479
5191
  return !this(token) //eslint-disable-line no-invalid-this
5480
- ;
5481
5192
  }
5193
+
5482
5194
  /**
5483
5195
  * Creates the negate function of the given function.
5484
5196
  * @param {function(Token):boolean} f - The function to negate.
5485
5197
  * @returns {function(Token):boolean} Negated function.
5486
- */ function negate(f) {
5487
- return negate0.bind(f);
5198
+ */
5199
+ function negate(f) {
5200
+ return negate0.bind(f)
5488
5201
  }
5202
+
5489
5203
  /**
5490
5204
  * Checks if the given token is a PunctuatorToken with the given value
5491
5205
  * @param {Token} token - The token to check.
5492
5206
  * @param {string} value - The value to check.
5493
5207
  * @returns {boolean} `true` if the token is a PunctuatorToken with the given value.
5494
- */ function isPunctuatorTokenWithValue(token, value) {
5495
- return token.type === "Punctuator" && token.value === value;
5208
+ */
5209
+ function isPunctuatorTokenWithValue(token, value) {
5210
+ return token.type === "Punctuator" && token.value === value
5496
5211
  }
5212
+
5497
5213
  /**
5498
5214
  * Checks if the given token is an arrow token or not.
5499
5215
  * @param {Token} token - The token to check.
5500
5216
  * @returns {boolean} `true` if the token is an arrow token.
5501
- */ function isArrowToken(token) {
5502
- return isPunctuatorTokenWithValue(token, "=>");
5217
+ */
5218
+ function isArrowToken(token) {
5219
+ return isPunctuatorTokenWithValue(token, "=>")
5503
5220
  }
5221
+
5504
5222
  /**
5505
5223
  * Checks if the given token is a comma token or not.
5506
5224
  * @param {Token} token - The token to check.
5507
5225
  * @returns {boolean} `true` if the token is a comma token.
5508
- */ function isCommaToken(token) {
5509
- return isPunctuatorTokenWithValue(token, ",");
5226
+ */
5227
+ function isCommaToken(token) {
5228
+ return isPunctuatorTokenWithValue(token, ",")
5510
5229
  }
5230
+
5511
5231
  /**
5512
5232
  * Checks if the given token is a semicolon token or not.
5513
5233
  * @param {Token} token - The token to check.
5514
5234
  * @returns {boolean} `true` if the token is a semicolon token.
5515
- */ function isSemicolonToken(token) {
5516
- return isPunctuatorTokenWithValue(token, ";");
5235
+ */
5236
+ function isSemicolonToken(token) {
5237
+ return isPunctuatorTokenWithValue(token, ";")
5517
5238
  }
5239
+
5518
5240
  /**
5519
5241
  * Checks if the given token is a colon token or not.
5520
5242
  * @param {Token} token - The token to check.
5521
5243
  * @returns {boolean} `true` if the token is a colon token.
5522
- */ function isColonToken(token) {
5523
- return isPunctuatorTokenWithValue(token, ":");
5244
+ */
5245
+ function isColonToken(token) {
5246
+ return isPunctuatorTokenWithValue(token, ":")
5524
5247
  }
5248
+
5525
5249
  /**
5526
5250
  * Checks if the given token is an opening parenthesis token or not.
5527
5251
  * @param {Token} token - The token to check.
5528
5252
  * @returns {boolean} `true` if the token is an opening parenthesis token.
5529
- */ function isOpeningParenToken(token) {
5530
- return isPunctuatorTokenWithValue(token, "(");
5253
+ */
5254
+ function isOpeningParenToken(token) {
5255
+ return isPunctuatorTokenWithValue(token, "(")
5531
5256
  }
5257
+
5532
5258
  /**
5533
5259
  * Checks if the given token is a closing parenthesis token or not.
5534
5260
  * @param {Token} token - The token to check.
5535
5261
  * @returns {boolean} `true` if the token is a closing parenthesis token.
5536
- */ function isClosingParenToken(token) {
5537
- return isPunctuatorTokenWithValue(token, ")");
5262
+ */
5263
+ function isClosingParenToken(token) {
5264
+ return isPunctuatorTokenWithValue(token, ")")
5538
5265
  }
5266
+
5539
5267
  /**
5540
5268
  * Checks if the given token is an opening square bracket token or not.
5541
5269
  * @param {Token} token - The token to check.
5542
5270
  * @returns {boolean} `true` if the token is an opening square bracket token.
5543
- */ function isOpeningBracketToken(token) {
5544
- return isPunctuatorTokenWithValue(token, "[");
5271
+ */
5272
+ function isOpeningBracketToken(token) {
5273
+ return isPunctuatorTokenWithValue(token, "[")
5545
5274
  }
5275
+
5546
5276
  /**
5547
5277
  * Checks if the given token is a closing square bracket token or not.
5548
5278
  * @param {Token} token - The token to check.
5549
5279
  * @returns {boolean} `true` if the token is a closing square bracket token.
5550
- */ function isClosingBracketToken(token) {
5551
- return isPunctuatorTokenWithValue(token, "]");
5280
+ */
5281
+ function isClosingBracketToken(token) {
5282
+ return isPunctuatorTokenWithValue(token, "]")
5552
5283
  }
5284
+
5553
5285
  /**
5554
5286
  * Checks if the given token is an opening brace token or not.
5555
5287
  * @param {Token} token - The token to check.
5556
5288
  * @returns {boolean} `true` if the token is an opening brace token.
5557
- */ function isOpeningBraceToken(token) {
5558
- return isPunctuatorTokenWithValue(token, "{");
5289
+ */
5290
+ function isOpeningBraceToken(token) {
5291
+ return isPunctuatorTokenWithValue(token, "{")
5559
5292
  }
5293
+
5560
5294
  /**
5561
5295
  * Checks if the given token is a closing brace token or not.
5562
5296
  * @param {Token} token - The token to check.
5563
5297
  * @returns {boolean} `true` if the token is a closing brace token.
5564
- */ function isClosingBraceToken(token) {
5565
- return isPunctuatorTokenWithValue(token, "}");
5298
+ */
5299
+ function isClosingBraceToken(token) {
5300
+ return isPunctuatorTokenWithValue(token, "}")
5566
5301
  }
5302
+
5567
5303
  /**
5568
5304
  * Checks if the given token is a comment token or not.
5569
5305
  * @param {Token} token - The token to check.
5570
5306
  * @returns {boolean} `true` if the token is a comment token.
5571
- */ function isCommentToken(token) {
5572
- return [
5573
- "Block",
5574
- "Line",
5575
- "Shebang"
5576
- ].includes(token.type);
5307
+ */
5308
+ function isCommentToken(token) {
5309
+ return ["Block", "Line", "Shebang"].includes(token.type)
5577
5310
  }
5311
+
5578
5312
  negate(isArrowToken);
5579
5313
  negate(isCommaToken);
5580
5314
  negate(isSemicolonToken);
@@ -5586,163 +5320,180 @@ negate(isClosingBracketToken);
5586
5320
  negate(isOpeningBraceToken);
5587
5321
  negate(isClosingBraceToken);
5588
5322
  negate(isCommentToken);
5589
- /* globals globalThis, global, self, window */ const globalObject = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {};
5590
- const builtinNames = Object.freeze(new Set([
5591
- "Array",
5592
- "ArrayBuffer",
5593
- "BigInt",
5594
- "BigInt64Array",
5595
- "BigUint64Array",
5596
- "Boolean",
5597
- "DataView",
5598
- "Date",
5599
- "decodeURI",
5600
- "decodeURIComponent",
5601
- "encodeURI",
5602
- "encodeURIComponent",
5603
- "escape",
5604
- "Float32Array",
5605
- "Float64Array",
5606
- "Function",
5607
- "Infinity",
5608
- "Int16Array",
5609
- "Int32Array",
5610
- "Int8Array",
5611
- "isFinite",
5612
- "isNaN",
5613
- "isPrototypeOf",
5614
- "JSON",
5615
- "Map",
5616
- "Math",
5617
- "NaN",
5618
- "Number",
5619
- "Object",
5620
- "parseFloat",
5621
- "parseInt",
5622
- "Promise",
5623
- "Proxy",
5624
- "Reflect",
5625
- "RegExp",
5626
- "Set",
5627
- "String",
5628
- "Symbol",
5629
- "Uint16Array",
5630
- "Uint32Array",
5631
- "Uint8Array",
5632
- "Uint8ClampedArray",
5633
- "undefined",
5634
- "unescape",
5635
- "WeakMap",
5636
- "WeakSet"
5637
- ]));
5638
- const callAllowed = new Set([
5639
- Array.isArray,
5640
- Array.of,
5641
- Array.prototype.at,
5642
- Array.prototype.concat,
5643
- Array.prototype.entries,
5644
- Array.prototype.every,
5645
- Array.prototype.filter,
5646
- Array.prototype.find,
5647
- Array.prototype.findIndex,
5648
- Array.prototype.flat,
5649
- Array.prototype.includes,
5650
- Array.prototype.indexOf,
5651
- Array.prototype.join,
5652
- Array.prototype.keys,
5653
- Array.prototype.lastIndexOf,
5654
- Array.prototype.slice,
5655
- Array.prototype.some,
5656
- Array.prototype.toString,
5657
- Array.prototype.values,
5658
- typeof BigInt === "function" ? BigInt : undefined,
5659
- Boolean,
5660
- Date,
5661
- Date.parse,
5662
- decodeURI,
5663
- decodeURIComponent,
5664
- encodeURI,
5665
- encodeURIComponent,
5666
- escape,
5667
- isFinite,
5668
- isNaN,
5669
- isPrototypeOf,
5670
- Map,
5671
- Map.prototype.entries,
5672
- Map.prototype.get,
5673
- Map.prototype.has,
5674
- Map.prototype.keys,
5675
- Map.prototype.values,
5676
- ...Object.getOwnPropertyNames(Math).filter((k)=>k !== "random").map((k)=>Math[k]).filter((f)=>typeof f === "function"),
5677
- Number,
5678
- Number.isFinite,
5679
- Number.isNaN,
5680
- Number.parseFloat,
5681
- Number.parseInt,
5682
- Number.prototype.toExponential,
5683
- Number.prototype.toFixed,
5684
- Number.prototype.toPrecision,
5685
- Number.prototype.toString,
5686
- Object,
5687
- Object.entries,
5688
- Object.is,
5689
- Object.isExtensible,
5690
- Object.isFrozen,
5691
- Object.isSealed,
5692
- Object.keys,
5693
- Object.values,
5694
- parseFloat,
5695
- parseInt,
5696
- RegExp,
5697
- Set,
5698
- Set.prototype.entries,
5699
- Set.prototype.has,
5700
- Set.prototype.keys,
5701
- Set.prototype.values,
5702
- String,
5703
- String.fromCharCode,
5704
- String.fromCodePoint,
5705
- String.raw,
5706
- String.prototype.at,
5707
- String.prototype.charAt,
5708
- String.prototype.charCodeAt,
5709
- String.prototype.codePointAt,
5710
- String.prototype.concat,
5711
- String.prototype.endsWith,
5712
- String.prototype.includes,
5713
- String.prototype.indexOf,
5714
- String.prototype.lastIndexOf,
5715
- String.prototype.normalize,
5716
- String.prototype.padEnd,
5717
- String.prototype.padStart,
5718
- String.prototype.slice,
5719
- String.prototype.startsWith,
5720
- String.prototype.substr,
5721
- String.prototype.substring,
5722
- String.prototype.toLowerCase,
5723
- String.prototype.toString,
5724
- String.prototype.toUpperCase,
5725
- String.prototype.trim,
5726
- String.prototype.trimEnd,
5727
- String.prototype.trimLeft,
5728
- String.prototype.trimRight,
5729
- String.prototype.trimStart,
5730
- Symbol.for,
5731
- Symbol.keyFor,
5732
- unescape
5733
- ].filter((f)=>typeof f === "function"));
5323
+
5324
+ /* globals globalThis, global, self, window */
5325
+
5326
+ const globalObject =
5327
+ typeof globalThis !== "undefined"
5328
+ ? globalThis
5329
+ : typeof self !== "undefined"
5330
+ ? self
5331
+ : typeof window !== "undefined"
5332
+ ? window
5333
+ : typeof global !== "undefined"
5334
+ ? global
5335
+ : {};
5336
+
5337
+ const builtinNames = Object.freeze(
5338
+ new Set([
5339
+ "Array",
5340
+ "ArrayBuffer",
5341
+ "BigInt",
5342
+ "BigInt64Array",
5343
+ "BigUint64Array",
5344
+ "Boolean",
5345
+ "DataView",
5346
+ "Date",
5347
+ "decodeURI",
5348
+ "decodeURIComponent",
5349
+ "encodeURI",
5350
+ "encodeURIComponent",
5351
+ "escape",
5352
+ "Float32Array",
5353
+ "Float64Array",
5354
+ "Function",
5355
+ "Infinity",
5356
+ "Int16Array",
5357
+ "Int32Array",
5358
+ "Int8Array",
5359
+ "isFinite",
5360
+ "isNaN",
5361
+ "isPrototypeOf",
5362
+ "JSON",
5363
+ "Map",
5364
+ "Math",
5365
+ "NaN",
5366
+ "Number",
5367
+ "Object",
5368
+ "parseFloat",
5369
+ "parseInt",
5370
+ "Promise",
5371
+ "Proxy",
5372
+ "Reflect",
5373
+ "RegExp",
5374
+ "Set",
5375
+ "String",
5376
+ "Symbol",
5377
+ "Uint16Array",
5378
+ "Uint32Array",
5379
+ "Uint8Array",
5380
+ "Uint8ClampedArray",
5381
+ "undefined",
5382
+ "unescape",
5383
+ "WeakMap",
5384
+ "WeakSet",
5385
+ ]),
5386
+ );
5387
+ const callAllowed = new Set(
5388
+ [
5389
+ Array.isArray,
5390
+ Array.of,
5391
+ Array.prototype.at,
5392
+ Array.prototype.concat,
5393
+ Array.prototype.entries,
5394
+ Array.prototype.every,
5395
+ Array.prototype.filter,
5396
+ Array.prototype.find,
5397
+ Array.prototype.findIndex,
5398
+ Array.prototype.flat,
5399
+ Array.prototype.includes,
5400
+ Array.prototype.indexOf,
5401
+ Array.prototype.join,
5402
+ Array.prototype.keys,
5403
+ Array.prototype.lastIndexOf,
5404
+ Array.prototype.slice,
5405
+ Array.prototype.some,
5406
+ Array.prototype.toString,
5407
+ Array.prototype.values,
5408
+ typeof BigInt === "function" ? BigInt : undefined,
5409
+ Boolean,
5410
+ Date,
5411
+ Date.parse,
5412
+ decodeURI,
5413
+ decodeURIComponent,
5414
+ encodeURI,
5415
+ encodeURIComponent,
5416
+ escape,
5417
+ isFinite,
5418
+ isNaN,
5419
+ isPrototypeOf,
5420
+ Map,
5421
+ Map.prototype.entries,
5422
+ Map.prototype.get,
5423
+ Map.prototype.has,
5424
+ Map.prototype.keys,
5425
+ Map.prototype.values,
5426
+ ...Object.getOwnPropertyNames(Math)
5427
+ .filter((k) => k !== "random")
5428
+ .map((k) => Math[k])
5429
+ .filter((f) => typeof f === "function"),
5430
+ Number,
5431
+ Number.isFinite,
5432
+ Number.isNaN,
5433
+ Number.parseFloat,
5434
+ Number.parseInt,
5435
+ Number.prototype.toExponential,
5436
+ Number.prototype.toFixed,
5437
+ Number.prototype.toPrecision,
5438
+ Number.prototype.toString,
5439
+ Object,
5440
+ Object.entries,
5441
+ Object.is,
5442
+ Object.isExtensible,
5443
+ Object.isFrozen,
5444
+ Object.isSealed,
5445
+ Object.keys,
5446
+ Object.values,
5447
+ parseFloat,
5448
+ parseInt,
5449
+ RegExp,
5450
+ Set,
5451
+ Set.prototype.entries,
5452
+ Set.prototype.has,
5453
+ Set.prototype.keys,
5454
+ Set.prototype.values,
5455
+ String,
5456
+ String.fromCharCode,
5457
+ String.fromCodePoint,
5458
+ String.raw,
5459
+ String.prototype.at,
5460
+ String.prototype.charAt,
5461
+ String.prototype.charCodeAt,
5462
+ String.prototype.codePointAt,
5463
+ String.prototype.concat,
5464
+ String.prototype.endsWith,
5465
+ String.prototype.includes,
5466
+ String.prototype.indexOf,
5467
+ String.prototype.lastIndexOf,
5468
+ String.prototype.normalize,
5469
+ String.prototype.padEnd,
5470
+ String.prototype.padStart,
5471
+ String.prototype.slice,
5472
+ String.prototype.startsWith,
5473
+ String.prototype.substr,
5474
+ String.prototype.substring,
5475
+ String.prototype.toLowerCase,
5476
+ String.prototype.toString,
5477
+ String.prototype.toUpperCase,
5478
+ String.prototype.trim,
5479
+ String.prototype.trimEnd,
5480
+ String.prototype.trimLeft,
5481
+ String.prototype.trimRight,
5482
+ String.prototype.trimStart,
5483
+ Symbol.for,
5484
+ Symbol.keyFor,
5485
+ unescape,
5486
+ ].filter((f) => typeof f === "function"),
5487
+ );
5734
5488
  const callPassThrough = new Set([
5735
5489
  Object.freeze,
5736
5490
  Object.preventExtensions,
5737
- Object.seal
5491
+ Object.seal,
5738
5492
  ]);
5739
- /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */ const getterAllowed = [
5740
- [
5741
- Map,
5742
- new Set([
5743
- "size"
5744
- ])
5745
- ],
5493
+
5494
+ /** @type {ReadonlyArray<readonly [Function, ReadonlySet<string>]>} */
5495
+ const getterAllowed = [
5496
+ [Map, new Set(["size"])],
5746
5497
  [
5747
5498
  RegExp,
5748
5499
  new Set([
@@ -5754,218 +5505,190 @@ const callPassThrough = new Set([
5754
5505
  "multiline",
5755
5506
  "source",
5756
5507
  "sticky",
5757
- "unicode"
5758
- ])
5508
+ "unicode",
5509
+ ]),
5759
5510
  ],
5760
- [
5761
- Set,
5762
- new Set([
5763
- "size"
5764
- ])
5765
- ]
5511
+ [Set, new Set(["size"])],
5766
5512
  ];
5513
+
5767
5514
  /**
5768
5515
  * Get the property descriptor.
5769
5516
  * @param {object} object The object to get.
5770
5517
  * @param {string|number|symbol} name The property name to get.
5771
- */ function getPropertyDescriptor(object, name) {
5518
+ */
5519
+ function getPropertyDescriptor(object, name) {
5772
5520
  let x = object;
5773
- while((typeof x === "object" || typeof x === "function") && x !== null){
5521
+ while ((typeof x === "object" || typeof x === "function") && x !== null) {
5774
5522
  const d = Object.getOwnPropertyDescriptor(x, name);
5775
5523
  if (d) {
5776
- return d;
5524
+ return d
5777
5525
  }
5778
5526
  x = Object.getPrototypeOf(x);
5779
5527
  }
5780
- return null;
5528
+ return null
5781
5529
  }
5530
+
5782
5531
  /**
5783
5532
  * Check if a property is getter or not.
5784
5533
  * @param {object} object The object to check.
5785
5534
  * @param {string|number|symbol} name The property name to check.
5786
- */ function isGetter(object, name) {
5535
+ */
5536
+ function isGetter(object, name) {
5787
5537
  const d = getPropertyDescriptor(object, name);
5788
- return d != null && d.get != null;
5538
+ return d != null && d.get != null
5789
5539
  }
5540
+
5790
5541
  /**
5791
5542
  * Get the element values of a given node list.
5792
5543
  * @param {Node[]} nodeList The node list to get values.
5793
5544
  * @param {Scope|undefined} initialScope The initial scope to find variables.
5794
5545
  * @returns {any[]|null} The value list if all nodes are constant. Otherwise, null.
5795
- */ function getElementValues(nodeList, initialScope) {
5546
+ */
5547
+ function getElementValues(nodeList, initialScope) {
5796
5548
  const valueList = [];
5797
- for(let i = 0; i < nodeList.length; ++i){
5549
+
5550
+ for (let i = 0; i < nodeList.length; ++i) {
5798
5551
  const elementNode = nodeList[i];
5552
+
5799
5553
  if (elementNode == null) {
5800
5554
  valueList.length = i + 1;
5801
5555
  } else if (elementNode.type === "SpreadElement") {
5802
5556
  const argument = getStaticValueR(elementNode.argument, initialScope);
5803
5557
  if (argument == null) {
5804
- return null;
5558
+ return null
5805
5559
  }
5806
5560
  valueList.push(...argument.value);
5807
5561
  } else {
5808
5562
  const element = getStaticValueR(elementNode, initialScope);
5809
5563
  if (element == null) {
5810
- return null;
5564
+ return null
5811
5565
  }
5812
5566
  valueList.push(element.value);
5813
5567
  }
5814
5568
  }
5815
- return valueList;
5569
+
5570
+ return valueList
5816
5571
  }
5572
+
5817
5573
  /**
5818
5574
  * Returns whether the given variable is never written to after initialization.
5819
5575
  * @param {import("eslint").Scope.Variable} variable
5820
5576
  * @returns {boolean}
5821
- */ function isEffectivelyConst(variable) {
5577
+ */
5578
+ function isEffectivelyConst(variable) {
5822
5579
  const refs = variable.references;
5823
- const inits = refs.filter((r)=>r.init).length;
5824
- const reads = refs.filter((r)=>r.isReadOnly()).length;
5580
+
5581
+ const inits = refs.filter((r) => r.init).length;
5582
+ const reads = refs.filter((r) => r.isReadOnly()).length;
5825
5583
  if (inits === 1 && reads + inits === refs.length) {
5826
5584
  // there is only one init and all other references only read
5827
- return true;
5585
+ return true
5828
5586
  }
5829
- return false;
5587
+ return false
5830
5588
  }
5589
+
5831
5590
  const operations = Object.freeze({
5832
- ArrayExpression (node, initialScope) {
5591
+ ArrayExpression(node, initialScope) {
5833
5592
  const elements = getElementValues(node.elements, initialScope);
5834
- return elements != null ? {
5835
- value: elements
5836
- } : null;
5593
+ return elements != null ? { value: elements } : null
5837
5594
  },
5838
- AssignmentExpression (node, initialScope) {
5595
+
5596
+ AssignmentExpression(node, initialScope) {
5839
5597
  if (node.operator === "=") {
5840
- return getStaticValueR(node.right, initialScope);
5598
+ return getStaticValueR(node.right, initialScope)
5841
5599
  }
5842
- return null;
5600
+ return null
5843
5601
  },
5602
+
5844
5603
  //eslint-disable-next-line complexity
5845
- BinaryExpression (node, initialScope) {
5604
+ BinaryExpression(node, initialScope) {
5846
5605
  if (node.operator === "in" || node.operator === "instanceof") {
5847
5606
  // Not supported.
5848
- return null;
5607
+ return null
5849
5608
  }
5609
+
5850
5610
  const left = getStaticValueR(node.left, initialScope);
5851
5611
  const right = getStaticValueR(node.right, initialScope);
5852
5612
  if (left != null && right != null) {
5853
- switch(node.operator){
5613
+ switch (node.operator) {
5854
5614
  case "==":
5855
- return {
5856
- value: left.value == right.value
5857
- } //eslint-disable-line eqeqeq
5858
- ;
5615
+ return { value: left.value == right.value } //eslint-disable-line eqeqeq
5859
5616
  case "!=":
5860
- return {
5861
- value: left.value != right.value
5862
- } //eslint-disable-line eqeqeq
5863
- ;
5617
+ return { value: left.value != right.value } //eslint-disable-line eqeqeq
5864
5618
  case "===":
5865
- return {
5866
- value: left.value === right.value
5867
- };
5619
+ return { value: left.value === right.value }
5868
5620
  case "!==":
5869
- return {
5870
- value: left.value !== right.value
5871
- };
5621
+ return { value: left.value !== right.value }
5872
5622
  case "<":
5873
- return {
5874
- value: left.value < right.value
5875
- };
5623
+ return { value: left.value < right.value }
5876
5624
  case "<=":
5877
- return {
5878
- value: left.value <= right.value
5879
- };
5625
+ return { value: left.value <= right.value }
5880
5626
  case ">":
5881
- return {
5882
- value: left.value > right.value
5883
- };
5627
+ return { value: left.value > right.value }
5884
5628
  case ">=":
5885
- return {
5886
- value: left.value >= right.value
5887
- };
5629
+ return { value: left.value >= right.value }
5888
5630
  case "<<":
5889
- return {
5890
- value: left.value << right.value
5891
- };
5631
+ return { value: left.value << right.value }
5892
5632
  case ">>":
5893
- return {
5894
- value: left.value >> right.value
5895
- };
5633
+ return { value: left.value >> right.value }
5896
5634
  case ">>>":
5897
- return {
5898
- value: left.value >>> right.value
5899
- };
5635
+ return { value: left.value >>> right.value }
5900
5636
  case "+":
5901
- return {
5902
- value: left.value + right.value
5903
- };
5637
+ return { value: left.value + right.value }
5904
5638
  case "-":
5905
- return {
5906
- value: left.value - right.value
5907
- };
5639
+ return { value: left.value - right.value }
5908
5640
  case "*":
5909
- return {
5910
- value: left.value * right.value
5911
- };
5641
+ return { value: left.value * right.value }
5912
5642
  case "/":
5913
- return {
5914
- value: left.value / right.value
5915
- };
5643
+ return { value: left.value / right.value }
5916
5644
  case "%":
5917
- return {
5918
- value: left.value % right.value
5919
- };
5645
+ return { value: left.value % right.value }
5920
5646
  case "**":
5921
- return {
5922
- value: left.value ** right.value
5923
- };
5647
+ return { value: left.value ** right.value }
5924
5648
  case "|":
5925
- return {
5926
- value: left.value | right.value
5927
- };
5649
+ return { value: left.value | right.value }
5928
5650
  case "^":
5929
- return {
5930
- value: left.value ^ right.value
5931
- };
5651
+ return { value: left.value ^ right.value }
5932
5652
  case "&":
5933
- return {
5934
- value: left.value & right.value
5935
- };
5653
+ return { value: left.value & right.value }
5654
+
5655
+ // no default
5936
5656
  }
5937
5657
  }
5938
- return null;
5658
+
5659
+ return null
5939
5660
  },
5940
- CallExpression (node, initialScope) {
5661
+
5662
+ CallExpression(node, initialScope) {
5941
5663
  const calleeNode = node.callee;
5942
5664
  const args = getElementValues(node.arguments, initialScope);
5665
+
5943
5666
  if (args != null) {
5944
5667
  if (calleeNode.type === "MemberExpression") {
5945
5668
  if (calleeNode.property.type === "PrivateIdentifier") {
5946
- return null;
5669
+ return null
5947
5670
  }
5948
5671
  const object = getStaticValueR(calleeNode.object, initialScope);
5949
5672
  if (object != null) {
5950
- if (object.value == null && (object.optional || node.optional)) {
5951
- return {
5952
- value: undefined,
5953
- optional: true
5954
- };
5673
+ if (
5674
+ object.value == null &&
5675
+ (object.optional || node.optional)
5676
+ ) {
5677
+ return { value: undefined, optional: true }
5955
5678
  }
5956
- const property = getStaticPropertyNameValue(calleeNode, initialScope);
5679
+ const property = getStaticPropertyNameValue(
5680
+ calleeNode,
5681
+ initialScope,
5682
+ );
5683
+
5957
5684
  if (property != null) {
5958
5685
  const receiver = object.value;
5959
5686
  const methodName = property.value;
5960
5687
  if (callAllowed.has(receiver[methodName])) {
5961
- return {
5962
- value: receiver[methodName](...args)
5963
- };
5688
+ return { value: receiver[methodName](...args) }
5964
5689
  }
5965
5690
  if (callPassThrough.has(receiver[methodName])) {
5966
- return {
5967
- value: args[0]
5968
- };
5691
+ return { value: args[0] }
5969
5692
  }
5970
5693
  }
5971
5694
  }
@@ -5973,409 +5696,815 @@ const operations = Object.freeze({
5973
5696
  const callee = getStaticValueR(calleeNode, initialScope);
5974
5697
  if (callee != null) {
5975
5698
  if (callee.value == null && node.optional) {
5976
- return {
5977
- value: undefined,
5978
- optional: true
5979
- };
5699
+ return { value: undefined, optional: true }
5980
5700
  }
5981
5701
  const func = callee.value;
5982
5702
  if (callAllowed.has(func)) {
5983
- return {
5984
- value: func(...args)
5985
- };
5703
+ return { value: func(...args) }
5986
5704
  }
5987
5705
  if (callPassThrough.has(func)) {
5988
- return {
5989
- value: args[0]
5990
- };
5706
+ return { value: args[0] }
5991
5707
  }
5992
5708
  }
5993
5709
  }
5994
5710
  }
5995
- return null;
5711
+
5712
+ return null
5996
5713
  },
5997
- ConditionalExpression (node, initialScope) {
5714
+
5715
+ ConditionalExpression(node, initialScope) {
5998
5716
  const test = getStaticValueR(node.test, initialScope);
5999
5717
  if (test != null) {
6000
- return test.value ? getStaticValueR(node.consequent, initialScope) : getStaticValueR(node.alternate, initialScope);
5718
+ return test.value
5719
+ ? getStaticValueR(node.consequent, initialScope)
5720
+ : getStaticValueR(node.alternate, initialScope)
6001
5721
  }
6002
- return null;
5722
+ return null
6003
5723
  },
6004
- ExpressionStatement (node, initialScope) {
6005
- return getStaticValueR(node.expression, initialScope);
5724
+
5725
+ ExpressionStatement(node, initialScope) {
5726
+ return getStaticValueR(node.expression, initialScope)
6006
5727
  },
6007
- Identifier (node, initialScope) {
5728
+
5729
+ Identifier(node, initialScope) {
6008
5730
  if (initialScope != null) {
6009
5731
  const variable = findVariable(initialScope, node);
5732
+
6010
5733
  // Built-in globals.
6011
- if (variable != null && variable.defs.length === 0 && builtinNames.has(variable.name) && variable.name in globalObject) {
6012
- return {
6013
- value: globalObject[variable.name]
6014
- };
5734
+ if (
5735
+ variable != null &&
5736
+ variable.defs.length === 0 &&
5737
+ builtinNames.has(variable.name) &&
5738
+ variable.name in globalObject
5739
+ ) {
5740
+ return { value: globalObject[variable.name] }
6015
5741
  }
5742
+
6016
5743
  // Constants.
6017
5744
  if (variable != null && variable.defs.length === 1) {
6018
5745
  const def = variable.defs[0];
6019
- if (def.parent && def.type === "Variable" && (def.parent.kind === "const" || isEffectivelyConst(variable)) && // TODO(mysticatea): don't support destructuring here.
6020
- def.node.id.type === "Identifier") {
6021
- return getStaticValueR(def.node.init, initialScope);
5746
+ if (
5747
+ def.parent &&
5748
+ def.type === "Variable" &&
5749
+ (def.parent.kind === "const" ||
5750
+ isEffectivelyConst(variable)) &&
5751
+ // TODO(mysticatea): don't support destructuring here.
5752
+ def.node.id.type === "Identifier"
5753
+ ) {
5754
+ return getStaticValueR(def.node.init, initialScope)
6022
5755
  }
6023
5756
  }
6024
5757
  }
6025
- return null;
5758
+ return null
6026
5759
  },
6027
- Literal (node) {
5760
+
5761
+ Literal(node) {
6028
5762
  //istanbul ignore if : this is implementation-specific behavior.
6029
5763
  if ((node.regex != null || node.bigint != null) && node.value == null) {
6030
5764
  // It was a RegExp/BigInt literal, but Node.js didn't support it.
6031
- return null;
5765
+ return null
6032
5766
  }
6033
- return {
6034
- value: node.value
6035
- };
5767
+ return { value: node.value }
6036
5768
  },
6037
- LogicalExpression (node, initialScope) {
5769
+
5770
+ LogicalExpression(node, initialScope) {
6038
5771
  const left = getStaticValueR(node.left, initialScope);
6039
5772
  if (left != null) {
6040
- if (node.operator === "||" && Boolean(left.value) === true || node.operator === "&&" && Boolean(left.value) === false || node.operator === "??" && left.value != null) {
6041
- return left;
5773
+ if (
5774
+ (node.operator === "||" && Boolean(left.value) === true) ||
5775
+ (node.operator === "&&" && Boolean(left.value) === false) ||
5776
+ (node.operator === "??" && left.value != null)
5777
+ ) {
5778
+ return left
6042
5779
  }
5780
+
6043
5781
  const right = getStaticValueR(node.right, initialScope);
6044
5782
  if (right != null) {
6045
- return right;
5783
+ return right
6046
5784
  }
6047
5785
  }
6048
- return null;
5786
+
5787
+ return null
6049
5788
  },
6050
- MemberExpression (node, initialScope) {
5789
+
5790
+ MemberExpression(node, initialScope) {
6051
5791
  if (node.property.type === "PrivateIdentifier") {
6052
- return null;
5792
+ return null
6053
5793
  }
6054
5794
  const object = getStaticValueR(node.object, initialScope);
6055
5795
  if (object != null) {
6056
5796
  if (object.value == null && (object.optional || node.optional)) {
6057
- return {
6058
- value: undefined,
6059
- optional: true
6060
- };
5797
+ return { value: undefined, optional: true }
6061
5798
  }
6062
5799
  const property = getStaticPropertyNameValue(node, initialScope);
5800
+
6063
5801
  if (property != null) {
6064
5802
  if (!isGetter(object.value, property.value)) {
6065
- return {
6066
- value: object.value[property.value]
6067
- };
5803
+ return { value: object.value[property.value] }
6068
5804
  }
6069
- for (const [classFn, allowed] of getterAllowed){
6070
- if (object.value instanceof classFn && allowed.has(property.value)) {
6071
- return {
6072
- value: object.value[property.value]
6073
- };
5805
+
5806
+ for (const [classFn, allowed] of getterAllowed) {
5807
+ if (
5808
+ object.value instanceof classFn &&
5809
+ allowed.has(property.value)
5810
+ ) {
5811
+ return { value: object.value[property.value] }
6074
5812
  }
6075
5813
  }
6076
5814
  }
6077
5815
  }
6078
- return null;
5816
+ return null
6079
5817
  },
6080
- ChainExpression (node, initialScope) {
5818
+
5819
+ ChainExpression(node, initialScope) {
6081
5820
  const expression = getStaticValueR(node.expression, initialScope);
6082
5821
  if (expression != null) {
6083
- return {
6084
- value: expression.value
6085
- };
5822
+ return { value: expression.value }
6086
5823
  }
6087
- return null;
5824
+ return null
6088
5825
  },
6089
- NewExpression (node, initialScope) {
5826
+
5827
+ NewExpression(node, initialScope) {
6090
5828
  const callee = getStaticValueR(node.callee, initialScope);
6091
5829
  const args = getElementValues(node.arguments, initialScope);
5830
+
6092
5831
  if (callee != null && args != null) {
6093
5832
  const Func = callee.value;
6094
5833
  if (callAllowed.has(Func)) {
6095
- return {
6096
- value: new Func(...args)
6097
- };
5834
+ return { value: new Func(...args) }
6098
5835
  }
6099
5836
  }
6100
- return null;
5837
+
5838
+ return null
6101
5839
  },
6102
- ObjectExpression (node, initialScope) {
5840
+
5841
+ ObjectExpression(node, initialScope) {
6103
5842
  const object = {};
6104
- for (const propertyNode of node.properties){
5843
+
5844
+ for (const propertyNode of node.properties) {
6105
5845
  if (propertyNode.type === "Property") {
6106
5846
  if (propertyNode.kind !== "init") {
6107
- return null;
5847
+ return null
6108
5848
  }
6109
- const key = getStaticPropertyNameValue(propertyNode, initialScope);
5849
+ const key = getStaticPropertyNameValue(
5850
+ propertyNode,
5851
+ initialScope,
5852
+ );
6110
5853
  const value = getStaticValueR(propertyNode.value, initialScope);
6111
5854
  if (key == null || value == null) {
6112
- return null;
5855
+ return null
6113
5856
  }
6114
5857
  object[key.value] = value.value;
6115
- } else if (propertyNode.type === "SpreadElement" || propertyNode.type === "ExperimentalSpreadProperty") {
6116
- const argument = getStaticValueR(propertyNode.argument, initialScope);
5858
+ } else if (
5859
+ propertyNode.type === "SpreadElement" ||
5860
+ propertyNode.type === "ExperimentalSpreadProperty"
5861
+ ) {
5862
+ const argument = getStaticValueR(
5863
+ propertyNode.argument,
5864
+ initialScope,
5865
+ );
6117
5866
  if (argument == null) {
6118
- return null;
5867
+ return null
6119
5868
  }
6120
5869
  Object.assign(object, argument.value);
6121
5870
  } else {
6122
- return null;
5871
+ return null
6123
5872
  }
6124
5873
  }
6125
- return {
6126
- value: object
6127
- };
5874
+
5875
+ return { value: object }
6128
5876
  },
6129
- SequenceExpression (node, initialScope) {
5877
+
5878
+ SequenceExpression(node, initialScope) {
6130
5879
  const last = node.expressions[node.expressions.length - 1];
6131
- return getStaticValueR(last, initialScope);
5880
+ return getStaticValueR(last, initialScope)
6132
5881
  },
6133
- TaggedTemplateExpression (node, initialScope) {
5882
+
5883
+ TaggedTemplateExpression(node, initialScope) {
6134
5884
  const tag = getStaticValueR(node.tag, initialScope);
6135
- const expressions = getElementValues(node.quasi.expressions, initialScope);
5885
+ const expressions = getElementValues(
5886
+ node.quasi.expressions,
5887
+ initialScope,
5888
+ );
5889
+
6136
5890
  if (tag != null && expressions != null) {
6137
5891
  const func = tag.value;
6138
- const strings = node.quasi.quasis.map((q)=>q.value.cooked);
6139
- strings.raw = node.quasi.quasis.map((q)=>q.value.raw);
5892
+ const strings = node.quasi.quasis.map((q) => q.value.cooked);
5893
+ strings.raw = node.quasi.quasis.map((q) => q.value.raw);
5894
+
6140
5895
  if (func === String.raw) {
6141
- return {
6142
- value: func(strings, ...expressions)
6143
- };
5896
+ return { value: func(strings, ...expressions) }
6144
5897
  }
6145
5898
  }
6146
- return null;
5899
+
5900
+ return null
6147
5901
  },
6148
- TemplateLiteral (node, initialScope) {
5902
+
5903
+ TemplateLiteral(node, initialScope) {
6149
5904
  const expressions = getElementValues(node.expressions, initialScope);
6150
5905
  if (expressions != null) {
6151
5906
  let value = node.quasis[0].value.cooked;
6152
- for(let i = 0; i < expressions.length; ++i){
5907
+ for (let i = 0; i < expressions.length; ++i) {
6153
5908
  value += expressions[i];
6154
5909
  value += node.quasis[i + 1].value.cooked;
6155
5910
  }
6156
- return {
6157
- value
6158
- };
5911
+ return { value }
6159
5912
  }
6160
- return null;
5913
+ return null
6161
5914
  },
6162
- UnaryExpression (node, initialScope) {
5915
+
5916
+ UnaryExpression(node, initialScope) {
6163
5917
  if (node.operator === "delete") {
6164
5918
  // Not supported.
6165
- return null;
5919
+ return null
6166
5920
  }
6167
5921
  if (node.operator === "void") {
6168
- return {
6169
- value: undefined
6170
- };
5922
+ return { value: undefined }
6171
5923
  }
5924
+
6172
5925
  const arg = getStaticValueR(node.argument, initialScope);
6173
5926
  if (arg != null) {
6174
- switch(node.operator){
5927
+ switch (node.operator) {
6175
5928
  case "-":
6176
- return {
6177
- value: -arg.value
6178
- };
5929
+ return { value: -arg.value }
6179
5930
  case "+":
6180
- return {
6181
- value: +arg.value
6182
- } //eslint-disable-line no-implicit-coercion
6183
- ;
5931
+ return { value: +arg.value } //eslint-disable-line no-implicit-coercion
6184
5932
  case "!":
6185
- return {
6186
- value: !arg.value
6187
- };
5933
+ return { value: !arg.value }
6188
5934
  case "~":
6189
- return {
6190
- value: ~arg.value
6191
- };
5935
+ return { value: ~arg.value }
6192
5936
  case "typeof":
6193
- return {
6194
- value: typeof arg.value
6195
- };
5937
+ return { value: typeof arg.value }
5938
+
5939
+ // no default
6196
5940
  }
6197
5941
  }
6198
- return null;
6199
- }
5942
+
5943
+ return null
5944
+ },
6200
5945
  });
5946
+
6201
5947
  /**
6202
5948
  * Get the value of a given node if it's a static value.
6203
5949
  * @param {Node} node The node to get.
6204
5950
  * @param {Scope|undefined} initialScope The scope to start finding variable.
6205
5951
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
6206
- */ function getStaticValueR(node, initialScope) {
5952
+ */
5953
+ function getStaticValueR(node, initialScope) {
6207
5954
  if (node != null && Object.hasOwnProperty.call(operations, node.type)) {
6208
- return operations[node.type](node, initialScope);
5955
+ return operations[node.type](node, initialScope)
6209
5956
  }
6210
- return null;
5957
+ return null
6211
5958
  }
5959
+
6212
5960
  /**
6213
5961
  * Get the static value of property name from a MemberExpression node or a Property node.
6214
5962
  * @param {Node} node The node to get.
6215
5963
  * @param {Scope} [initialScope] The scope to start finding variable. Optional. If the node is a computed property node and this scope was given, this checks the computed property name by the `getStringIfConstant` function with the scope, and returns the value of it.
6216
5964
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the property name of the node, or `null`.
6217
- */ function getStaticPropertyNameValue(node, initialScope) {
5965
+ */
5966
+ function getStaticPropertyNameValue(node, initialScope) {
6218
5967
  const nameNode = node.type === "Property" ? node.key : node.property;
5968
+
6219
5969
  if (node.computed) {
6220
- return getStaticValueR(nameNode, initialScope);
5970
+ return getStaticValueR(nameNode, initialScope)
6221
5971
  }
5972
+
6222
5973
  if (nameNode.type === "Identifier") {
6223
- return {
6224
- value: nameNode.name
6225
- };
5974
+ return { value: nameNode.name }
6226
5975
  }
5976
+
6227
5977
  if (nameNode.type === "Literal") {
6228
5978
  if (nameNode.bigint) {
6229
- return {
6230
- value: nameNode.bigint
6231
- };
5979
+ return { value: nameNode.bigint }
6232
5980
  }
6233
- return {
6234
- value: String(nameNode.value)
6235
- };
5981
+ return { value: String(nameNode.value) }
6236
5982
  }
6237
- return null;
5983
+
5984
+ return null
6238
5985
  }
5986
+
6239
5987
  /**
6240
5988
  * Get the value of a given node if it's a static value.
6241
5989
  * @param {Node} node The node to get.
6242
5990
  * @param {Scope} [initialScope] The scope to start finding variable. Optional. If this scope was given, this tries to resolve identifier references which are in the given node as much as possible.
6243
5991
  * @returns {{value:any}|{value:undefined,optional?:true}|null} The static value of the node, or `null`.
6244
- */ function getStaticValue$1(node, initialScope = null) {
5992
+ */
5993
+ function getStaticValue$1(node, initialScope = null) {
6245
5994
  try {
6246
- return getStaticValueR(node, initialScope);
5995
+ return getStaticValueR(node, initialScope)
6247
5996
  } catch (_error) {
6248
- return null;
5997
+ return null
6249
5998
  }
6250
5999
  }
6251
- const typeConversionBinaryOps = Object.freeze(new Set([
6252
- "==",
6253
- "!=",
6254
- "<",
6255
- "<=",
6256
- ">",
6257
- ">=",
6258
- "<<",
6259
- ">>",
6260
- ">>>",
6261
- "+",
6262
- "-",
6263
- "*",
6264
- "/",
6265
- "%",
6266
- "|",
6267
- "^",
6268
- "&",
6269
- "in"
6270
- ]));
6271
- const typeConversionUnaryOps = Object.freeze(new Set([
6272
- "-",
6273
- "+",
6274
- "!",
6275
- "~"
6276
- ]));
6000
+
6001
+ const typeConversionBinaryOps = Object.freeze(
6002
+ new Set([
6003
+ "==",
6004
+ "!=",
6005
+ "<",
6006
+ "<=",
6007
+ ">",
6008
+ ">=",
6009
+ "<<",
6010
+ ">>",
6011
+ ">>>",
6012
+ "+",
6013
+ "-",
6014
+ "*",
6015
+ "/",
6016
+ "%",
6017
+ "|",
6018
+ "^",
6019
+ "&",
6020
+ "in",
6021
+ ]),
6022
+ );
6023
+ const typeConversionUnaryOps = Object.freeze(new Set(["-", "+", "!", "~"]));
6024
+
6277
6025
  /**
6278
6026
  * Check whether the given value is an ASTNode or not.
6279
6027
  * @param {any} x The value to check.
6280
6028
  * @returns {boolean} `true` if the value is an ASTNode.
6281
- */ function isNode(x) {
6282
- return x !== null && typeof x === "object" && typeof x.type === "string";
6029
+ */
6030
+ function isNode(x) {
6031
+ return x !== null && typeof x === "object" && typeof x.type === "string"
6283
6032
  }
6284
- Object.freeze(Object.assign(Object.create(null), {
6285
- $visit (node, options, visitorKeys) {
6286
- const { type } = node;
6287
- if (typeof this[type] === "function") {
6288
- return this[type](node, options, visitorKeys);
6289
- }
6290
- return this.$visitChildren(node, options, visitorKeys);
6291
- },
6292
- $visitChildren (node, options, visitorKeys) {
6293
- const { type } = node;
6294
- for (const key of visitorKeys[type] || getKeys(node)){
6295
- const value = node[key];
6296
- if (Array.isArray(value)) {
6297
- for (const element of value){
6298
- if (isNode(element) && this.$visit(element, options, visitorKeys)) {
6299
- return true;
6033
+
6034
+ Object.freeze(
6035
+ Object.assign(Object.create(null), {
6036
+ $visit(node, options, visitorKeys) {
6037
+ const { type } = node;
6038
+
6039
+ if (typeof this[type] === "function") {
6040
+ return this[type](node, options, visitorKeys)
6041
+ }
6042
+
6043
+ return this.$visitChildren(node, options, visitorKeys)
6044
+ },
6045
+
6046
+ $visitChildren(node, options, visitorKeys) {
6047
+ const { type } = node;
6048
+
6049
+ for (const key of visitorKeys[type] || getKeys(node)) {
6050
+ const value = node[key];
6051
+
6052
+ if (Array.isArray(value)) {
6053
+ for (const element of value) {
6054
+ if (
6055
+ isNode(element) &&
6056
+ this.$visit(element, options, visitorKeys)
6057
+ ) {
6058
+ return true
6059
+ }
6300
6060
  }
6061
+ } else if (
6062
+ isNode(value) &&
6063
+ this.$visit(value, options, visitorKeys)
6064
+ ) {
6065
+ return true
6301
6066
  }
6302
- } else if (isNode(value) && this.$visit(value, options, visitorKeys)) {
6303
- return true;
6304
6067
  }
6068
+
6069
+ return false
6070
+ },
6071
+
6072
+ ArrowFunctionExpression() {
6073
+ return false
6074
+ },
6075
+ AssignmentExpression() {
6076
+ return true
6077
+ },
6078
+ AwaitExpression() {
6079
+ return true
6080
+ },
6081
+ BinaryExpression(node, options, visitorKeys) {
6082
+ if (
6083
+ options.considerImplicitTypeConversion &&
6084
+ typeConversionBinaryOps.has(node.operator) &&
6085
+ (node.left.type !== "Literal" || node.right.type !== "Literal")
6086
+ ) {
6087
+ return true
6088
+ }
6089
+ return this.$visitChildren(node, options, visitorKeys)
6090
+ },
6091
+ CallExpression() {
6092
+ return true
6093
+ },
6094
+ FunctionExpression() {
6095
+ return false
6096
+ },
6097
+ ImportExpression() {
6098
+ return true
6099
+ },
6100
+ MemberExpression(node, options, visitorKeys) {
6101
+ if (options.considerGetters) {
6102
+ return true
6103
+ }
6104
+ if (
6105
+ options.considerImplicitTypeConversion &&
6106
+ node.computed &&
6107
+ node.property.type !== "Literal"
6108
+ ) {
6109
+ return true
6110
+ }
6111
+ return this.$visitChildren(node, options, visitorKeys)
6112
+ },
6113
+ MethodDefinition(node, options, visitorKeys) {
6114
+ if (
6115
+ options.considerImplicitTypeConversion &&
6116
+ node.computed &&
6117
+ node.key.type !== "Literal"
6118
+ ) {
6119
+ return true
6120
+ }
6121
+ return this.$visitChildren(node, options, visitorKeys)
6122
+ },
6123
+ NewExpression() {
6124
+ return true
6125
+ },
6126
+ Property(node, options, visitorKeys) {
6127
+ if (
6128
+ options.considerImplicitTypeConversion &&
6129
+ node.computed &&
6130
+ node.key.type !== "Literal"
6131
+ ) {
6132
+ return true
6133
+ }
6134
+ return this.$visitChildren(node, options, visitorKeys)
6135
+ },
6136
+ PropertyDefinition(node, options, visitorKeys) {
6137
+ if (
6138
+ options.considerImplicitTypeConversion &&
6139
+ node.computed &&
6140
+ node.key.type !== "Literal"
6141
+ ) {
6142
+ return true
6143
+ }
6144
+ return this.$visitChildren(node, options, visitorKeys)
6145
+ },
6146
+ UnaryExpression(node, options, visitorKeys) {
6147
+ if (node.operator === "delete") {
6148
+ return true
6149
+ }
6150
+ if (
6151
+ options.considerImplicitTypeConversion &&
6152
+ typeConversionUnaryOps.has(node.operator) &&
6153
+ node.argument.type !== "Literal"
6154
+ ) {
6155
+ return true
6156
+ }
6157
+ return this.$visitChildren(node, options, visitorKeys)
6158
+ },
6159
+ UpdateExpression() {
6160
+ return true
6161
+ },
6162
+ YieldExpression() {
6163
+ return true
6164
+ },
6165
+ }),
6166
+ );
6167
+ Function.call.bind(Object.hasOwnProperty);
6168
+
6169
+ /**
6170
+ * Tests if a value is a `string`.
6171
+ *
6172
+ * @param input - The value to test.
6173
+ *
6174
+ * @example
6175
+ * import { isString } from "effect/Predicate"
6176
+ *
6177
+ * assert.deepStrictEqual(isString("a"), true)
6178
+ *
6179
+ * assert.deepStrictEqual(isString(1), false)
6180
+ *
6181
+ * @category guards
6182
+ * @since 2.0.0
6183
+ */ const isString$1 = (input)=>typeof input === "string";
6184
+ const t$1 = Symbol.for("@ts-pattern/matcher"), e$1 = Symbol.for("@ts-pattern/isVariadic"), n$1 = "@ts-pattern/anonymous-select-key", r$1 = (t)=>Boolean(t && "object" == typeof t), i$1 = (e)=>e && !!e[t$1], s$1 = (n, o, c)=>{
6185
+ if (i$1(n)) {
6186
+ const e = n[t$1](), { matched: r, selections: i } = e.match(o);
6187
+ return r && i && Object.keys(i).forEach((t)=>c(t, i[t])), r;
6188
+ }
6189
+ if (r$1(n)) {
6190
+ if (!r$1(o)) return !1;
6191
+ if (Array.isArray(n)) {
6192
+ if (!Array.isArray(o)) return !1;
6193
+ let t = [], r = [], a = [];
6194
+ for (const s of n.keys()){
6195
+ const o = n[s];
6196
+ i$1(o) && o[e$1] ? a.push(o) : a.length ? r.push(o) : t.push(o);
6197
+ }
6198
+ if (a.length) {
6199
+ if (a.length > 1) throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");
6200
+ if (o.length < t.length + r.length) return !1;
6201
+ const e = o.slice(0, t.length), n = 0 === r.length ? [] : o.slice(-r.length), i = o.slice(t.length, 0 === r.length ? Infinity : -r.length);
6202
+ return t.every((t, n)=>s$1(t, e[n], c)) && r.every((t, e)=>s$1(t, n[e], c)) && (0 === a.length || s$1(a[0], i, c));
6203
+ }
6204
+ return n.length === o.length && n.every((t, e)=>s$1(t, o[e], c));
6305
6205
  }
6306
- return false;
6307
- },
6308
- ArrowFunctionExpression () {
6309
- return false;
6310
- },
6311
- AssignmentExpression () {
6312
- return true;
6313
- },
6314
- AwaitExpression () {
6315
- return true;
6316
- },
6317
- BinaryExpression (node, options, visitorKeys) {
6318
- if (options.considerImplicitTypeConversion && typeConversionBinaryOps.has(node.operator) && (node.left.type !== "Literal" || node.right.type !== "Literal")) {
6319
- return true;
6320
- }
6321
- return this.$visitChildren(node, options, visitorKeys);
6322
- },
6323
- CallExpression () {
6324
- return true;
6325
- },
6326
- FunctionExpression () {
6327
- return false;
6328
- },
6329
- ImportExpression () {
6330
- return true;
6331
- },
6332
- MemberExpression (node, options, visitorKeys) {
6333
- if (options.considerGetters) {
6334
- return true;
6335
- }
6336
- if (options.considerImplicitTypeConversion && node.computed && node.property.type !== "Literal") {
6337
- return true;
6338
- }
6339
- return this.$visitChildren(node, options, visitorKeys);
6340
- },
6341
- MethodDefinition (node, options, visitorKeys) {
6342
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6343
- return true;
6344
- }
6345
- return this.$visitChildren(node, options, visitorKeys);
6346
- },
6347
- NewExpression () {
6348
- return true;
6349
- },
6350
- Property (node, options, visitorKeys) {
6351
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6352
- return true;
6353
- }
6354
- return this.$visitChildren(node, options, visitorKeys);
6355
- },
6356
- PropertyDefinition (node, options, visitorKeys) {
6357
- if (options.considerImplicitTypeConversion && node.computed && node.key.type !== "Literal") {
6358
- return true;
6359
- }
6360
- return this.$visitChildren(node, options, visitorKeys);
6361
- },
6362
- UnaryExpression (node, options, visitorKeys) {
6363
- if (node.operator === "delete") {
6364
- return true;
6365
- }
6366
- if (options.considerImplicitTypeConversion && typeConversionUnaryOps.has(node.operator) && node.argument.type !== "Literal") {
6367
- return true;
6368
- }
6369
- return this.$visitChildren(node, options, visitorKeys);
6370
- },
6371
- UpdateExpression () {
6372
- return true;
6373
- },
6374
- YieldExpression () {
6375
- return true;
6206
+ return Object.keys(n).every((e)=>{
6207
+ const r = n[e];
6208
+ return (e in o || i$1(a = r) && "optional" === a[t$1]().matcherType) && s$1(r, o[e], c);
6209
+ var a;
6210
+ });
6376
6211
  }
6212
+ return Object.is(o, n);
6213
+ }, o$1 = (e)=>{
6214
+ var n, s, a;
6215
+ return r$1(e) ? i$1(e) ? null != (n = null == (s = (a = e[t$1]()).getSelectionKeys) ? void 0 : s.call(a)) ? n : [] : Array.isArray(e) ? c$1(e, o$1) : c$1(Object.values(e), o$1) : [];
6216
+ }, c$1 = (t, e)=>t.reduce((t, n)=>t.concat(e(n)), []);
6217
+ function u$1(t) {
6218
+ return Object.assign(t, {
6219
+ optional: ()=>l$1(t),
6220
+ and: (e)=>m$1(t, e),
6221
+ or: (e)=>y$1(t, e),
6222
+ select: (e)=>void 0 === e ? p$1(t) : p$1(e, t)
6223
+ });
6224
+ }
6225
+ function l$1(e) {
6226
+ return u$1({
6227
+ [t$1]: ()=>({
6228
+ match: (t)=>{
6229
+ let n = {};
6230
+ const r = (t, e)=>{
6231
+ n[t] = e;
6232
+ };
6233
+ return void 0 === t ? (o$1(e).forEach((t)=>r(t, void 0)), {
6234
+ matched: !0,
6235
+ selections: n
6236
+ }) : {
6237
+ matched: s$1(e, t, r),
6238
+ selections: n
6239
+ };
6240
+ },
6241
+ getSelectionKeys: ()=>o$1(e),
6242
+ matcherType: "optional"
6243
+ })
6244
+ });
6245
+ }
6246
+ function m$1(...e) {
6247
+ return u$1({
6248
+ [t$1]: ()=>({
6249
+ match: (t)=>{
6250
+ let n = {};
6251
+ const r = (t, e)=>{
6252
+ n[t] = e;
6253
+ };
6254
+ return {
6255
+ matched: e.every((e)=>s$1(e, t, r)),
6256
+ selections: n
6257
+ };
6258
+ },
6259
+ getSelectionKeys: ()=>c$1(e, o$1),
6260
+ matcherType: "and"
6261
+ })
6262
+ });
6263
+ }
6264
+ function y$1(...e) {
6265
+ return u$1({
6266
+ [t$1]: ()=>({
6267
+ match: (t)=>{
6268
+ let n = {};
6269
+ const r = (t, e)=>{
6270
+ n[t] = e;
6271
+ };
6272
+ return c$1(e, o$1).forEach((t)=>r(t, void 0)), {
6273
+ matched: e.some((e)=>s$1(e, t, r)),
6274
+ selections: n
6275
+ };
6276
+ },
6277
+ getSelectionKeys: ()=>c$1(e, o$1),
6278
+ matcherType: "or"
6279
+ })
6280
+ });
6281
+ }
6282
+ function d$1(e) {
6283
+ return {
6284
+ [t$1]: ()=>({
6285
+ match: (t)=>({
6286
+ matched: Boolean(e(t))
6287
+ })
6288
+ })
6289
+ };
6290
+ }
6291
+ function p$1(...e) {
6292
+ const r = "string" == typeof e[0] ? e[0] : void 0, i = 2 === e.length ? e[1] : "string" == typeof e[0] ? void 0 : e[0];
6293
+ return u$1({
6294
+ [t$1]: ()=>({
6295
+ match: (t)=>{
6296
+ let e = {
6297
+ [null != r ? r : n$1]: t
6298
+ };
6299
+ return {
6300
+ matched: void 0 === i || s$1(i, t, (t, n)=>{
6301
+ e[t] = n;
6302
+ }),
6303
+ selections: e
6304
+ };
6305
+ },
6306
+ getSelectionKeys: ()=>[
6307
+ null != r ? r : n$1
6308
+ ].concat(void 0 === i ? [] : o$1(i))
6309
+ })
6310
+ });
6311
+ }
6312
+ function v$1(t) {
6313
+ return "number" == typeof t;
6314
+ }
6315
+ function b$1(t) {
6316
+ return "string" == typeof t;
6317
+ }
6318
+ function w$1(t) {
6319
+ return "bigint" == typeof t;
6320
+ }
6321
+ u$1(d$1(function(t) {
6322
+ return !0;
6377
6323
  }));
6378
- Function.call.bind(Object.hasOwnProperty);
6324
+ const j$1 = (t)=>Object.assign(u$1(t), {
6325
+ startsWith: (e)=>{
6326
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.startsWith(n)))));
6327
+ var n;
6328
+ },
6329
+ endsWith: (e)=>{
6330
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.endsWith(n)))));
6331
+ var n;
6332
+ },
6333
+ minLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length >= t))(e))),
6334
+ maxLength: (e)=>j$1(m$1(t, ((t)=>d$1((e)=>b$1(e) && e.length <= t))(e))),
6335
+ includes: (e)=>{
6336
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && t.includes(n)))));
6337
+ var n;
6338
+ },
6339
+ regex: (e)=>{
6340
+ return j$1(m$1(t, (n = e, d$1((t)=>b$1(t) && Boolean(t.match(n))))));
6341
+ var n;
6342
+ }
6343
+ });
6344
+ j$1(d$1(b$1));
6345
+ const K$1 = (t)=>Object.assign(u$1(t), {
6346
+ between: (e, n)=>K$1(m$1(t, ((t, e)=>d$1((n)=>v$1(n) && t <= n && e >= n))(e, n))),
6347
+ lt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e < t))(e))),
6348
+ gt: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e > t))(e))),
6349
+ lte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e <= t))(e))),
6350
+ gte: (e)=>K$1(m$1(t, ((t)=>d$1((e)=>v$1(e) && e >= t))(e))),
6351
+ int: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isInteger(t)))),
6352
+ finite: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && Number.isFinite(t)))),
6353
+ positive: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t > 0))),
6354
+ negative: ()=>K$1(m$1(t, d$1((t)=>v$1(t) && t < 0)))
6355
+ });
6356
+ K$1(d$1(v$1));
6357
+ const x$1 = (t)=>Object.assign(u$1(t), {
6358
+ between: (e, n)=>x$1(m$1(t, ((t, e)=>d$1((n)=>w$1(n) && t <= n && e >= n))(e, n))),
6359
+ lt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e < t))(e))),
6360
+ gt: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e > t))(e))),
6361
+ lte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e <= t))(e))),
6362
+ gte: (e)=>x$1(m$1(t, ((t)=>d$1((e)=>w$1(e) && e >= t))(e))),
6363
+ positive: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t > 0))),
6364
+ negative: ()=>x$1(m$1(t, d$1((t)=>w$1(t) && t < 0)))
6365
+ });
6366
+ x$1(d$1(w$1));
6367
+ u$1(d$1(function(t) {
6368
+ return "boolean" == typeof t;
6369
+ }));
6370
+ u$1(d$1(function(t) {
6371
+ return "symbol" == typeof t;
6372
+ }));
6373
+ u$1(d$1(function(t) {
6374
+ return null == t;
6375
+ }));
6376
+ const NodeType = AST_NODE_TYPES;
6377
+ const is = ASTUtils.isNodeOfType;
6378
+ const isOneOf = ASTUtils.isNodeOfTypes;
6379
+ isOneOf([
6380
+ NodeType.ArrowFunctionExpression,
6381
+ NodeType.FunctionDeclaration,
6382
+ NodeType.FunctionExpression
6383
+ ]);
6384
+ isOneOf([
6385
+ NodeType.ArrowFunctionExpression,
6386
+ NodeType.FunctionDeclaration,
6387
+ NodeType.FunctionExpression,
6388
+ NodeType.TSCallSignatureDeclaration,
6389
+ NodeType.TSConstructSignatureDeclaration,
6390
+ NodeType.TSDeclareFunction,
6391
+ NodeType.TSEmptyBodyFunctionExpression,
6392
+ NodeType.TSFunctionType,
6393
+ NodeType.TSMethodSignature
6394
+ ]);
6395
+ isOneOf([
6396
+ NodeType.ClassDeclaration,
6397
+ NodeType.ClassExpression
6398
+ ]);
6399
+ isOneOf([
6400
+ NodeType.DoWhileStatement,
6401
+ NodeType.ForInStatement,
6402
+ NodeType.ForOfStatement,
6403
+ NodeType.ForStatement,
6404
+ NodeType.WhileStatement
6405
+ ]);
6406
+ isOneOf([
6407
+ NodeType.TSArrayType,
6408
+ NodeType.TSTupleType
6409
+ ]);
6410
+ isOneOf([
6411
+ NodeType.PropertyDefinition,
6412
+ NodeType.TSIndexSignature,
6413
+ NodeType.TSParameterProperty,
6414
+ NodeType.TSPropertySignature
6415
+ ]);
6416
+ is(NodeType.JSXElement);
6417
+ is(NodeType.JSXFragment);
6418
+ isOneOf([
6419
+ NodeType.JSXAttribute,
6420
+ NodeType.JSXSpreadChild,
6421
+ NodeType.JSXClosingElement,
6422
+ NodeType.JSXClosingFragment,
6423
+ NodeType.JSXElement,
6424
+ NodeType.JSXEmptyExpression,
6425
+ NodeType.JSXExpressionContainer,
6426
+ NodeType.JSXFragment,
6427
+ NodeType.JSXIdentifier,
6428
+ NodeType.JSXMemberExpression,
6429
+ NodeType.JSXNamespacedName,
6430
+ NodeType.JSXOpeningElement,
6431
+ NodeType.JSXOpeningFragment,
6432
+ NodeType.JSXSpreadAttribute,
6433
+ NodeType.JSXSpreadChild,
6434
+ NodeType.JSXText
6435
+ ]);
6436
+ const isJSXTagNameExpression = isOneOf([
6437
+ NodeType.JSXIdentifier,
6438
+ NodeType.JSXMemberExpression,
6439
+ NodeType.JSXNamespacedName
6440
+ ]);
6441
+ isOneOf([
6442
+ NodeType.ArrayPattern,
6443
+ NodeType.AssignmentPattern,
6444
+ NodeType.ObjectPattern,
6445
+ NodeType.RestElement
6446
+ ]);
6447
+ isOneOf([
6448
+ NodeType.TSInterfaceDeclaration,
6449
+ NodeType.TSTypeAliasDeclaration
6450
+ ]);
6451
+ isOneOf([
6452
+ NodeType.ArrayExpression,
6453
+ NodeType.ArrayPattern,
6454
+ NodeType.ArrowFunctionExpression,
6455
+ NodeType.CallExpression,
6456
+ NodeType.ClassExpression,
6457
+ NodeType.FunctionExpression,
6458
+ NodeType.Identifier,
6459
+ NodeType.JSXElement,
6460
+ NodeType.JSXFragment,
6461
+ NodeType.Literal,
6462
+ NodeType.TemplateLiteral,
6463
+ NodeType.MemberExpression,
6464
+ NodeType.MetaProperty,
6465
+ NodeType.ObjectExpression,
6466
+ NodeType.ObjectPattern,
6467
+ NodeType.SequenceExpression,
6468
+ NodeType.Super,
6469
+ NodeType.TaggedTemplateExpression,
6470
+ NodeType.ThisExpression
6471
+ ]);
6472
+ isOneOf([
6473
+ NodeType.ArrayExpression,
6474
+ NodeType.ArrayPattern,
6475
+ NodeType.ArrowFunctionExpression,
6476
+ NodeType.CallExpression,
6477
+ NodeType.ClassExpression,
6478
+ NodeType.FunctionExpression,
6479
+ NodeType.Identifier,
6480
+ NodeType.JSXElement,
6481
+ NodeType.JSXFragment,
6482
+ NodeType.Literal,
6483
+ NodeType.TemplateLiteral,
6484
+ NodeType.MemberExpression,
6485
+ NodeType.MetaProperty,
6486
+ NodeType.ObjectExpression,
6487
+ NodeType.ObjectPattern,
6488
+ NodeType.SequenceExpression,
6489
+ NodeType.Super,
6490
+ NodeType.TaggedTemplateExpression,
6491
+ NodeType.ThisExpression,
6492
+ NodeType.TSAsExpression,
6493
+ NodeType.TSNonNullExpression,
6494
+ NodeType.TSTypeAssertion
6495
+ ]);
6496
+ const Construction = effectData_esm.taggedEnum();
6497
+ Construction.None();
6498
+ [
6499
+ NodeType.JSXElement,
6500
+ NodeType.ArrayExpression,
6501
+ NodeType.ObjectExpression,
6502
+ NodeType.FunctionExpression,
6503
+ NodeType.ArrowFunctionExpression,
6504
+ NodeType.ClassExpression,
6505
+ NodeType.NewExpression,
6506
+ NodeType.CallExpression
6507
+ ];
6379
6508
  /**
6380
6509
  * Get the value of a given node if it can decide the value statically.
6381
6510
  * If the 2nd parameter `initialScope` was given, this function tries to resolve identifier references which are in the
@@ -6496,13 +6625,24 @@ function isStringLiteral(node) {
6496
6625
  */ function findVariableByNameUpToGlobal(name, startScope) {
6497
6626
  return effectFunction_esm.pipe(getVariablesUpToGlobal(startScope), findVariableByName(name));
6498
6627
  }
6628
+ /**
6629
+ * Get the first definition of a variable
6630
+ * @param variable The variable to get the definition from
6631
+ */ function getVariableDefinitionFirst(variable) {
6632
+ return effectOption_esm.fromNullable(variable.defs[0]);
6633
+ }
6499
6634
  /**
6500
6635
  * Get the init node of the nth definition of a variable
6501
- * @param at The index of the definition to get, negative numbers are counted from the end, -1 is the last definition
6502
- */ function getVariableNthDefNodeInit(at) {
6503
- return (variable)=>{
6504
- return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMapNullable((v)=>v.defs.at(at)), effectOption_esm.flatMapNullable((d)=>d.node), effectOption_esm.flatMapNullable((n)=>"init" in n ? n.init : null));
6505
- };
6636
+ * @param variable
6637
+ * @param getDefinition A function that returns the nth definition of a variable
6638
+ */ function getVariableInit(variable, getDefinition) {
6639
+ return effectFunction_esm.pipe(effectOption_esm.some(variable), effectOption_esm.flatMap(getDefinition), effectOption_esm.flatMapNullable((d)=>d.node), effectOption_esm.flatMapNullable((n)=>"init" in n ? n.init : null));
6640
+ }
6641
+ /**
6642
+ * Get the init node of the first definition of a variable
6643
+ * @param variable
6644
+ */ function getVariableInitFirst(variable) {
6645
+ return getVariableInit(variable, getVariableDefinitionFirst);
6506
6646
  }
6507
6647
 
6508
6648
  /**
@@ -6561,7 +6701,7 @@ const getPragmaFromContext = memo((context)=>{
6561
6701
  return effectFunction_esm.pipe(effectOption_esm.orElse(effectOption_esm.fromNullable(settings.react?.pragma), ()=>effectFunction_esm.pipe(effectOption_esm.fromNullable(pragmaNode), effectOption_esm.map(({ value })=>RE_JSX_ANNOTATION_REGEX.exec(value)), effectOption_esm.flatMapNullable((matches)=>matches?.[1]?.split(".")[0]))), effectOption_esm.flatMap(effectOption_esm.liftPredicate((x)=>RE_JS_IDENTIFIER_REGEX.test(x))), effectOption_esm.getOrElse(effectFunction_esm.constant("React")));
6562
6702
  });
6563
6703
 
6564
- const t=Symbol.for("@ts-pattern/matcher"),e=Symbol.for("@ts-pattern/isVariadic"),n="@ts-pattern/anonymous-select-key",r=t=>Boolean(t&&"object"==typeof t),i=e=>e&&!!e[t],s=(n,o,c)=>{if(i(n)){const e=n[t](),{matched:r,selections:i}=e.match(o);return r&&i&&Object.keys(i).forEach(t=>c(t,i[t])),r}if(r(n)){if(!r(o))return !1;if(Array.isArray(n)){if(!Array.isArray(o))return !1;let t=[],r=[],a=[];for(const s of n.keys()){const o=n[s];i(o)&&o[e]?a.push(o):a.length?r.push(o):t.push(o);}if(a.length){if(a.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(o.length<t.length+r.length)return !1;const e=o.slice(0,t.length),n=0===r.length?[]:o.slice(-r.length),i=o.slice(t.length,0===r.length?Infinity:-r.length);return t.every((t,n)=>s(t,e[n],c))&&r.every((t,e)=>s(t,n[e],c))&&(0===a.length||s(a[0],i,c))}return n.length===o.length&&n.every((t,e)=>s(t,o[e],c))}return Object.keys(n).every(e=>{const r=n[e];return (e in o||i(a=r)&&"optional"===a[t]().matcherType)&&s(r,o[e],c);var a;})}return Object.is(o,n)},o=e=>{var n,s,a;return r(e)?i(e)?null!=(n=null==(s=(a=e[t]()).getSelectionKeys)?void 0:s.call(a))?n:[]:Array.isArray(e)?c(e,o):c(Object.values(e),o):[]},c=(t,e)=>t.reduce((t,n)=>t.concat(e(n)),[]);function a(...t){if(1===t.length){const[e]=t;return t=>s(e,t,()=>{})}if(2===t.length){const[e,n]=t;return s(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`)}function u(t){return Object.assign(t,{optional:()=>l(t),and:e=>m(t,e),or:e=>y(t,e),select:e=>void 0===e?p(t):p(e,t)})}function h(t){return Object.assign((t=>Object.assign(t,{*[Symbol.iterator](){yield Object.assign(t,{[e]:!0});}}))(t),{optional:()=>h(l(t)),select:e=>h(void 0===e?p(t):p(e,t))})}function l(e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return void 0===t?(o(e).forEach(t=>r(t,void 0)),{matched:!0,selections:n}):{matched:s(e,t,r),selections:n}},getSelectionKeys:()=>o(e),matcherType:"optional"})})}const f=(t,e)=>{for(const n of t)if(!e(n))return !1;return !0},g=(t,e)=>{for(const[n,r]of t.entries())if(!e(r,n))return !1;return !0};function m(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return {matched:e.every(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"and"})})}function y(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return c(e,o).forEach(t=>r(t,void 0)),{matched:e.some(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"or"})})}function d(e){return {[t]:()=>({match:t=>({matched:Boolean(e(t))})})}}function p(...e){const r="string"==typeof e[0]?e[0]:void 0,i=2===e.length?e[1]:"string"==typeof e[0]?void 0:e[0];return u({[t]:()=>({match:t=>{let e={[null!=r?r:n]:t};return {matched:void 0===i||s(i,t,(t,n)=>{e[t]=n;}),selections:e}},getSelectionKeys:()=>[null!=r?r:n].concat(void 0===i?[]:o(i))})})}function v(t){return "number"==typeof t}function b(t){return "string"==typeof t}function w(t){return "bigint"==typeof t}const S=u(d(function(t){return !0})),O=S,j=t=>Object.assign(u(t),{startsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.startsWith(n)))));var n;},endsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.endsWith(n)))));var n;},minLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length>=t))(e))),maxLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length<=t))(e))),includes:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.includes(n)))));var n;},regex:e=>{return j(m(t,(n=e,d(t=>b(t)&&Boolean(t.match(n))))));var n;}}),E=j(d(b)),K=t=>Object.assign(u(t),{between:(e,n)=>K(m(t,((t,e)=>d(n=>v(n)&&t<=n&&e>=n))(e,n))),lt:e=>K(m(t,(t=>d(e=>v(e)&&e<t))(e))),gt:e=>K(m(t,(t=>d(e=>v(e)&&e>t))(e))),lte:e=>K(m(t,(t=>d(e=>v(e)&&e<=t))(e))),gte:e=>K(m(t,(t=>d(e=>v(e)&&e>=t))(e))),int:()=>K(m(t,d(t=>v(t)&&Number.isInteger(t)))),finite:()=>K(m(t,d(t=>v(t)&&Number.isFinite(t)))),positive:()=>K(m(t,d(t=>v(t)&&t>0))),negative:()=>K(m(t,d(t=>v(t)&&t<0)))}),A=K(d(v)),x=t=>Object.assign(u(t),{between:(e,n)=>x(m(t,((t,e)=>d(n=>w(n)&&t<=n&&e>=n))(e,n))),lt:e=>x(m(t,(t=>d(e=>w(e)&&e<t))(e))),gt:e=>x(m(t,(t=>d(e=>w(e)&&e>t))(e))),lte:e=>x(m(t,(t=>d(e=>w(e)&&e<=t))(e))),gte:e=>x(m(t,(t=>d(e=>w(e)&&e>=t))(e))),positive:()=>x(m(t,d(t=>w(t)&&t>0))),negative:()=>x(m(t,d(t=>w(t)&&t<0)))}),P=x(d(w)),T=u(d(function(t){return "boolean"==typeof t})),k=u(d(function(t){return "symbol"==typeof t})),B=u(d(function(t){return null==t}));var _={__proto__:null,matcher:t,optional:l,array:function(...e){return h({[t]:()=>({match:t=>{if(!Array.isArray(t))return {matched:!1};if(0===e.length)return {matched:!0};const n=e[0];let r={};if(0===t.length)return o(n).forEach(t=>{r[t]=[];}),{matched:!0,selections:r};const i=(t,e)=>{r[t]=(r[t]||[]).concat([e]);};return {matched:t.every(t=>s(n,t,i)),selections:r}},getSelectionKeys:()=>0===e.length?[]:o(e[0])})})},set:function(...e){return u({[t]:()=>({match:t=>{if(!(t instanceof Set))return {matched:!1};let n={};if(0===t.size)return {matched:!0,selections:n};if(0===e.length)return {matched:!0};const r=(t,e)=>{n[t]=(n[t]||[]).concat([e]);},i=e[0];return {matched:f(t,t=>s(i,t,r)),selections:n}},getSelectionKeys:()=>0===e.length?[]:o(e[0])})})},map:function(...e){return u({[t]:()=>({match:t=>{if(!(t instanceof Map))return {matched:!1};let n={};if(0===t.size)return {matched:!0,selections:n};const r=(t,e)=>{n[t]=(n[t]||[]).concat([e]);};if(0===e.length)return {matched:!0};var i;if(1===e.length)throw new Error(`\`P.map\` wasn't given enough arguments. Expected (key, value), received ${null==(i=e[0])?void 0:i.toString()}`);const[o,c]=e;return {matched:g(t,(t,e)=>{const n=s(o,e,r),i=s(c,t,r);return n&&i}),selections:n}},getSelectionKeys:()=>0===e.length?[]:[...o(e[0]),...o(e[1])]})})},intersection:m,union:y,not:function(e){return u({[t]:()=>({match:t=>({matched:!s(e,t,()=>{})}),getSelectionKeys:()=>[],matcherType:"not"})})},when:d,select:p,any:S,_:O,string:E,number:A,bigint:P,boolean:T,symbol:k,nullish:B,instanceOf:function(t){return u(d(function(t){return e=>e instanceof t}(t)))},shape:function(t){return u(d(a(t)))}};const W={matched:!1,value:void 0};function N(t){return new $(t,W)}class ${constructor(t,e){this.input=void 0,this.state=void 0,this.input=t,this.state=e;}with(...t){if(this.state.matched)return this;const e=t[t.length-1],r=[t[0]];let i;3===t.length&&"function"==typeof t[1]?(r.push(t[0]),i=t[1]):t.length>2&&r.push(...t.slice(1,t.length-1));let o=!1,c={};const a=(t,e)=>{o=!0,c[t]=e;},u=!r.some(t=>s(t,this.input,a))||i&&!Boolean(i(this.input))?W:{matched:!0,value:e(o?n in c?c[n]:c:this.input,this.input)};return new $(this.input,u)}when(t,e){if(this.state.matched)return this;const n=Boolean(t(this.input));return new $(this.input,n?{matched:!0,value:e(this.input,this.input)}:W)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){return this.run()}run(){if(this.state.matched)return this.state.value;let t;try{t=JSON.stringify(this.input);}catch(e){t=this.input;}throw new Error(`Pattern matching error: no pattern matches value ${t}`)}returnType(){return this}}
6704
+ const t=Symbol.for("@ts-pattern/matcher"),e=Symbol.for("@ts-pattern/isVariadic"),n="@ts-pattern/anonymous-select-key",r=t=>Boolean(t&&"object"==typeof t),i=e=>e&&!!e[t],s=(n,o,c)=>{if(i(n)){const e=n[t](),{matched:r,selections:i}=e.match(o);return r&&i&&Object.keys(i).forEach(t=>c(t,i[t])),r}if(r(n)){if(!r(o))return !1;if(Array.isArray(n)){if(!Array.isArray(o))return !1;let t=[],r=[],a=[];for(const s of n.keys()){const o=n[s];i(o)&&o[e]?a.push(o):a.length?r.push(o):t.push(o);}if(a.length){if(a.length>1)throw new Error("Pattern error: Using `...P.array(...)` several times in a single pattern is not allowed.");if(o.length<t.length+r.length)return !1;const e=o.slice(0,t.length),n=0===r.length?[]:o.slice(-r.length),i=o.slice(t.length,0===r.length?Infinity:-r.length);return t.every((t,n)=>s(t,e[n],c))&&r.every((t,e)=>s(t,n[e],c))&&(0===a.length||s(a[0],i,c))}return n.length===o.length&&n.every((t,e)=>s(t,o[e],c))}return Object.keys(n).every(e=>{const r=n[e];return (e in o||i(a=r)&&"optional"===a[t]().matcherType)&&s(r,o[e],c);var a;})}return Object.is(o,n)},o=e=>{var n,s,a;return r(e)?i(e)?null!=(n=null==(s=(a=e[t]()).getSelectionKeys)?void 0:s.call(a))?n:[]:Array.isArray(e)?c(e,o):c(Object.values(e),o):[]},c=(t,e)=>t.reduce((t,n)=>t.concat(e(n)),[]);function a(...t){if(1===t.length){const[e]=t;return t=>s(e,t,()=>{})}if(2===t.length){const[e,n]=t;return s(e,n,()=>{})}throw new Error(`isMatching wasn't given the right number of arguments: expected 1 or 2, received ${t.length}.`)}function u(t){return Object.assign(t,{optional:()=>l(t),and:e=>m(t,e),or:e=>y(t,e),select:e=>void 0===e?p(t):p(e,t)})}function l(e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return void 0===t?(o(e).forEach(t=>r(t,void 0)),{matched:!0,selections:n}):{matched:s(e,t,r),selections:n}},getSelectionKeys:()=>o(e),matcherType:"optional"})})}function m(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return {matched:e.every(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"and"})})}function y(...e){return u({[t]:()=>({match:t=>{let n={};const r=(t,e)=>{n[t]=e;};return c(e,o).forEach(t=>r(t,void 0)),{matched:e.some(e=>s(e,t,r)),selections:n}},getSelectionKeys:()=>c(e,o),matcherType:"or"})})}function d(e){return {[t]:()=>({match:t=>({matched:Boolean(e(t))})})}}function p(...e){const r="string"==typeof e[0]?e[0]:void 0,i=2===e.length?e[1]:"string"==typeof e[0]?void 0:e[0];return u({[t]:()=>({match:t=>{let e={[null!=r?r:n]:t};return {matched:void 0===i||s(i,t,(t,n)=>{e[t]=n;}),selections:e}},getSelectionKeys:()=>[null!=r?r:n].concat(void 0===i?[]:o(i))})})}function v(t){return "number"==typeof t}function b(t){return "string"==typeof t}function w(t){return "bigint"==typeof t}u(d(function(t){return !0}));const j=t=>Object.assign(u(t),{startsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.startsWith(n)))));var n;},endsWith:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.endsWith(n)))));var n;},minLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length>=t))(e))),maxLength:e=>j(m(t,(t=>d(e=>b(e)&&e.length<=t))(e))),includes:e=>{return j(m(t,(n=e,d(t=>b(t)&&t.includes(n)))));var n;},regex:e=>{return j(m(t,(n=e,d(t=>b(t)&&Boolean(t.match(n))))));var n;}});j(d(b));const K=t=>Object.assign(u(t),{between:(e,n)=>K(m(t,((t,e)=>d(n=>v(n)&&t<=n&&e>=n))(e,n))),lt:e=>K(m(t,(t=>d(e=>v(e)&&e<t))(e))),gt:e=>K(m(t,(t=>d(e=>v(e)&&e>t))(e))),lte:e=>K(m(t,(t=>d(e=>v(e)&&e<=t))(e))),gte:e=>K(m(t,(t=>d(e=>v(e)&&e>=t))(e))),int:()=>K(m(t,d(t=>v(t)&&Number.isInteger(t)))),finite:()=>K(m(t,d(t=>v(t)&&Number.isFinite(t)))),positive:()=>K(m(t,d(t=>v(t)&&t>0))),negative:()=>K(m(t,d(t=>v(t)&&t<0)))});K(d(v));const x=t=>Object.assign(u(t),{between:(e,n)=>x(m(t,((t,e)=>d(n=>w(n)&&t<=n&&e>=n))(e,n))),lt:e=>x(m(t,(t=>d(e=>w(e)&&e<t))(e))),gt:e=>x(m(t,(t=>d(e=>w(e)&&e>t))(e))),lte:e=>x(m(t,(t=>d(e=>w(e)&&e<=t))(e))),gte:e=>x(m(t,(t=>d(e=>w(e)&&e>=t))(e))),positive:()=>x(m(t,d(t=>w(t)&&t>0))),negative:()=>x(m(t,d(t=>w(t)&&t<0)))});x(d(w));u(d(function(t){return "boolean"==typeof t}));u(d(function(t){return "symbol"==typeof t}));u(d(function(t){return null==t}));const W={matched:!1,value:void 0};function N(t){return new $(t,W)}class ${constructor(t,e){this.input=void 0,this.state=void 0,this.input=t,this.state=e;}with(...t){if(this.state.matched)return this;const e=t[t.length-1],r=[t[0]];let i;3===t.length&&"function"==typeof t[1]?(r.push(t[0]),i=t[1]):t.length>2&&r.push(...t.slice(1,t.length-1));let o=!1,c={};const a=(t,e)=>{o=!0,c[t]=e;},u=!r.some(t=>s(t,this.input,a))||i&&!Boolean(i(this.input))?W:{matched:!0,value:e(o?n in c?c[n]:c:this.input,this.input)};return new $(this.input,u)}when(t,e){if(this.state.matched)return this;const n=Boolean(t(this.input));return new $(this.input,n?{matched:!0,value:e(this.input,this.input)}:W)}otherwise(t){return this.state.matched?this.state.value:t(this.input)}exhaustive(){return this.run()}run(){if(this.state.matched)return this.state.value;let t;try{t=JSON.stringify(this.input);}catch(e){t=this.input;}throw new Error(`Pattern matching error: no pattern matches value ${t}`)}returnType(){return this}}
6565
6705
 
6566
6706
  function isPropertyOfPragma(name, context, pragma = getPragmaFromContext(context)) {
6567
6707
  const isMatch = a({
@@ -6929,190 +7069,175 @@ function isFragmentWithSingleExpression(node) {
6929
7069
  return children.length === 1 && children[0]?.type === NodeType.JSXExpressionContainer;
6930
7070
  }
6931
7071
 
6932
- const defaultJSXValueCheckOptions = {
6933
- ignoreNull: false,
6934
- strict: false
7072
+ /* eslint-disable perfectionist/sort-objects */ const JSXValueCheckHint = {
7073
+ None: 0n,
7074
+ IgnoreNull: 1n << 0n,
7075
+ IgnoreCreateElement: 1n << 1n,
7076
+ StrictLogical: 1n << 2n,
7077
+ StrictConditional: 1n << 3n
6935
7078
  };
6936
- /**
7079
+ /* eslint-enable perfectionist/sort-objects */ /**
6937
7080
  * Check if a node is a JSX value
6938
7081
  * @param node The AST node to check
6939
7082
  * @param context The rule context
6940
- * @param options The `JSXValueCheckOptions` to use
7083
+ * @param hint The `JSXValueCheckHint` to use
6941
7084
  * @returns boolean
6942
- */ function isJSXValue(node, context, options = defaultJSXValueCheckOptions) {
7085
+ */ function isJSXValue(node, context, hint = JSXValueCheckHint.None) {
6943
7086
  if (!node) {
6944
7087
  return false;
6945
7088
  }
6946
- // TODO: implement strict mode
6947
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
6948
- const { ignoreNull = false, strict = false } = options;
6949
- return N(node.type).with(NodeType.JSXElement, effectFunction_esm.constTrue).with(NodeType.JSXFragment, effectFunction_esm.constTrue).with(NodeType.Literal, ()=>{
6950
- if (!("value" in node) || ignoreNull) {
7089
+ return N(node).with({
7090
+ type: NodeType.JSXElement
7091
+ }, effectFunction_esm.constTrue).with({
7092
+ type: NodeType.JSXFragment
7093
+ }, effectFunction_esm.constTrue).with({
7094
+ type: NodeType.Literal
7095
+ }, (node)=>{
7096
+ if (!("value" in node) || hint & JSXValueCheckHint.IgnoreNull) {
6951
7097
  return false;
6952
7098
  }
6953
7099
  return node.value === null;
6954
- }).with(NodeType.ConditionalExpression, ()=>{
7100
+ }).with({
7101
+ type: NodeType.ConditionalExpression
7102
+ }, (node)=>{
6955
7103
  if (!("consequent" in node)) {
6956
7104
  return false;
6957
7105
  }
6958
- const leftHasJSX = N(node.consequent).with(_.array(), (n)=>n.some((n)=>isJSXValue(n, context, options))).with(_.any, (n)=>isJSXValue(n, context, options)).exhaustive();
6959
- if (leftHasJSX) {
6960
- return true;
7106
+ function leftHasJSX(node) {
7107
+ if (!("consequent" in node)) {
7108
+ return false;
7109
+ }
7110
+ if (Array.isArray(node.consequent)) {
7111
+ return node.consequent.some((n)=>isJSXValue(n, context, hint));
7112
+ }
7113
+ return isJSXValue(node.consequent, context, hint);
7114
+ }
7115
+ function rightHasJSX(node) {
7116
+ return "alternate" in node && isJSXValue(node.alternate, context, hint);
6961
7117
  }
6962
- return "alternate" in node && isJSXValue(node.alternate, context, options);
6963
- }).with(NodeType.LogicalExpression, ()=>{
7118
+ if (hint & JSXValueCheckHint.StrictConditional) {
7119
+ return leftHasJSX(node) && rightHasJSX(node);
7120
+ }
7121
+ return leftHasJSX(node) || rightHasJSX(node);
7122
+ }).with({
7123
+ type: NodeType.LogicalExpression
7124
+ }, (node)=>{
6964
7125
  if (!("left" in node)) {
6965
7126
  return false;
6966
7127
  }
6967
- return isJSXValue(node.left, context, options) || isJSXValue(node.right, context, options);
6968
- }).with(NodeType.SequenceExpression, ()=>{
7128
+ return isJSXValue(node.left, context, hint) || isJSXValue(node.right, context, hint);
7129
+ }).with({
7130
+ type: NodeType.SequenceExpression
7131
+ }, (node)=>{
6969
7132
  if (!("expressions" in node)) {
6970
7133
  return false;
6971
7134
  }
6972
7135
  const exp = node.expressions.at(-1);
6973
- return isJSXValue(exp, context, options);
6974
- }).with(NodeType.CallExpression, ()=>isCreateElementCall(node, context)).with(NodeType.Identifier, ()=>{
7136
+ return isJSXValue(exp, context, hint);
7137
+ }).with({
7138
+ type: NodeType.CallExpression
7139
+ }, (node)=>{
7140
+ if (hint & JSXValueCheckHint.IgnoreCreateElement) {
7141
+ return false;
7142
+ }
7143
+ return isCreateElementCall(node, context);
7144
+ }).with({
7145
+ type: NodeType.Identifier
7146
+ }, (node)=>{
6975
7147
  if (!("name" in node)) {
6976
7148
  return false;
6977
7149
  }
6978
7150
  if (isJSXTagNameExpression(node)) {
6979
7151
  return true;
6980
7152
  }
6981
- if (!isString(node.name) && node.name.type !== NodeType.Identifier) {
6982
- return isJSXTagNameExpression(node.name);
6983
- }
6984
- const name = N(node.name).with(_.string, effectFunction_esm.identity).with({
6985
- type: NodeType.Identifier
6986
- }, (n)=>n.name).exhaustive();
6987
- const variable = findVariableByNameUpToGlobal(name, context.getScope());
6988
- return effectFunction_esm.pipe(variable, effectOption_esm.flatMap(getVariableNthDefNodeInit(0)), effectOption_esm.map(isOneOf([
7153
+ const variable = findVariableByNameUpToGlobal(node.name, context.getScope());
7154
+ return effectFunction_esm.pipe(variable, effectOption_esm.flatMap(getVariableInitFirst), effectOption_esm.filter(isOneOf([
6989
7155
  NodeType.JSXElement,
6990
7156
  NodeType.JSXFragment
6991
- ])), effectOption_esm.getOrElse(effectFunction_esm.constFalse));
6992
- }).otherwise(effectFunction_esm.constFalse);
7157
+ ])), effectOption_esm.isSome);
7158
+ }).with({
7159
+ type: NodeType.JSXMemberExpression
7160
+ }, effectFunction_esm.constTrue).with({
7161
+ type: NodeType.JSXNamespacedName
7162
+ }, effectFunction_esm.constTrue).otherwise(effectFunction_esm.constFalse);
6993
7163
  }
6994
7164
 
6995
7165
  /**
6996
7166
  * Check if function is returning JSX
6997
7167
  * @param node The return statement node to check
6998
7168
  * @param context The rule context
6999
- * @param options The JSX value check options
7169
+ * @param hint The `JSXValueCheckHint` to use
7000
7170
  * @returns boolean
7001
- */ function isFunctionReturningJSXValue(node, context, options) {
7171
+ */ function isFunctionReturningJSXValue(node, context, hint = JSXValueCheckHint.None) {
7002
7172
  if (node.body.type !== NodeType.BlockStatement) {
7003
- return isJSXValue(node.body, context, options);
7173
+ return isJSXValue(node.body, context, hint);
7004
7174
  }
7005
7175
  const statements = getNestedReturnStatements(node.body);
7006
- return statements.some((statement)=>isJSXValue(statement.argument, context, options));
7176
+ return statements.some((statement)=>isJSXValue(statement.argument, context, hint));
7007
7177
  }
7008
7178
 
7009
- /**
7010
- * Check if the given prop name is present in the given attributes
7011
- * @param attributes The attributes to search in
7012
- * @param propName The prop name to search for
7013
- * @param context The rule context
7014
- * @returns `true` if the given prop name is present in the given properties
7015
- */ function hasProp(attributes, propName, context) {
7016
- return effectOption_esm.isSome(findPropInAttributes(attributes, context)(propName));
7017
- }
7018
- /**
7019
- * Check if any of the given prop names are present in the given attributes
7020
- * @param attributes The attributes to search in
7021
- * @param propNames The prop names to search for
7022
- * @param context The rule context
7023
- * @returns `true` if any of the given prop names are present in the given attributes
7024
- */ function hasAnyProp(attributes, propNames, context) {
7025
- return propNames.some((propName)=>hasProp(attributes, propName, context));
7026
- }
7027
- /**
7028
- * Check if all of the given prop names are present in the given attributes
7029
- * @param attributes The attributes to search in
7030
- * @param propNames The prop names to search for
7031
- * @param context The rule context
7032
- * @returns `true` if all of the given prop names are present in the given attributes
7033
- */ function hasEveryProp(attributes, propNames, context) {
7034
- return propNames.every((propName)=>hasProp(attributes, propName, context));
7035
- }
7036
- /**
7037
- * Get the name of a JSX attribute
7038
- * @param node The JSX attribute node
7039
- * @returns string
7040
- */ function getPropName(node) {
7041
- return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>n.name.name).exhaustive();
7042
- }
7043
- /**
7044
- * Get the name of a JSX attribute with namespace
7045
- * @param node The JSX attribute node
7046
- * @returns string
7047
- */ function getPropNameWithNamespace(node) {
7048
- return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>`${n.namespace.name}:${n.name.name}`).exhaustive();
7049
- }
7050
- /**
7051
- * Traverses up prop node
7052
- * @param node The AST node to start traversing from
7053
- * @param predicate The predicate to check each node
7054
- * @returns prop node if found
7055
- */ function traverseUpProp(node, predicate = effectFunction_esm.constTrue) {
7056
- const matcher = (node)=>{
7057
- return node.type === NodeType.JSXAttribute && predicate(node);
7058
- };
7059
- return effectOption_esm.fromNullable(traverseUpGuard(node, matcher));
7060
- }
7061
- /**
7062
- * Checks if the node is inside a prop's value
7063
- * @param node The AST node to check
7064
- * @returns `true` if the node is inside a prop's value
7065
- */ function isInsidePropValue(node) {
7066
- if (isStringLiteral(node)) {
7067
- return node.parent.type === NodeType.JSXAttribute;
7068
- }
7069
- return effectOption_esm.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
7070
- }
7071
7179
  /**
7072
7180
  * @param properties The properties to search in
7073
7181
  * @param context The rule context
7074
7182
  * @param seenProps The properties that have already been seen
7075
7183
  * @returns A function that searches for a property in the given properties
7076
7184
  */ function findPropInProperties(properties, context, seenProps = []) {
7185
+ const startScope = context.getScope();
7077
7186
  /**
7078
7187
  * Search for a property in the given properties
7079
7188
  * @param propName The name of the property to search for
7080
7189
  * @returns The property if found
7081
7190
  */ return (propName)=>{
7082
7191
  return effectOption_esm.fromNullable(properties.find((prop)=>{
7083
- if (prop.type === NodeType.Property) {
7192
+ return N(prop).when(is(NodeType.Property), (prop)=>{
7084
7193
  return "name" in prop.key && prop.key.name === propName;
7085
- }
7086
- if (prop.type === NodeType.SpreadElement) {
7087
- if (!("argument" in prop && "name" in prop.argument)) {
7088
- return false;
7089
- }
7090
- const { name } = prop.argument;
7091
- const maybeFirstDefNodeInit = effectFunction_esm.pipe(findVariableByNameUpToGlobal(name, context.getScope()), effectOption_esm.flatMap(getVariableNthDefNodeInit(0)));
7092
- if (effectOption_esm.isNone(maybeFirstDefNodeInit)) {
7093
- return false;
7094
- }
7095
- const firstDefNodeInit = maybeFirstDefNodeInit.value;
7096
- if (firstDefNodeInit.type !== NodeType.ObjectExpression) {
7097
- return false;
7098
- }
7099
- if (seenProps.includes(name)) {
7100
- return false;
7101
- }
7102
- return effectOption_esm.isSome(findPropInProperties(firstDefNodeInit.properties, context, [
7103
- ...seenProps,
7104
- name
7105
- ])(propName));
7106
- }
7107
- return false;
7194
+ }).when(is(NodeType.SpreadElement), (prop)=>{
7195
+ return N(prop.argument).when(is(NodeType.Identifier), (argument)=>{
7196
+ const { name } = argument;
7197
+ const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInitFirst);
7198
+ if (effectOption_esm.isNone(maybeInit)) {
7199
+ return false;
7200
+ }
7201
+ const init = maybeInit.value;
7202
+ if (init.type !== NodeType.ObjectExpression) {
7203
+ return false;
7204
+ }
7205
+ if (seenProps.includes(name)) {
7206
+ return false;
7207
+ }
7208
+ return effectOption_esm.isSome(findPropInProperties(init.properties, context, [
7209
+ ...seenProps,
7210
+ name
7211
+ ])(propName));
7212
+ }).when(is(NodeType.ObjectExpression), (argument)=>{
7213
+ return effectOption_esm.isSome(findPropInProperties(argument.properties, context, seenProps)(propName));
7214
+ }).when(is(NodeType.MemberExpression), ()=>{
7215
+ // Not implemented
7216
+ }).when(is(NodeType.CallExpression), ()=>{
7217
+ // Not implemented
7218
+ }).otherwise(effectFunction_esm.constFalse);
7219
+ }).when(is(NodeType.RestElement), ()=>{
7220
+ // Not implemented
7221
+ return false;
7222
+ }).otherwise(effectFunction_esm.constFalse);
7108
7223
  }));
7109
7224
  };
7110
7225
  }
7226
+
7227
+ /**
7228
+ * Get the name of a JSX attribute with namespace
7229
+ * @param node The JSX attribute node
7230
+ * @returns string
7231
+ */ function getPropName(node) {
7232
+ return N(node.name).when(is(NodeType.JSXIdentifier), (n)=>n.name).when(is(NodeType.JSXNamespacedName), (n)=>`${n.namespace.name}:${n.name.name}`).exhaustive();
7233
+ }
7234
+
7111
7235
  /**
7112
7236
  * @param attributes The attributes to search in
7113
7237
  * @param context The rule context
7114
7238
  * @returns A function that searches for a property in the given attributes
7115
7239
  */ function findPropInAttributes(attributes, context) {
7240
+ const startScope = context.getScope();
7116
7241
  /**
7117
7242
  * Search for a property in the given attributes
7118
7243
  * @param propName The name of the property to search for
@@ -7120,22 +7245,36 @@ const defaultJSXValueCheckOptions = {
7120
7245
  */ return (propName)=>{
7121
7246
  return effectOption_esm.fromNullable(attributes.find((attr)=>{
7122
7247
  return N(attr).when(is(NodeType.JSXAttribute), (attr)=>getPropName(attr) === propName).when(is(NodeType.JSXSpreadAttribute), (attr)=>{
7123
- if (!("argument" in attr && "name" in attr.argument)) {
7124
- return false;
7125
- }
7126
- const { name } = attr.argument;
7127
- const maybeFirstDefNodeInit = effectFunction_esm.pipe(findVariableByNameUpToGlobal(name, context.getScope()), effectOption_esm.flatMap(getVariableNthDefNodeInit(0)));
7128
- if (effectOption_esm.isNone(maybeFirstDefNodeInit)) {
7248
+ return N(attr.argument).with({
7249
+ type: NodeType.Identifier
7250
+ }, (argument)=>{
7251
+ const { name } = argument;
7252
+ const maybeInit = effectOption_esm.flatMap(findVariableByNameUpToGlobal(name, startScope), getVariableInitFirst);
7253
+ if (effectOption_esm.isNone(maybeInit)) {
7254
+ return false;
7255
+ }
7256
+ const init = maybeInit.value;
7257
+ if (!("properties" in init)) {
7258
+ return false;
7259
+ }
7260
+ return effectOption_esm.isSome(findPropInProperties(init.properties, context)(propName));
7261
+ }).when(is(NodeType.ObjectExpression), (argument)=>{
7262
+ return effectOption_esm.isSome(findPropInProperties(argument.properties, context)(propName));
7263
+ }).when(is(NodeType.MemberExpression), ()=>{
7264
+ // Not implemented
7129
7265
  return false;
7130
- }
7131
- if (!("properties" in maybeFirstDefNodeInit.value)) {
7266
+ }).when(is(NodeType.CallExpression), ()=>{
7267
+ // Not implemented
7132
7268
  return false;
7133
- }
7134
- return effectOption_esm.isSome(findPropInProperties(maybeFirstDefNodeInit.value.properties, context)(propName));
7269
+ }).otherwise(effectFunction_esm.constFalse);
7135
7270
  }).otherwise(effectFunction_esm.constFalse);
7136
7271
  }));
7137
7272
  };
7138
7273
  }
7274
+
7275
+ function getProp(props, propName, context) {
7276
+ return findPropInAttributes(props, context)(propName);
7277
+ }
7139
7278
  /**
7140
7279
  * Gets and resolves the static value of a JSX attribute
7141
7280
  * @param attribute The JSX attribute to get the value of
@@ -7160,4 +7299,55 @@ const defaultJSXValueCheckOptions = {
7160
7299
  return effectOption_esm.some(getStaticValue(argument, scope));
7161
7300
  }
7162
7301
 
7163
- export { defaultJSXValueCheckOptions, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getPropName, getPropNameWithNamespace, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentHasLessThanTwoChildren, isFragmentSyntax, isFragmentWithOnlyTextAndIsNotChild, isFragmentWithSingleExpression, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };
7302
+ /**
7303
+ * Check if the given prop name is present in the given attributes
7304
+ * @param attributes The attributes to search in
7305
+ * @param propName The prop name to search for
7306
+ * @param context The rule context
7307
+ * @returns `true` if the given prop name is present in the given properties
7308
+ */ function hasProp(attributes, propName, context) {
7309
+ return effectOption_esm.isSome(findPropInAttributes(attributes, context)(propName));
7310
+ }
7311
+ /**
7312
+ * Check if any of the given prop names are present in the given attributes
7313
+ * @param attributes The attributes to search in
7314
+ * @param propNames The prop names to search for
7315
+ * @param context The rule context
7316
+ * @returns `true` if any of the given prop names are present in the given attributes
7317
+ */ function hasAnyProp(attributes, propNames, context) {
7318
+ return propNames.some((propName)=>hasProp(attributes, propName, context));
7319
+ }
7320
+ /**
7321
+ * Check if all of the given prop names are present in the given attributes
7322
+ * @param attributes The attributes to search in
7323
+ * @param propNames The prop names to search for
7324
+ * @param context The rule context
7325
+ * @returns `true` if all of the given prop names are present in the given attributes
7326
+ */ function hasEveryProp(attributes, propNames, context) {
7327
+ return propNames.every((propName)=>hasProp(attributes, propName, context));
7328
+ }
7329
+
7330
+ /**
7331
+ * Traverses up prop node
7332
+ * @param node The AST node to start traversing from
7333
+ * @param predicate The predicate to check each node
7334
+ * @returns prop node if found
7335
+ */ function traverseUpProp(node, predicate = effectFunction_esm.constTrue) {
7336
+ const matcher = (node)=>{
7337
+ return node.type === NodeType.JSXAttribute && predicate(node);
7338
+ };
7339
+ return effectOption_esm.fromNullable(traverseUpGuard(node, matcher));
7340
+ }
7341
+
7342
+ /**
7343
+ * Checks if the node is inside a prop's value
7344
+ * @param node The AST node to check
7345
+ * @returns `true` if the node is inside a prop's value
7346
+ */ function isInsidePropValue(node) {
7347
+ if (isStringLiteral(node)) {
7348
+ return node.parent.type === NodeType.JSXAttribute;
7349
+ }
7350
+ return effectOption_esm.isSome(traverseUpProp(node, (n)=>n.value?.type === NodeType.JSXExpressionContainer));
7351
+ }
7352
+
7353
+ export { JSXValueCheckHint, elementType, findPropInAttributes, findPropInProperties, getFragmentFromContext, getPragmaFromContext, getProp, getPropName, getPropValue, hasAnyProp, hasChildren, hasEveryProp, hasProp, hdlAnimation, hdlClipboard, hdlComposition, hdlFocus, hdlForm, hdlImage, hdlKeyboard, hdlMedia, hdlMouse, hdlScroll, hdlSelection, hdlTouch, hdlTransition, hdlWheel, isCallFromPragma, isChildOfJSXElement, isChildrenOfCreateElement, isCloneElementCall, isCreateElementCall, isFragment, isFragmentElement, isFragmentHasLessThanTwoChildren, isFragmentSyntax, isFragmentWithOnlyTextAndIsNotChild, isFragmentWithSingleExpression, isFunctionReturningJSXValue, isInitializedFromPragma, isInsideCreateElementProps, isInsidePropValue, isJSXElementOfBuiltinComponent, isJSXElementOfUserDefinedComponent, isJSXValue, isLineBreak, isLiteral, isPaddingSpaces, isPropertyOfPragma, isWhiteSpace, traverseUpProp };