vxrn 2.6.9 → 2.6.11

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.
@@ -331,6 +331,16 @@ function declarationStart(list, floor, keyword) {
331
331
  }
332
332
  return first;
333
333
  }
334
+ function declarationModifiers(list, floor, keyword) {
335
+ const words = [];
336
+ for (let i = declarationStart(list, floor, keyword), depth = 0; i < keyword; i++) {
337
+ const text = list[i].text;
338
+ if (text === "(") depth++;
339
+ else if (text === ")") depth--;
340
+ else if (depth === 0) words.push(text);
341
+ }
342
+ return words;
343
+ }
334
344
  function subscriptionPayload(file, typeTokens, language, named) {
335
345
  try {
336
346
  if (typeTokens.at(-1)?.text === "?") return null;
@@ -375,7 +385,7 @@ function methods(file, list, start, end, language, named) {
375
385
  i++;
376
386
  continue;
377
387
  }
378
- const modifiers = list.slice(declarationStart(list, previous, i), i).map((token) => token.text);
388
+ const modifiers = declarationModifiers(list, previous, i);
379
389
  const hidden = modifiers.includes("private") || modifiers.includes("fileprivate");
380
390
  if (!hidden && (modifiers.includes("static") || modifiers.includes("class"))) {
381
391
  fail(file, list[i], "static native exports are unsupported");
@@ -541,7 +551,7 @@ function storedProperty(file, list, i, previous, end, owner) {
541
551
  };
542
552
  }
543
553
  function swiftView(file, list, keyword, floor, body, end, named) {
544
- const modifiers = list.slice(declarationStart(list, floor, keyword), keyword).map((token) => token.text);
554
+ const modifiers = declarationModifiers(list, floor, keyword);
545
555
  if (list[keyword].text !== "struct" || !modifiers.includes("public")) return null;
546
556
  if (!list.slice(keyword + 2, body).some((token) => token.text === "View")) return null;
547
557
  const name = list[keyword + 1].text;
@@ -605,7 +615,7 @@ function swiftView(file, list, keyword, floor, body, end, named) {
605
615
  };
606
616
  }
607
617
  function collectDataClass(file, list, keyword, name, token, generic, packageName) {
608
- const modifiers = list.slice(declarationStart(list, 0, keyword - 1), keyword).map((entry) => entry.text);
618
+ const modifiers = declarationModifiers(list, 0, keyword - 1);
609
619
  let problem = null;
610
620
  if (modifiers.includes("private")) {
611
621
  problem = `data class ${name} must be public to cross the boundary`;
@@ -1048,7 +1058,7 @@ function collectNamedTypes(file, list, language, packageName) {
1048
1058
  const header = list.slice(i + 2, body);
1049
1059
  if (isSwiftStruct) {
1050
1060
  const inherits = header.map((entry) => entry.text);
1051
- const modifiers = list.slice(declarationStart(list, 0, i), i).map((entry) => entry.text);
1061
+ const modifiers = declarationModifiers(list, 0, i);
1052
1062
  structs.push({
1053
1063
  name,
1054
1064
  token,
@@ -1081,7 +1091,7 @@ function collectNamedTypes(file, list, language, packageName) {
1081
1091
  };
1082
1092
  }
1083
1093
  function composableView(file, list, keyword, floor, named) {
1084
- const modifiers = list.slice(declarationStart(list, floor, keyword), keyword).map((token) => token.text);
1094
+ const modifiers = declarationModifiers(list, floor, keyword);
1085
1095
  if (!modifiers.some((value, index) => value === "@" && modifiers[index + 1] === "Composable")) return null;
1086
1096
  if (modifiers.includes("private") || modifiers.includes("internal")) return null;
1087
1097
  const name = list[keyword + 1]?.text;