@swmansion/argent 0.29.1-next.7 → 0.29.1-next.9

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/client.js CHANGED
@@ -978,36 +978,38 @@ var require_Alias = __commonJS({
978
978
  if (node.anchor === this.source)
979
979
  found = node;
980
980
  }
981
+ if (found && ctx) {
982
+ const { anchors: anchors2, doc: doc2, maxAliasCount } = ctx;
983
+ let data = anchors2.get(found);
984
+ if (!data) {
985
+ toJS.toJS(found, null, ctx);
986
+ data = anchors2.get(found);
987
+ }
988
+ if (data?.res === void 0) {
989
+ const msg = "This should not happen: Alias anchor was not resolved?";
990
+ throw new ReferenceError(msg);
991
+ }
992
+ if (maxAliasCount >= 0) {
993
+ data.count += 1;
994
+ if (data.aliasCount === 0)
995
+ data.aliasCount = getAliasCount(doc2, found, anchors2);
996
+ if (data.count * data.aliasCount > maxAliasCount) {
997
+ const msg = "Excessive alias count indicates a resource exhaustion attack";
998
+ throw new ReferenceError(msg);
999
+ }
1000
+ }
1001
+ }
981
1002
  return found;
982
1003
  }
983
1004
  toJSON(_arg, ctx) {
984
1005
  if (!ctx)
985
1006
  return { source: this.source };
986
- const { anchors: anchors2, doc, maxAliasCount } = ctx;
987
- const source = this.resolve(doc, ctx);
1007
+ const source = this.resolve(ctx.doc, ctx);
988
1008
  if (!source) {
989
1009
  const msg = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
990
1010
  throw new ReferenceError(msg);
991
1011
  }
992
- let data = anchors2.get(source);
993
- if (!data) {
994
- toJS.toJS(source, null, ctx);
995
- data = anchors2.get(source);
996
- }
997
- if (data?.res === void 0) {
998
- const msg = "This should not happen: Alias anchor was not resolved?";
999
- throw new ReferenceError(msg);
1000
- }
1001
- if (maxAliasCount >= 0) {
1002
- data.count += 1;
1003
- if (data.aliasCount === 0)
1004
- data.aliasCount = getAliasCount(doc, source, anchors2);
1005
- if (data.count * data.aliasCount > maxAliasCount) {
1006
- const msg = "Excessive alias count indicates a resource exhaustion attack";
1007
- throw new ReferenceError(msg);
1008
- }
1009
- }
1010
- return data.res;
1012
+ return ctx.anchors.get(source).res;
1011
1013
  }
1012
1014
  toString(ctx, _onComment, _onChompKeep) {
1013
1015
  const src = `*${this.source}`;
@@ -5009,37 +5011,38 @@ var require_resolve_flow_scalar = __commonJS({
5009
5011
  }
5010
5012
  if (badChar)
5011
5013
  onError(0, "BAD_SCALAR_START", `Plain value cannot start with ${badChar}`);
5012
- return foldLines(source);
5014
+ return unfoldLines(source);
5013
5015
  }
5014
5016
  function singleQuotedValue(source, onError) {
5015
5017
  if (source[source.length - 1] !== "'" || source.length === 1)
5016
5018
  onError(source.length, "MISSING_CHAR", "Missing closing 'quote");
5017
- return foldLines(source.slice(1, -1)).replace(/''/g, "'");
5019
+ return unfoldLines(source.slice(1, -1)).replace(/''/g, "'");
5018
5020
  }
5019
- function foldLines(source) {
5020
- let first, line;
5021
+ function unfoldLines(source) {
5022
+ const line = /(.*?)\r?\n/sy;
5023
+ let match = line.exec(source);
5024
+ if (!match)
5025
+ return source;
5026
+ let trimEnd, trimBoth;
5021
5027
  try {
5022
- first = new RegExp("(.*?)(?<![ ])[ ]*\r?\n", "sy");
5023
- line = new RegExp("[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?\n", "sy");
5028
+ trimEnd = new RegExp("(?<![ ])[ ]+$");
5029
+ trimBoth = new RegExp("^[ ]+|(?<![ ])[ ]+$", "g");
5024
5030
  } catch {
5025
- first = /(.*?)[ \t]*\r?\n/sy;
5026
- line = /[ \t]*(.*?)[ \t]*\r?\n/sy;
5031
+ trimEnd = /[ \t]+$/;
5032
+ trimBoth = /^[ \t]+|[ \t]+$/g;
5027
5033
  }
5028
- let match = first.exec(source);
5029
- if (!match)
5030
- return source;
5031
- let res = match[1];
5034
+ let res = match[1].replace(trimEnd, "");
5032
5035
  let sep6 = " ";
5033
- let pos = first.lastIndex;
5034
- line.lastIndex = pos;
5036
+ let pos = line.lastIndex;
5035
5037
  while (match = line.exec(source)) {
5036
- if (match[1] === "") {
5038
+ const lm = match[1].replace(trimBoth, "");
5039
+ if (lm === "") {
5037
5040
  if (sep6 === "\n")
5038
5041
  res += sep6;
5039
5042
  else
5040
5043
  sep6 = "\n";
5041
5044
  } else {
5042
- res += sep6 + match[1];
5045
+ res += sep6 + lm;
5043
5046
  sep6 = " ";
5044
5047
  }
5045
5048
  pos = line.lastIndex;