@diagonal-hq/cli 0.21.3 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.mjs CHANGED
@@ -8983,7 +8983,7 @@ var require_typescript = __commonJS({
8983
8983
  isCommaListExpression: () => isCommaListExpression,
8984
8984
  isCommaSequence: () => isCommaSequence,
8985
8985
  isCommaToken: () => isCommaToken,
8986
- isComment: () => isComment,
8986
+ isComment: () => isComment2,
8987
8987
  isCommonJsExportPropertyAssignment: () => isCommonJsExportPropertyAssignment,
8988
8988
  isCommonJsExportedExpression: () => isCommonJsExportedExpression,
8989
8989
  isCompoundAssignment: () => isCompoundAssignment,
@@ -19719,7 +19719,7 @@ ${lanes.join("\n")}
19719
19719
  function computeLineStarts(text2) {
19720
19720
  const result = [];
19721
19721
  let pos = 0;
19722
- let lineStart = 0;
19722
+ let lineStart2 = 0;
19723
19723
  while (pos < text2.length) {
19724
19724
  const ch = text2.charCodeAt(pos);
19725
19725
  pos++;
@@ -19730,18 +19730,18 @@ ${lanes.join("\n")}
19730
19730
  }
19731
19731
  // falls through
19732
19732
  case 10:
19733
- result.push(lineStart);
19734
- lineStart = pos;
19733
+ result.push(lineStart2);
19734
+ lineStart2 = pos;
19735
19735
  break;
19736
19736
  default:
19737
19737
  if (ch > 127 && isLineBreak(ch)) {
19738
- result.push(lineStart);
19739
- lineStart = pos;
19738
+ result.push(lineStart2);
19739
+ lineStart2 = pos;
19740
19740
  }
19741
19741
  break;
19742
19742
  }
19743
19743
  }
19744
- result.push(lineStart);
19744
+ result.push(lineStart2);
19745
19745
  return result;
19746
19746
  }
19747
19747
  function getPositionOfLineAndCharacter(sourceFile, line, character, allowEdits) {
@@ -22412,7 +22412,7 @@ ${lanes.join("\n")}
22412
22412
  error2(Diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, getNameOfScriptTarget(availableFrom));
22413
22413
  }
22414
22414
  }
22415
- function appendIfCommentDirective(commentDirectives2, text22, commentDirectiveRegEx, lineStart) {
22415
+ function appendIfCommentDirective(commentDirectives2, text22, commentDirectiveRegEx, lineStart2) {
22416
22416
  const type = getDirectiveFromComment(text22.trimStart(), commentDirectiveRegEx);
22417
22417
  if (type === void 0) {
22418
22418
  return commentDirectives2;
@@ -22420,7 +22420,7 @@ ${lanes.join("\n")}
22420
22420
  return append(
22421
22421
  commentDirectives2,
22422
22422
  {
22423
- range: { pos: lineStart, end: pos },
22423
+ range: { pos: lineStart2, end: pos },
22424
22424
  type
22425
22425
  }
22426
22426
  );
@@ -28408,7 +28408,7 @@ ${lanes.join("\n")}
28408
28408
  function createTextWriter(newLine) {
28409
28409
  var output;
28410
28410
  var indent3;
28411
- var lineStart;
28411
+ var lineStart2;
28412
28412
  var lineCount;
28413
28413
  var linePos;
28414
28414
  var hasTrailingComment = false;
@@ -28417,16 +28417,16 @@ ${lanes.join("\n")}
28417
28417
  if (lineStartsOfS.length > 1) {
28418
28418
  lineCount = lineCount + lineStartsOfS.length - 1;
28419
28419
  linePos = output.length - s.length + last2(lineStartsOfS);
28420
- lineStart = linePos - output.length === 0;
28420
+ lineStart2 = linePos - output.length === 0;
28421
28421
  } else {
28422
- lineStart = false;
28422
+ lineStart2 = false;
28423
28423
  }
28424
28424
  }
28425
28425
  function writeText(s) {
28426
28426
  if (s && s.length) {
28427
- if (lineStart) {
28427
+ if (lineStart2) {
28428
28428
  s = getIndentString(indent3) + s;
28429
- lineStart = false;
28429
+ lineStart2 = false;
28430
28430
  }
28431
28431
  output += s;
28432
28432
  updateLineCountAndPosFor(s);
@@ -28443,7 +28443,7 @@ ${lanes.join("\n")}
28443
28443
  function reset2() {
28444
28444
  output = "";
28445
28445
  indent3 = 0;
28446
- lineStart = true;
28446
+ lineStart2 = true;
28447
28447
  lineCount = 0;
28448
28448
  linePos = 0;
28449
28449
  hasTrailingComment = false;
@@ -28461,11 +28461,11 @@ ${lanes.join("\n")}
28461
28461
  }
28462
28462
  }
28463
28463
  function writeLine(force) {
28464
- if (!lineStart || force) {
28464
+ if (!lineStart2 || force) {
28465
28465
  output += newLine;
28466
28466
  lineCount++;
28467
28467
  linePos = output.length;
28468
- lineStart = true;
28468
+ lineStart2 = true;
28469
28469
  hasTrailingComment = false;
28470
28470
  }
28471
28471
  }
@@ -28484,9 +28484,9 @@ ${lanes.join("\n")}
28484
28484
  getIndent: () => indent3,
28485
28485
  getTextPos: () => output.length,
28486
28486
  getLine: () => lineCount,
28487
- getColumn: () => lineStart ? indent3 * getIndentSize() : output.length - linePos,
28487
+ getColumn: () => lineStart2 ? indent3 * getIndentSize() : output.length - linePos,
28488
28488
  getText: () => output,
28489
- isAtStartOfLine: () => lineStart,
28489
+ isAtStartOfLine: () => lineStart2,
28490
28490
  hasTrailingComment: () => hasTrailingComment,
28491
28491
  hasTrailingWhitespace: () => !!output.length && isWhiteSpaceLike(output.charCodeAt(output.length - 1)),
28492
28492
  clear: reset2,
@@ -132030,7 +132030,7 @@ ${lanes.join("\n")}
132030
132030
  }
132031
132031
  }
132032
132032
  function createImportCallExpressionAMD(arg, containsLexicalThis) {
132033
- const resolve7 = factory2.createUniqueName("resolve");
132033
+ const resolve8 = factory2.createUniqueName("resolve");
132034
132034
  const reject = factory2.createUniqueName("reject");
132035
132035
  const parameters = [
132036
132036
  factory2.createParameterDeclaration(
@@ -132039,7 +132039,7 @@ ${lanes.join("\n")}
132039
132039
  /*dotDotDotToken*/
132040
132040
  void 0,
132041
132041
  /*name*/
132042
- resolve7
132042
+ resolve8
132043
132043
  ),
132044
132044
  factory2.createParameterDeclaration(
132045
132045
  /*modifiers*/
@@ -132056,7 +132056,7 @@ ${lanes.join("\n")}
132056
132056
  factory2.createIdentifier("require"),
132057
132057
  /*typeArguments*/
132058
132058
  void 0,
132059
- [factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve7, reject]
132059
+ [factory2.createArrayLiteralExpression([arg || factory2.createOmittedExpression()]), resolve8, reject]
132060
132060
  )
132061
132061
  )
132062
132062
  ]);
@@ -140997,15 +140997,15 @@ ${lanes.join("\n")}
140997
140997
  function emitJsxExpression(node) {
140998
140998
  var _a;
140999
140999
  if (node.expression || !commentsDisabled && !nodeIsSynthesized(node) && hasCommentsAtPosition(node.pos)) {
141000
- const isMultiline = currentSourceFile && !nodeIsSynthesized(node) && getLineAndCharacterOfPosition(currentSourceFile, node.pos).line !== getLineAndCharacterOfPosition(currentSourceFile, node.end).line;
141001
- if (isMultiline) {
141000
+ const isMultiline2 = currentSourceFile && !nodeIsSynthesized(node) && getLineAndCharacterOfPosition(currentSourceFile, node.pos).line !== getLineAndCharacterOfPosition(currentSourceFile, node.end).line;
141001
+ if (isMultiline2) {
141002
141002
  writer.increaseIndent();
141003
141003
  }
141004
141004
  const end = emitTokenWithComment(19, node.pos, writePunctuation, node);
141005
141005
  emit(node.dotDotDotToken);
141006
141006
  emitExpression(node.expression);
141007
141007
  emitTokenWithComment(20, ((_a = node.expression) == null ? void 0 : _a.end) || end, writePunctuation, node);
141008
- if (isMultiline) {
141008
+ if (isMultiline2) {
141009
141009
  writer.decreaseIndent();
141010
141010
  }
141011
141011
  }
@@ -143857,9 +143857,9 @@ ${lanes.join("\n")}
143857
143857
  context += indent3 + formatColorAndReset(ellipsis.padStart(gutterWidth), gutterStyleSequence) + gutterSeparator + host.getNewLine();
143858
143858
  i = lastLine - 1;
143859
143859
  }
143860
- const lineStart = getPositionOfLineAndCharacter(file2, i, 0);
143860
+ const lineStart2 = getPositionOfLineAndCharacter(file2, i, 0);
143861
143861
  const lineEnd = i < lastLineInFile ? getPositionOfLineAndCharacter(file2, i + 1, 0) : file2.text.length;
143862
- let lineContent = file2.text.slice(lineStart, lineEnd);
143862
+ let lineContent = file2.text.slice(lineStart2, lineEnd);
143863
143863
  lineContent = lineContent.trimEnd();
143864
143864
  lineContent = lineContent.replace(/\t/g, " ");
143865
143865
  context += indent3 + formatColorAndReset((i + 1 + "").padStart(gutterWidth), gutterStyleSequence) + gutterSeparator;
@@ -151458,7 +151458,7 @@ ${lanes.join("\n")}
151458
151458
  function getSourceFileVersionAsHashFromText(host, text2) {
151459
151459
  if (text2.match(sourceMapCommentRegExpDontCareLineStart)) {
151460
151460
  let lineEnd = text2.length;
151461
- let lineStart = lineEnd;
151461
+ let lineStart2 = lineEnd;
151462
151462
  for (let pos = lineEnd - 1; pos >= 0; pos--) {
151463
151463
  const ch = text2.charCodeAt(pos);
151464
151464
  switch (ch) {
@@ -151471,19 +151471,19 @@ ${lanes.join("\n")}
151471
151471
  break;
151472
151472
  default:
151473
151473
  if (ch < 127 || !isLineBreak(ch)) {
151474
- lineStart = pos;
151474
+ lineStart2 = pos;
151475
151475
  continue;
151476
151476
  }
151477
151477
  break;
151478
151478
  }
151479
- const line = text2.substring(lineStart, lineEnd);
151479
+ const line = text2.substring(lineStart2, lineEnd);
151480
151480
  if (line.match(sourceMapCommentRegExp)) {
151481
- text2 = text2.substring(0, lineStart);
151481
+ text2 = text2.substring(0, lineStart2);
151482
151482
  break;
151483
151483
  } else if (!line.match(whitespaceOrMapCommentRegExp)) {
151484
151484
  break;
151485
151485
  }
151486
- lineEnd = lineStart;
151486
+ lineEnd = lineStart2;
151487
151487
  }
151488
151488
  }
151489
151489
  return (host.createHash || generateDjb2Hash)(text2);
@@ -158538,7 +158538,7 @@ ${lanes.join("\n")}
158538
158538
  }
158539
158539
  return void 0;
158540
158540
  }
158541
- function isComment(kind) {
158541
+ function isComment2(kind) {
158542
158542
  return kind === 2 || kind === 3;
158543
158543
  }
158544
158544
  function isStringOrRegularExpressionOrTemplateLiteral(kind) {
@@ -158959,7 +158959,7 @@ ${lanes.join("\n")}
158959
158959
  function getDisplayPartWriterWorker(maximumLength) {
158960
158960
  const absoluteMaximumLength = maximumLength * 10;
158961
158961
  let displayParts;
158962
- let lineStart;
158962
+ let lineStart2;
158963
158963
  let indent3;
158964
158964
  let length2;
158965
158965
  resetWriter();
@@ -159055,7 +159055,7 @@ ${lanes.join("\n")}
159055
159055
  };
159056
159056
  function writeIndent() {
159057
159057
  if (length2 > absoluteMaximumLength) return;
159058
- if (lineStart) {
159058
+ if (lineStart2) {
159059
159059
  const indentString = getIndentString(indent3);
159060
159060
  if (indentString) {
159061
159061
  length2 += indentString.length;
@@ -159065,7 +159065,7 @@ ${lanes.join("\n")}
159065
159065
  /* space */
159066
159066
  ));
159067
159067
  }
159068
- lineStart = false;
159068
+ lineStart2 = false;
159069
159069
  }
159070
159070
  }
159071
159071
  function writeKind(text2, kind) {
@@ -159084,11 +159084,11 @@ ${lanes.join("\n")}
159084
159084
  if (length2 > absoluteMaximumLength) return;
159085
159085
  length2 += 1;
159086
159086
  displayParts.push(lineBreakPart());
159087
- lineStart = true;
159087
+ lineStart2 = true;
159088
159088
  }
159089
159089
  function resetWriter() {
159090
159090
  displayParts = [];
159091
- lineStart = true;
159091
+ lineStart2 = true;
159092
159092
  indent3 = 0;
159093
159093
  length2 = 0;
159094
159094
  }
@@ -187811,8 +187811,8 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
187811
187811
  /* JsDocTagName */
187812
187812
  };
187813
187813
  } else {
187814
- const lineStart = getLineStartPositionForPosition(position2, sourceFile);
187815
- if (!/[^*|\s(/)]/.test(sourceFile.text.substring(lineStart, position2))) {
187814
+ const lineStart2 = getLineStartPositionForPosition(position2, sourceFile);
187815
+ if (!/[^*|\s(/)]/.test(sourceFile.text.substring(lineStart2, position2))) {
187816
187816
  return {
187817
187817
  kind: 2
187818
187818
  /* JsDocTag */
@@ -195291,10 +195291,10 @@ ${newComment.split("\n").map((c) => ` * ${c}`).join("\n")}
195291
195291
  }
195292
195292
  function getIndentationStringAtPosition(sourceFile, position2) {
195293
195293
  const { text: text2 } = sourceFile;
195294
- const lineStart = getLineStartPositionForPosition(position2, sourceFile);
195295
- let pos = lineStart;
195294
+ const lineStart2 = getLineStartPositionForPosition(position2, sourceFile);
195295
+ let pos = lineStart2;
195296
195296
  for (; pos <= position2 && isWhiteSpaceSingleLine(text2.charCodeAt(pos)); pos++) ;
195297
- return text2.slice(lineStart, pos);
195297
+ return text2.slice(lineStart2, pos);
195298
195298
  }
195299
195299
  function parameterDocComments(parameters, isJavaScriptFile, indentationStr, newLine) {
195300
195300
  return parameters.map(({ name, dotDotDotToken }, i) => {
@@ -202982,7 +202982,7 @@ ${options2.prefix}` : "\n" : options2.prefix
202982
202982
  }
202983
202983
  function processTrivia(trivia, parent2, contextNode, dynamicIndentation) {
202984
202984
  for (const triviaItem of trivia) {
202985
- if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
202985
+ if (isComment2(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
202986
202986
  const triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
202987
202987
  processRange(triviaItem, triviaItemStart, parent2, contextNode, dynamicIndentation);
202988
202988
  }
@@ -203125,7 +203125,7 @@ ${options2.prefix}` : "\n" : options2.prefix
203125
203125
  for (let line = line1; line < line2; line++) {
203126
203126
  const lineStartPosition = getStartPositionOfLine(line, sourceFile);
203127
203127
  const lineEndPosition = getEndLinePosition(line, sourceFile);
203128
- if (range && (isComment(range.kind) || isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
203128
+ if (range && (isComment2(range.kind) || isStringOrRegularExpressionOrTemplateLiteral(range.kind)) && range.pos <= lineEndPosition && range.end > lineEndPosition) {
203129
203129
  continue;
203130
203130
  }
203131
203131
  const whitespaceStart = getTrailingWhitespaceStartPosition(lineStartPosition, lineEndPosition);
@@ -203148,7 +203148,7 @@ ${options2.prefix}` : "\n" : options2.prefix
203148
203148
  function trimTrailingWhitespacesForRemainingRange(trivias) {
203149
203149
  let startPos = previousRange ? previousRange.end : originalRange.pos;
203150
203150
  for (const trivia of trivias) {
203151
- if (isComment(trivia.kind)) {
203151
+ if (isComment2(trivia.kind)) {
203152
203152
  if (startPos < trivia.pos) {
203153
203153
  trimTrailingWitespacesForPositions(startPos, trivia.pos - 1, previousRange);
203154
203154
  }
@@ -203425,8 +203425,8 @@ ${options2.prefix}` : "\n" : options2.prefix
203425
203425
  }
203426
203426
  current--;
203427
203427
  }
203428
- const lineStart = getLineStartPositionForPosition(current, sourceFile);
203429
- return findFirstNonWhitespaceColumn(lineStart, current, sourceFile, options2);
203428
+ const lineStart2 = getLineStartPositionForPosition(current, sourceFile);
203429
+ return findFirstNonWhitespaceColumn(lineStart2, current, sourceFile, options2);
203430
203430
  }
203431
203431
  function getSmartIndent(sourceFile, position2, precedingToken, lineAtPosition, assumeNewLineBeforeCloseBrace, options2) {
203432
203432
  let previous;
@@ -203713,8 +203713,8 @@ ${options2.prefix}` : "\n" : options2.prefix
203713
203713
  return -1;
203714
203714
  }
203715
203715
  function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options2) {
203716
- const lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
203717
- return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options2);
203716
+ const lineStart2 = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
203717
+ return findFirstNonWhitespaceColumn(lineStart2, lineStart2 + lineAndCharacter.character, sourceFile, options2);
203718
203718
  }
203719
203719
  function findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options2) {
203720
203720
  let character = 0;
@@ -205240,7 +205240,7 @@ ${options2.prefix}` : "\n" : options2.prefix
205240
205240
  isCommaListExpression: () => isCommaListExpression,
205241
205241
  isCommaSequence: () => isCommaSequence,
205242
205242
  isCommaToken: () => isCommaToken,
205243
- isComment: () => isComment,
205243
+ isComment: () => isComment2,
205244
205244
  isCommonJsExportPropertyAssignment: () => isCommonJsExportPropertyAssignment,
205245
205245
  isCommonJsExportedExpression: () => isCommonJsExportedExpression,
205246
205246
  isCompoundAssignment: () => isCompoundAssignment,
@@ -218987,8 +218987,8 @@ Additional information: BADCLIENT: Bad error code, ${badCode} not found in range
218987
218987
  installPackage(options2) {
218988
218988
  this.packageInstallId++;
218989
218989
  const request2 = { kind: "installPackage", ...options2, id: this.packageInstallId };
218990
- const promise = new Promise((resolve7, reject) => {
218991
- (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve7, reject });
218990
+ const promise = new Promise((resolve8, reject) => {
218991
+ (this.packageInstalledPromise ?? (this.packageInstalledPromise = /* @__PURE__ */ new Map())).set(this.packageInstallId, { resolve: resolve8, reject });
218992
218992
  });
218993
218993
  this.installer.send(request2);
218994
218994
  return promise;
@@ -232592,7 +232592,7 @@ var require_resolve_uri_umd = __commonJS({
232592
232592
  }
232593
232593
  url.path = path;
232594
232594
  }
232595
- function resolve7(input, base2) {
232595
+ function resolve8(input, base2) {
232596
232596
  if (!input && !base2)
232597
232597
  return "";
232598
232598
  const url = parseUrl2(input);
@@ -232645,7 +232645,7 @@ var require_resolve_uri_umd = __commonJS({
232645
232645
  return url.scheme + "//" + url.user + url.host + url.port + url.path + queryHash;
232646
232646
  }
232647
232647
  }
232648
- return resolve7;
232648
+ return resolve8;
232649
232649
  }));
232650
232650
  }
232651
232651
  });
@@ -232991,8 +232991,8 @@ var require_trace_mapping_umd = __commonJS({
232991
232991
  this.sources = sources;
232992
232992
  this.sourcesContent = sourcesContent;
232993
232993
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
232994
- const resolve7 = resolver2(mapUrl, sourceRoot);
232995
- this.resolvedSources = sources.map(resolve7);
232994
+ const resolve8 = resolver2(mapUrl, sourceRoot);
232995
+ this.resolvedSources = sources.map(resolve8);
232996
232996
  const { mappings } = parsed;
232997
232997
  if (typeof mappings === "string") {
232998
232998
  this._encoded = mappings;
@@ -233561,13 +233561,13 @@ var require_computeSourceMap = __commonJS({
233561
233561
  currentMapping = rawMappings[tokenIndex];
233562
233562
  }
233563
233563
  let line = 0;
233564
- let lineStart = 0;
233565
- if (currentMapping !== lineStart) {
233564
+ let lineStart2 = 0;
233565
+ if (currentMapping !== lineStart2) {
233566
233566
  _genmapping.maybeAddSegment.call(void 0, map, line, 0, filePath, line, 0);
233567
233567
  }
233568
233568
  for (let i = 0; i < generatedCode.length; i++) {
233569
233569
  if (i === currentMapping) {
233570
- const genColumn = currentMapping - lineStart;
233570
+ const genColumn = currentMapping - lineStart2;
233571
233571
  const sourceColumn = sourceColumns[tokenIndex];
233572
233572
  _genmapping.maybeAddSegment.call(void 0, map, line, genColumn, filePath, line, sourceColumn);
233573
233573
  while ((currentMapping === i || currentMapping === void 0) && tokenIndex < rawMappings.length - 1) {
@@ -233577,8 +233577,8 @@ var require_computeSourceMap = __commonJS({
233577
233577
  }
233578
233578
  if (generatedCode.charCodeAt(i) === _charcodes.charCodes.lineFeed) {
233579
233579
  line++;
233580
- lineStart = i + 1;
233581
- if (currentMapping !== lineStart) {
233580
+ lineStart2 = i + 1;
233581
+ if (currentMapping !== lineStart2) {
233582
233582
  _genmapping.maybeAddSegment.call(void 0, map, line, 0, filePath, line, 0);
233583
233583
  }
233584
233584
  }
@@ -233591,15 +233591,15 @@ var require_computeSourceMap = __commonJS({
233591
233591
  const sourceColumns = new Array(tokens.length);
233592
233592
  let tokenIndex = 0;
233593
233593
  let currentMapping = tokens[tokenIndex].start;
233594
- let lineStart = 0;
233594
+ let lineStart2 = 0;
233595
233595
  for (let i = 0; i < code2.length; i++) {
233596
233596
  if (i === currentMapping) {
233597
- sourceColumns[tokenIndex] = currentMapping - lineStart;
233597
+ sourceColumns[tokenIndex] = currentMapping - lineStart2;
233598
233598
  tokenIndex++;
233599
233599
  currentMapping = tokens[tokenIndex].start;
233600
233600
  }
233601
233601
  if (code2.charCodeAt(i) === _charcodes.charCodes.lineFeed) {
233602
- lineStart = i + 1;
233602
+ lineStart2 = i + 1;
233603
233603
  }
233604
233604
  }
233605
233605
  return sourceColumns;
@@ -251803,7 +251803,7 @@ interface String {
251803
251803
  // scripts/lib/runtime-build/check-cli.mjs
251804
251804
  init_define_globalThis_DIAGONAL_SDK_RUNTIME();
251805
251805
  import { statSync as statSync6 } from "node:fs";
251806
- import { resolve as resolve6 } from "node:path";
251806
+ import { resolve as resolve7 } from "node:path";
251807
251807
 
251808
251808
  // scripts/lib/runtime-build/api-cli.mjs
251809
251809
  init_define_globalThis_DIAGONAL_SDK_RUNTIME();
@@ -253774,9 +253774,9 @@ var isAllowedNumericSeparatorSibling = {
253774
253774
  dec: (ch) => ch >= 48 && ch <= 57,
253775
253775
  hex: (ch) => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
253776
253776
  };
253777
- function readStringContents(type, input, pos, lineStart, curLine, errors) {
253777
+ function readStringContents(type, input, pos, lineStart2, curLine, errors) {
253778
253778
  const initialPos = pos;
253779
- const initialLineStart = lineStart;
253779
+ const initialLineStart = lineStart2;
253780
253780
  const initialCurLine = curLine;
253781
253781
  let out = "";
253782
253782
  let firstInvalidLoc = null;
@@ -253797,11 +253797,11 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
253797
253797
  }
253798
253798
  if (ch === 92) {
253799
253799
  out += input.slice(chunkStart, pos);
253800
- const res = readEscapedChar(input, pos, lineStart, curLine, type === "template", errors);
253800
+ const res = readEscapedChar(input, pos, lineStart2, curLine, type === "template", errors);
253801
253801
  if (res.ch === null && !firstInvalidLoc) {
253802
253802
  firstInvalidLoc = {
253803
253803
  pos,
253804
- lineStart,
253804
+ lineStart: lineStart2,
253805
253805
  curLine
253806
253806
  };
253807
253807
  } else {
@@ -253809,14 +253809,14 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
253809
253809
  }
253810
253810
  ({
253811
253811
  pos,
253812
- lineStart,
253812
+ lineStart: lineStart2,
253813
253813
  curLine
253814
253814
  } = res);
253815
253815
  chunkStart = pos;
253816
253816
  } else if (ch === 8232 || ch === 8233) {
253817
253817
  ++pos;
253818
253818
  ++curLine;
253819
- lineStart = pos;
253819
+ lineStart2 = pos;
253820
253820
  } else if (ch === 10 || ch === 13) {
253821
253821
  if (type === "template") {
253822
253822
  out += input.slice(chunkStart, pos) + "\n";
@@ -253825,7 +253825,7 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
253825
253825
  ++pos;
253826
253826
  }
253827
253827
  ++curLine;
253828
- chunkStart = lineStart = pos;
253828
+ chunkStart = lineStart2 = pos;
253829
253829
  } else {
253830
253830
  errors.unterminated(initialPos, initialLineStart, initialCurLine);
253831
253831
  }
@@ -253837,7 +253837,7 @@ function readStringContents(type, input, pos, lineStart, curLine, errors) {
253837
253837
  pos,
253838
253838
  str: out,
253839
253839
  firstInvalidLoc,
253840
- lineStart,
253840
+ lineStart: lineStart2,
253841
253841
  curLine
253842
253842
  };
253843
253843
  }
@@ -253847,13 +253847,13 @@ function isStringEnd(type, ch, input, pos) {
253847
253847
  }
253848
253848
  return ch === (type === "double" ? 34 : 39);
253849
253849
  }
253850
- function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253850
+ function readEscapedChar(input, pos, lineStart2, curLine, inTemplate, errors) {
253851
253851
  const throwOnInvalid = !inTemplate;
253852
253852
  pos++;
253853
253853
  const res = (ch2) => ({
253854
253854
  pos,
253855
253855
  ch: ch2,
253856
- lineStart,
253856
+ lineStart: lineStart2,
253857
253857
  curLine
253858
253858
  });
253859
253859
  const ch = input.charCodeAt(pos++);
@@ -253867,7 +253867,7 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253867
253867
  ({
253868
253868
  code: code2,
253869
253869
  pos
253870
- } = readHexChar(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
253870
+ } = readHexChar(input, pos, lineStart2, curLine, 2, false, throwOnInvalid, errors));
253871
253871
  return res(code2 === null ? null : String.fromCharCode(code2));
253872
253872
  }
253873
253873
  case 117: {
@@ -253875,7 +253875,7 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253875
253875
  ({
253876
253876
  code: code2,
253877
253877
  pos
253878
- } = readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors));
253878
+ } = readCodePoint(input, pos, lineStart2, curLine, throwOnInvalid, errors));
253879
253879
  return res(code2 === null ? null : String.fromCodePoint(code2));
253880
253880
  }
253881
253881
  case 116:
@@ -253891,7 +253891,7 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253891
253891
  ++pos;
253892
253892
  }
253893
253893
  case 10:
253894
- lineStart = pos;
253894
+ lineStart2 = pos;
253895
253895
  ++curLine;
253896
253896
  case 8232:
253897
253897
  case 8233:
@@ -253901,7 +253901,7 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253901
253901
  if (inTemplate) {
253902
253902
  return res(null);
253903
253903
  } else {
253904
- errors.strictNumericEscape(pos - 1, lineStart, curLine);
253904
+ errors.strictNumericEscape(pos - 1, lineStart2, curLine);
253905
253905
  }
253906
253906
  default:
253907
253907
  if (ch >= 48 && ch <= 55) {
@@ -253919,7 +253919,7 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253919
253919
  if (inTemplate) {
253920
253920
  return res(null);
253921
253921
  } else {
253922
- errors.strictNumericEscape(startPos, lineStart, curLine);
253922
+ errors.strictNumericEscape(startPos, lineStart2, curLine);
253923
253923
  }
253924
253924
  }
253925
253925
  return res(String.fromCharCode(octal));
@@ -253927,16 +253927,16 @@ function readEscapedChar(input, pos, lineStart, curLine, inTemplate, errors) {
253927
253927
  return res(String.fromCharCode(ch));
253928
253928
  }
253929
253929
  }
253930
- function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
253930
+ function readHexChar(input, pos, lineStart2, curLine, len, forceLen, throwOnInvalid, errors) {
253931
253931
  const initialPos = pos;
253932
253932
  let n;
253933
253933
  ({
253934
253934
  n,
253935
253935
  pos
253936
- } = readInt(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
253936
+ } = readInt(input, pos, lineStart2, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
253937
253937
  if (n === null) {
253938
253938
  if (throwOnInvalid) {
253939
- errors.invalidEscapeSequence(initialPos, lineStart, curLine);
253939
+ errors.invalidEscapeSequence(initialPos, lineStart2, curLine);
253940
253940
  } else {
253941
253941
  pos = initialPos - 1;
253942
253942
  }
@@ -253946,7 +253946,7 @@ function readHexChar(input, pos, lineStart, curLine, len, forceLen, throwOnInval
253946
253946
  pos
253947
253947
  };
253948
253948
  }
253949
- function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
253949
+ function readInt(input, pos, lineStart2, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
253950
253950
  const start = pos;
253951
253951
  const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings.hex : forbiddenNumericSeparatorSiblings.decBinOct;
253952
253952
  const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling.hex : radix === 10 ? isAllowedNumericSeparatorSibling.dec : radix === 8 ? isAllowedNumericSeparatorSibling.oct : isAllowedNumericSeparatorSibling.bin;
@@ -253963,13 +253963,13 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
253963
253963
  n: null,
253964
253964
  pos
253965
253965
  };
253966
- errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
253966
+ errors.numericSeparatorInEscapeSequence(pos, lineStart2, curLine);
253967
253967
  } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev)) {
253968
253968
  if (bailOnError) return {
253969
253969
  n: null,
253970
253970
  pos
253971
253971
  };
253972
- errors.unexpectedNumericSeparator(pos, lineStart, curLine);
253972
+ errors.unexpectedNumericSeparator(pos, lineStart2, curLine);
253973
253973
  }
253974
253974
  ++pos;
253975
253975
  continue;
@@ -253989,7 +253989,7 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
253989
253989
  n: null,
253990
253990
  pos
253991
253991
  };
253992
- errors.invalidDigit(pos, lineStart, curLine, radix);
253992
+ errors.invalidDigit(pos, lineStart2, curLine, radix);
253993
253993
  val = 0;
253994
253994
  } else if (forceLen) {
253995
253995
  val = 0;
@@ -254012,7 +254012,7 @@ function readInt(input, pos, lineStart, curLine, radix, len, forceLen, allowNumS
254012
254012
  pos
254013
254013
  };
254014
254014
  }
254015
- function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
254015
+ function readCodePoint(input, pos, lineStart2, curLine, throwOnInvalid, errors) {
254016
254016
  const ch = input.charCodeAt(pos);
254017
254017
  let code2;
254018
254018
  if (ch === 123) {
@@ -254020,11 +254020,11 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
254020
254020
  ({
254021
254021
  code: code2,
254022
254022
  pos
254023
- } = readHexChar(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
254023
+ } = readHexChar(input, pos, lineStart2, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
254024
254024
  ++pos;
254025
254025
  if (code2 !== null && code2 > 1114111) {
254026
254026
  if (throwOnInvalid) {
254027
- errors.invalidCodePoint(pos, lineStart, curLine);
254027
+ errors.invalidCodePoint(pos, lineStart2, curLine);
254028
254028
  } else {
254029
254029
  return {
254030
254030
  code: null,
@@ -254036,7 +254036,7 @@ function readCodePoint(input, pos, lineStart, curLine, throwOnInvalid, errors) {
254036
254036
  ({
254037
254037
  code: code2,
254038
254038
  pos
254039
- } = readHexChar(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
254039
+ } = readHexChar(input, pos, lineStart2, curLine, 4, false, throwOnInvalid, errors));
254040
254040
  }
254041
254041
  return {
254042
254042
  code: code2,
@@ -265196,8 +265196,8 @@ var TraceMap = class {
265196
265196
  this.sources = sources;
265197
265197
  this.sourcesContent = sourcesContent;
265198
265198
  this.ignoreList = parsed.ignoreList || parsed.x_google_ignoreList || void 0;
265199
- const resolve7 = resolver(mapUrl, sourceRoot);
265200
- this.resolvedSources = sources.map(resolve7);
265199
+ const resolve8 = resolver(mapUrl, sourceRoot);
265200
+ this.resolvedSources = sources.map(resolve8);
265201
265201
  const { mappings } = parsed;
265202
265202
  if (typeof mappings === "string") {
265203
265203
  this._encoded = mappings;
@@ -276152,9 +276152,9 @@ var isAllowedNumericSeparatorSibling2 = {
276152
276152
  dec: (ch) => ch >= 48 && ch <= 57,
276153
276153
  hex: (ch) => ch >= 48 && ch <= 57 || ch >= 65 && ch <= 70 || ch >= 97 && ch <= 102
276154
276154
  };
276155
- function readStringContents2(type, input, pos, lineStart, curLine, errors) {
276155
+ function readStringContents2(type, input, pos, lineStart2, curLine, errors) {
276156
276156
  const initialPos = pos;
276157
- const initialLineStart = lineStart;
276157
+ const initialLineStart = lineStart2;
276158
276158
  const initialCurLine = curLine;
276159
276159
  let out = "";
276160
276160
  let firstInvalidLoc = null;
@@ -276175,11 +276175,11 @@ function readStringContents2(type, input, pos, lineStart, curLine, errors) {
276175
276175
  }
276176
276176
  if (ch === 92) {
276177
276177
  out += input.slice(chunkStart, pos);
276178
- const res = readEscapedChar2(input, pos, lineStart, curLine, type === "template", errors);
276178
+ const res = readEscapedChar2(input, pos, lineStart2, curLine, type === "template", errors);
276179
276179
  if (res.ch === null && !firstInvalidLoc) {
276180
276180
  firstInvalidLoc = {
276181
276181
  pos,
276182
- lineStart,
276182
+ lineStart: lineStart2,
276183
276183
  curLine
276184
276184
  };
276185
276185
  } else {
@@ -276187,14 +276187,14 @@ function readStringContents2(type, input, pos, lineStart, curLine, errors) {
276187
276187
  }
276188
276188
  ({
276189
276189
  pos,
276190
- lineStart,
276190
+ lineStart: lineStart2,
276191
276191
  curLine
276192
276192
  } = res);
276193
276193
  chunkStart = pos;
276194
276194
  } else if (ch === 8232 || ch === 8233) {
276195
276195
  ++pos;
276196
276196
  ++curLine;
276197
- lineStart = pos;
276197
+ lineStart2 = pos;
276198
276198
  } else if (ch === 10 || ch === 13) {
276199
276199
  if (type === "template") {
276200
276200
  out += input.slice(chunkStart, pos) + "\n";
@@ -276203,7 +276203,7 @@ function readStringContents2(type, input, pos, lineStart, curLine, errors) {
276203
276203
  ++pos;
276204
276204
  }
276205
276205
  ++curLine;
276206
- chunkStart = lineStart = pos;
276206
+ chunkStart = lineStart2 = pos;
276207
276207
  } else {
276208
276208
  errors.unterminated(initialPos, initialLineStart, initialCurLine);
276209
276209
  }
@@ -276215,7 +276215,7 @@ function readStringContents2(type, input, pos, lineStart, curLine, errors) {
276215
276215
  pos,
276216
276216
  str: out,
276217
276217
  firstInvalidLoc,
276218
- lineStart,
276218
+ lineStart: lineStart2,
276219
276219
  curLine
276220
276220
  };
276221
276221
  }
@@ -276225,13 +276225,13 @@ function isStringEnd2(type, ch, input, pos) {
276225
276225
  }
276226
276226
  return ch === (type === "double" ? 34 : 39);
276227
276227
  }
276228
- function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276228
+ function readEscapedChar2(input, pos, lineStart2, curLine, inTemplate, errors) {
276229
276229
  const throwOnInvalid = !inTemplate;
276230
276230
  pos++;
276231
276231
  const res = (ch2) => ({
276232
276232
  pos,
276233
276233
  ch: ch2,
276234
- lineStart,
276234
+ lineStart: lineStart2,
276235
276235
  curLine
276236
276236
  });
276237
276237
  const ch = input.charCodeAt(pos++);
@@ -276245,7 +276245,7 @@ function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276245
276245
  ({
276246
276246
  code: code2,
276247
276247
  pos
276248
- } = readHexChar2(input, pos, lineStart, curLine, 2, false, throwOnInvalid, errors));
276248
+ } = readHexChar2(input, pos, lineStart2, curLine, 2, false, throwOnInvalid, errors));
276249
276249
  return res(code2 === null ? null : String.fromCharCode(code2));
276250
276250
  }
276251
276251
  case 117: {
@@ -276253,7 +276253,7 @@ function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276253
276253
  ({
276254
276254
  code: code2,
276255
276255
  pos
276256
- } = readCodePoint2(input, pos, lineStart, curLine, throwOnInvalid, errors));
276256
+ } = readCodePoint2(input, pos, lineStart2, curLine, throwOnInvalid, errors));
276257
276257
  return res(code2 === null ? null : String.fromCodePoint(code2));
276258
276258
  }
276259
276259
  case 116:
@@ -276269,7 +276269,7 @@ function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276269
276269
  ++pos;
276270
276270
  }
276271
276271
  case 10:
276272
- lineStart = pos;
276272
+ lineStart2 = pos;
276273
276273
  ++curLine;
276274
276274
  case 8232:
276275
276275
  case 8233:
@@ -276279,7 +276279,7 @@ function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276279
276279
  if (inTemplate) {
276280
276280
  return res(null);
276281
276281
  } else {
276282
- errors.strictNumericEscape(pos - 1, lineStart, curLine);
276282
+ errors.strictNumericEscape(pos - 1, lineStart2, curLine);
276283
276283
  }
276284
276284
  default:
276285
276285
  if (ch >= 48 && ch <= 55) {
@@ -276297,7 +276297,7 @@ function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276297
276297
  if (inTemplate) {
276298
276298
  return res(null);
276299
276299
  } else {
276300
- errors.strictNumericEscape(startPos, lineStart, curLine);
276300
+ errors.strictNumericEscape(startPos, lineStart2, curLine);
276301
276301
  }
276302
276302
  }
276303
276303
  return res(String.fromCharCode(octal));
@@ -276305,16 +276305,16 @@ function readEscapedChar2(input, pos, lineStart, curLine, inTemplate, errors) {
276305
276305
  return res(String.fromCharCode(ch));
276306
276306
  }
276307
276307
  }
276308
- function readHexChar2(input, pos, lineStart, curLine, len, forceLen, throwOnInvalid, errors) {
276308
+ function readHexChar2(input, pos, lineStart2, curLine, len, forceLen, throwOnInvalid, errors) {
276309
276309
  const initialPos = pos;
276310
276310
  let n;
276311
276311
  ({
276312
276312
  n,
276313
276313
  pos
276314
- } = readInt2(input, pos, lineStart, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
276314
+ } = readInt2(input, pos, lineStart2, curLine, 16, len, forceLen, false, errors, !throwOnInvalid));
276315
276315
  if (n === null) {
276316
276316
  if (throwOnInvalid) {
276317
- errors.invalidEscapeSequence(initialPos, lineStart, curLine);
276317
+ errors.invalidEscapeSequence(initialPos, lineStart2, curLine);
276318
276318
  } else {
276319
276319
  pos = initialPos - 1;
276320
276320
  }
@@ -276324,7 +276324,7 @@ function readHexChar2(input, pos, lineStart, curLine, len, forceLen, throwOnInva
276324
276324
  pos
276325
276325
  };
276326
276326
  }
276327
- function readInt2(input, pos, lineStart, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
276327
+ function readInt2(input, pos, lineStart2, curLine, radix, len, forceLen, allowNumSeparator, errors, bailOnError) {
276328
276328
  const start = pos;
276329
276329
  const forbiddenSiblings = radix === 16 ? forbiddenNumericSeparatorSiblings2.hex : forbiddenNumericSeparatorSiblings2.decBinOct;
276330
276330
  const isAllowedSibling = radix === 16 ? isAllowedNumericSeparatorSibling2.hex : radix === 10 ? isAllowedNumericSeparatorSibling2.dec : radix === 8 ? isAllowedNumericSeparatorSibling2.oct : isAllowedNumericSeparatorSibling2.bin;
@@ -276341,13 +276341,13 @@ function readInt2(input, pos, lineStart, curLine, radix, len, forceLen, allowNum
276341
276341
  n: null,
276342
276342
  pos
276343
276343
  };
276344
- errors.numericSeparatorInEscapeSequence(pos, lineStart, curLine);
276344
+ errors.numericSeparatorInEscapeSequence(pos, lineStart2, curLine);
276345
276345
  } else if (Number.isNaN(next) || !isAllowedSibling(next) || forbiddenSiblings.has(prev)) {
276346
276346
  if (bailOnError) return {
276347
276347
  n: null,
276348
276348
  pos
276349
276349
  };
276350
- errors.unexpectedNumericSeparator(pos, lineStart, curLine);
276350
+ errors.unexpectedNumericSeparator(pos, lineStart2, curLine);
276351
276351
  }
276352
276352
  ++pos;
276353
276353
  continue;
@@ -276367,7 +276367,7 @@ function readInt2(input, pos, lineStart, curLine, radix, len, forceLen, allowNum
276367
276367
  n: null,
276368
276368
  pos
276369
276369
  };
276370
- errors.invalidDigit(pos, lineStart, curLine, radix);
276370
+ errors.invalidDigit(pos, lineStart2, curLine, radix);
276371
276371
  val = 0;
276372
276372
  } else if (forceLen) {
276373
276373
  val = 0;
@@ -276390,7 +276390,7 @@ function readInt2(input, pos, lineStart, curLine, radix, len, forceLen, allowNum
276390
276390
  pos
276391
276391
  };
276392
276392
  }
276393
- function readCodePoint2(input, pos, lineStart, curLine, throwOnInvalid, errors) {
276393
+ function readCodePoint2(input, pos, lineStart2, curLine, throwOnInvalid, errors) {
276394
276394
  const ch = input.charCodeAt(pos);
276395
276395
  let code2;
276396
276396
  if (ch === 123) {
@@ -276398,11 +276398,11 @@ function readCodePoint2(input, pos, lineStart, curLine, throwOnInvalid, errors)
276398
276398
  ({
276399
276399
  code: code2,
276400
276400
  pos
276401
- } = readHexChar2(input, pos, lineStart, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
276401
+ } = readHexChar2(input, pos, lineStart2, curLine, input.indexOf("}", pos) - pos, true, throwOnInvalid, errors));
276402
276402
  ++pos;
276403
276403
  if (code2 !== null && code2 > 1114111) {
276404
276404
  if (throwOnInvalid) {
276405
- errors.invalidCodePoint(pos, lineStart, curLine);
276405
+ errors.invalidCodePoint(pos, lineStart2, curLine);
276406
276406
  } else {
276407
276407
  return {
276408
276408
  code: null,
@@ -276414,15 +276414,15 @@ function readCodePoint2(input, pos, lineStart, curLine, throwOnInvalid, errors)
276414
276414
  ({
276415
276415
  code: code2,
276416
276416
  pos
276417
- } = readHexChar2(input, pos, lineStart, curLine, 4, false, throwOnInvalid, errors));
276417
+ } = readHexChar2(input, pos, lineStart2, curLine, 4, false, throwOnInvalid, errors));
276418
276418
  }
276419
276419
  return {
276420
276420
  code: code2,
276421
276421
  pos
276422
276422
  };
276423
276423
  }
276424
- function buildPosition(pos, lineStart, curLine) {
276425
- return new Position(curLine, pos - lineStart, pos);
276424
+ function buildPosition(pos, lineStart2, curLine) {
276425
+ return new Position(curLine, pos - lineStart2, pos);
276426
276426
  }
276427
276427
  var VALID_REGEX_FLAGS = /* @__PURE__ */ new Set([103, 109, 115, 105, 121, 117, 100, 118]);
276428
276428
  var Token = class {
@@ -277227,10 +277227,10 @@ var Tokenizer = class extends CommentsParser {
277227
277227
  str,
277228
277228
  pos,
277229
277229
  curLine,
277230
- lineStart
277230
+ lineStart: lineStart2
277231
277231
  } = readStringContents2(quote === 34 ? "double" : "single", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_string);
277232
277232
  this.state.pos = pos + 1;
277233
- this.state.lineStart = lineStart;
277233
+ this.state.lineStart = lineStart2;
277234
277234
  this.state.curLine = curLine;
277235
277235
  this.finishToken(131, str);
277236
277236
  }
@@ -277248,10 +277248,10 @@ var Tokenizer = class extends CommentsParser {
277248
277248
  firstInvalidLoc,
277249
277249
  pos,
277250
277250
  curLine,
277251
- lineStart
277251
+ lineStart: lineStart2
277252
277252
  } = readStringContents2("template", this.input, this.state.pos + 1, this.state.lineStart, this.state.curLine, this.errorHandlers_readStringContents_template);
277253
277253
  this.state.pos = pos + 1;
277254
- this.state.lineStart = lineStart;
277254
+ this.state.lineStart = lineStart2;
277255
277255
  this.state.curLine = curLine;
277256
277256
  if (firstInvalidLoc) {
277257
277257
  this.state.firstInvalidTemplateEscapePos = new Position(firstInvalidLoc.curLine, firstInvalidLoc.pos - firstInvalidLoc.lineStart, this.sourceToOffsetPos(firstInvalidLoc.pos));
@@ -277371,13 +277371,13 @@ var Tokenizer = class extends CommentsParser {
277371
277371
  }
277372
277372
  }
277373
277373
  errorBuilder(error) {
277374
- return (pos, lineStart, curLine) => {
277375
- this.raise(error, buildPosition(pos, lineStart, curLine));
277374
+ return (pos, lineStart2, curLine) => {
277375
+ this.raise(error, buildPosition(pos, lineStart2, curLine));
277376
277376
  };
277377
277377
  }
277378
277378
  errorHandlers_readInt = {
277379
- invalidDigit: (pos, lineStart, curLine, radix) => {
277380
- this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart, curLine), {
277379
+ invalidDigit: (pos, lineStart2, curLine, radix) => {
277380
+ this.raise(Errors.InvalidDigit, buildPosition(pos, lineStart2, curLine), {
277381
277381
  radix
277382
277382
  });
277383
277383
  },
@@ -277391,18 +277391,18 @@ var Tokenizer = class extends CommentsParser {
277391
277391
  };
277392
277392
  errorHandlers_readStringContents_string = {
277393
277393
  ...this.errorHandlers_readCodePoint,
277394
- strictNumericEscape: (pos, lineStart, curLine) => {
277395
- this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart, curLine));
277394
+ strictNumericEscape: (pos, lineStart2, curLine) => {
277395
+ this.recordStrictModeErrors(Errors.StrictNumericEscape, buildPosition(pos, lineStart2, curLine));
277396
277396
  },
277397
- unterminated: (pos, lineStart, curLine) => {
277398
- throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart, curLine));
277397
+ unterminated: (pos, lineStart2, curLine) => {
277398
+ throw this.raise(Errors.UnterminatedString, buildPosition(pos - 1, lineStart2, curLine));
277399
277399
  }
277400
277400
  };
277401
277401
  errorHandlers_readStringContents_template = {
277402
277402
  ...this.errorHandlers_readCodePoint,
277403
277403
  strictNumericEscape: this.errorBuilder(Errors.StrictNumericEscape),
277404
- unterminated: (pos, lineStart, curLine) => {
277405
- throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart, curLine));
277404
+ unterminated: (pos, lineStart2, curLine) => {
277405
+ throw this.raise(Errors.UnterminatedTemplate, buildPosition(pos, lineStart2, curLine));
277406
277406
  }
277407
277407
  };
277408
277408
  };
@@ -291662,7 +291662,7 @@ function cssReferences(source) {
291662
291662
  let composing = false;
291663
291663
  let nextNewline = source.indexOf("\n");
291664
291664
  let line = 1;
291665
- let lineStart = 0;
291665
+ let lineStart2 = 0;
291666
291666
  const skipSpace = () => {
291667
291667
  while (offset < source.length) {
291668
291668
  if (/\s/.test(source[offset])) {
@@ -291688,10 +291688,10 @@ function cssReferences(source) {
291688
291688
  const add = (value, start) => {
291689
291689
  while (nextNewline !== -1 && nextNewline < start) {
291690
291690
  line++;
291691
- lineStart = nextNewline + 1;
291692
- nextNewline = source.indexOf("\n", lineStart);
291691
+ lineStart2 = nextNewline + 1;
291692
+ nextNewline = source.indexOf("\n", lineStart2);
291693
291693
  }
291694
- const column = start - lineStart + 1;
291694
+ const column = start - lineStart2 + 1;
291695
291695
  (importing ? imports : urls).push({ value, line, column });
291696
291696
  importing = false;
291697
291697
  };
@@ -304820,8 +304820,8 @@ function offsetOf(text2, line, column) {
304820
304820
  }
304821
304821
  function positionOf(text2, offset) {
304822
304822
  const before = text2.slice(0, offset);
304823
- const lineStart = before.lastIndexOf("\n") + 1;
304824
- return { line: before.split("\n").length, column: offset - lineStart + 1 };
304823
+ const lineStart2 = before.lastIndexOf("\n") + 1;
304824
+ return { line: before.split("\n").length, column: offset - lineStart2 + 1 };
304825
304825
  }
304826
304826
  function memberName(node, object) {
304827
304827
  if ((node?.type === "MemberExpression" || node?.type === "OptionalMemberExpression") && node.object === object && !node.computed && node.property.type === "Identifier") {
@@ -305582,8 +305582,8 @@ export default defineAssets({
305582
305582
  }
305583
305583
  const multiline = last2.loc.end.line < definition.loc.end.line;
305584
305584
  if (multiline) {
305585
- const lineStart = source.lastIndexOf("\n", last2.start - 1) + 1;
305586
- const indent = source.slice(lineStart, last2.start).match(/^[\t ]*/)[0];
305585
+ const lineStart2 = source.lastIndexOf("\n", last2.start - 1) + 1;
305586
+ const indent = source.slice(lineStart2, last2.start).match(/^[\t ]*/)[0];
305587
305587
  if (!trailingComma) {
305588
305588
  edits.push({ start: last2.end, text: "," });
305589
305589
  }
@@ -305991,8 +305991,8 @@ function readUid(object, { version = null } = {}) {
305991
305991
  }
305992
305992
  function locationAt(source, offset) {
305993
305993
  const before = source.slice(0, offset);
305994
- const lineStart = before.lastIndexOf("\n") + 1;
305995
- return { loc: { start: { line: before.split("\n").length, column: offset - lineStart } } };
305994
+ const lineStart2 = before.lastIndexOf("\n") + 1;
305995
+ return { loc: { start: { line: before.split("\n").length, column: offset - lineStart2 } } };
305996
305996
  }
305997
305997
  function readFrontMatterUid(source, { map, offset }) {
305998
305998
  const pair = map.items.find((item) => (0, import_yaml.isScalar)(item.key) && item.key.value === "uid") ?? null;
@@ -306075,9 +306075,9 @@ function uidInsertion(source, object, uid2) {
306075
306075
  if (anchor.loc.start.line === object.loc.start.line) {
306076
306076
  return { start: anchor.start, end: anchor.start, text: `${property}, ` };
306077
306077
  }
306078
- const lineStart = source.lastIndexOf("\n", anchor.start - 1) + 1;
306079
- const indent = source.slice(lineStart, anchor.start);
306080
- const newline = source[lineStart - 2] === "\r" ? "\r\n" : "\n";
306078
+ const lineStart2 = source.lastIndexOf("\n", anchor.start - 1) + 1;
306079
+ const indent = source.slice(lineStart2, anchor.start);
306080
+ const newline = source[lineStart2 - 2] === "\r" ? "\r\n" : "\n";
306081
306081
  return { start: anchor.start, end: anchor.start, text: `${property},${newline}${indent}` };
306082
306082
  }
306083
306083
  function frontMatterUidInsertion(source, { map, offset }, uid2) {
@@ -319728,7 +319728,7 @@ var SUCRASE_OPTIONS = {
319728
319728
  function authoringColumns(code2) {
319729
319729
  const { tokens } = (0, import_parser4.parse)(code2, true, true, false);
319730
319730
  const columns = [];
319731
- let lineStart = 0;
319731
+ let lineStart2 = 0;
319732
319732
  let scanned = 0;
319733
319733
  for (let index3 = 0; index3 < tokens.length; index3 += 1) {
319734
319734
  if (tokens[index3].type !== import_types.TokenType.jsxTagStart) {
@@ -319741,11 +319741,11 @@ function authoringColumns(code2) {
319741
319741
  const { start } = tokens[index3];
319742
319742
  while (scanned < start) {
319743
319743
  if (code2.charCodeAt(scanned) === 10) {
319744
- lineStart = scanned + 1;
319744
+ lineStart2 = scanned + 1;
319745
319745
  }
319746
319746
  scanned += 1;
319747
319747
  }
319748
- columns.push(start - lineStart);
319748
+ columns.push(start - lineStart2);
319749
319749
  }
319750
319750
  return columns;
319751
319751
  }
@@ -319753,7 +319753,7 @@ function addAuthoringColumns(transformed, columns, trackInsertions) {
319753
319753
  let sourceIndex = 0;
319754
319754
  let scannedOffset = 0;
319755
319755
  let line = 0;
319756
- let lineStart = 0;
319756
+ let lineStart2 = 0;
319757
319757
  const insertions = [];
319758
319758
  const code2 = transformed.replace(
319759
319759
  /(__source:\s*\{fileName:\s*_jsxFileName,\s*lineNumber:\s*\d+)(\})/g,
@@ -319764,11 +319764,11 @@ function addAuthoringColumns(transformed, columns, trackInsertions) {
319764
319764
  while (scannedOffset < insertionOffset) {
319765
319765
  if (transformed.charCodeAt(scannedOffset) === 10) {
319766
319766
  line += 1;
319767
- lineStart = scannedOffset + 1;
319767
+ lineStart2 = scannedOffset + 1;
319768
319768
  }
319769
319769
  scannedOffset += 1;
319770
319770
  }
319771
- insertions.push({ line, column: insertionOffset - lineStart, length: insertion.length });
319771
+ insertions.push({ line, column: insertionOffset - lineStart2, length: insertion.length });
319772
319772
  }
319773
319773
  return `${source}${insertion}${closingBrace}`;
319774
319774
  }
@@ -323158,8 +323158,8 @@ function propertyValue2(objectNode, property) {
323158
323158
  }
323159
323159
  }
323160
323160
  function lineIndent(source, offset) {
323161
- const lineStart = source.lastIndexOf("\n", offset - 1) + 1;
323162
- return /^[ \t]*/.exec(source.slice(lineStart))[0];
323161
+ const lineStart2 = source.lastIndexOf("\n", offset - 1) + 1;
323162
+ return /^[ \t]*/.exec(source.slice(lineStart2))[0];
323163
323163
  }
323164
323164
  function removalEnd(property, next) {
323165
323165
  const comments = (next.leadingComments ?? []).filter(
@@ -324372,7 +324372,7 @@ function setupResultType(setupModule) {
324372
324372
  return `(typeof import('${setupModule}').default extends import('@diagonal/workflow').WorkflowDefinition<any, infer O> ? ${output} : never)`;
324373
324373
  }
324374
324374
  function testFunctionHeader(hasSetup) {
324375
- return `type Sdk = Omit<DiagonalTestSdk, 'setup'> & { readonly setup: ${setupResultType(hasSetup ? "./setup" : null)} }; export async function diagonalTest(Sdk: Sdk) {`;
324375
+ return `type Sdk = Omit<DiagonalTestSdk, 'setup'>; export async function diagonalTest(Sdk: Sdk, ctx: ${setupResultType(hasSetup ? "./setup" : null)}) {`;
324376
324376
  }
324377
324377
  function checkTestFunctions({ tests, appModules, resourceNames: resourceNames2, workspaceDeclarations, files }) {
324378
324378
  const resources = resourceNames2.map((name) => ` readonly ${JSON.stringify(name)}: string;
@@ -324497,7 +324497,7 @@ var TEST_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,99}$/;
324497
324497
  var SUITE_PROPERTIES = /* @__PURE__ */ new Set(["uid", "name", "description"]);
324498
324498
  var TEST_PROPERTIES = /* @__PURE__ */ new Set(["name", "description", "enabled", "timeoutSeconds"]);
324499
324499
  var HANDLERS = ["setup", "test", "assert"];
324500
- var TEST_FIXTURES = /* @__PURE__ */ new Set(["page", "context", "request", "browser", "expect", "Sdk"]);
324500
+ var TEST_FIXTURES = /* @__PURE__ */ new Set(["page", "context", "request", "browser", "expect", "Sdk", "ctx"]);
324501
324501
  var PHASE_DEFINE = "__diagonalTestPhase";
324502
324502
  var PHASE_IMPORT = `import { defineWorkflow as ${PHASE_DEFINE} } from '@diagonal-hq/workflows/test'; `;
324503
324503
  var SETUP_TYPE_MODULE = "setup.ts";
@@ -324627,10 +324627,15 @@ function readHandlers(node, report) {
324627
324627
  report(property, `"${key}" cannot be a generator`);
324628
324628
  continue;
324629
324629
  }
324630
+ if (key !== "test" && fn.params.length > 1) {
324631
+ valid = false;
324632
+ report(fn.params[1], `"${key}" takes one argument: async ${key}(ctx) { ... }`);
324633
+ continue;
324634
+ }
324630
324635
  handlers[key] = { node: property, fn, method: property.type === "ObjectMethod" };
324631
324636
  }
324632
324637
  if (valid && handlers.test === void 0) {
324633
- report(node, 'The test has no "test" function. Add async test({ page, expect, Sdk }) { ... }');
324638
+ report(node, 'The test has no "test" function. Add async test({ page, expect, ctx }) { ... }');
324634
324639
  return null;
324635
324640
  }
324636
324641
  return valid ? handlers : null;
@@ -324687,7 +324692,7 @@ function readTestFunction(handler, source, ast, enabled2, report) {
324687
324692
  report(node, message);
324688
324693
  };
324689
324694
  if (fn.params.length > 1) {
324690
- problem2(fn.params[1], "The test function takes one argument: { page, context, request, browser, expect, Sdk }");
324695
+ problem2(fn.params[1], "The test function takes one argument: { page, context, request, browser, expect, Sdk, ctx }");
324691
324696
  }
324692
324697
  const fixtures = fn.params[0];
324693
324698
  if (fixtures !== void 0 && fixtures.type !== "ObjectPattern") {
@@ -324722,7 +324727,7 @@ function readTestFunction(handler, source, ast, enabled2, report) {
324722
324727
  reported.add(reference.name);
324723
324728
  problem2(
324724
324729
  reference,
324725
- `The test function runs in the browser runner and cannot use "${reference.name}" from this file. Return the value from setup and read it as Sdk.setup`
324730
+ `The test function runs in the browser runner and cannot use "${reference.name}" from this file. Return the value from setup and read it as ctx.<name>`
324726
324731
  );
324727
324732
  }
324728
324733
  });
@@ -327119,10 +327124,597 @@ function buildWorkspace(root, { assetCatalog = null, writeSource = false, fixSou
327119
327124
  };
327120
327125
  }
327121
327126
 
327127
+ // scripts/lib/runtime-build/git-cli.mjs
327128
+ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
327129
+ import { spawnSync as spawnSync2 } from "node:child_process";
327130
+ import { readFileSync as readFileSync14, writeFileSync as writeFileSync5 } from "node:fs";
327131
+ import { join as join18, resolve as resolve6 } from "node:path";
327132
+
327133
+ // scripts/lib/runtime-build/resource-merge.mjs
327134
+ init_define_globalThis_DIAGONAL_SDK_RUNTIME();
327135
+ var KEYED_PROPERTIES = /* @__PURE__ */ new Set(["fields", "records"]);
327136
+ var CLOSING_TOKENS = /* @__PURE__ */ new Set(["}", "]", ")"]);
327137
+ var RESOURCE_PATH = /^resources\/[^/]+\.ts$/;
327138
+ function isResourceFilePath(path) {
327139
+ return RESOURCE_PATH.test(path);
327140
+ }
327141
+ function tokenLabel(token) {
327142
+ return typeof token.type === "string" ? token.type : token.type.label;
327143
+ }
327144
+ function isComment(token) {
327145
+ return token.type === "CommentLine" || token.type === "CommentBlock";
327146
+ }
327147
+ function firstTokenAt(tokens, position2) {
327148
+ let low = 0;
327149
+ let high = tokens.length;
327150
+ while (low < high) {
327151
+ const middle = low + high >> 1;
327152
+ if (tokens[middle].start < position2) {
327153
+ low = middle + 1;
327154
+ } else {
327155
+ high = middle;
327156
+ }
327157
+ }
327158
+ return low;
327159
+ }
327160
+ function nextCodeToken(tokens, index3) {
327161
+ for (let next = index3 + 1; next < tokens.length; next++) {
327162
+ if (!isComment(tokens[next])) {
327163
+ return tokens[next];
327164
+ }
327165
+ }
327166
+ return null;
327167
+ }
327168
+ function normalizedText(side, start, end) {
327169
+ const { tokens, source } = side;
327170
+ const parts = [];
327171
+ for (let index3 = firstTokenAt(tokens, start); index3 < tokens.length; index3++) {
327172
+ const token = tokens[index3];
327173
+ if (token.end > end) {
327174
+ break;
327175
+ }
327176
+ const label = tokenLabel(token);
327177
+ if (label === "eof") {
327178
+ continue;
327179
+ }
327180
+ if (label === ",") {
327181
+ const next = nextCodeToken(tokens, index3);
327182
+ if (next === null || next.end > end || CLOSING_TOKENS.has(tokenLabel(next))) {
327183
+ continue;
327184
+ }
327185
+ }
327186
+ const text2 = source.slice(token.start, token.end);
327187
+ parts.push(isComment(token) ? text2.replace(/\s+/g, " ") : text2);
327188
+ }
327189
+ return parts.join(" ");
327190
+ }
327191
+ function lineStart(source, position2) {
327192
+ return source.lastIndexOf("\n", position2 - 1) + 1;
327193
+ }
327194
+ function lineIndent2(source, position2) {
327195
+ const start = lineStart(source, position2);
327196
+ return /^[ \t]*/.exec(source.slice(start, position2))[0];
327197
+ }
327198
+ function insideValueToken(tokens, position2) {
327199
+ const token = tokens[firstTokenAt(tokens, position2) - 1];
327200
+ return token !== void 0 && !isComment(token) && token.end > position2;
327201
+ }
327202
+ function reindent(ctx, entry, indent) {
327203
+ const { source, tokens, unit: step } = entry.side;
327204
+ const from = lineIndent2(source, entry.start);
327205
+ const lines = source.slice(entry.start, entry.end).split("\n");
327206
+ let position2 = entry.start;
327207
+ return lines.map((raw, index3) => {
327208
+ const start = position2;
327209
+ position2 += raw.length + 1;
327210
+ const line = index3 < lines.length - 1 && raw.endsWith("\r") ? raw.slice(0, -1) : raw;
327211
+ if (index3 === 0 || !line.startsWith(from) || insideValueToken(tokens, start)) {
327212
+ return line;
327213
+ }
327214
+ let rest = line.slice(from.length);
327215
+ let steps = 0;
327216
+ while (rest.startsWith(step)) {
327217
+ rest = rest.slice(step.length);
327218
+ steps++;
327219
+ }
327220
+ return `${indent}${ctx.unit.repeat(steps)}${rest}`;
327221
+ }).join(ctx.newline);
327222
+ }
327223
+ function readKey(element) {
327224
+ if (element.type !== "ObjectProperty" && element.type !== "ObjectMethod") {
327225
+ return null;
327226
+ }
327227
+ try {
327228
+ return propertyKey2(element);
327229
+ } catch (error) {
327230
+ if (error instanceof SourceError) {
327231
+ return null;
327232
+ }
327233
+ throw error;
327234
+ }
327235
+ }
327236
+ function readPolicyUid(element) {
327237
+ if (element.type !== "ObjectExpression") {
327238
+ return null;
327239
+ }
327240
+ const property = element.properties.find(
327241
+ (candidate) => candidate.type === "ObjectProperty" && !candidate.computed && readKey(candidate) === "uid"
327242
+ );
327243
+ return property?.value.type === "StringLiteral" ? property.value.value : null;
327244
+ }
327245
+ var KEY_READERS = {
327246
+ keyed: readKey,
327247
+ strings: (element) => element.type === "StringLiteral" ? element.value : null,
327248
+ uids: readPolicyUid
327249
+ };
327250
+ function tokenAfter(side, position2, label) {
327251
+ for (let index3 = firstTokenAt(side.tokens, position2); index3 < side.tokens.length; index3++) {
327252
+ const token = side.tokens[index3];
327253
+ if (tokenLabel(token) === label) {
327254
+ return token;
327255
+ }
327256
+ if (!isComment(token)) {
327257
+ return null;
327258
+ }
327259
+ }
327260
+ return null;
327261
+ }
327262
+ function containerOf(side, node, keyOf) {
327263
+ const elements = node.type === "ObjectExpression" ? node.properties : node.elements;
327264
+ const entries = [];
327265
+ const seen = /* @__PURE__ */ new Set();
327266
+ let boundary = node.start + 1;
327267
+ let boundaryLine = node.loc.start.line;
327268
+ for (const [index3, element] of elements.entries()) {
327269
+ if (element === null) {
327270
+ return null;
327271
+ }
327272
+ const key = keyOf(element);
327273
+ if (key === null || seen.has(key)) {
327274
+ return null;
327275
+ }
327276
+ seen.add(key);
327277
+ if (index3 > 0) {
327278
+ const comma2 = tokenAfter(side, elements[index3 - 1].end, ",");
327279
+ if (comma2 === null) {
327280
+ return null;
327281
+ }
327282
+ boundary = comma2.end;
327283
+ boundaryLine = comma2.loc.start.line;
327284
+ }
327285
+ const leading = (element.leadingComments ?? []).find(
327286
+ (comment) => comment.start >= boundary && comment.loc.start.line > boundaryLine
327287
+ );
327288
+ entries.push({
327289
+ side,
327290
+ key,
327291
+ index: index3,
327292
+ value: element.type === "ObjectProperty" ? element.value : null,
327293
+ start: leading?.start ?? element.start,
327294
+ end: element.end
327295
+ });
327296
+ }
327297
+ return { side, node, entries };
327298
+ }
327299
+ function readSide(source) {
327300
+ let ast;
327301
+ try {
327302
+ ast = parse2(source, { sourceType: "module", plugins: ["typescript"], errorRecovery: false, tokens: true });
327303
+ } catch (error) {
327304
+ if (error instanceof SyntaxError) {
327305
+ return null;
327306
+ }
327307
+ throw error;
327308
+ }
327309
+ const exports = ast.program.body.filter((statement2) => statement2.type === "ExportDefaultDeclaration");
327310
+ if (exports.length !== 1) {
327311
+ return null;
327312
+ }
327313
+ const call = exports[0].declaration;
327314
+ if (call.type !== "CallExpression" || call.callee.type !== "Identifier" || call.callee.name !== "defineResource" || call.arguments.length !== 1 || call.arguments[0].type !== "ObjectExpression") {
327315
+ return null;
327316
+ }
327317
+ const side = { source, tokens: ast.tokens, object: call.arguments[0], container: null, unit: " " };
327318
+ side.container = containerOf(side, side.object, KEY_READERS.keyed);
327319
+ if (side.container === null) {
327320
+ return null;
327321
+ }
327322
+ side.unit = indentUnit(side);
327323
+ return side;
327324
+ }
327325
+ function nestedKind(key, values) {
327326
+ if (KEYED_PROPERTIES.has(key)) {
327327
+ return values.every((value) => value?.type === "ObjectExpression") ? "keyed" : null;
327328
+ }
327329
+ if (!values.every((value) => value?.type === "ArrayExpression")) {
327330
+ return null;
327331
+ }
327332
+ const elements = values.flatMap((value) => value.elements);
327333
+ if (elements.length === 0) {
327334
+ return null;
327335
+ }
327336
+ if (elements.every((element) => element?.type === "StringLiteral")) {
327337
+ return "strings";
327338
+ }
327339
+ return elements.every((element) => element !== null && readPolicyUid(element) !== null) ? "uids" : null;
327340
+ }
327341
+ function decide(base2, ours, theirs, same) {
327342
+ if (ours !== void 0 && theirs !== void 0) {
327343
+ if (same(ours, theirs)) {
327344
+ return "ours";
327345
+ }
327346
+ if (base2 !== void 0 && same(ours, base2)) {
327347
+ return "theirs";
327348
+ }
327349
+ return base2 !== void 0 && same(theirs, base2) ? "ours" : "conflict";
327350
+ }
327351
+ if (ours !== void 0) {
327352
+ if (base2 === void 0) {
327353
+ return "ours";
327354
+ }
327355
+ return same(ours, base2) ? "delete" : "conflict";
327356
+ }
327357
+ if (theirs !== void 0) {
327358
+ if (base2 === void 0) {
327359
+ return "theirs";
327360
+ }
327361
+ return same(theirs, base2) ? "delete" : "conflict";
327362
+ }
327363
+ return "delete";
327364
+ }
327365
+ function entryText(entry) {
327366
+ return entry.side.source.slice(entry.start, entry.end);
327367
+ }
327368
+ function entryIndent(entry) {
327369
+ return lineIndent2(entry.side.source, entry.start);
327370
+ }
327371
+ function isMultiline(container) {
327372
+ const [first] = container.entries;
327373
+ return first !== void 0 && container.side.source.slice(container.node.start, first.start).includes("\n");
327374
+ }
327375
+ function containerLayout(ctx, ours, theirs) {
327376
+ const { source } = ours.side;
327377
+ const { node, entries } = ours;
327378
+ const isObject = node.type === "ObjectExpression";
327379
+ if (entries.length === 0) {
327380
+ const multiline2 = isMultiline(theirs);
327381
+ const outer = lineIndent2(source, node.start);
327382
+ const indent2 = multiline2 ? `${outer}${ctx.unit}` : outer;
327383
+ const padding = isObject ? " " : "";
327384
+ return {
327385
+ indent: indent2,
327386
+ first: multiline2 ? `${ctx.newline}${indent2}` : padding,
327387
+ last: multiline2 ? `${ctx.newline}${outer}` : padding,
327388
+ between: [],
327389
+ separator: multiline2 ? `,${ctx.newline}${indent2}` : ", "
327390
+ };
327391
+ }
327392
+ const multiline = isMultiline(ours);
327393
+ const indent = multiline ? entryIndent(entries[0]) : lineIndent2(source, node.start);
327394
+ const between = entries.map((entry, index3) => index3 === 0 ? null : source.slice(entries[index3 - 1].end, entry.start));
327395
+ return {
327396
+ indent,
327397
+ first: source.slice(node.start + 1, entries[0].start),
327398
+ last: source.slice(entries.at(-1).end, node.end - 1),
327399
+ between,
327400
+ separator: multiline ? `,${ctx.newline}${indent}` : ", "
327401
+ };
327402
+ }
327403
+ function conflictBlock(ctx, { ours, base: base2, hasBase, theirs }) {
327404
+ const lines = [`<<<<<<< ${ctx.labels.ours}`];
327405
+ if (ours !== null) {
327406
+ lines.push(ours);
327407
+ }
327408
+ if (hasBase) {
327409
+ lines.push(`||||||| ${ctx.labels.base}`);
327410
+ if (base2 !== null) {
327411
+ lines.push(base2);
327412
+ }
327413
+ }
327414
+ lines.push("=======");
327415
+ if (theirs !== null) {
327416
+ lines.push(theirs);
327417
+ }
327418
+ lines.push(`>>>>>>> ${ctx.labels.theirs}`);
327419
+ return lines.join(ctx.newline);
327420
+ }
327421
+ function renderContainer(ctx, ours, layout, items) {
327422
+ const { source } = ours.side;
327423
+ const { node, entries } = ours;
327424
+ if (items.length === 0) {
327425
+ return entries.length === 0 ? source.slice(node.start, node.end) : `${source[node.start]}${source[node.end - 1]}`;
327426
+ }
327427
+ let text2 = source[node.start];
327428
+ let separator = layout.first;
327429
+ for (const [position2, item] of items.entries()) {
327430
+ if (item.type === "conflict") {
327431
+ text2 += separator.replace(/[ \t]+$/, "");
327432
+ if (!text2.endsWith("\n")) {
327433
+ text2 += ctx.newline;
327434
+ }
327435
+ text2 += item.text;
327436
+ } else {
327437
+ text2 += `${separator}${item.text}`;
327438
+ }
327439
+ if (position2 === items.length - 1) {
327440
+ separator = layout.last;
327441
+ } else if (item.index !== null && item.index < entries.length - 1) {
327442
+ separator = layout.between[item.index + 1];
327443
+ } else {
327444
+ separator = layout.separator;
327445
+ }
327446
+ if (item.type === "conflict") {
327447
+ separator = separator.replace(",", "");
327448
+ if (!/^[ \t]*\r?\n/.test(separator)) {
327449
+ separator = `${ctx.newline}${separator.replace(/^[ \t]+/, "")}`;
327450
+ }
327451
+ }
327452
+ }
327453
+ return `${text2}${separator}${source[node.end - 1]}`;
327454
+ }
327455
+ function mergeContainer(ctx, { base: base2, ours, theirs }, { label, same, nested = () => null }) {
327456
+ const byKey = (container) => new Map((container?.entries ?? []).map((entry) => [entry.key, entry]));
327457
+ const baseEntries = byKey(base2);
327458
+ const oursEntries = byKey(ours);
327459
+ const theirsEntries = byKey(theirs);
327460
+ const layout = containerLayout(ctx, ours, theirs);
327461
+ const section = (entry) => `${layout.indent}${reindent(ctx, entry, layout.indent)},`;
327462
+ const items = /* @__PURE__ */ new Map();
327463
+ for (const key of /* @__PURE__ */ new Set([...oursEntries.keys(), ...theirsEntries.keys()])) {
327464
+ const baseEntry = baseEntries.get(key);
327465
+ const oursEntry = oursEntries.get(key);
327466
+ const theirsEntry = theirsEntries.get(key);
327467
+ const decision = decide(baseEntry, oursEntry, theirsEntry, same);
327468
+ const index3 = oursEntry?.index ?? null;
327469
+ if (decision === "ours") {
327470
+ items.set(key, { type: "entry", index: index3, text: entryText(oursEntry) });
327471
+ } else if (decision === "theirs") {
327472
+ items.set(key, { type: "entry", index: index3, text: reindent(ctx, theirsEntry, layout.indent) });
327473
+ } else if (decision === "conflict") {
327474
+ const merged = oursEntry !== void 0 && theirsEntry !== void 0 ? nested(key, baseEntry, oursEntry, theirsEntry) : null;
327475
+ if (merged !== null) {
327476
+ items.set(key, { type: "entry", index: index3, text: merged });
327477
+ continue;
327478
+ }
327479
+ ctx.conflicts.push(label(key));
327480
+ items.set(key, {
327481
+ type: "conflict",
327482
+ index: index3,
327483
+ text: conflictBlock(ctx, {
327484
+ ours: oursEntry === void 0 ? null : section(oursEntry),
327485
+ hasBase: baseEntry !== void 0,
327486
+ base: baseEntry === void 0 ? null : section(baseEntry),
327487
+ theirs: theirsEntry === void 0 ? null : section(theirsEntry)
327488
+ })
327489
+ });
327490
+ }
327491
+ }
327492
+ const order = ours.entries.map((entry) => entry.key).filter((key) => items.has(key));
327493
+ for (const [position2, entry] of theirs.entries.entries()) {
327494
+ if (oursEntries.has(entry.key) || !items.has(entry.key)) {
327495
+ continue;
327496
+ }
327497
+ let at = 0;
327498
+ for (let previous = position2 - 1; previous >= 0; previous--) {
327499
+ const found2 = order.indexOf(theirs.entries[previous].key);
327500
+ if (found2 !== -1) {
327501
+ at = found2 + 1;
327502
+ break;
327503
+ }
327504
+ }
327505
+ while (at < order.length && !theirsEntries.has(order[at])) {
327506
+ at++;
327507
+ }
327508
+ order.splice(at, 0, entry.key);
327509
+ }
327510
+ return renderContainer(
327511
+ ctx,
327512
+ ours,
327513
+ layout,
327514
+ order.map((key) => items.get(key))
327515
+ );
327516
+ }
327517
+ function sameEntryText() {
327518
+ const cache2 = /* @__PURE__ */ new Map();
327519
+ const text2 = (entry) => {
327520
+ if (!cache2.has(entry)) {
327521
+ cache2.set(entry, normalizedText(entry.side, entry.start, entry.end));
327522
+ }
327523
+ return cache2.get(entry);
327524
+ };
327525
+ return (left, right) => text2(left) === text2(right);
327526
+ }
327527
+ function mergeNestedOption(ctx, sides, key, baseEntry, oursEntry, theirsEntry) {
327528
+ const values = [baseEntry?.value, oursEntry.value, theirsEntry.value].filter((value) => value !== void 0);
327529
+ const kind = nestedKind(key, values);
327530
+ if (kind === null) {
327531
+ return null;
327532
+ }
327533
+ const keyOf = KEY_READERS[kind];
327534
+ const containers = {
327535
+ base: baseEntry === void 0 ? null : containerOf(sides.base, baseEntry.value, keyOf),
327536
+ ours: containerOf(sides.ours, oursEntry.value, keyOf),
327537
+ theirs: containerOf(sides.theirs, theirsEntry.value, keyOf)
327538
+ };
327539
+ if (containers.ours === null || containers.theirs === null || baseEntry !== void 0 && containers.base === null) {
327540
+ return null;
327541
+ }
327542
+ const same = kind === "strings" ? () => true : sameEntryText();
327543
+ const merged = mergeContainer(ctx, containers, { label: (entryKey) => `${key}.${entryKey}`, same });
327544
+ const { source } = sides.ours;
327545
+ return `${source.slice(oursEntry.start, oursEntry.value.start)}${merged}${source.slice(oursEntry.value.end, oursEntry.end)}`;
327546
+ }
327547
+ function mergeOutside(ctx, sides, range, label) {
327548
+ const versions = {};
327549
+ for (const name of ["base", "ours", "theirs"]) {
327550
+ const side = sides[name];
327551
+ if (side !== null) {
327552
+ const [start, end] = range(side);
327553
+ versions[name] = { text: side.source.slice(start, end), normalized: normalizedText(side, start, end) };
327554
+ }
327555
+ }
327556
+ const decision = decide(versions.base, versions.ours, versions.theirs, (left, right) => left.normalized === right.normalized);
327557
+ if (decision === "ours") {
327558
+ return { text: versions.ours.text, conflict: false };
327559
+ }
327560
+ if (decision === "theirs") {
327561
+ return { text: versions.theirs.text, conflict: false };
327562
+ }
327563
+ ctx.conflicts.push(label);
327564
+ const trimmed = (version) => version.text.replace(/\r?\n$/, "");
327565
+ return {
327566
+ text: conflictBlock(ctx, {
327567
+ ours: trimmed(versions.ours),
327568
+ hasBase: versions.base !== void 0,
327569
+ base: versions.base === void 0 ? null : trimmed(versions.base),
327570
+ theirs: trimmed(versions.theirs)
327571
+ }),
327572
+ conflict: true
327573
+ };
327574
+ }
327575
+ function indentUnit(side) {
327576
+ const { container, source } = side;
327577
+ if (!isMultiline(container)) {
327578
+ return " ";
327579
+ }
327580
+ const outer = lineIndent2(source, container.node.start);
327581
+ const inner = entryIndent(container.entries[0]);
327582
+ return inner.startsWith(outer) && inner.length > outer.length ? inner.slice(outer.length) : " ";
327583
+ }
327584
+ function mergeResourceSource({ base: base2, ours, theirs }, { oursLabel = "branch", baseLabel = "base", theirsLabel = "main" } = {}) {
327585
+ if (ours === theirs || base2 === theirs) {
327586
+ return { status: "merged", content: ours };
327587
+ }
327588
+ if (base2 === ours) {
327589
+ return { status: "merged", content: theirs };
327590
+ }
327591
+ const sides = { base: base2 === null ? null : readSide(base2), ours: readSide(ours), theirs: readSide(theirs) };
327592
+ if (sides.ours === null || sides.theirs === null || base2 !== null && sides.base === null) {
327593
+ return { status: "unsupported" };
327594
+ }
327595
+ const ctx = {
327596
+ conflicts: [],
327597
+ labels: { ours: oursLabel, base: baseLabel, theirs: theirsLabel },
327598
+ newline: ours.includes("\r\n") ? "\r\n" : "\n",
327599
+ unit: sides.ours.unit
327600
+ };
327601
+ const containers = { base: sides.base?.container ?? null, ours: sides.ours.container, theirs: sides.theirs.container };
327602
+ const before = mergeOutside(ctx, sides, (side) => [0, side.object.start], "module code before defineResource");
327603
+ const object = mergeContainer(ctx, containers, {
327604
+ label: (key) => key,
327605
+ same: sameEntryText(),
327606
+ nested: (key, baseEntry, oursEntry, theirsEntry) => mergeNestedOption(ctx, sides, key, baseEntry, oursEntry, theirsEntry)
327607
+ });
327608
+ const after = mergeOutside(ctx, sides, (side) => [side.object.end, side.source.length], "module code after defineResource");
327609
+ const content = [
327610
+ before.conflict ? `${before.text}${ctx.newline}` : before.text,
327611
+ object,
327612
+ after.conflict ? `${ctx.newline}${after.text}${ctx.newline}` : after.text
327613
+ ].join("");
327614
+ if (ctx.conflicts.length > 0) {
327615
+ return { status: "conflict", content, conflicts: ctx.conflicts };
327616
+ }
327617
+ return readSide(content) === null ? { status: "unsupported" } : { status: "merged", content };
327618
+ }
327619
+
327620
+ // scripts/lib/runtime-build/git-cli.mjs
327621
+ var MERGE_DRIVER_USAGE = "Usage: diagonal merge-driver <base> <ours> <theirs> [path]";
327622
+ var GIT_SETUP_USAGE = "Usage: diagonal git setup";
327623
+ var DRIVER = "diagonal-resource";
327624
+ var DRIVER_COMMAND = "npx --no-install diagonal merge-driver %O %A %B %P";
327625
+ var ATTRIBUTES_LINE = `resources/*.ts merge=${DRIVER}`;
327626
+ var LABELS = { oursLabel: "branch", baseLabel: "base", theirsLabel: "main" };
327627
+ function git(args, cwd) {
327628
+ return spawnSync2("git", args, { cwd, encoding: "utf8" });
327629
+ }
327630
+ function lineMerge(base2, ours, theirs, { cwd, stderr }) {
327631
+ const result = git(
327632
+ ["merge-file", "--diff3", "-L", LABELS.oursLabel, "-L", LABELS.baseLabel, "-L", LABELS.theirsLabel, ours, base2, theirs],
327633
+ cwd
327634
+ );
327635
+ if (result.error !== void 0 || result.status === null) {
327636
+ stderr.write(`git merge-file did not run: ${result.error?.message ?? result.signal}
327637
+ `);
327638
+ return 2;
327639
+ }
327640
+ return result.status;
327641
+ }
327642
+ function mergeDriver(args, { cwd, stderr }) {
327643
+ if (args.length < 3 || args.length > 4) {
327644
+ stderr.write(`${MERGE_DRIVER_USAGE}
327645
+ `);
327646
+ return 2;
327647
+ }
327648
+ const [base2, ours, theirs] = args.slice(0, 3).map((file2) => resolve6(cwd, file2));
327649
+ const path = args[3];
327650
+ if (path === void 0 || !isResourceFilePath(path)) {
327651
+ return lineMerge(base2, ours, theirs, { cwd, stderr });
327652
+ }
327653
+ const baseSource = readFileSync14(base2, "utf8");
327654
+ const result = mergeResourceSource(
327655
+ { base: baseSource === "" ? null : baseSource, ours: readFileSync14(ours, "utf8"), theirs: readFileSync14(theirs, "utf8") },
327656
+ LABELS
327657
+ );
327658
+ if (result.status === "unsupported") {
327659
+ return lineMerge(base2, ours, theirs, { cwd, stderr });
327660
+ }
327661
+ writeFileSync5(ours, result.content);
327662
+ if (result.status === "conflict") {
327663
+ stderr.write(`${path}: conflict in ${result.conflicts.join(", ")}
327664
+ `);
327665
+ return 1;
327666
+ }
327667
+ return 0;
327668
+ }
327669
+ function gitSetup(args, { cwd, stdout, stderr }) {
327670
+ if (args.length > 0) {
327671
+ stderr.write(`${GIT_SETUP_USAGE}
327672
+ `);
327673
+ return 2;
327674
+ }
327675
+ const topLevel = git(["rev-parse", "--show-toplevel"], cwd);
327676
+ if (topLevel.status !== 0) {
327677
+ stderr.write("Run this command in a git repository.\n");
327678
+ return 2;
327679
+ }
327680
+ const root = topLevel.stdout.trim();
327681
+ for (const [key, value] of [
327682
+ [`merge.${DRIVER}.name`, "Diagonal resource merge"],
327683
+ [`merge.${DRIVER}.driver`, DRIVER_COMMAND]
327684
+ ]) {
327685
+ const result = git(["config", key, value], root);
327686
+ if (result.status !== 0) {
327687
+ stderr.write(`git config ${key} failed: ${result.stderr.trim()}
327688
+ `);
327689
+ return 1;
327690
+ }
327691
+ }
327692
+ const attributesPath = join18(root, ".gitattributes");
327693
+ let attributes = "";
327694
+ try {
327695
+ attributes = readFileSync14(attributesPath, "utf8");
327696
+ } catch (error) {
327697
+ if (error.code !== "ENOENT") {
327698
+ throw error;
327699
+ }
327700
+ }
327701
+ stdout.write(`Registered the ${DRIVER} merge driver in the git config.
327702
+ `);
327703
+ if (attributes.split(/\r?\n/).some((line) => line.trim() === ATTRIBUTES_LINE)) {
327704
+ return 0;
327705
+ }
327706
+ const separator = attributes === "" || attributes.endsWith("\n") ? "" : "\n";
327707
+ writeFileSync5(attributesPath, `${attributes}${separator}${ATTRIBUTES_LINE}
327708
+ `);
327709
+ stdout.write(`Added "${ATTRIBUTES_LINE}" to .gitattributes. Commit .gitattributes.
327710
+ `);
327711
+ return 0;
327712
+ }
327713
+
327122
327714
  // scripts/lib/runtime-build/migration-cli.mjs
327123
327715
  init_define_globalThis_DIAGONAL_SDK_RUNTIME();
327124
- import { mkdirSync as mkdirSync3, readdirSync as readdirSync5, statSync as statSync5, writeFileSync as writeFileSync5 } from "node:fs";
327125
- import { join as join18 } from "node:path";
327716
+ import { mkdirSync as mkdirSync3, readdirSync as readdirSync5, statSync as statSync5, writeFileSync as writeFileSync6 } from "node:fs";
327717
+ import { join as join19 } from "node:path";
327126
327718
  var MIGRATION_USAGE = "Usage: diagonal make:migration <name>";
327127
327719
  var NAME = /^[a-z0-9][a-z0-9_]{0,84}$/;
327128
327720
  function makeMigration(args, { cwd, stdout, stderr }) {
@@ -327134,12 +327726,12 @@ ${MIGRATION_USAGE}
327134
327726
  );
327135
327727
  return 2;
327136
327728
  }
327137
- if (!statSync5(join18(cwd, "diagonal.config.ts"), { throwIfNoEntry: false })?.isFile()) {
327729
+ if (!statSync5(join19(cwd, "diagonal.config.ts"), { throwIfNoEntry: false })?.isFile()) {
327138
327730
  stderr.write("Run this command in a workspace directory with diagonal.config.ts.\n");
327139
327731
  return 2;
327140
327732
  }
327141
327733
  const name = args[0];
327142
- const directory = join18(cwd, "migrations");
327734
+ const directory = join19(cwd, "migrations");
327143
327735
  mkdirSync3(directory, { recursive: true });
327144
327736
  const used = new Set(
327145
327737
  readdirSync5(directory).filter((file2) => file2.endsWith(".ts") && !file2.endsWith(".test.ts")).map((file2) => migrationTimestamp(file2.slice(0, -3))).filter((timestamp2) => timestamp2 !== null)
@@ -327163,7 +327755,7 @@ export default defineWorkflow(
327163
327755
  async () => {}
327164
327756
  );
327165
327757
  `;
327166
- writeFileSync5(join18(cwd, path), source, { flag: "wx" });
327758
+ writeFileSync6(join19(cwd, path), source, { flag: "wx" });
327167
327759
  stdout.write(`Created ${path}
327168
327760
  `);
327169
327761
  return 0;
@@ -327179,7 +327771,9 @@ var USAGE = [
327179
327771
  RUN_USAGE,
327180
327772
  LOGS_USAGE,
327181
327773
  ASSETS_UPLOAD_USAGE,
327182
- ASSETS_LIST_USAGE
327774
+ ASSETS_LIST_USAGE,
327775
+ MERGE_DRIVER_USAGE,
327776
+ GIT_SETUP_USAGE
327183
327777
  ].join("\n");
327184
327778
  function plural(count, word) {
327185
327779
  return `${count} ${word}${count === 1 ? "" : "s"}`;
@@ -327213,7 +327807,7 @@ ${CHECK_USAGE}
327213
327807
  `);
327214
327808
  return 2;
327215
327809
  }
327216
- const root = resolve6(cwd, parsed.dir);
327810
+ const root = resolve7(cwd, parsed.dir);
327217
327811
  if (!statSync6(root, { throwIfNoEntry: false })?.isDirectory()) {
327218
327812
  stderr.write(`Not a directory: ${root}
327219
327813
  `);
@@ -327251,6 +327845,15 @@ async function main(argv, io) {
327251
327845
  if (subcommand === "list") return listAssets(assetArgs, io);
327252
327846
  io.stderr.write(`${ASSETS_UPLOAD_USAGE}
327253
327847
  ${ASSETS_LIST_USAGE}
327848
+ `);
327849
+ return 2;
327850
+ }
327851
+ case "merge-driver":
327852
+ return mergeDriver(args, io);
327853
+ case "git": {
327854
+ const [subcommand, ...gitArgs] = args;
327855
+ if (subcommand === "setup") return gitSetup(gitArgs, io);
327856
+ io.stderr.write(`${GIT_SETUP_USAGE}
327254
327857
  `);
327255
327858
  return 2;
327256
327859
  }