@gridsheet/engine 3.4.0 → 3.4.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.js CHANGED
@@ -1958,9 +1958,10 @@ class Y {
1958
1958
  }
1959
1959
  /** @internal */
1960
1960
  processFormula(t, { idMap: e, ...s }) {
1961
+ var i, n;
1961
1962
  if ((typeof t == "string" || t instanceof String) && t.charAt(0) === "=") {
1962
- const i = new te(t.substring(1));
1963
- return i.tokenize(e), i.identify({ ...s, sheet: this }), i.dependencyIds.forEach((n) => this.addDependency(n, s.dependency)), s.dependency != null && (this._formulaHasAsync(i) ? this.registry.asyncFormulaCells.add(s.dependency) : this.registry.asyncFormulaCells.delete(s.dependency)), "=" + i.identifiedFormula;
1963
+ const o = new te(t.substring(1));
1964
+ return o.tokenize(e), o.identify({ ...s, sheet: this }), o.dependencyIds.forEach((a) => this.addDependency(a, s.dependency)), s.dependency != null && (this._formulaHasAsync(o) ? this.registry.asyncFormulaCells.add(s.dependency) : this.registry.asyncFormulaCells.delete(s.dependency), (n = (i = this.registry).onFormula) == null || n.call(i)), "=" + o.identifiedFormula;
1964
1965
  }
1965
1966
  return s.dependency != null && this.registry.asyncFormulaCells.delete(s.dependency), t;
1966
1967
  }
@@ -3280,7 +3281,7 @@ class Y {
3280
3281
  if (!Dt.is(this._stripped))
3281
3282
  return this._stripped;
3282
3283
  let s = this;
3283
- for (; s instanceof Y; )
3284
+ for (; Y.is(s); )
3284
3285
  s = (i = Ve({ sheet: s, raise: t, at: e })[0]) == null ? void 0 : i[0];
3285
3286
  return this._stripped = s, this._stripped;
3286
3287
  }
@@ -3669,7 +3670,7 @@ const we = ({ value: r, sheet: t, point: e, raise: s = !0, resolution: i = "RESO
3669
3670
  throw t.finishSolvedCache(e, u), u;
3670
3671
  return u;
3671
3672
  }
3672
- return W.is(l) ? l = t.spill(e, l.matrix) : t.finishSolvedCache(e, l), i === "RESOLVED" && l instanceof Y && (l = ut({ value: l, raise: s, at: n })), L.is(l) && t.finishSolvedCache(e, l), l;
3673
+ return W.is(l) ? l = t.spill(e, l.matrix) : t.finishSolvedCache(e, l), i === "RESOLVED" && Y.is(l) && (l = ut({ value: l, raise: s, at: n })), L.is(l) && t.finishSolvedCache(e, l), l;
3673
3674
  }, Ve = ({ sheet: r, raise: t = !0, at: e }) => {
3674
3675
  const s = r.area;
3675
3676
  return r._toValueMatrix({ area: s, at: e, resolution: "SYSTEM" }).map((n, o) => {
@@ -3695,7 +3696,7 @@ const we = ({ value: r, sheet: t, point: e, raise: s = !0, resolution: i = "RESO
3695
3696
  }
3696
3697
  });
3697
3698
  });
3698
- }, ut = ({ value: r, at: t, raise: e = !0 }) => r instanceof Y ? r.strip({ raise: e, at: t }) : r, xe = new _t("asyncCacheMiss"), Ci = (r) => r.some((t) => L.is(t)), ps = (r) => (r == null ? void 0 : r.__gsType) === "Sheet", Pt = (r, t) => {
3699
+ }, ut = ({ value: r, at: t, raise: e = !0 }) => Y.is(r) ? r.strip({ raise: e, at: t }) : r, xe = new _t("asyncCacheMiss"), Ci = (r) => r.some((t) => L.is(t)), ps = (r) => (r == null ? void 0 : r.__gsType) === "Sheet", Pt = (r, t) => {
3699
3700
  for (const e of r)
3700
3701
  if (L.is(e) || Array.isArray(e) && Pt(e, t) || W.is(e) && Pt(e.matrix, t) || ps(e) && Pt(e._toValueMatrix({ at: t }), t))
3701
3702
  return !0;
@@ -3774,7 +3775,7 @@ const we = ({ value: r, sheet: t, point: e, raise: s = !0, resolution: i = "RESO
3774
3775
  return e;
3775
3776
  if (!r)
3776
3777
  return 0;
3777
- if (r instanceof Y) {
3778
+ if (Y.is(r)) {
3778
3779
  const n = ut({ value: r });
3779
3780
  return O(n, { alternative: e });
3780
3781
  }
@@ -3798,7 +3799,7 @@ const we = ({ value: r, sheet: t, point: e, raise: s = !0, resolution: i = "RESO
3798
3799
  return "0";
3799
3800
  if (!r)
3800
3801
  return "";
3801
- if (r instanceof Y) {
3802
+ if (Y.is(r)) {
3802
3803
  const t = ut({ value: r });
3803
3804
  return Q(t);
3804
3805
  }
@@ -3816,7 +3817,7 @@ const we = ({ value: r, sheet: t, point: e, raise: s = !0, resolution: i = "RESO
3816
3817
  return e;
3817
3818
  if (r === null)
3818
3819
  return !1;
3819
- if (r instanceof Y) {
3820
+ if (Y.is(r)) {
3820
3821
  const i = ut({ value: r });
3821
3822
  return Wt(i, t);
3822
3823
  }
@@ -3834,7 +3835,7 @@ const we = ({ value: r, sheet: t, point: e, raise: s = !0, resolution: i = "RESO
3834
3835
  function Ni(r) {
3835
3836
  if (L.is(r) || r instanceof Date)
3836
3837
  return r;
3837
- if (r instanceof Y) {
3838
+ if (Y.is(r)) {
3838
3839
  const t = ut({ value: r });
3839
3840
  return Ni(t);
3840
3841
  }
@@ -3870,7 +3871,7 @@ const vi = /^(<=|>=|<>|>|<|=)?(.*)$/, ki = (r, t) => {
3870
3871
  }
3871
3872
  return Oe(r, n) === o;
3872
3873
  }, dt = (r, t, e) => {
3873
- if (r instanceof Y) {
3874
+ if (Y.is(r)) {
3874
3875
  const s = r.solve({ at: e });
3875
3876
  for (let i = 0; i < s.length; i++)
3876
3877
  for (let n = 0; n < s[i].length; n++)
@@ -4701,7 +4702,7 @@ class Pr extends A {
4701
4702
  ], this.category = "logical", this.broadcastDisabled = !0;
4702
4703
  }
4703
4704
  main(t) {
4704
- return W.is(t) ? t : t instanceof Y ? t._toValueMatrix() : Array.isArray(t) ? t : [[t]];
4705
+ return W.is(t) ? t : Y.is(t) ? t._toValueMatrix() : Array.isArray(t) ? t : [[t]];
4705
4706
  }
4706
4707
  }
4707
4708
  const gs = {
@@ -4766,18 +4767,19 @@ class Hr {
4766
4767
  onInsertCols: h,
4767
4768
  onSelect: u,
4768
4769
  onKeyUp: c,
4769
- onInit: f
4770
+ onInit: f,
4771
+ onFormula: d
4770
4772
  } = {}) {
4771
- this.sheetHead = 0, this.cellHead = 0, this.data = {}, this.systems = {}, this.sheetIdsByName = {}, this.contextsBySheetId = {}, this.choosingSheetId = 0, this.choosingAddress = "", this.editingSheetId = 0, this.editingAddress = "", this.paletteBySheetName = {}, this.lastFocused = null, this.solvedCaches = /* @__PURE__ */ new Map(), this.lastSpilledTargetIds = /* @__PURE__ */ new Set(), this.asyncFormulaCells = /* @__PURE__ */ new Set(), this.asyncPending = /* @__PURE__ */ new Map(), this.copyingSheetId = 0, this.copyingZone = Ms, this.cutting = !1, this.histories = [], this.historyIndex = -1, this.historyLimit = Cs, this._componentSheetIds = /* @__PURE__ */ new Map(), this.ready = !1, this.functions = {}, this.policies = {}, this.transmit = (d) => {
4772
- }, this.updateSheet = (d) => ({ type: 0, value: d }), t != null && (this.historyLimit = t), this.functions = {
4773
+ this.sheetHead = 0, this.cellHead = 0, this.data = {}, this.systems = {}, this.sheetIdsByName = {}, this.contextsBySheetId = {}, this.choosingSheetId = 0, this.choosingAddress = "", this.editingSheetId = 0, this.editingAddress = "", this.paletteBySheetName = {}, this.lastFocused = null, this.solvedCaches = /* @__PURE__ */ new Map(), this.lastSpilledTargetIds = /* @__PURE__ */ new Set(), this.asyncFormulaCells = /* @__PURE__ */ new Set(), this.asyncPending = /* @__PURE__ */ new Map(), this.copyingSheetId = 0, this.copyingZone = Ms, this.cutting = !1, this.histories = [], this.historyIndex = -1, this.historyLimit = Cs, this._componentSheetIds = /* @__PURE__ */ new Map(), this.ready = !1, this.functions = {}, this.policies = {}, this.transmit = (p) => {
4774
+ }, this.updateSheet = (p) => ({ type: 0, value: p }), t != null && (this.historyLimit = t), this.functions = {
4773
4775
  ...gs,
4774
4776
  ...e
4775
4777
  };
4776
- for (const d in this.functions) {
4777
- const p = this.functions[d];
4778
- p.__name = d;
4778
+ for (const p in this.functions) {
4779
+ const m = this.functions[p];
4780
+ m.__name = p;
4779
4781
  }
4780
- this.policies = s, this.onSave = i, this.onChange = n, this.onRemoveRows = o, this.onRemoveCols = a, this.onInsertRows = l, this.onInsertCols = h, this.onSelect = u, this.onKeyUp = c, this.onInit = f;
4782
+ this.policies = s, this.onSave = i, this.onChange = n, this.onRemoveRows = o, this.onRemoveCols = a, this.onInsertRows = l, this.onInsertCols = h, this.onSelect = u, this.onKeyUp = c, this.onInit = f, this.onFormula = d;
4781
4783
  }
4782
4784
  boot() {
4783
4785
  if (this.ready || Object.keys(this.contextsBySheetId).length === 0)