Don't use sync*, as it is unimplemented in dart2wasm. (flutter/engine#38149)

* Don't use sync*, as it is unimplemented in dart2wasm.

* Address Joshua's comments.

* Even more terse syntax, and change the name of the library
This commit is contained in:
Jackson Gardner
2022-12-09 13:15:11 -08:00
committed by GitHub
parent 8c609c5c42
commit 1f8ce4fd94
7 changed files with 33 additions and 36 deletions

View File

@@ -5,15 +5,15 @@
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
//
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_layouts based on
// https://github.com/microsoft/vscode/tree/ab7ccc9e872dfcdfc429f8f2815109ec0ca926e3/src/vs/workbench/services/keybinding/browser/keyboardLayouts
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_keymap based on
// https://github.com/microsoft/vscode/tree/422b581e3802e30cfb780c21d9cc1a2cd0c9f0aa/src/vs/workbench/services/keybinding/browser/keyboardLayouts
//
// Edit the following files instead:
//
// - Script: lib/main.dart
// - Templates: data/*.tmpl
//
// See flutter/engine:flutter/tools/gen_web_keyboard_layouts/README.md for more information.
// See flutter/engine:flutter/tools/gen_web_locale_keymap/README.md for more information.
/// Used in the final mapping indicating the logical key should be derived from
/// KeyboardEvent.keyCode.
@@ -100,16 +100,17 @@ bool isLetter(int charCode) {
///
/// This greatly reduces the entries needed in the final mapping.
int? heuristicMapper(String code, String key) {
// Digit code: return the digit.
// Digit code: return the digit by event code.
if (code.startsWith('Digit')) {
assert(code.length == 6);
return code.codeUnitAt(5); // The character immediately after 'Digit'
}
final int charCode = key.codeUnitAt(0);
// Non-ascii: return the goal (i.e. US mapping by event code).
if (key.length > 1 || !_isAscii(charCode)) {
return kLayoutGoals[code]?.codeUnitAt(0);
}
// Letter key: return the letter.
// Letter key: return the event key letter.
if (isLetter(charCode)) {
return key.toLowerCase().codeUnitAt(0);
}
@@ -167,22 +168,20 @@ class _StringStream {
Map<String, int> _unmarshallCodeMap(_StringStream stream) {
final int entryNum = stream.readIntAsVerbatim();
return Map<String, int>.fromEntries((() sync* {
for (int entryIndex = 0; entryIndex < entryNum; entryIndex += 1) {
yield MapEntry<String, int>(stream.readEventKey(), stream.readIntAsChar());
}
})());
return <String, int>{
for (int i = 0; i < entryNum; i++)
stream.readEventKey(): stream.readIntAsChar(),
};
}
/// Decode a key mapping data out of the string.
Map<String, Map<String, int>> unmarshallMappingData(String compressed) {
final _StringStream stream = _StringStream(compressed);
final int eventCodeNum = stream.readIntAsVerbatim();
return Map<String, Map<String, int>>.fromEntries((() sync* {
for (int eventCodeIndex = 0; eventCodeIndex < eventCodeNum; eventCodeIndex += 1) {
yield MapEntry<String, Map<String, int>>(stream.readEventCode(), _unmarshallCodeMap(stream));
}
})());
return <String, Map<String, int>>{
for (int i = 0; i < eventCodeNum; i++)
stream.readEventCode() : _unmarshallCodeMap(stream),
};
}
/// Data for [LocaleKeymap] on Windows.

View File

@@ -5,7 +5,7 @@
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
//
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_layouts based on
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_keymap based on
// https://github.com/microsoft/vscode/tree/@@@COMMIT_ID@@@/src/vs/workbench/services/keybinding/browser/keyboardLayouts
//
// Edit the following files instead:
@@ -13,7 +13,7 @@
// - Script: lib/main.dart
// - Templates: data/*.tmpl
//
// See flutter/engine:flutter/tools/gen_web_keyboard_layouts/README.md for more information.
// See flutter/engine:flutter/tools/gen_web_keyboard_keymap/README.md for more information.
import 'package:test/test.dart';
import 'package:web_locale_keymap/web_locale_keymap.dart';

View File

@@ -5,10 +5,10 @@
import 'dart:io';
import 'package:args/args.dart';
import 'package:gen_web_keyboard_layouts/benchmark_planner.dart';
import 'package:gen_web_keyboard_layouts/common.dart';
import 'package:gen_web_keyboard_layouts/github.dart';
import 'package:gen_web_keyboard_layouts/layout_types.dart';
import 'package:gen_web_keyboard_keymap/benchmark_planner.dart';
import 'package:gen_web_keyboard_keymap/common.dart';
import 'package:gen_web_keyboard_keymap/github.dart';
import 'package:gen_web_keyboard_keymap/layout_types.dart';
import 'package:path/path.dart' as path;
const String kEnvGithubToken = 'GITHUB_TOKEN';

View File

@@ -5,7 +5,7 @@
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
//
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_layouts based on
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_keymap based on
// @@@COMMIT_URL@@@
//
// Edit the following files instead:
@@ -13,7 +13,7 @@
// - Script: lib/main.dart
// - Templates: data/*.tmpl
//
// See flutter/engine:flutter/tools/gen_web_keyboard_layouts/README.md for more information.
// See flutter/engine:flutter/tools/gen_web_locale_keymap/README.md for more information.
@@@COMMON@@@
/// Data for [LocaleKeymap] on Windows.

View File

@@ -5,7 +5,7 @@
// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
//
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_layouts based on
// This file is auto generated by flutter/engine:flutter/tools/gen_web_keyboard_keymap based on
// https://github.com/microsoft/vscode/tree/@@@COMMIT_ID@@@/src/vs/workbench/services/keybinding/browser/keyboardLayouts
//
// Edit the following files instead:
@@ -13,7 +13,7 @@
// - Script: lib/main.dart
// - Templates: data/*.tmpl
//
// See flutter/engine:flutter/tools/gen_web_keyboard_layouts/README.md for more information.
// See flutter/engine:flutter/tools/gen_web_keyboard_keymap/README.md for more information.
import 'package:test/test.dart';
import 'package:web_locale_keymap/web_locale_keymap.dart';

View File

@@ -159,22 +159,20 @@ class _StringStream {
Map<String, int> _unmarshallCodeMap(_StringStream stream) {
final int entryNum = stream.readIntAsVerbatim();
return Map<String, int>.fromEntries((() sync* {
for (int entryIndex = 0; entryIndex < entryNum; entryIndex += 1) {
yield MapEntry<String, int>(stream.readEventKey(), stream.readIntAsChar());
}
})());
return <String, int>{
for (int i = 0; i < entryNum; i++)
stream.readEventKey(): stream.readIntAsChar(),
};
}
/// Decode a key mapping data out of the string.
Map<String, Map<String, int>> unmarshallMappingData(String compressed) {
final _StringStream stream = _StringStream(compressed);
final int eventCodeNum = stream.readIntAsVerbatim();
return Map<String, Map<String, int>>.fromEntries((() sync* {
for (int eventCodeIndex = 0; eventCodeIndex < eventCodeNum; eventCodeIndex += 1) {
yield MapEntry<String, Map<String, int>>(stream.readEventCode(), _unmarshallCodeMap(stream));
}
})());
return <String, Map<String, int>>{
for (int i = 0; i < eventCodeNum; i++)
stream.readEventCode() : _unmarshallCodeMap(stream),
};
}
/*@@@ SHARED SEGMENT END @@@*/

View File

@@ -1,4 +1,4 @@
name: gen_web_keyboard_layouts
name: gen_web_keyboard_keymap
description: Generates keyboard layouts for Web from external sources.
environment: