OLD | NEW |
1 dart_library.library('dart/js', null, /* Imports */[ | 1 dart_library.library('dart/js', null, /* Imports */[ |
2 "dart_runtime/dart", | 2 "dart_runtime/dart", |
3 'dart/core', | 3 'dart/core', |
4 'dart/collection', | 4 'dart/collection', |
5 'dart/_js_helper' | 5 'dart/_js_helper' |
6 ], /* Lazy imports */[ | 6 ], /* Lazy imports */[ |
7 ], function(exports, dart, core, collection, _js_helper) { | 7 ], function(exports, dart, core, collection, _js_helper) { |
8 'use strict'; | 8 'use strict'; |
9 let dartx = dart.dartx; | 9 let dartx = dart.dartx; |
10 dart.defineLazyProperties(exports, { | 10 dart.defineLazyProperties(exports, { |
11 get context() { | 11 get context() { |
12 return dart.as(_wrapToDart(dart.global), JsObject); | 12 return dart.as(dart.dcall(_wrapToDart, dart.global), JsObject); |
13 } | 13 } |
14 }); | 14 }); |
15 let _jsObject = Symbol('_jsObject'); | 15 let _jsObject = Symbol('_jsObject'); |
16 class JsObject extends core.Object { | 16 class JsObject extends core.Object { |
17 _fromJs(jsObject) { | 17 _fromJs(jsObject) { |
18 this[_jsObject] = jsObject; | 18 this[_jsObject] = jsObject; |
19 dart.assert(this[_jsObject] != null); | 19 dart.assert(this[_jsObject] != null); |
20 } | 20 } |
21 static new(constructor, arguments$) { | 21 static new(constructor, arguments$) { |
22 if (arguments$ === void 0) | 22 if (arguments$ === void 0) |
23 arguments$ = null; | 23 arguments$ = null; |
24 let ctor = constructor[_jsObject]; | 24 let ctor = constructor[_jsObject]; |
25 if (arguments$ == null) { | 25 if (arguments$ == null) { |
26 return dart.as(_wrapToDart(new ctor()), JsObject); | 26 return dart.as(dart.dcall(_wrapToDart, new ctor()), JsObject); |
27 } | 27 } |
28 return dart.as(_wrapToDart(new ctor(...arguments$)), JsObject); | 28 return dart.as(dart.dcall(_wrapToDart, new ctor(...arguments$)), JsObject)
; |
29 } | 29 } |
30 static fromBrowserObject(object) { | 30 static fromBrowserObject(object) { |
31 if (dart.is(object, core.num) || typeof object == 'string' || typeof objec
t == 'boolean' || object == null) { | 31 if (dart.is(object, core.num) || typeof object == 'string' || typeof objec
t == 'boolean' || object == null) { |
32 dart.throw(new core.ArgumentError("object cannot be a num, string, bool,
or null")); | 32 dart.throw(new core.ArgumentError("object cannot be a num, string, bool,
or null")); |
33 } | 33 } |
34 return dart.as(_wrapToDart(_convertToJS(object)), JsObject); | 34 return dart.as(dart.dcall(_wrapToDart, dart.dcall(_convertToJS, object)),
JsObject); |
35 } | 35 } |
36 static jsify(object) { | 36 static jsify(object) { |
37 if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) { | 37 if (!dart.is(object, core.Map) && !dart.is(object, core.Iterable)) { |
38 dart.throw(new core.ArgumentError("object must be a Map or Iterable")); | 38 dart.throw(new core.ArgumentError("object must be a Map or Iterable")); |
39 } | 39 } |
40 return dart.as(_wrapToDart(JsObject._convertDataTree(object)), JsObject); | 40 return dart.as(dart.dcall(_wrapToDart, dart.dcall(JsObject._convertDataTre
e, object)), JsObject); |
41 } | 41 } |
42 static _convertDataTree(data) { | 42 static _convertDataTree(data) { |
43 let _convertedObjects = collection.HashMap.identity(); | 43 let _convertedObjects = collection.HashMap.identity(); |
44 function _convert(o) { | 44 function _convert(o) { |
45 if (dart.notNull(_convertedObjects.containsKey(o))) { | 45 if (dart.notNull(dart.as(dart.dsend(_convertedObjects, 'containsKey', o)
, core.bool))) { |
46 return _convertedObjects.get(o); | 46 return dart.dindex(_convertedObjects, o); |
47 } | 47 } |
48 if (dart.is(o, core.Map)) { | 48 if (dart.is(o, core.Map)) { |
49 let convertedMap = {}; | 49 let convertedMap = {}; |
50 _convertedObjects.set(o, convertedMap); | 50 dart.dsetindex(_convertedObjects, o, convertedMap); |
51 for (let key of dart.as(dart.dload(o, 'keys'), core.Iterable)) { | 51 for (let key of dart.as(dart.dload(o, 'keys'), core.Iterable)) { |
52 convertedMap[key] = _convert(dart.dindex(o, key)); | 52 convertedMap[key] = dart.dcall(_convert, dart.dindex(o, key)); |
53 } | 53 } |
54 return convertedMap; | 54 return convertedMap; |
55 } else if (dart.is(o, core.Iterable)) { | 55 } else if (dart.is(o, core.Iterable)) { |
56 let convertedList = []; | 56 let convertedList = []; |
57 _convertedObjects.set(o, convertedList); | 57 dart.dsetindex(_convertedObjects, o, convertedList); |
58 convertedList[dartx.addAll](dart.as(dart.dsend(o, 'map', _convert), co
re.Iterable)); | 58 dart.dsend(convertedList, 'addAll', dart.dsend(o, 'map', _convert)); |
59 return convertedList; | 59 return convertedList; |
60 } else { | 60 } else { |
61 return _convertToJS(o); | 61 return dart.dcall(_convertToJS, o); |
62 } | 62 } |
63 } | 63 } |
64 dart.fn(_convert); | 64 dart.fn(_convert); |
65 return _convert(data); | 65 return dart.dcall(_convert, data); |
66 } | 66 } |
67 get(property) { | 67 get(property) { |
68 if (!(typeof property == 'string') && !dart.is(property, core.num)) { | 68 if (!(typeof property == 'string') && !dart.is(property, core.num)) { |
69 dart.throw(new core.ArgumentError("property is not a String or num")); | 69 dart.throw(new core.ArgumentError("property is not a String or num")); |
70 } | 70 } |
71 return _convertToDart(this[_jsObject][property]); | 71 return dart.dcall(_convertToDart, this[_jsObject][property]); |
72 } | 72 } |
73 set(property, value) { | 73 set(property, value) { |
74 if (!(typeof property == 'string') && !dart.is(property, core.num)) { | 74 if (!(typeof property == 'string') && !dart.is(property, core.num)) { |
75 dart.throw(new core.ArgumentError("property is not a String or num")); | 75 dart.throw(new core.ArgumentError("property is not a String or num")); |
76 } | 76 } |
77 this[_jsObject][property] = _convertToJS(value); | 77 this[_jsObject][property] = dart.dcall(_convertToJS, value); |
78 return value; | 78 return value; |
79 } | 79 } |
80 get hashCode() { | 80 get hashCode() { |
81 return 0; | 81 return 0; |
82 } | 82 } |
83 ['=='](other) { | 83 ['=='](other) { |
84 return dart.is(other, JsObject) && this[_jsObject] === dart.dload(other, _
jsObject); | 84 return dart.is(other, JsObject) && dart.notNull(dart.as(this[_jsObject] ==
= dart.dload(other, _jsObject), core.bool)); |
85 } | 85 } |
86 hasProperty(property) { | 86 hasProperty(property) { |
87 if (!(typeof property == 'string') && !dart.is(property, core.num)) { | 87 if (!(typeof property == 'string') && !dart.is(property, core.num)) { |
88 dart.throw(new core.ArgumentError("property is not a String or num")); | 88 dart.throw(new core.ArgumentError("property is not a String or num")); |
89 } | 89 } |
90 return property in this[_jsObject]; | 90 return dart.as(property in this[_jsObject], core.bool); |
91 } | 91 } |
92 deleteProperty(property) { | 92 deleteProperty(property) { |
93 if (!(typeof property == 'string') && !dart.is(property, core.num)) { | 93 if (!(typeof property == 'string') && !dart.is(property, core.num)) { |
94 dart.throw(new core.ArgumentError("property is not a String or num")); | 94 dart.throw(new core.ArgumentError("property is not a String or num")); |
95 } | 95 } |
96 delete this[_jsObject][property]; | 96 delete this[_jsObject][property]; |
97 } | 97 } |
98 instanceof(type) { | 98 instanceof(type) { |
99 return this[_jsObject] instanceof _convertToJS(type); | 99 return dart.as(this[_jsObject] instanceof dart.dcall(_convertToJS, type),
core.bool); |
100 } | 100 } |
101 toString() { | 101 toString() { |
102 try { | 102 try { |
103 return String(this[_jsObject]); | 103 return dart.as(String(this[_jsObject]), core.String); |
104 } catch (e) { | 104 } catch (e) { |
105 return super.toString(); | 105 return dart.dcall(super.toString); |
106 } | 106 } |
107 | 107 |
108 } | 108 } |
109 callMethod(method, args) { | 109 callMethod(method, args) { |
110 if (args === void 0) | 110 if (args === void 0) |
111 args = null; | 111 args = null; |
112 if (!(typeof method == 'string') && !dart.is(method, core.num)) { | 112 if (!(typeof method == 'string') && !dart.is(method, core.num)) { |
113 dart.throw(new core.ArgumentError("method is not a String or num")); | 113 dart.throw(new core.ArgumentError("method is not a String or num")); |
114 } | 114 } |
115 if (args != null) | 115 if (args != null) |
116 args = core.List.from(args[dartx.map](_convertToJS)); | 116 args = core.List.from(dart.dcall(args[dartx.map], _convertToJS)); |
117 let fn = this[_jsObject][method]; | 117 let fn = this[_jsObject][method]; |
118 if (!(fn instanceof Function)) { | 118 if (!dart.notNull(dart.as(fn instanceof Function, core.bool))) { |
119 dart.throw(new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(d
art.as(method, core.String)), args, dart.map())); | 119 dart.throw(new core.NoSuchMethodError(this[_jsObject], core.Symbol.new(d
art.as(method, core.String)), args, dart.map())); |
120 } | 120 } |
121 return _convertToDart(fn.apply(this[_jsObject], args)); | 121 return dart.dcall(_convertToDart, fn.apply(this[_jsObject], args)); |
122 } | 122 } |
123 } | 123 } |
124 dart.defineNamedConstructor(JsObject, '_fromJs'); | 124 dart.defineNamedConstructor(JsObject, '_fromJs'); |
125 dart.setSignature(JsObject, { | 125 dart.setSignature(JsObject, { |
126 constructors: () => ({ | 126 constructors: () => ({ |
127 _fromJs: [JsObject, [dart.dynamic]], | 127 _fromJs: [JsObject, [dart.dynamic]], |
128 new: [JsObject, [JsFunction], [core.List]], | 128 new: [JsObject, [JsFunction], [core.List]], |
129 fromBrowserObject: [JsObject, [dart.dynamic]], | 129 fromBrowserObject: [JsObject, [dart.dynamic]], |
130 jsify: [JsObject, [dart.dynamic]] | 130 jsify: [JsObject, [dart.dynamic]] |
131 }), | 131 }), |
(...skipping 16 matching lines...) Expand all Loading... |
148 args.push(_convertToDart(arg)); | 148 args.push(_convertToDart(arg)); |
149 } | 149 } |
150 return _convertToJS(f(...args)); | 150 return _convertToJS(f(...args)); |
151 }); | 151 }); |
152 } | 152 } |
153 _fromJs(jsObject) { | 153 _fromJs(jsObject) { |
154 super._fromJs(jsObject); | 154 super._fromJs(jsObject); |
155 } | 155 } |
156 apply(args, opts) { | 156 apply(args, opts) { |
157 let thisArg = opts && 'thisArg' in opts ? opts.thisArg : null; | 157 let thisArg = opts && 'thisArg' in opts ? opts.thisArg : null; |
158 return _convertToDart(this[_jsObject].apply(_convertToJS(thisArg), args ==
null ? null : core.List.from(args[dartx.map](_convertToJS)))); | 158 return dart.dcall(_convertToDart, this[_jsObject].apply(dart.dcall(_conver
tToJS, thisArg), args == null ? null : core.List.from(dart.dcall(args[dartx.map]
, _convertToJS)))); |
159 } | 159 } |
160 } | 160 } |
161 dart.defineNamedConstructor(JsFunction, '_fromJs'); | 161 dart.defineNamedConstructor(JsFunction, '_fromJs'); |
162 dart.setSignature(JsFunction, { | 162 dart.setSignature(JsFunction, { |
163 constructors: () => ({ | 163 constructors: () => ({ |
164 withThis: [JsFunction, [core.Function]], | 164 withThis: [JsFunction, [core.Function]], |
165 _fromJs: [JsFunction, [dart.dynamic]] | 165 _fromJs: [JsFunction, [dart.dynamic]] |
166 }), | 166 }), |
167 methods: () => ({apply: [dart.dynamic, [core.List], {thisArg: dart.dynamic}]
}) | 167 methods: () => ({apply: [dart.dynamic, [core.List], {thisArg: dart.dynamic}]
}) |
168 }); | 168 }); |
169 let _checkIndex = Symbol('_checkIndex'); | 169 let _checkIndex = Symbol('_checkIndex'); |
170 let _checkInsertIndex = Symbol('_checkInsertIndex'); | 170 let _checkInsertIndex = Symbol('_checkInsertIndex'); |
171 let JsArray$ = dart.generic(function(E) { | 171 let JsArray$ = dart.generic(function(E) { |
172 class JsArray extends dart.mixin(JsObject, collection.ListMixin$(E)) { | 172 class JsArray extends dart.mixin(JsObject, collection.ListMixin$(E)) { |
173 JsArray() { | 173 JsArray() { |
174 super._fromJs([]); | 174 super._fromJs([]); |
175 } | 175 } |
176 from(other) { | 176 from(other) { |
177 super._fromJs((() => { | 177 super._fromJs((() => { |
178 let _ = []; | 178 let _ = []; |
179 _[dartx.addAll](other[dartx.map](dart.as(_convertToJS, __CastType0))); | 179 dart.dcall(_[dartx.addAll], dart.dcall(other[dartx.map], _convertToJS)
); |
180 return _; | 180 return _; |
181 })()); | 181 })()); |
182 } | 182 } |
183 _fromJs(jsObject) { | 183 _fromJs(jsObject) { |
184 super._fromJs(jsObject); | 184 super._fromJs(jsObject); |
185 } | 185 } |
186 [_checkIndex](index) { | 186 [_checkIndex](index) { |
187 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull
(index) >= dart.notNull(this.length))) { | 187 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull
(index) >= dart.notNull(this.length))) { |
188 dart.throw(new core.RangeError.range(index, 0, this.length)); | 188 dart.throw(new core.RangeError.range(index, 0, this.length)); |
189 } | 189 } |
190 } | 190 } |
191 [_checkInsertIndex](index) { | 191 [_checkInsertIndex](index) { |
192 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull
(index) >= dart.notNull(this.length) + 1)) { | 192 if (typeof index == 'number' && (dart.notNull(index) < 0 || dart.notNull
(index) >= dart.notNull(this.length) + 1)) { |
193 dart.throw(new core.RangeError.range(index, 0, this.length)); | 193 dart.throw(new core.RangeError.range(index, 0, this.length)); |
194 } | 194 } |
195 } | 195 } |
196 static _checkRange(start, end, length) { | 196 static _checkRange(start, end, length) { |
197 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(length
)) { | 197 if (dart.notNull(start) < 0 || dart.notNull(start) > dart.notNull(length
)) { |
198 dart.throw(new core.RangeError.range(start, 0, length)); | 198 dart.throw(new core.RangeError.range(start, 0, length)); |
199 } | 199 } |
200 if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart.
notNull(length)) { | 200 if (dart.notNull(end) < dart.notNull(start) || dart.notNull(end) > dart.
notNull(length)) { |
201 dart.throw(new core.RangeError.range(end, start, length)); | 201 dart.throw(new core.RangeError.range(end, start, length)); |
202 } | 202 } |
203 } | 203 } |
204 get(index) { | 204 get(index) { |
205 if (dart.is(index, core.num) && index == index[dartx.toInt]()) { | 205 if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'to
Int'))) { |
206 this[_checkIndex](index); | 206 dart.dcall(this[_checkIndex], index); |
207 } | 207 } |
208 return dart.as(super.get(index), E); | 208 return dart.as(super.get(index), E); |
209 } | 209 } |
210 set(index, value) { | 210 set(index, value) { |
211 dart.as(value, E); | 211 dart.as(value, E); |
212 if (dart.is(index, core.num) && index == index[dartx.toInt]()) { | 212 if (dart.is(index, core.num) && dart.equals(index, dart.dsend(index, 'to
Int'))) { |
213 this[_checkIndex](index); | 213 dart.dcall(this[_checkIndex], index); |
214 } | 214 } |
215 super.set(index, value); | 215 super.set(index, value); |
216 return value; | 216 return value; |
217 } | 217 } |
218 get length() { | 218 get length() { |
219 let len = this[_jsObject].length; | 219 let len = this[_jsObject].length; |
220 if (typeof len === "number" && len >>> 0 === len) { | 220 if (dart.notNull(dart.as(typeof len === "number" && len >>> 0 === len, c
ore.bool))) { |
221 return len; | 221 return dart.as(len, core.int); |
222 } | 222 } |
223 dart.throw(new core.StateError('Bad JsArray length')); | 223 dart.throw(new core.StateError('Bad JsArray length')); |
224 } | 224 } |
225 set length(length) { | 225 set length(length) { |
226 super.set('length', length); | 226 super.set('length', length); |
227 } | 227 } |
228 add(value) { | 228 add(value) { |
229 dart.as(value, E); | 229 dart.as(value, E); |
230 this.callMethod('push', [value]); | 230 dart.dcall(this.callMethod, 'push', [value]); |
231 } | 231 } |
232 addAll(iterable) { | 232 addAll(iterable) { |
233 dart.as(iterable, core.Iterable$(E)); | 233 dart.as(iterable, core.Iterable$(E)); |
234 let list = iterable instanceof Array ? iterable : core.List.from(iterabl
e); | 234 let list = dart.notNull(dart.as(iterable instanceof Array, core.bool)) ?
iterable : core.List.from(iterable); |
235 this.callMethod('push', dart.as(list, core.List)); | 235 dart.dcall(this.callMethod, 'push', list); |
236 } | 236 } |
237 insert(index, element) { | 237 insert(index, element) { |
238 dart.as(element, E); | 238 dart.as(element, E); |
239 this[_checkInsertIndex](index); | 239 dart.dcall(this[_checkInsertIndex], index); |
240 this.callMethod('splice', [index, 0, element]); | 240 dart.dcall(this.callMethod, 'splice', [index, 0, element]); |
241 } | 241 } |
242 removeAt(index) { | 242 removeAt(index) { |
243 this[_checkIndex](index); | 243 dart.dcall(this[_checkIndex], index); |
244 return dart.as(dart.dindex(this.callMethod('splice', [index, 1]), 0), E)
; | 244 return dart.as(dart.dindex(dart.dcall(this.callMethod, 'splice', [index,
1]), 0), E); |
245 } | 245 } |
246 removeLast() { | 246 removeLast() { |
247 if (this.length == 0) | 247 if (this.length == 0) |
248 dart.throw(new core.RangeError(-1)); | 248 dart.throw(new core.RangeError(-1)); |
249 return dart.as(this.callMethod('pop'), E); | 249 return dart.as(dart.dcall(this.callMethod, 'pop'), E); |
250 } | 250 } |
251 removeRange(start, end) { | 251 removeRange(start, end) { |
252 JsArray$()._checkRange(start, end, this.length); | 252 dart.dcall(JsArray$()._checkRange, start, end, this.length); |
253 this.callMethod('splice', [start, dart.notNull(end) - dart.notNull(start
)]); | 253 dart.dcall(this.callMethod, 'splice', [start, dart.notNull(end) - dart.n
otNull(start)]); |
254 } | 254 } |
255 setRange(start, end, iterable, skipCount) { | 255 setRange(start, end, iterable, skipCount) { |
256 dart.as(iterable, core.Iterable$(E)); | 256 dart.as(iterable, core.Iterable$(E)); |
257 if (skipCount === void 0) | 257 if (skipCount === void 0) |
258 skipCount = 0; | 258 skipCount = 0; |
259 JsArray$()._checkRange(start, end, this.length); | 259 dart.dcall(JsArray$()._checkRange, start, end, this.length); |
260 let length = dart.notNull(end) - dart.notNull(start); | 260 let length = dart.notNull(end) - dart.notNull(start); |
261 if (length == 0) | 261 if (length == 0) |
262 return; | 262 return; |
263 if (dart.notNull(skipCount) < 0) | 263 if (dart.notNull(skipCount) < 0) |
264 dart.throw(new core.ArgumentError(skipCount)); | 264 dart.throw(new core.ArgumentError(skipCount)); |
265 let args = [start, length]; | 265 let args = [start, length]; |
266 args[dartx.addAll](iterable[dartx.skip](skipCount)[dartx.take](length)); | 266 dart.dcall(args[dartx.addAll], dart.dcall(dart.dcall(iterable[dartx.skip
], skipCount)[dartx.take], length)); |
267 this.callMethod('splice', args); | 267 dart.dcall(this.callMethod, 'splice', args); |
268 } | 268 } |
269 sort(compare) { | 269 sort(compare) { |
270 if (compare === void 0) | 270 if (compare === void 0) |
271 compare = null; | 271 compare = null; |
272 dart.as(compare, dart.functionType(core.int, [E, E])); | 272 dart.as(compare, dart.functionType(core.int, [E, E])); |
273 this.callMethod('sort', compare == null ? [] : [compare]); | 273 dart.dcall(this.callMethod, 'sort', compare == null ? [] : [compare]); |
274 } | 274 } |
275 } | 275 } |
276 dart.defineNamedConstructor(JsArray, 'from'); | 276 dart.defineNamedConstructor(JsArray, 'from'); |
277 dart.defineNamedConstructor(JsArray, '_fromJs'); | 277 dart.defineNamedConstructor(JsArray, '_fromJs'); |
278 dart.setSignature(JsArray, { | 278 dart.setSignature(JsArray, { |
279 constructors: () => ({ | 279 constructors: () => ({ |
280 JsArray: [JsArray$(E), []], | 280 JsArray: [JsArray$(E), []], |
281 from: [JsArray$(E), [core.Iterable$(E)]], | 281 from: [JsArray$(E), [core.Iterable$(E)]], |
282 _fromJs: [JsArray$(E), [dart.dynamic]] | 282 _fromJs: [JsArray$(E), [dart.dynamic]] |
283 }), | 283 }), |
284 methods: () => ({ | 284 methods: () => ({ |
285 [_checkIndex]: [dart.dynamic, [core.int]], | 285 [_checkIndex]: [dart.dynamic, [core.int]], |
286 [_checkInsertIndex]: [dart.dynamic, [core.int]], | 286 [_checkInsertIndex]: [dart.dynamic, [core.int]], |
287 get: [E, [core.int]], | 287 get: [E, [dart.dynamic]], |
288 set: [dart.void, [core.int, E]], | 288 set: [dart.void, [dart.dynamic, E]], |
289 add: [dart.void, [E]], | 289 add: [dart.void, [E]], |
290 addAll: [dart.void, [core.Iterable$(E)]], | 290 addAll: [dart.void, [core.Iterable$(E)]], |
291 insert: [dart.void, [core.int, E]], | 291 insert: [dart.void, [core.int, E]], |
292 removeAt: [E, [core.int]], | 292 removeAt: [E, [core.int]], |
293 removeLast: [E, []], | 293 removeLast: [E, []], |
294 setRange: [dart.void, [core.int, core.int, core.Iterable$(E)], [core.int
]], | 294 setRange: [dart.void, [core.int, core.int, core.Iterable$(E)], [core.int
]], |
295 sort: [dart.void, [], [dart.functionType(core.int, [E, E])]] | 295 sort: [dart.void, [], [dart.functionType(core.int, [E, E])]] |
296 }), | 296 }), |
297 statics: () => ({_checkRange: [dart.dynamic, [core.int, core.int, core.int
]]}), | 297 statics: () => ({_checkRange: [dart.dynamic, [core.int, core.int, core.int
]]}), |
298 names: ['_checkRange'] | 298 names: ['_checkRange'] |
299 }); | 299 }); |
300 dart.defineExtensionMembers(JsArray, [ | 300 dart.defineExtensionMembers(JsArray, [ |
301 'get', | 301 'get', |
302 'set', | 302 'set', |
303 'add', | 303 'add', |
304 'addAll', | 304 'addAll', |
305 'insert', | 305 'insert', |
306 'removeAt', | 306 'removeAt', |
307 'removeLast', | 307 'removeLast', |
308 'removeRange', | 308 'removeRange', |
309 'setRange', | 309 'setRange', |
310 'sort', | 310 'sort', |
311 'length', | 311 'length', |
312 'length' | 312 'length' |
313 ]); | 313 ]); |
314 return JsArray; | 314 return JsArray; |
315 }); | 315 }); |
316 let JsArray = JsArray$(); | 316 let JsArray = JsArray$(); |
317 function _isBrowserType(o) { | 317 function _isBrowserType(o) { |
318 return o instanceof Blob || o instanceof Event || window.KeyRange && o insta
nceof KeyRange || o instanceof ImageData || o instanceof Node || window.TypedDat
a && o instanceof TypedData || o instanceof Window; | 318 return dart.as(o instanceof Blob || o instanceof Event || window.KeyRange &&
o instanceof KeyRange || o instanceof ImageData || o instanceof Node || window.
TypedData && o instanceof TypedData || o instanceof Window, core.bool); |
319 } | 319 } |
320 dart.fn(_isBrowserType, core.bool, [dart.dynamic]); | 320 dart.fn(_isBrowserType, core.bool, [dart.dynamic]); |
321 let _dartObj = Symbol('_dartObj'); | 321 let _dartObj = Symbol('_dartObj'); |
322 class _DartObject extends core.Object { | 322 class _DartObject extends core.Object { |
323 _DartObject(dartObj) { | 323 _DartObject(dartObj) { |
324 this[_dartObj] = dartObj; | 324 this[_dartObj] = dartObj; |
325 } | 325 } |
326 } | 326 } |
327 dart.setSignature(_DartObject, { | 327 dart.setSignature(_DartObject, { |
328 constructors: () => ({_DartObject: [_DartObject, [dart.dynamic]]}) | 328 constructors: () => ({_DartObject: [_DartObject, [dart.dynamic]]}) |
329 }); | 329 }); |
330 function _convertToJS(o) { | 330 function _convertToJS(o) { |
331 if (o == null || typeof o == 'string' || dart.is(o, core.num) || typeof o ==
'boolean' || dart.notNull(_isBrowserType(o))) { | 331 if (o == null || typeof o == 'string' || dart.is(o, core.num) || typeof o ==
'boolean' || dart.notNull(dart.dcall(_isBrowserType, o))) { |
332 return o; | 332 return o; |
333 } else if (dart.is(o, core.DateTime)) { | 333 } else if (dart.is(o, core.DateTime)) { |
334 return _js_helper.Primitives.lazyAsJsDate(o); | 334 return dart.dcall(_js_helper.Primitives.lazyAsJsDate, o); |
335 } else if (dart.is(o, JsObject)) { | 335 } else if (dart.is(o, JsObject)) { |
336 return dart.dload(o, _jsObject); | 336 return dart.dload(o, _jsObject); |
337 } else if (dart.is(o, core.Function)) { | 337 } else if (dart.is(o, core.Function)) { |
338 return _putIfAbsent(exports._jsProxies, o, _wrapDartFunction); | 338 return dart.dcall(_putIfAbsent, exports._jsProxies, o, _wrapDartFunction); |
339 } else { | 339 } else { |
340 return _putIfAbsent(exports._jsProxies, o, dart.fn(o => new _DartObject(o)
, _DartObject, [dart.dynamic])); | 340 return dart.dcall(_putIfAbsent, exports._jsProxies, o, dart.fn(o => new _D
artObject(o), _DartObject, [dart.dynamic])); |
341 } | 341 } |
342 } | 342 } |
343 dart.fn(_convertToJS); | 343 dart.fn(_convertToJS); |
344 function _wrapDartFunction(f) { | 344 function _wrapDartFunction(f) { |
345 let wrapper = function() { | 345 let wrapper = function() { |
346 let args = Array.prototype.map.call(arguments, _convertToDart); | 346 let args = Array.prototype.map.call(arguments, _convertToDart); |
347 return _convertToJS(f(...args)); | 347 return _convertToJS(f(...args)); |
348 }; | 348 }; |
349 dart.dsetindex(exports._dartProxies, wrapper, f); | 349 dart.dsetindex(exports._dartProxies, wrapper, f); |
350 return wrapper; | 350 return wrapper; |
351 } | 351 } |
352 dart.fn(_wrapDartFunction); | 352 dart.fn(_wrapDartFunction); |
353 function _convertToDart(o) { | 353 function _convertToDart(o) { |
354 if (o == null || typeof o == "string" || typeof o == "number" || typeof o ==
"boolean" || dart.notNull(_isBrowserType(o))) { | 354 if (dart.notNull(dart.as(o == null, core.bool)) || dart.notNull(dart.as(type
of o == "string", core.bool)) || dart.notNull(dart.as(typeof o == "number", core
.bool)) || dart.notNull(dart.as(typeof o == "boolean", core.bool)) || dart.notNu
ll(dart.dcall(_isBrowserType, o))) { |
355 return o; | 355 return o; |
356 } else if (o instanceof Date) { | 356 } else if (dart.notNull(dart.as(o instanceof Date, core.bool))) { |
357 let ms = o.getTime(); | 357 let ms = o.getTime(); |
358 return new core.DateTime.fromMillisecondsSinceEpoch(ms); | 358 return new core.DateTime.fromMillisecondsSinceEpoch(dart.as(ms, core.int))
; |
359 } else if (dart.is(o, _DartObject) && dart.jsobject != dart.realRuntimeType(
o)) { | 359 } else if (dart.is(o, _DartObject) && dart.notNull(dart.as(dart.jsobject !=
dart.realRuntimeType(o), core.bool))) { |
360 return dart.dload(o, _dartObj); | 360 return dart.dload(o, _dartObj); |
361 } else { | 361 } else { |
362 return _putIfAbsent(exports._dartProxies, o, _wrapToDart); | 362 return dart.dcall(_putIfAbsent, exports._dartProxies, o, _wrapToDart); |
363 } | 363 } |
364 } | 364 } |
365 dart.fn(_convertToDart, core.Object, [dart.dynamic]); | 365 dart.fn(_convertToDart, core.Object, [dart.dynamic]); |
366 function _wrapToDart(o) { | 366 function _wrapToDart(o) { |
367 if (typeof o == "function") { | 367 if (dart.notNull(dart.as(typeof o == "function", core.bool))) { |
368 return new JsFunction._fromJs(o); | 368 return new JsFunction._fromJs(o); |
369 } | 369 } |
370 if (o instanceof Array) { | 370 if (dart.notNull(dart.as(o instanceof Array, core.bool))) { |
371 return new JsArray._fromJs(o); | 371 return new JsArray._fromJs(o); |
372 } | 372 } |
373 return new JsObject._fromJs(o); | 373 return new JsObject._fromJs(o); |
374 } | 374 } |
375 dart.fn(_wrapToDart); | 375 dart.fn(_wrapToDart); |
376 dart.defineLazyProperties(exports, { | 376 dart.defineLazyProperties(exports, { |
377 get _dartProxies() { | 377 get _dartProxies() { |
378 return new WeakMap(); | 378 return new WeakMap(); |
379 }, | 379 }, |
380 get _jsProxies() { | 380 get _jsProxies() { |
381 return new WeakMap(); | 381 return new WeakMap(); |
382 } | 382 } |
383 }); | 383 }); |
384 function _putIfAbsent(weakMap, o, getValue) { | 384 function _putIfAbsent(weakMap, o, getValue) { |
385 let value = weakMap.get(o); | 385 let value = weakMap.get(o); |
386 if (value == null) { | 386 if (value == null) { |
387 value = dart.dcall(getValue, o); | 387 value = dart.dcall(getValue, o); |
388 weakMap.set(o, value); | 388 weakMap.set(o, value); |
389 } | 389 } |
390 return value; | 390 return value; |
391 } | 391 } |
392 dart.fn(_putIfAbsent, core.Object, [dart.dynamic, dart.dynamic, dart.functionT
ype(dart.dynamic, [dart.dynamic])]); | 392 dart.fn(_putIfAbsent, core.Object, [dart.dynamic, dart.dynamic, dart.functionT
ype(dart.dynamic, [dart.dynamic])]); |
393 let __CastType0$ = dart.generic(function(E) { | |
394 let __CastType0 = dart.typedef('__CastType0', () => dart.functionType(dart.d
ynamic, [E])); | |
395 return __CastType0; | |
396 }); | |
397 let __CastType0 = __CastType0$(); | |
398 // Exports: | 393 // Exports: |
399 exports.JsObject = JsObject; | 394 exports.JsObject = JsObject; |
400 exports.JsFunction = JsFunction; | 395 exports.JsFunction = JsFunction; |
401 exports.JsArray$ = JsArray$; | 396 exports.JsArray$ = JsArray$; |
402 exports.JsArray = JsArray; | 397 exports.JsArray = JsArray; |
403 }); | 398 }); |
OLD | NEW |