| OLD | NEW |
| 1 /** | 1 /** |
| 2 * An API for storing data in the browser that can be queried with SQL. | 2 * An API for storing data in the browser that can be queried with SQL. |
| 3 * | 3 * |
| 4 * **Caution:** this specification is no longer actively maintained by the Web | 4 * **Caution:** this specification is no longer actively maintained by the Web |
| 5 * Applications Working Group and may be removed at any time. | 5 * Applications Working Group and may be removed at any time. |
| 6 * See [the W3C Web SQL Database specification](http://www.w3.org/TR/webdatabase
/) | 6 * See [the W3C Web SQL Database specification](http://www.w3.org/TR/webdatabase
/) |
| 7 * for more information. | 7 * for more information. |
| 8 * | 8 * |
| 9 * The [dart:indexed_db] APIs is a recommended alternatives. | 9 * The [dart:indexed_db] APIs is a recommended alternatives. |
| 10 */ | 10 */ |
| 11 library dart.dom.web_sql; | 11 library dart.dom.web_sql; |
| 12 | 12 |
| 13 import 'dart:async'; | 13 import 'dart:async'; |
| 14 import 'dart:collection'; | 14 import 'dart:collection'; |
| 15 import 'dart:_collection-dev'; | 15 import 'dart:_collection-dev'; |
| 16 import 'dart:html'; | 16 import 'dart:html'; |
| 17 import 'dart:html_common'; | 17 import 'dart:html_common'; |
| 18 import 'dart:_js_helper' show convertDartClosureToJS, Creates, JavaScriptIndexin
gBehavior, JSName; | 18 import 'dart:_js_helper' show convertDartClosureToJS, Creates, JavaScriptIndexin
gBehavior, JSName; |
| 19 import 'dart:_foreign_helper' show JS; | 19 import 'dart:_foreign_helper' show JS; |
| 20 // DO NOT EDIT - unless you are editing documentation as per: | 20 // DO NOT EDIT - unless you are editing documentation as per: |
| 21 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation | 21 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation |
| 22 // Auto-generated dart:audio library. | 22 // Auto-generated dart:audio library. |
| 23 | 23 |
| 24 | 24 |
| 25 | 25 |
| 26 | 26 |
| 27 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 28 // for details. All rights reserved. Use of this source code is governed by a |
| 29 // BSD-style license that can be found in the LICENSE file. |
| 30 |
| 31 // WARNING: Do not edit - generated code. |
| 32 |
| 33 |
| 34 typedef void SqlStatementCallback(SqlTransaction transaction, SqlResultSet resul
tSet); |
| 35 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 36 // for details. All rights reserved. Use of this source code is governed by a |
| 37 // BSD-style license that can be found in the LICENSE file. |
| 38 |
| 39 // WARNING: Do not edit - generated code. |
| 40 |
| 41 |
| 42 typedef void SqlStatementErrorCallback(SqlTransaction transaction, SqlError erro
r); |
| 43 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 44 // for details. All rights reserved. Use of this source code is governed by a |
| 45 // BSD-style license that can be found in the LICENSE file. |
| 46 |
| 47 // WARNING: Do not edit - generated code. |
| 48 |
| 49 |
| 50 typedef void SqlTransactionCallback(SqlTransaction transaction); |
| 51 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 52 // for details. All rights reserved. Use of this source code is governed by a |
| 53 // BSD-style license that can be found in the LICENSE file. |
| 54 |
| 55 // WARNING: Do not edit - generated code. |
| 56 |
| 57 |
| 58 typedef void SqlTransactionErrorCallback(SqlError error); |
| 59 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 60 // for details. All rights reserved. Use of this source code is governed by a |
| 61 // BSD-style license that can be found in the LICENSE file. |
| 62 |
| 63 |
| 64 @DocsEditable |
| 65 @DomName('Database') |
| 66 @SupportedBrowser(SupportedBrowser.CHROME) |
| 67 @SupportedBrowser(SupportedBrowser.SAFARI) |
| 68 @Experimental |
| 69 class SqlDatabase native "*Database" { |
| 70 |
| 71 /// Checks if this type is supported on the current platform. |
| 72 static bool get supported => JS('bool', '!!(window.openDatabase)'); |
| 73 |
| 74 @DomName('Database.version') |
| 75 @DocsEditable |
| 76 final String version; |
| 77 |
| 78 /** |
| 79 * Atomically update the database version to [newVersion], asynchronously |
| 80 * running [callback] on the [SqlTransaction] representing this |
| 81 * [changeVersion] transaction. |
| 82 * |
| 83 * If [callback] runs successfully, then [successCallback] is called. |
| 84 * Otherwise, [errorCallback] is called. |
| 85 * |
| 86 * [oldVersion] should match the database's current [version] exactly. |
| 87 * |
| 88 * * [Database.changeVersion](http://www.w3.org/TR/webdatabase/#dom-database-c
hangeversion) from W3C. |
| 89 */ |
| 90 @DomName('Database.changeVersion') |
| 91 @DocsEditable |
| 92 void changeVersion(String oldVersion, String newVersion, [SqlTransactionCallba
ck callback, SqlTransactionErrorCallback errorCallback, VoidCallback successCall
back]) native; |
| 93 |
| 94 @DomName('Database.readTransaction') |
| 95 @DocsEditable |
| 96 void readTransaction(SqlTransactionCallback callback, [SqlTransactionErrorCall
back errorCallback, VoidCallback successCallback]) native; |
| 97 |
| 98 @DomName('Database.transaction') |
| 99 @DocsEditable |
| 100 void transaction(SqlTransactionCallback callback, [SqlTransactionErrorCallback
errorCallback, VoidCallback successCallback]) native; |
| 101 } |
| 102 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 103 // for details. All rights reserved. Use of this source code is governed by a |
| 104 // BSD-style license that can be found in the LICENSE file. |
| 105 |
| 106 |
| 107 @DocsEditable |
| 108 @DomName('SQLError') |
| 109 class SqlError native "*SQLError" { |
| 110 |
| 111 static const int CONSTRAINT_ERR = 6; |
| 112 |
| 113 static const int DATABASE_ERR = 1; |
| 114 |
| 115 static const int QUOTA_ERR = 4; |
| 116 |
| 117 static const int SYNTAX_ERR = 5; |
| 118 |
| 119 static const int TIMEOUT_ERR = 7; |
| 120 |
| 121 static const int TOO_LARGE_ERR = 3; |
| 122 |
| 123 static const int UNKNOWN_ERR = 0; |
| 124 |
| 125 static const int VERSION_ERR = 2; |
| 126 |
| 127 @DomName('SQLError.code') |
| 128 @DocsEditable |
| 129 final int code; |
| 130 |
| 131 @DomName('SQLError.message') |
| 132 @DocsEditable |
| 133 final String message; |
| 134 } |
| 135 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 136 // for details. All rights reserved. Use of this source code is governed by a |
| 137 // BSD-style license that can be found in the LICENSE file. |
| 138 |
| 139 |
| 140 @DocsEditable |
| 141 @DomName('SQLException') |
| 142 class SqlException native "*SQLException" { |
| 143 |
| 144 static const int CONSTRAINT_ERR = 6; |
| 145 |
| 146 static const int DATABASE_ERR = 1; |
| 147 |
| 148 static const int QUOTA_ERR = 4; |
| 149 |
| 150 static const int SYNTAX_ERR = 5; |
| 151 |
| 152 static const int TIMEOUT_ERR = 7; |
| 153 |
| 154 static const int TOO_LARGE_ERR = 3; |
| 155 |
| 156 static const int UNKNOWN_ERR = 0; |
| 157 |
| 158 static const int VERSION_ERR = 2; |
| 159 |
| 160 @DomName('SQLException.code') |
| 161 @DocsEditable |
| 162 final int code; |
| 163 |
| 164 @DomName('SQLException.message') |
| 165 @DocsEditable |
| 166 final String message; |
| 167 } |
| 168 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 169 // for details. All rights reserved. Use of this source code is governed by a |
| 170 // BSD-style license that can be found in the LICENSE file. |
| 171 |
| 172 |
| 173 @DocsEditable |
| 174 @DomName('SQLResultSet') |
| 175 class SqlResultSet native "*SQLResultSet" { |
| 176 |
| 177 @DomName('SQLResultSet.insertId') |
| 178 @DocsEditable |
| 179 final int insertId; |
| 180 |
| 181 @DomName('SQLResultSet.rows') |
| 182 @DocsEditable |
| 183 final SqlResultSetRowList rows; |
| 184 |
| 185 @DomName('SQLResultSet.rowsAffected') |
| 186 @DocsEditable |
| 187 final int rowsAffected; |
| 188 } |
| 189 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 190 // for details. All rights reserved. Use of this source code is governed by a |
| 191 // BSD-style license that can be found in the LICENSE file. |
| 192 |
| 193 |
| 194 @DocsEditable |
| 195 @DomName('SQLResultSetRowList') |
| 196 class SqlResultSetRowList implements JavaScriptIndexingBehavior, List<Map> nativ
e "*SQLResultSetRowList" { |
| 197 |
| 198 @DomName('SQLResultSetRowList.length') |
| 199 @DocsEditable |
| 200 int get length => JS("int", "#.length", this); |
| 201 |
| 202 Map operator[](int index) => this.item(index); |
| 203 |
| 204 void operator[]=(int index, Map value) { |
| 205 throw new UnsupportedError("Cannot assign element of immutable List."); |
| 206 } |
| 207 // -- start List<Map> mixins. |
| 208 // Map is the element type. |
| 209 |
| 210 // From Iterable<Map>: |
| 211 |
| 212 Iterator<Map> get iterator { |
| 213 // Note: NodeLists are not fixed size. And most probably length shouldn't |
| 214 // be cached in both iterator _and_ forEach method. For now caching it |
| 215 // for consistency. |
| 216 return new FixedSizeListIterator<Map>(this); |
| 217 } |
| 218 |
| 219 Map reduce(Map combine(Map value, Map element)) { |
| 220 return IterableMixinWorkaround.reduce(this, combine); |
| 221 } |
| 222 |
| 223 dynamic fold(dynamic initialValue, |
| 224 dynamic combine(dynamic previousValue, Map element)) { |
| 225 return IterableMixinWorkaround.fold(this, initialValue, combine); |
| 226 } |
| 227 |
| 228 bool contains(Map element) => IterableMixinWorkaround.contains(this, element); |
| 229 |
| 230 void forEach(void f(Map element)) => IterableMixinWorkaround.forEach(this, f); |
| 231 |
| 232 String join([String separator = ""]) => |
| 233 IterableMixinWorkaround.joinList(this, separator); |
| 234 |
| 235 Iterable map(f(Map element)) => |
| 236 IterableMixinWorkaround.mapList(this, f); |
| 237 |
| 238 Iterable<Map> where(bool f(Map element)) => |
| 239 IterableMixinWorkaround.where(this, f); |
| 240 |
| 241 Iterable expand(Iterable f(Map element)) => |
| 242 IterableMixinWorkaround.expand(this, f); |
| 243 |
| 244 bool every(bool f(Map element)) => IterableMixinWorkaround.every(this, f); |
| 245 |
| 246 bool any(bool f(Map element)) => IterableMixinWorkaround.any(this, f); |
| 247 |
| 248 List<Map> toList({ bool growable: true }) => |
| 249 new List<Map>.from(this, growable: growable); |
| 250 |
| 251 Set<Map> toSet() => new Set<Map>.from(this); |
| 252 |
| 253 bool get isEmpty => this.length == 0; |
| 254 |
| 255 Iterable<Map> take(int n) => IterableMixinWorkaround.takeList(this, n); |
| 256 |
| 257 Iterable<Map> takeWhile(bool test(Map value)) { |
| 258 return IterableMixinWorkaround.takeWhile(this, test); |
| 259 } |
| 260 |
| 261 Iterable<Map> skip(int n) => IterableMixinWorkaround.skipList(this, n); |
| 262 |
| 263 Iterable<Map> skipWhile(bool test(Map value)) { |
| 264 return IterableMixinWorkaround.skipWhile(this, test); |
| 265 } |
| 266 |
| 267 Map firstWhere(bool test(Map value), { Map orElse() }) { |
| 268 return IterableMixinWorkaround.firstWhere(this, test, orElse); |
| 269 } |
| 270 |
| 271 Map lastWhere(bool test(Map value), {Map orElse()}) { |
| 272 return IterableMixinWorkaround.lastWhereList(this, test, orElse); |
| 273 } |
| 274 |
| 275 Map singleWhere(bool test(Map value)) { |
| 276 return IterableMixinWorkaround.singleWhere(this, test); |
| 277 } |
| 278 |
| 279 Map elementAt(int index) { |
| 280 return this[index]; |
| 281 } |
| 282 |
| 283 // From Collection<Map>: |
| 284 |
| 285 void add(Map value) { |
| 286 throw new UnsupportedError("Cannot add to immutable List."); |
| 287 } |
| 288 |
| 289 void addAll(Iterable<Map> iterable) { |
| 290 throw new UnsupportedError("Cannot add to immutable List."); |
| 291 } |
| 292 |
| 293 // From List<Map>: |
| 294 void set length(int value) { |
| 295 throw new UnsupportedError("Cannot resize immutable List."); |
| 296 } |
| 297 |
| 298 void clear() { |
| 299 throw new UnsupportedError("Cannot clear immutable List."); |
| 300 } |
| 301 |
| 302 Iterable<Map> get reversed { |
| 303 return IterableMixinWorkaround.reversedList(this); |
| 304 } |
| 305 |
| 306 void sort([int compare(Map a, Map b)]) { |
| 307 throw new UnsupportedError("Cannot sort immutable List."); |
| 308 } |
| 309 |
| 310 int indexOf(Map element, [int start = 0]) => |
| 311 Lists.indexOf(this, element, start, this.length); |
| 312 |
| 313 int lastIndexOf(Map element, [int start]) { |
| 314 if (start == null) start = length - 1; |
| 315 return Lists.lastIndexOf(this, element, start); |
| 316 } |
| 317 |
| 318 Map get first { |
| 319 if (this.length > 0) return this[0]; |
| 320 throw new StateError("No elements"); |
| 321 } |
| 322 |
| 323 Map get last { |
| 324 if (this.length > 0) return this[this.length - 1]; |
| 325 throw new StateError("No elements"); |
| 326 } |
| 327 |
| 328 Map get single { |
| 329 if (length == 1) return this[0]; |
| 330 if (length == 0) throw new StateError("No elements"); |
| 331 throw new StateError("More than one element"); |
| 332 } |
| 333 |
| 334 void insert(int index, Map element) { |
| 335 throw new UnsupportedError("Cannot add to immutable List."); |
| 336 } |
| 337 |
| 338 void insertAll(int index, Iterable<Map> iterable) { |
| 339 throw new UnsupportedError("Cannot add to immutable List."); |
| 340 } |
| 341 |
| 342 void setAll(int index, Iterable<Map> iterable) { |
| 343 throw new UnsupportedError("Cannot modify an immutable List."); |
| 344 } |
| 345 |
| 346 Map removeAt(int pos) { |
| 347 throw new UnsupportedError("Cannot remove from immutable List."); |
| 348 } |
| 349 |
| 350 Map removeLast() { |
| 351 throw new UnsupportedError("Cannot remove from immutable List."); |
| 352 } |
| 353 |
| 354 void remove(Object object) { |
| 355 throw new UnsupportedError("Cannot remove from immutable List."); |
| 356 } |
| 357 |
| 358 void removeWhere(bool test(Map element)) { |
| 359 throw new UnsupportedError("Cannot remove from immutable List."); |
| 360 } |
| 361 |
| 362 void retainWhere(bool test(Map element)) { |
| 363 throw new UnsupportedError("Cannot remove from immutable List."); |
| 364 } |
| 365 |
| 366 void setRange(int start, int end, Iterable<Map> iterable, [int skipCount]) { |
| 367 throw new UnsupportedError("Cannot setRange on immutable List."); |
| 368 } |
| 369 |
| 370 void removeRange(int start, int end) { |
| 371 throw new UnsupportedError("Cannot removeRange on immutable List."); |
| 372 } |
| 373 |
| 374 void replaceRange(int start, int end, Iterable<Map> iterable) { |
| 375 throw new UnsupportedError("Cannot modify an immutable List."); |
| 376 } |
| 377 |
| 378 void fillRange(int start, int end, [Map fillValue]) { |
| 379 throw new UnsupportedError("Cannot modify an immutable List."); |
| 380 } |
| 381 |
| 382 Iterable<Map> getRange(int start, int end) => |
| 383 IterableMixinWorkaround.getRangeList(this, start, end); |
| 384 |
| 385 List<Map> sublist(int start, [int end]) { |
| 386 if (end == null) end = length; |
| 387 return Lists.getRange(this, start, end, <Map>[]); |
| 388 } |
| 389 |
| 390 Map<int, Map> asMap() => |
| 391 IterableMixinWorkaround.asMapList(this); |
| 392 |
| 393 String toString() { |
| 394 StringBuffer buffer = new StringBuffer('['); |
| 395 buffer.writeAll(this, ', '); |
| 396 buffer.write(']'); |
| 397 return buffer.toString(); |
| 398 } |
| 399 |
| 400 // -- end List<Map> mixins. |
| 401 |
| 402 @DomName('SQLResultSetRowList.item') |
| 403 @DocsEditable |
| 404 @Creates('=Object') |
| 405 Map item(int index) { |
| 406 return convertNativeToDart_Dictionary(_item_1(index)); |
| 407 } |
| 408 @JSName('item') |
| 409 @DomName('SQLResultSetRowList.item') |
| 410 @DocsEditable |
| 411 @Creates('=Object') |
| 412 _item_1(index) native; |
| 413 } |
| 414 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 415 // for details. All rights reserved. Use of this source code is governed by a |
| 416 // BSD-style license that can be found in the LICENSE file. |
| 417 |
| 418 |
| 419 @DocsEditable |
| 420 @DomName('SQLTransaction') |
| 421 @SupportedBrowser(SupportedBrowser.CHROME) |
| 422 @SupportedBrowser(SupportedBrowser.SAFARI) |
| 423 @Experimental |
| 424 class SqlTransaction native "*SQLTransaction" { |
| 425 |
| 426 @DomName('SQLTransaction.executeSql') |
| 427 @DocsEditable |
| 428 void executeSql(String sqlStatement, List arguments, [SqlStatementCallback cal
lback, SqlStatementErrorCallback errorCallback]) native; |
| 429 } |
| 430 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 431 // for details. All rights reserved. Use of this source code is governed by a |
| 432 // BSD-style license that can be found in the LICENSE file. |
| 433 |
| 434 |
| 435 @DocsEditable |
| 436 @DomName('SQLTransactionSync') |
| 437 @SupportedBrowser(SupportedBrowser.CHROME) |
| 438 @SupportedBrowser(SupportedBrowser.SAFARI) |
| 439 @Experimental |
| 440 abstract class _SQLTransactionSync native "*SQLTransactionSync" { |
| 441 } |
| OLD | NEW |