Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions ci/licenses_golden/licenses_flutter
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/key_map.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/keyboard.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/keyboard_binding.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/mouse_cursor.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/navigation.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/navigation/history.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/navigation/js_url_strategy.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/navigation/url_strategy.dart
Expand All @@ -542,6 +543,7 @@ FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/semantics.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/semantics_helper.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/tappable.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/semantics/text_field.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/services.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/services/buffers.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/services/message_codec.dart
FILE: ../../../flutter/lib/web_ui/lib/src/engine/services/message_codecs.dart
Expand Down
90 changes: 71 additions & 19 deletions lib/web_ui/lib/src/engine.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,19 @@
@JS()
library engine;

// This file is transformed during the build process in order to make it a
// single library. Some notable transformations:
//
// 1. Imports of engine/* files are stripped out.
// 2. Exports of engine/* files are replaced with a part directive.
//
// The code that performs the transformations lives in:
// - https://github.com/flutter/engine/blob/master/web_sdk/sdk_rewriter.dart

import 'dart:async';
import 'dart:collection'
// Some of these names are used in services/buffers.dart for example.
// ignore: unused_shown_name
show ListBase, IterableBase, DoubleLinkedQueue, DoubleLinkedQueueEntry;
import 'dart:convert' hide Codec;
import 'dart:developer' as developer;
Expand All @@ -21,10 +32,68 @@ import 'package:meta/meta.dart';

import '../ui.dart' as ui;

part 'engine/alarm_clock.dart';
import 'engine/alarm_clock.dart';
Copy link
Contributor

Choose a reason for hiding this comment

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

We should leave a comment that explains how this file is pre-processed and point to the sdk_rewriter.dart

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally!

export 'engine/alarm_clock.dart';

import 'engine/browser_detection.dart';
export 'engine/browser_detection.dart';

import 'engine/mouse_cursor.dart';
export 'engine/mouse_cursor.dart';

import 'engine/navigation/history.dart';
export 'engine/navigation/history.dart';

import 'engine/navigation/js_url_strategy.dart';
export 'engine/navigation/js_url_strategy.dart';

import 'engine/navigation/url_strategy.dart';
export 'engine/navigation/url_strategy.dart';
Comment on lines +44 to +51
Copy link
Member

@ditman ditman Apr 13, 2021

Choose a reason for hiding this comment

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

Something that might make this files slightly more compact (but still maintaining modularity), is to make a engine/navigation/navigation.dart that exports everything it needs to export from within the navigation "sub-package".

That way, in this more global package, you just need to do: export engine/navigation/navigation.dart.

If you prefer to have more control, you can then show only what's really part of the public API of the engine, vs what navigation was available to engine programmers.

We've done this here, for example:

And then, from the google maps, only reexport (via a show) what we explicitly want end users to see from the package above:

(Note that the last link still has two part'ed files, because there's a cross-dependency between them! :P)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense! I'll do this.


import 'engine/plugins.dart';
export 'engine/plugins.dart';

import 'engine/pointer_binding.dart';
export 'engine/pointer_binding.dart';

// This import is intentionally commented out because the analyzer says it's unused.
// import 'engine/pointer_converter.dart';
export 'engine/pointer_converter.dart';

// This import is intentionally commented out because the analyzer says it's unused.
// import 'engine/services/buffers.dart';
export 'engine/services/buffers.dart';

import 'engine/services/message_codec.dart';
export 'engine/services/message_codec.dart';

import 'engine/services/message_codecs.dart';
export 'engine/services/message_codecs.dart';

// This import is intentionally commented out because the analyzer says it's unused.
// import 'engine/services/serialization.dart';
export 'engine/services/serialization.dart';

import 'engine/shadow.dart';
export 'engine/shadow.dart';

import 'engine/test_embedding.dart';
export 'engine/test_embedding.dart';

import 'engine/ulps.dart';
export 'engine/ulps.dart';

import 'engine/validators.dart';
export 'engine/validators.dart';

import 'engine/vector_math.dart';
export 'engine/vector_math.dart';

import 'engine/web_experiments.dart';
export 'engine/web_experiments.dart';

part 'engine/assets.dart';
part 'engine/bitmap_canvas.dart';
part 'engine/browser_detection.dart';
part 'engine/canvaskit/canvas.dart';
part 'engine/canvaskit/canvaskit_canvas.dart';
part 'engine/canvaskit/canvaskit_api.dart';
Expand Down Expand Up @@ -63,9 +132,6 @@ part 'engine/dom_canvas.dart';
part 'engine/dom_renderer.dart';
part 'engine/engine_canvas.dart';
part 'engine/frame_reference.dart';
part 'engine/navigation/history.dart';
part 'engine/navigation/js_url_strategy.dart';
part 'engine/navigation/url_strategy.dart';
part 'engine/html/backdrop_filter.dart';
part 'engine/html/canvas.dart';
part 'engine/html/clip.dart';
Expand Down Expand Up @@ -101,14 +167,10 @@ part 'engine/html_image_codec.dart';
part 'engine/keyboard_binding.dart';
part 'engine/keyboard.dart';
part 'engine/key_map.dart';
part 'engine/mouse_cursor.dart';
part 'engine/onscreen_logging.dart';
part 'engine/picture.dart';
part 'engine/platform_dispatcher.dart';
part 'engine/platform_views.dart';
part 'engine/plugins.dart';
part 'engine/pointer_binding.dart';
part 'engine/pointer_converter.dart';
part 'engine/profiler.dart';
part 'engine/rrect_renderer.dart';
part 'engine/semantics/accessibility.dart';
Expand All @@ -122,12 +184,6 @@ part 'engine/semantics/semantics.dart';
part 'engine/semantics/semantics_helper.dart';
part 'engine/semantics/tappable.dart';
part 'engine/semantics/text_field.dart';
part 'engine/services/buffers.dart';
part 'engine/services/message_codec.dart';
part 'engine/services/message_codecs.dart';
part 'engine/services/serialization.dart';
part 'engine/shadow.dart';
part 'engine/test_embedding.dart';
part 'engine/text/font_collection.dart';
part 'engine/text/layout_service.dart';
part 'engine/text/line_break_properties.dart';
Expand All @@ -144,11 +200,7 @@ part 'engine/text_editing/autofill_hint.dart';
part 'engine/text_editing/input_type.dart';
part 'engine/text_editing/text_capitalization.dart';
part 'engine/text_editing/text_editing.dart';
part 'engine/ulps.dart';
part 'engine/util.dart';
part 'engine/validators.dart';
part 'engine/vector_math.dart';
part 'engine/web_experiments.dart';
part 'engine/window.dart';

// The mode the app is running in.
Expand Down
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/alarm_clock.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:async';

import 'package:ui/ui.dart' as ui;

/// A function that returns current system time.
typedef TimestampFunction = DateTime Function();
Expand Down
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/browser_detection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:html' as html;

import 'package:meta/meta.dart';

/// The HTML engine used by the current browser.
enum BrowserEngine {
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/mouse_cursor.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'package:ui/src/engine.dart' show domRenderer, DomRenderer;

/// Provides mouse cursor bindings, such as the `flutter/mousecursor` channel.
class MouseCursor {
Expand Down
8 changes: 8 additions & 0 deletions lib/web_ui/lib/src/engine/navigation.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.12
export 'navigation/history.dart';
export 'navigation/js_url_strategy.dart';
export 'navigation/url_strategy.dart';
9 changes: 8 additions & 1 deletion lib/web_ui/lib/src/engine/navigation/history.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:html' as html;

import 'package:ui/src/engine.dart' show EnginePlatformDispatcher;
import 'package:ui/ui.dart' as ui;

import '../services/message_codec.dart';
import '../services/message_codecs.dart';
import 'url_strategy.dart';

/// An abstract class that provides the API for [EngineWindow] to delegate its
/// navigating events.
Expand Down
8 changes: 7 additions & 1 deletion lib/web_ui/lib/src/engine/navigation/js_url_strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
@JS()
library js_url_strategy;

import 'dart:html' as html;

import 'package:js/js.dart';
import 'package:ui/ui.dart' as ui;

typedef _PathGetter = String Function();

Expand Down
7 changes: 6 additions & 1 deletion lib/web_ui/lib/src/engine/navigation/url_strategy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:async';
import 'dart:html' as html;

import 'package:ui/ui.dart' as ui;

import 'js_url_strategy.dart';

/// Represents and reads route state from the browser's URL.
///
Expand Down
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/plugins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:typed_data';

import 'package:ui/ui.dart' as ui;

Future<void> Function(String, ByteData?, ui.PlatformMessageResponseCallback?)? pluginMessageCallHandler;
11 changes: 10 additions & 1 deletion lib/web_ui/lib/src/engine/pointer_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,16 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:html' as html;
import 'dart:js' as js;
import 'dart:js_util' as js_util;
import 'dart:math' as math;

import 'package:meta/meta.dart';
import 'package:ui/src/engine.dart';
import 'package:ui/ui.dart' as ui;

import 'pointer_converter.dart';

/// Set this flag to true to see all the fired events in the console.
const bool _debugLogPointerEvents = false;
Expand Down
2 changes: 1 addition & 1 deletion lib/web_ui/lib/src/engine/pointer_converter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'package:ui/ui.dart' as ui;

const bool _debugLogPointerConverter = false;

Expand Down
9 changes: 9 additions & 0 deletions lib/web_ui/lib/src/engine/services.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// @dart = 2.12
export 'services/buffers.dart';
export 'services/message_codec.dart';
export 'services/message_codecs.dart';
export 'services/serialization.dart';
3 changes: 2 additions & 1 deletion lib/web_ui/lib/src/engine/services/buffers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:collection';
import 'dart:typed_data';

abstract class _TypedDataBuffer<E> extends ListBase<E> {
static const int _initialLength = 8;
Expand Down
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/services/message_codec.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:typed_data';

import 'package:meta/meta.dart';

/// A message encoding/decoding mechanism.
///
Expand Down
6 changes: 5 additions & 1 deletion lib/web_ui/lib/src/engine/services/message_codecs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:convert';
import 'dart:typed_data';

import 'message_codec.dart';
import 'serialization.dart';

/// [MessageCodec] with unencoded binary messages represented using [ByteData].
///
Expand Down
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/services/serialization.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:typed_data';

import 'buffers.dart';

/// Write-only buffer for incrementally building a [ByteData] instance.
///
Expand Down
6 changes: 5 additions & 1 deletion lib/web_ui/lib/src/engine/shadow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:html' as html;
import 'dart:math' as math;

import 'package:meta/meta.dart';
import 'package:ui/ui.dart' as ui;

/// How far is the light source from the surface of the UI.
///
Expand Down
7 changes: 6 additions & 1 deletion lib/web_ui/lib/src/engine/test_embedding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:async';
import 'dart:html' as html;

import 'package:ui/ui.dart' as ui;

import 'navigation/url_strategy.dart';

const bool _debugLogHistoryActions = false;

Expand Down
3 changes: 2 additions & 1 deletion lib/web_ui/lib/src/engine/ulps.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:math' as math;
import 'dart:typed_data';

// This is a small library to handle stability for floating point operations.
//
Expand Down
4 changes: 3 additions & 1 deletion lib/web_ui/lib/src/engine/validators.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:typed_data';

import 'package:ui/ui.dart' as ui;

bool rectIsValid(ui.Rect rect) {
assert(rect != null, 'Rect argument was null.'); // ignore: unnecessary_null_comparison
Expand Down
5 changes: 4 additions & 1 deletion lib/web_ui/lib/src/engine/vector_math.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

part of engine;
import 'dart:math' as math;
import 'dart:typed_data';

import 'package:ui/src/engine.dart' show assertionsEnabled;

class Matrix4 {
final Float32List _m4storage;
Expand Down
Loading