OLD | NEW |
1 dart_library.library('dart/js', null, /* Imports */[ | 1 dart_library.library('dart/js', null, /* Imports */[ |
2 'dart/_runtime', | 2 'dart/_runtime', |
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 const _global = dart.global; | 10 const _global = dart.global; |
(...skipping 30 matching lines...) Expand all Loading... |
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(_convertedObjects.containsKey(o))) { |
46 return _convertedObjects.get(o); | 46 return _convertedObjects.get(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 _convertedObjects.set(o, convertedMap); |
51 for (let key of dart.as(dart.dload(o, 'keys'), core.Iterable)) { | 51 for (let key of o.keys) { |
52 convertedMap[key] = _convert(dart.dindex(o, key)); | 52 convertedMap[key] = _convert(o.get(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 _convertedObjects.set(o, convertedList); |
58 convertedList[dartx.addAll](dart.as(dart.dsend(o, 'map', _convert), co
re.Iterable)); | 58 convertedList[dartx.addAll](o[dartx.map](_convert)); |
59 return convertedList; | 59 return convertedList; |
60 } else { | 60 } else { |
61 return _convertToJS(o); | 61 return _convertToJS(o); |
62 } | 62 } |
63 } | 63 } |
64 dart.fn(_convert); | 64 dart.fn(_convert); |
65 return _convert(data); | 65 return _convert(data); |
66 } | 66 } |
67 get(property) { | 67 get(property) { |
68 if (!(typeof property == 'string') && !(typeof property == 'number')) { | 68 if (!(typeof property == 'string') && !(typeof property == 'number')) { |
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 _convertToDart(this[_jsObject][property]); |
72 } | 72 } |
73 set(property, value) { | 73 set(property, value) { |
74 if (!(typeof property == 'string') && !(typeof property == 'number')) { | 74 if (!(typeof property == 'string') && !(typeof property == 'number')) { |
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] = _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) && this[_jsObject] === other[_jsObject]; |
85 } | 85 } |
86 hasProperty(property) { | 86 hasProperty(property) { |
87 if (!(typeof property == 'string') && !(typeof property == 'number')) { | 87 if (!(typeof property == 'string') && !(typeof property == 'number')) { |
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 property in this[_jsObject]; |
91 } | 91 } |
92 deleteProperty(property) { | 92 deleteProperty(property) { |
93 if (!(typeof property == 'string') && !(typeof property == 'number')) { | 93 if (!(typeof property == 'string') && !(typeof property == 'number')) { |
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")); |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 } | 319 } |
320 dart.setSignature(_DartObject, { | 320 dart.setSignature(_DartObject, { |
321 constructors: () => ({_DartObject: [_DartObject, [dart.dynamic]]}) | 321 constructors: () => ({_DartObject: [_DartObject, [dart.dynamic]]}) |
322 }); | 322 }); |
323 function _convertToJS(o) { | 323 function _convertToJS(o) { |
324 if (o == null || typeof o == 'string' || typeof o == 'number' || typeof o ==
'boolean' || dart.notNull(_isBrowserType(o))) { | 324 if (o == null || typeof o == 'string' || typeof o == 'number' || typeof o ==
'boolean' || dart.notNull(_isBrowserType(o))) { |
325 return o; | 325 return o; |
326 } else if (dart.is(o, core.DateTime)) { | 326 } else if (dart.is(o, core.DateTime)) { |
327 return _js_helper.Primitives.lazyAsJsDate(o); | 327 return _js_helper.Primitives.lazyAsJsDate(o); |
328 } else if (dart.is(o, JsObject)) { | 328 } else if (dart.is(o, JsObject)) { |
329 return dart.dload(o, _jsObject); | 329 return o[_jsObject]; |
330 } else if (dart.is(o, core.Function)) { | 330 } else if (dart.is(o, core.Function)) { |
331 return _putIfAbsent(_jsProxies, o, _wrapDartFunction); | 331 return _putIfAbsent(_jsProxies, o, _wrapDartFunction); |
332 } else { | 332 } else { |
333 return _putIfAbsent(_jsProxies, o, dart.fn(o => new _DartObject(o), _DartO
bject, [dart.dynamic])); | 333 return _putIfAbsent(_jsProxies, o, dart.fn(o => new _DartObject(o), _DartO
bject, [dart.dynamic])); |
334 } | 334 } |
335 } | 335 } |
336 dart.fn(_convertToJS); | 336 dart.fn(_convertToJS); |
337 function _wrapDartFunction(f) { | 337 function _wrapDartFunction(f) { |
338 let wrapper = function() { | 338 let wrapper = function() { |
339 let args = Array.prototype.map.call(arguments, _convertToDart); | 339 let args = Array.prototype.map.call(arguments, _convertToDart); |
340 return _convertToJS(f(...args)); | 340 return _convertToJS(f(...args)); |
341 }; | 341 }; |
342 dart.dsetindex(_dartProxies, wrapper, f); | 342 dart.dsetindex(_dartProxies, wrapper, f); |
343 return wrapper; | 343 return wrapper; |
344 } | 344 } |
345 dart.fn(_wrapDartFunction); | 345 dart.fn(_wrapDartFunction); |
346 function _convertToDart(o) { | 346 function _convertToDart(o) { |
347 if (o == null || typeof o == "string" || typeof o == "number" || typeof o ==
"boolean" || dart.notNull(_isBrowserType(o))) { | 347 if (o == null || typeof o == "string" || typeof o == "number" || typeof o ==
"boolean" || dart.notNull(_isBrowserType(o))) { |
348 return o; | 348 return o; |
349 } else if (o instanceof Date) { | 349 } else if (o instanceof Date) { |
350 let ms = o.getTime(); | 350 let ms = o.getTime(); |
351 return new core.DateTime.fromMillisecondsSinceEpoch(dart.asInt(ms)); | 351 return new core.DateTime.fromMillisecondsSinceEpoch(dart.asInt(ms)); |
352 } else if (dart.is(o, _DartObject) && dart.jsobject != dart.realRuntimeType(
o)) { | 352 } else if (dart.is(o, _DartObject) && dart.jsobject != dart.realRuntimeType(
o)) { |
353 return dart.dload(o, _dartObj); | 353 return o[_dartObj]; |
354 } else { | 354 } else { |
355 return _putIfAbsent(_dartProxies, o, _wrapToDart); | 355 return _putIfAbsent(_dartProxies, o, _wrapToDart); |
356 } | 356 } |
357 } | 357 } |
358 dart.fn(_convertToDart, core.Object, [dart.dynamic]); | 358 dart.fn(_convertToDart, core.Object, [dart.dynamic]); |
359 function _wrapToDart(o) { | 359 function _wrapToDart(o) { |
360 if (typeof o == "function") { | 360 if (typeof o == "function") { |
361 return new JsFunction._fromJs(o); | 361 return new JsFunction._fromJs(o); |
362 } | 362 } |
363 if (o instanceof Array) { | 363 if (o instanceof Array) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 }); | 408 }); |
409 let __CastType0 = __CastType0$(); | 409 let __CastType0 = __CastType0$(); |
410 // Exports: | 410 // Exports: |
411 exports.JsObject = JsObject; | 411 exports.JsObject = JsObject; |
412 exports.JsFunction = JsFunction; | 412 exports.JsFunction = JsFunction; |
413 exports.JsArray$ = JsArray$; | 413 exports.JsArray$ = JsArray$; |
414 exports.JsArray = JsArray; | 414 exports.JsArray = JsArray; |
415 exports.allowInterop = allowInterop; | 415 exports.allowInterop = allowInterop; |
416 exports.allowInteropCaptureThis = allowInteropCaptureThis; | 416 exports.allowInteropCaptureThis = allowInteropCaptureThis; |
417 }); | 417 }); |
OLD | NEW |