Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Nov 30, 2021

  • Move all code accessing JavaScript API via JS-interop libraries into two libraries:
    • canvaskit_api.dart - interop with CanvasKit API
    • safe_browser_api.dart - interop with browser APIs that can't be accessed normally via dart:html, dart:svg, or dart:webgl.
  • Add js_access_test.dart that:
    • Enforces all JS-interop code to go only into the libraries above
    • Enforces that engine.dart is exclusively an import/export library (there's no functional code in it)

@google-cla google-cla bot added the cla: yes label Nov 30, 2021
@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Nov 30, 2021
@yjbanov yjbanov changed the title Js interop consolidation [web] consolidate JS interop code Nov 30, 2021
@yjbanov yjbanov force-pushed the js-interop-consolidation branch from 9215e41 to 2a1efdb Compare December 1, 2021 22:44
@yjbanov yjbanov requested a review from mdebbar December 1, 2021 22:50
// added by this script during the rewrite.
void _validateEngineSource(String engineDartPath, String engineDartCode) {
const List<String> expectedLines = <String>[
'library engine;',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was bitten before by having a different number of spaces. That's why I added \s+ to many regexes above. Maybe turn this into a list of regexes?

Another issue that I can think of is this line could have a trailing comment in the source code:

library engine; // some comment here.

Could also be fixed if we use a list of regexes.

If you think this is overkill now, you can just leave it as is. We can always fix it in the future if it becomes a problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing for this particular line it probably doesn't matter. But I agree, for code that's more malleable that could be annoying.

Comment on lines +38 to +51
@JS()
library dart._engine;
import 'dart:async';
import 'dart:collection';
import 'dart:convert' hide Codec;
import 'dart:developer' as developer;
import 'dart:html' as html;
import 'dart:js' as js;
import 'dart:js_util' as js_util;
import 'dart:_js_annotations';
import 'dart:math' as math;
import 'dart:svg' as svg;
import 'dart:typed_data';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, this change is expected fail sdk_rewriter_test.dart. So the tests need to be updated as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@yjbanov yjbanov force-pushed the js-interop-consolidation branch from d37e94f to 94d137e Compare December 3, 2021 22:41
@yjbanov yjbanov merged commit a104af8 into flutter:main Dec 3, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 4, 2021
flar added a commit that referenced this pull request Dec 5, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 5, 2021
flar added a commit that referenced this pull request Dec 5, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 5, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Dec 5, 2021
yjbanov added a commit to yjbanov/engine that referenced this pull request Dec 6, 2021
The original flutter#30007 was reverted
because it broke the framework. Turns out the framework still used the
WebExperiments code, which has been cleaned up in flutter/flutter#94739.

This PR must land after flutter/flutter#94739.

This reverts commit bd3a394.
yjbanov added a commit that referenced this pull request Dec 7, 2021
The original #30007 was reverted
because it broke the framework. Turns out the framework still used the
WebExperiments code, which has been cleaned up in flutter/flutter#94739.

This PR must land after flutter/flutter#94739.

This reverts commit bd3a394.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants