Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Change some lints into fenced code blocks.
  • Loading branch information
kallentu committed Oct 31, 2024
commit f4fb9f5ac8beac28b76aaca737a974edfd02e50a
3 changes: 2 additions & 1 deletion packages/process/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 5.0.3

* Adds `missing_code_block_language_in_doc_comment` lint.
* Updates minimum supported SDK version to Flutter 3.19/Dart 3.3.

## 5.0.2
Expand Down
30 changes: 14 additions & 16 deletions packages/process/lib/src/interface/process_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,13 @@ abstract class ProcessManager {
/// The following code uses `start` to grep for `main` in the
/// file `test.dart` on Linux.
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// ProcessManager mgr = new LocalProcessManager();
/// mgr.start(['grep', '-i', 'main', 'test.dart']).then((process) {
/// stdout.addStream(process.stdout);
/// stderr.addStream(process.stderr);
/// });
/// ```dart
/// ProcessManager mgr = new LocalProcessManager();
/// mgr.start(['grep', '-i', 'main', 'test.dart']).then((process) {
/// stdout.addStream(process.stdout);
/// stderr.addStream(process.stderr);
/// });
/// ```
///
/// If [mode] is [ProcessStartMode.normal] (the default) a child
/// process will be started with `stdin`, `stdout` and `stderr`
Expand Down Expand Up @@ -133,14 +132,13 @@ abstract class ProcessManager {
/// The following code uses `run` to grep for `main` in the
/// file `test.dart` on Linux.
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// ProcessManager mgr = new LocalProcessManager();
/// mgr.run('grep', ['-i', 'main', 'test.dart']).then((result) {
/// stdout.write(result.stdout);
/// stderr.write(result.stderr);
/// });
/// ```dart
/// ProcessManager mgr = new LocalProcessManager();
/// mgr.run('grep', ['-i', 'main', 'test.dart']).then((result) {
/// stdout.write(result.stdout);
/// stderr.write(result.stderr);
/// });
/// ```
Future<ProcessResult> run(
List<Object> command, {
String? workingDirectory,
Expand Down
2 changes: 1 addition & 1 deletion packages/process/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: process
description: A pluggable, mockable process invocation abstraction for Dart.
repository: https://github.com/flutter/packages/tree/main/packages/process
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+process%22
version: 5.0.2
version: 5.0.3

environment:
sdk: ^3.3.0
Expand Down
133 changes: 74 additions & 59 deletions packages/rfw/lib/src/dart/binary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ Uint8List encodeDataBlob(Object value) {
/// Remote Flutter Widgets binary library blobs.
/// * [parseDataFile], which parses the text variant of this format.
Object decodeDataBlob(Uint8List bytes) {
final _BlobDecoder decoder = _BlobDecoder(bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes));
final _BlobDecoder decoder = _BlobDecoder(
bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes));
decoder.expectSignature(dataBlobSignature);
final Object result = decoder.readValue();
if (!decoder.finished) {
Expand Down Expand Up @@ -115,10 +116,9 @@ Uint8List encodeLibraryBlob(RemoteWidgetLibrary value) {
///
/// For example, the string "Hello" would be encoded as:
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// 05 00 00 00 00 00 00 00 48 65 6C 6C 6F
/// ```none
/// 05 00 00 00 00 00 00 00 48 65 6C 6C 6F
/// ```
///
/// * Lists are encoded as an integer length, followed by that many values
/// back to back. When lists are of specific types (e.g. lists of imports),
Expand All @@ -127,21 +127,19 @@ Uint8List encodeLibraryBlob(RemoteWidgetLibrary value) {
/// followed by the value (tagged lists). For example, a list of integers with
/// the values 1 and 2 in that order would be encoded as:
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
/// 02 00 00 00 00 00 00 00
/// ```none
/// 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
/// 02 00 00 00 00 00 00 00
/// ```
///
/// A list of arbitrary values that happens to contain one string "Hello"
/// would be encoded as follows; 0x04 is the tag for "String" (the full list
/// of tags is described below):
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// 01 00 00 00 00 00 00 00 04 05 00 00 00 00 00 00
/// 00 48 65 6C 6C 6F
/// ```none
/// 01 00 00 00 00 00 00 00 04 05 00 00 00 00 00 00
/// 00 48 65 6C 6C 6F
/// ```
///
/// A list of length zero is eight zero bytes with no additional payload.
///
Expand All @@ -156,11 +154,10 @@ Uint8List encodeLibraryBlob(RemoteWidgetLibrary value) {
/// strings, so they are untagged) is encoded as follows (0x02 is the tag for
/// integers):
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
/// 61 02 0F 00 00 00 00 00 00 00
/// ```none
/// 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
/// 61 02 0F 00 00 00 00 00 00 00
/// ```
///
/// Objects are encoded as follows:
///
Expand All @@ -171,11 +168,10 @@ Uint8List encodeLibraryBlob(RemoteWidgetLibrary value) {
/// one of the subparts of the imported library name. For example, `import
/// a.b` is encoded as:
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
/// 61 01 00 00 00 00 00 00 00 62
/// ```none
/// 02 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00
/// 61 01 00 00 00 00 00 00 00 62
/// ```
///
/// * Widget declarations are encoded as a string giving the declaration name,
/// an untagged map for the initial state, and finally the value that
Expand Down Expand Up @@ -245,14 +241,13 @@ Uint8List encodeLibraryBlob(RemoteWidgetLibrary value) {
///
/// ...is encoded as follows (including the tag for the switch itself):
///
// TODO(kallentu): Remove ignore and fix when stable is bumped.
// https://github.com/flutter/flutter/issues/157620
// ignore: missing_code_block_language_in_doc_comment
/// 0F 0A 01 00 00 00 00 00 00 00 61 03 00 00 00 00
/// 00 00 00 02 00 00 00 00 00 00 00 00 04 01 00 00
/// 00 00 00 00 00 7A 02 01 00 00 00 00 00 00 00 04
/// 01 00 00 00 00 00 00 00 6F 10 04 01 00 00 00 00
/// 00 00 00 64
/// ```none
/// 0F 0A 01 00 00 00 00 00 00 00 61 03 00 00 00 00
/// 00 00 00 02 00 00 00 00 00 00 00 00 04 01 00 00
/// 00 00 00 00 00 7A 02 01 00 00 00 00 00 00 00 04
/// 01 00 00 00 00 00 00 00 6F 10 04 01 00 00 00 00
/// 00 00 00 64
/// ```
///
/// * Event handlers have the tag 0x0E, and are encoded as a string
/// ([EventHandler.eventName]) and an untagged map
Expand Down Expand Up @@ -282,11 +277,13 @@ Uint8List encodeLibraryBlob(RemoteWidgetLibrary value) {
/// Remote Flutter Widgets binary data blobs.
/// * [parseDataFile], which parses the text variant of this format.
RemoteWidgetLibrary decodeLibraryBlob(Uint8List bytes) {
final _BlobDecoder decoder = _BlobDecoder(bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes));
final _BlobDecoder decoder = _BlobDecoder(
bytes.buffer.asByteData(bytes.offsetInBytes, bytes.lengthInBytes));
decoder.expectSignature(libraryBlobSignature);
final RemoteWidgetLibrary result = decoder.readLibrary();
if (!decoder.finished) {
throw const FormatException('Unexpected trailing bytes after constructors.');
throw const FormatException(
'Unexpected trailing bytes after constructors.');
}
return result;
}
Expand Down Expand Up @@ -338,7 +335,8 @@ class _BlobDecoder {

void _advance(String context, int length) {
if (_cursor + length > bytes.lengthInBytes) {
throw FormatException('Could not read $context at offset $_cursor: unexpected end of file.');
throw FormatException(
'Could not read $context at offset $_cursor: unexpected end of file.');
}
_cursor += length;
}
Expand All @@ -357,8 +355,10 @@ class _BlobDecoder {
}
// We use multiplication rather than bit shifts because << truncates to 32 bits when compiled to JS:
// https://dart.dev/guides/language/numbers#bitwise-operations
final int a = bytes.getUint32(byteOffset, _blobEndian); // dead code on VM target
final int b = bytes.getInt32(byteOffset + 4, _blobEndian); // dead code on VM target
final int a =
bytes.getUint32(byteOffset, _blobEndian); // dead code on VM target
final int b =
bytes.getInt32(byteOffset + 4, _blobEndian); // dead code on VM target
return a + (b * 0x100000000); // dead code on VM target
}

Expand All @@ -372,7 +372,8 @@ class _BlobDecoder {
final int length = _readInt64();
final int byteOffset = _cursor;
_advance('string', length);
return utf8.decode(bytes.buffer.asUint8List(bytes.offsetInBytes + byteOffset, length));
return utf8.decode(
bytes.buffer.asUint8List(bytes.offsetInBytes + byteOffset, length));
}

List<Object> _readPartList() {
Expand All @@ -384,12 +385,14 @@ class _BlobDecoder {
case _msInt64:
return _readInt64();
default:
throw FormatException('Invalid reference type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding blob.');
throw FormatException(
'Invalid reference type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding blob.');
}
});
}

Map<String, Object?>? _readMap(Object Function() readNode, { bool nullIfEmpty = false }) {
Map<String, Object?>? _readMap(Object Function() readNode,
{bool nullIfEmpty = false}) {
final int count = _readInt64();
if (count == 0 && nullIfEmpty) {
return null;
Expand Down Expand Up @@ -444,7 +447,9 @@ class _BlobDecoder {
return DynamicList.generate(_readInt64(), (int index) => readNode());
case _msMap:
return _readMap(readNode)!;
default: throw FormatException('Unrecognized data type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding blob.');
default:
throw FormatException(
'Unrecognized data type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding blob.');
}
}

Expand Down Expand Up @@ -472,7 +477,8 @@ class _BlobDecoder {
case _msSwitch:
return _readSwitch();
case _msSetState:
return SetStateHandler(StateReference(_readPartList()), _readArgument());
return SetStateHandler(
StateReference(_readPartList()), _readArgument());
case _msWidgetBuilder:
return _readWidgetBuilder();
case _msWidgetBuilderArgReference:
Expand All @@ -496,7 +502,8 @@ class _BlobDecoder {
final String argumentName = _readString();
final int type = _readByte();
if (type != _msWidget && type != _msSwitch) {
throw FormatException('Unrecognized data type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding widget builder blob.');
throw FormatException(
'Unrecognized data type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding widget builder blob.');
}
final BlobNode widget = type == _msWidget ? _readWidget() : _readSwitch();
return WidgetBuilderDeclaration(argumentName, widget);
Expand All @@ -513,17 +520,20 @@ class _BlobDecoder {
case _msWidget:
root = _readWidget();
default:
throw FormatException('Unrecognized data type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding widget declaration root.');
throw FormatException(
'Unrecognized data type 0x${type.toRadixString(16).toUpperCase().padLeft(2, "0")} while decoding widget declaration root.');
}
return WidgetDeclaration(name, initialState, root);
}

List<WidgetDeclaration> _readDeclarationList() {
return List<WidgetDeclaration>.generate(_readInt64(), (int index) => _readDeclaration());
return List<WidgetDeclaration>.generate(
_readInt64(), (int index) => _readDeclaration());
}

Import _readImport() {
return Import(LibraryName(List<String>.generate(_readInt64(), (int index) => _readString())));
return Import(LibraryName(
List<String>.generate(_readInt64(), (int index) => _readString())));
}

List<Import> _readImportList() {
Expand All @@ -546,11 +556,9 @@ class _BlobDecoder {
}
}
if (!match) {
throw FormatException(
'File signature mismatch. '
'Expected ${signature.map<String>((int byte) => byte.toRadixString(16).toUpperCase().padLeft(2, "0")).join(" ")} '
'but found ${bytes.map<String>((int byte) => byte.toRadixString(16).toUpperCase().padLeft(2, "0")).join(" ")}.'
);
throw FormatException('File signature mismatch. '
'Expected ${signature.map<String>((int byte) => byte.toRadixString(16).toUpperCase().padLeft(2, "0")).join(" ")} '
'but found ${bytes.map<String>((int byte) => byte.toRadixString(16).toUpperCase().padLeft(2, "0")).join(" ")}.');
}
}
}
Expand All @@ -566,22 +574,27 @@ class _BlobEncoder {
_BlobEncoder();

static final Uint8List _scratchOut = Uint8List(8);
static final ByteData _scratchIn = _scratchOut.buffer.asByteData(_scratchOut.offsetInBytes, _scratchOut.lengthInBytes);
static final ByteData _scratchIn = _scratchOut.buffer
.asByteData(_scratchOut.offsetInBytes, _scratchOut.lengthInBytes);

final BytesBuilder bytes = BytesBuilder(); // copying builder -- we repeatedly add _scratchOut after changing it
final BytesBuilder bytes =
BytesBuilder(); // copying builder -- we repeatedly add _scratchOut after changing it

void _writeInt64(int value) {
if (_has64Bits) {
_scratchIn.setInt64(0, value, _blobEndian);
} else {
// We use division rather than bit shifts because >> truncates to 32 bits when compiled to JS:
// https://dart.dev/guides/language/numbers#bitwise-operations
if (value >= 0) { // dead code on VM target
if (value >= 0) {
// dead code on VM target
_scratchIn.setInt32(0, value, _blobEndian); // dead code on VM target
_scratchIn.setInt32(4, value ~/ 0x100000000, _blobEndian); // dead code on VM target
_scratchIn.setInt32(
4, value ~/ 0x100000000, _blobEndian); // dead code on VM target
} else {
_scratchIn.setInt32(0, value, _blobEndian); // dead code on VM target
_scratchIn.setInt32(4, -((-value) ~/ 0x100000000 + 1), _blobEndian); // dead code on VM target
_scratchIn.setInt32(4, -((-value) ~/ 0x100000000 + 1),
_blobEndian); // dead code on VM target
}
}
bytes.add(_scratchOut);
Expand Down Expand Up @@ -609,7 +622,8 @@ class _BlobEncoder {
bytes.addByte(_msString);
_writeString(value);
} else {
throw StateError('Unexpected type ${value.runtimeType} while encoding blob.');
throw StateError(
'Unexpected type ${value.runtimeType} while encoding blob.');
}
}

Expand All @@ -618,7 +632,8 @@ class _BlobEncoder {
bytes.addByte(_msFalse);
} else if (value == true) {
bytes.addByte(_msTrue);
} else if (value is double && value is! int) { // When compiled to JS, a Number can be both.
} else if (value is double && value is! int) {
// When compiled to JS, a Number can be both.
bytes.addByte(_msBinary64);
_scratchIn.setFloat64(0, value, _blobEndian);
bytes.add(_scratchOut);
Expand Down
3 changes: 2 additions & 1 deletion packages/webview_flutter/webview_flutter_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT
## 0.2.3+3

* Adds `missing_code_block_language_in_doc_comment` lint.
* Updates minimum supported SDK version to Flutter 3.22/Dart 3.4.

## 0.2.3+2
Expand Down
Loading