File size: 1,492 Bytes
6c71972
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2e813e6
6c71972
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/// Stub implementation for dart:html when not on web platform
/// This file is imported when dart.library.html is not available

class Window {
  final Document document = Document();
  final History history = History();
  final Location location = Location();
  final Storage localStorage = Storage();
  
  Stream<dynamic> get onBeforeUnload => 
      Stream.fromIterable([]).asBroadcastStream();
}

class Storage {
  final Map<String, String> _storage = {};
  
  String? operator [](String key) => _storage[key];
  
  void operator []=(String key, String value) {
    _storage[key] = value;
  }
  
  void clear() {
    _storage.clear();
  }
  
  void removeItem(String key) {
    _storage.remove(key);
  }
  
  String? getItem(String key) => _storage[key];
  
  void setItem(String key, String value) {
    _storage[key] = value;
  }
  
  int get length => _storage.length;
  
  String key(int index) {
    if (index < 0 || index >= _storage.length) return '';
    return _storage.keys.elementAt(index);
  }
}

class Document {
  String get visibilityState => 'visible';
  
  Stream<dynamic> get onVisibilityChange => 
      Stream.fromIterable([]).asBroadcastStream();
}

class History {
  void pushState(dynamic data, String title, String url) {}
}

class Location {
  String get href => '';
  String get host => '';
  String get hostname => '';
  String get protocol => '';
  String get search => '';
  String get pathname => '';
}

// Exported instances
final Window window = Window();