Skip to content

Commit

Permalink
Run dart format
Browse files Browse the repository at this point in the history
  • Loading branch information
jellejurre committed Nov 12, 2024
1 parent 645cc78 commit 4fda381
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 10 deletions.
19 changes: 12 additions & 7 deletions vrchat_dart/tool/patch_output.dart
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,26 @@ void patchApi() {
var content = file.readAsStringSync();

if (file.path.contains('files_api.dart')) {

final filesApiMapped = {
"final _path = r'/file/image';": "try {_bodyData = FormData.fromMap({'file': file, 'tag': tag, if (animationStyle != null) 'animationStyle': animationStyle, if (maskTag != null) 'maskTag': maskTag,});} catch (error, stackTrace) {",
"final _path = r'/icon';": "try {_bodyData = FormData.fromMap({'file': file});} catch (error, stackTrace) {",
"final _path = r'/gallery';": "try {_bodyData = FormData.fromMap({'file': file});} catch (error, stackTrace) {",
"final _path = r'/file/image';":
"try {\n _bodyData = FormData.fromMap({\n 'file': file,\n 'tag': tag,\n if (animationStyle != null) 'animationStyle': animationStyle,\n if (maskTag != null) 'maskTag': maskTag,\n });\n } catch (error, stackTrace) {",
"final _path = r'/icon';":
"try {\n _bodyData = FormData.fromMap({'file': file});\n } catch (error, stackTrace) {",
"final _path = r'/gallery';":
"try {\n _bodyData = FormData.fromMap({'file': file});\n } catch (error, stackTrace) {",
};

final emptyBlockRegExp = RegExp(r'try \{\} catch \(error, stackTrace\) \{');
final emptyBlockRegExp =
RegExp(r'try \{\} catch \(error, stackTrace\) \{');
final resultContent = StringBuffer();
var currentIndex = 0;

for (final emptyBlock in emptyBlockRegExp.allMatches(content)) {
resultContent.write(content.substring(currentIndex, emptyBlock.start));
final closestPathIndex = content.lastIndexOf(RegExp(r"(final _path = r'[^']+?';)"), emptyBlock.start);
final closestPath = content.substring(closestPathIndex, content.indexOf(';', closestPathIndex) + 1);
final closestPathIndex = content.lastIndexOf(
RegExp(r"(final _path = r'[^']+?';)"), emptyBlock.start);
final closestPath = content.substring(
closestPathIndex, content.indexOf(';', closestPathIndex) + 1);
final replacement = filesApiMapped[closestPath] ?? '';
resultContent.write(replacement);
currentIndex = emptyBlock.end;
Expand Down
17 changes: 14 additions & 3 deletions vrchat_dart_generated/lib/src/api/files_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,9 @@ class FilesApi {

dynamic _bodyData;

try {_bodyData = FormData.fromMap({'file': file});} catch (error, stackTrace) {
try {
_bodyData = FormData.fromMap({'file': file});
} catch (error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
Expand Down Expand Up @@ -1052,7 +1054,9 @@ class FilesApi {

dynamic _bodyData;

try {_bodyData = FormData.fromMap({'file': file});} catch (error, stackTrace) {
try {
_bodyData = FormData.fromMap({'file': file});
} catch (error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
Expand Down Expand Up @@ -1154,7 +1158,14 @@ class FilesApi {

dynamic _bodyData;

try {_bodyData = FormData.fromMap({'file': file, 'tag': tag, if (animationStyle != null) 'animationStyle': animationStyle, if (maskTag != null) 'maskTag': maskTag,});} catch (error, stackTrace) {
try {
_bodyData = FormData.fromMap({
'file': file,
'tag': tag,
if (animationStyle != null) 'animationStyle': animationStyle,
if (maskTag != null) 'maskTag': maskTag,
});
} catch (error, stackTrace) {
throw DioException(
requestOptions: _options.compose(
_dio.options,
Expand Down

0 comments on commit 4fda381

Please sign in to comment.