@fairfox/polly 0.13.2 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -236940,6 +236940,39 @@ class HandlerExtractor {
236940
236940
  if (value !== undefined) {
236941
236941
  assignments.push({ field, value });
236942
236942
  }
236943
+ return;
236944
+ }
236945
+ const valueMatch = fieldPath.match(/\.value\.(.+)$/);
236946
+ if (valueMatch && valueMatch[1]) {
236947
+ const field = valueMatch[1];
236948
+ const value = this.extractValue(right);
236949
+ if (value !== undefined) {
236950
+ assignments.push({ field, value });
236951
+ }
236952
+ return;
236953
+ }
236954
+ if (fieldPath.endsWith(".value") && import_ts_morph4.Node.isObjectLiteralExpression(right)) {
236955
+ this.extractObjectLiteralAssignments(right, assignments);
236956
+ }
236957
+ }
236958
+ extractObjectLiteralAssignments(objectLiteral, assignments) {
236959
+ if (!import_ts_morph4.Node.isObjectLiteralExpression(objectLiteral))
236960
+ return;
236961
+ for (const prop of objectLiteral.getProperties()) {
236962
+ if (import_ts_morph4.Node.isPropertyAssignment(prop)) {
236963
+ const name = prop.getName();
236964
+ const initializer = prop.getInitializer();
236965
+ if (!name || !initializer)
236966
+ continue;
236967
+ const value = this.extractValue(initializer);
236968
+ if (value !== undefined) {
236969
+ assignments.push({ field: name, value });
236970
+ }
236971
+ }
236972
+ if (import_ts_morph4.Node.isShorthandPropertyAssignment(prop)) {
236973
+ const name = prop.getName();
236974
+ assignments.push({ field: name, value: "@" });
236975
+ }
236943
236976
  }
236944
236977
  }
236945
236978
  extractElementAccessAssignment(left, right, assignments) {
@@ -236949,9 +236982,9 @@ class HandlerExtractor {
236949
236982
  if (!import_ts_morph4.Node.isPropertyAccessExpression(expr))
236950
236983
  return;
236951
236984
  const fieldPath = this.getPropertyPath(expr);
236952
- if (!fieldPath.startsWith("state."))
236985
+ const field = this.extractFieldFromStatePath(fieldPath);
236986
+ if (!field)
236953
236987
  return;
236954
- const field = fieldPath.substring(6);
236955
236988
  const indexExpr = left.getArgumentExpression();
236956
236989
  const index = indexExpr ? indexExpr.getText() : "0";
236957
236990
  const value = this.extractValue(right);
@@ -236963,6 +236996,16 @@ class HandlerExtractor {
236963
236996
  });
236964
236997
  }
236965
236998
  }
236999
+ extractFieldFromStatePath(fieldPath) {
237000
+ if (fieldPath.startsWith("state.")) {
237001
+ return fieldPath.substring(6);
237002
+ }
237003
+ const valueMatch = fieldPath.match(/\.value\.(.+)$/);
237004
+ if (valueMatch && valueMatch[1]) {
237005
+ return valueMatch[1];
237006
+ }
237007
+ return null;
237008
+ }
236966
237009
  extractCompoundAssignment(node, assignments) {
236967
237010
  if (!import_ts_morph4.Node.isBinaryExpression(node))
236968
237011
  return;
@@ -236971,8 +237014,8 @@ class HandlerExtractor {
236971
237014
  const right = node.getRight();
236972
237015
  if (import_ts_morph4.Node.isPropertyAccessExpression(left)) {
236973
237016
  const fieldPath = this.getPropertyPath(left);
236974
- if (fieldPath.startsWith("state.")) {
236975
- const field = fieldPath.substring(6);
237017
+ const field = this.extractFieldFromStatePath(fieldPath);
237018
+ if (field) {
236976
237019
  const rightValue = right.getText();
236977
237020
  const tlaOp = operator.slice(0, -1);
236978
237021
  assignments.push({
@@ -237006,8 +237049,8 @@ class HandlerExtractor {
237006
237049
  if (!import_ts_morph4.Node.isPropertyAccessExpression(operand))
237007
237050
  return;
237008
237051
  const fieldPath = this.getPropertyPath(operand);
237009
- if (fieldPath.startsWith("state.")) {
237010
- const field = fieldPath.substring(6);
237052
+ const field = this.extractFieldFromStatePath(fieldPath);
237053
+ if (field) {
237011
237054
  const value = operatorText === "++" ? "@ + 1" : "@ - 1";
237012
237055
  assignments.push({ field, value });
237013
237056
  }
@@ -237022,8 +237065,8 @@ class HandlerExtractor {
237022
237065
  const object = expr.getExpression();
237023
237066
  if (import_ts_morph4.Node.isPropertyAccessExpression(object)) {
237024
237067
  const fieldPath = this.getPropertyPath(object);
237025
- if (fieldPath.startsWith("state.")) {
237026
- const field = fieldPath.substring(6);
237068
+ const field = this.extractFieldFromStatePath(fieldPath);
237069
+ if (field) {
237027
237070
  const args = node.getArguments().map((arg) => arg.getText());
237028
237071
  const tlaValue = this.translateArrayMethod(methodName, args, fieldPath);
237029
237072
  if (tlaValue) {
@@ -237663,8 +237706,8 @@ class HandlerExtractor {
237663
237706
  if (!import_ts_morph4.Node.isPropertyAccessExpression(left) && !import_ts_morph4.Node.isElementAccessExpression(left))
237664
237707
  return;
237665
237708
  const fieldPath = import_ts_morph4.Node.isPropertyAccessExpression(left) ? this.getPropertyPath(left) : this.getPropertyPath(left.getExpression());
237666
- if (fieldPath.startsWith("state.")) {
237667
- const field = fieldPath.substring(6);
237709
+ const field = this.extractFieldFromStatePath(fieldPath);
237710
+ if (field) {
237668
237711
  const line = node.getStartLineNumber();
237669
237712
  const afterAwait = node.getStart() > firstAwaitPos;
237670
237713
  mutations.push({ field, line, afterAwait });
@@ -237681,10 +237724,8 @@ class HandlerExtractor {
237681
237724
  if (!import_ts_morph4.Node.isPropertyAccessExpression(object))
237682
237725
  return;
237683
237726
  const fieldPath = this.getPropertyPath(object);
237684
- if (!fieldPath.startsWith("state."))
237685
- return;
237686
- if (["push", "pop", "shift", "unshift", "splice"].includes(methodName)) {
237687
- const field = fieldPath.substring(6);
237727
+ const field = this.extractFieldFromStatePath(fieldPath);
237728
+ if (field && ["push", "pop", "shift", "unshift", "splice"].includes(methodName)) {
237688
237729
  const line = node.getStartLineNumber();
237689
237730
  const afterAwait = node.getStart() > firstAwaitPos;
237690
237731
  mutations.push({ field, line, afterAwait });
@@ -240753,4 +240794,4 @@ export {
240753
240794
  generateTeachingMaterial
240754
240795
  };
240755
240796
 
240756
- //# debugId=555FA35403EDF64764756E2164756E21
240797
+ //# debugId=CA5D1CF4CE333DEB64756E2164756E21