Skip to content

Commit

Permalink
[dartpad_ui] Use the new cross origin window support for pkg:web (#3068)
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough authored Oct 1, 2024
1 parent 1878439 commit 26580f5
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 38 deletions.
2 changes: 1 addition & 1 deletion pkgs/dartpad_ui/lib/embed.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'model.dart';
/// Listen to frame messages if embedded as an iFrame
/// to accept injected snippets.
void handleEmbedMessage(AppServices services, {bool runOnInject = false}) {
final parent = web.window.parent;
final parent = web.window.parentCrossOrigin;
if (parent == null) return;

web.window.addEventListener(
Expand Down
13 changes: 7 additions & 6 deletions pkgs/dartpad_ui/lib/execution/frame.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import 'dart:js_interop';
import 'package:web/web.dart' as web;

import '../model.dart';
import 'frame_utils.dart';

class ExecutionServiceImpl implements ExecutionService {
final StreamController<String> _stdoutController =
Expand Down Expand Up @@ -134,12 +133,14 @@ require(["dartpad_main", "dart_sdk"], function(dartpad_main, dart_sdk) {
}

Future<void> _send(String command, Map<String, Object?> params) {
final message = {
'command': command,
...params,
}.jsify();
// TODO: Use dartpad.dev instead of '*'?
_frame.safelyPostMessage(message, '*');
_frame.contentWindowCrossOrigin?.postMessage(
{
'command': command,
...params,
}.jsify(),
'*'.toJS,
);
return Future.value();
}

Expand Down
30 changes: 0 additions & 30 deletions pkgs/dartpad_ui/lib/execution/frame_utils.dart

This file was deleted.

2 changes: 1 addition & 1 deletion pkgs/dartpad_ui/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ dependencies:
split_view: ^3.2.1
url_launcher: ^6.3.0
vtable: ^0.4.0
web: ^1.0.0
web: ^1.1.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 26580f5

Please sign in to comment.