OLD | NEW |
(Empty) | |
| 1 /** |
| 2 * An API for storing data in the browser that can be queried with SQL. |
| 3 * |
| 4 * **Caution:** this specification is no longer actively maintained by the Web |
| 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
/) |
| 7 * for more information. |
| 8 * |
| 9 * The [dart:indexed_db] APIs is a recommended alternatives. |
| 10 */ |
| 11 library dart.dom.web_sql; |
| 12 |
| 13 import 'dart:async'; |
| 14 import 'dart:collection'; |
| 15 import 'dart:_internal'; |
| 16 import 'dart:html'; |
| 17 import 'dart:html_common'; |
| 18 import 'dart:_js_helper' show convertDartClosureToJS, Creates, JSName, Native; |
| 19 import 'dart:_foreign_helper' show JS; |
| 20 import 'dart:_interceptors' show Interceptor; |
| 21 // DO NOT EDIT - unless you are editing documentation as per: |
| 22 // https://code.google.com/p/dart/wiki/ContributingHTMLDocumentation |
| 23 // Auto-generated dart:audio library. |
| 24 |
| 25 |
| 26 |
| 27 |
| 28 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 29 // for details. All rights reserved. Use of this source code is governed by a |
| 30 // BSD-style license that can be found in the LICENSE file. |
| 31 |
| 32 // WARNING: Do not edit - generated code. |
| 33 |
| 34 |
| 35 @DomName('SQLStatementCallback') |
| 36 // http://www.w3.org/TR/webdatabase/#sqlstatementcallback |
| 37 @Experimental() // deprecated |
| 38 typedef void SqlStatementCallback(SqlTransaction transaction, SqlResultSet resul
tSet); |
| 39 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 40 // for details. All rights reserved. Use of this source code is governed by a |
| 41 // BSD-style license that can be found in the LICENSE file. |
| 42 |
| 43 // WARNING: Do not edit - generated code. |
| 44 |
| 45 |
| 46 @DomName('SQLStatementErrorCallback') |
| 47 // http://www.w3.org/TR/webdatabase/#sqlstatementerrorcallback |
| 48 @Experimental() // deprecated |
| 49 typedef void SqlStatementErrorCallback(SqlTransaction transaction, SqlError erro
r); |
| 50 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 51 // for details. All rights reserved. Use of this source code is governed by a |
| 52 // BSD-style license that can be found in the LICENSE file. |
| 53 |
| 54 // WARNING: Do not edit - generated code. |
| 55 |
| 56 |
| 57 @DomName('SQLTransactionCallback') |
| 58 // http://www.w3.org/TR/webdatabase/#sqltransactioncallback |
| 59 @Experimental() // deprecated |
| 60 typedef void SqlTransactionCallback(SqlTransaction transaction); |
| 61 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 62 // for details. All rights reserved. Use of this source code is governed by a |
| 63 // BSD-style license that can be found in the LICENSE file. |
| 64 |
| 65 // WARNING: Do not edit - generated code. |
| 66 |
| 67 |
| 68 @DomName('SQLTransactionErrorCallback') |
| 69 // http://www.w3.org/TR/webdatabase/#sqltransactionerrorcallback |
| 70 @Experimental() // deprecated |
| 71 typedef void SqlTransactionErrorCallback(SqlError error); |
| 72 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 73 // for details. All rights reserved. Use of this source code is governed by a |
| 74 // BSD-style license that can be found in the LICENSE file. |
| 75 |
| 76 |
| 77 @DocsEditable() |
| 78 @DomName('Database') |
| 79 @SupportedBrowser(SupportedBrowser.CHROME) |
| 80 @SupportedBrowser(SupportedBrowser.SAFARI) |
| 81 @Experimental() |
| 82 // http://www.w3.org/TR/webdatabase/#asynchronous-database-api |
| 83 @Experimental() // deprecated |
| 84 @Native("Database") |
| 85 class SqlDatabase extends Interceptor { |
| 86 // To suppress missing implicit constructor warnings. |
| 87 factory SqlDatabase._() { throw new UnsupportedError("Not supported"); } |
| 88 |
| 89 /// Checks if this type is supported on the current platform. |
| 90 static bool get supported => JS('bool', '!!(window.openDatabase)'); |
| 91 |
| 92 @DomName('Database.version') |
| 93 @DocsEditable() |
| 94 final String version; |
| 95 |
| 96 /** |
| 97 * Atomically update the database version to [newVersion], asynchronously |
| 98 * running [callback] on the [SqlTransaction] representing this |
| 99 * [changeVersion] transaction. |
| 100 * |
| 101 * If [callback] runs successfully, then [successCallback] is called. |
| 102 * Otherwise, [errorCallback] is called. |
| 103 * |
| 104 * [oldVersion] should match the database's current [version] exactly. |
| 105 * |
| 106 * See also: |
| 107 * |
| 108 * * [Database.changeVersion](http://www.w3.org/TR/webdatabase/#dom-database-c
hangeversion) from W3C. |
| 109 */ |
| 110 @DomName('Database.changeVersion') |
| 111 @DocsEditable() |
| 112 void changeVersion(String oldVersion, String newVersion, [SqlTransactionCallba
ck callback, SqlTransactionErrorCallback errorCallback, VoidCallback successCall
back]) native; |
| 113 |
| 114 @DomName('Database.readTransaction') |
| 115 @DocsEditable() |
| 116 void readTransaction(SqlTransactionCallback callback, [SqlTransactionErrorCall
back errorCallback, VoidCallback successCallback]) native; |
| 117 |
| 118 @DomName('Database.transaction') |
| 119 @DocsEditable() |
| 120 void transaction(SqlTransactionCallback callback, [SqlTransactionErrorCallback
errorCallback, VoidCallback successCallback]) native; |
| 121 } |
| 122 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 123 // for details. All rights reserved. Use of this source code is governed by a |
| 124 // BSD-style license that can be found in the LICENSE file. |
| 125 |
| 126 |
| 127 @DocsEditable() |
| 128 @DomName('SQLError') |
| 129 // http://www.w3.org/TR/webdatabase/#sqlerror |
| 130 @Experimental() // deprecated |
| 131 @Native("SQLError") |
| 132 class SqlError extends Interceptor { |
| 133 // To suppress missing implicit constructor warnings. |
| 134 factory SqlError._() { throw new UnsupportedError("Not supported"); } |
| 135 |
| 136 @DomName('SQLError.CONSTRAINT_ERR') |
| 137 @DocsEditable() |
| 138 static const int CONSTRAINT_ERR = 6; |
| 139 |
| 140 @DomName('SQLError.DATABASE_ERR') |
| 141 @DocsEditable() |
| 142 static const int DATABASE_ERR = 1; |
| 143 |
| 144 @DomName('SQLError.QUOTA_ERR') |
| 145 @DocsEditable() |
| 146 static const int QUOTA_ERR = 4; |
| 147 |
| 148 @DomName('SQLError.SYNTAX_ERR') |
| 149 @DocsEditable() |
| 150 static const int SYNTAX_ERR = 5; |
| 151 |
| 152 @DomName('SQLError.TIMEOUT_ERR') |
| 153 @DocsEditable() |
| 154 static const int TIMEOUT_ERR = 7; |
| 155 |
| 156 @DomName('SQLError.TOO_LARGE_ERR') |
| 157 @DocsEditable() |
| 158 static const int TOO_LARGE_ERR = 3; |
| 159 |
| 160 @DomName('SQLError.UNKNOWN_ERR') |
| 161 @DocsEditable() |
| 162 static const int UNKNOWN_ERR = 0; |
| 163 |
| 164 @DomName('SQLError.VERSION_ERR') |
| 165 @DocsEditable() |
| 166 static const int VERSION_ERR = 2; |
| 167 |
| 168 @DomName('SQLError.code') |
| 169 @DocsEditable() |
| 170 final int code; |
| 171 |
| 172 @DomName('SQLError.message') |
| 173 @DocsEditable() |
| 174 final String message; |
| 175 } |
| 176 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 177 // for details. All rights reserved. Use of this source code is governed by a |
| 178 // BSD-style license that can be found in the LICENSE file. |
| 179 |
| 180 |
| 181 @DocsEditable() |
| 182 @DomName('SQLResultSet') |
| 183 // http://www.w3.org/TR/webdatabase/#sqlresultset |
| 184 @Experimental() // deprecated |
| 185 @Native("SQLResultSet") |
| 186 class SqlResultSet extends Interceptor { |
| 187 // To suppress missing implicit constructor warnings. |
| 188 factory SqlResultSet._() { throw new UnsupportedError("Not supported"); } |
| 189 |
| 190 @DomName('SQLResultSet.insertId') |
| 191 @DocsEditable() |
| 192 final int insertId; |
| 193 |
| 194 @DomName('SQLResultSet.rows') |
| 195 @DocsEditable() |
| 196 final SqlResultSetRowList rows; |
| 197 |
| 198 @DomName('SQLResultSet.rowsAffected') |
| 199 @DocsEditable() |
| 200 final int rowsAffected; |
| 201 } |
| 202 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 203 // for details. All rights reserved. Use of this source code is governed by a |
| 204 // BSD-style license that can be found in the LICENSE file. |
| 205 |
| 206 |
| 207 @DocsEditable() |
| 208 @DomName('SQLResultSetRowList') |
| 209 // http://www.w3.org/TR/webdatabase/#sqlresultsetrowlist |
| 210 @Experimental() // deprecated |
| 211 @Native("SQLResultSetRowList") |
| 212 class SqlResultSetRowList extends Interceptor with ListMixin<Map>, ImmutableList
Mixin<Map> implements List<Map> { |
| 213 // To suppress missing implicit constructor warnings. |
| 214 factory SqlResultSetRowList._() { throw new UnsupportedError("Not supported");
} |
| 215 |
| 216 @DomName('SQLResultSetRowList.length') |
| 217 @DocsEditable() |
| 218 int get length => JS("int", "#.length", this); |
| 219 |
| 220 Map operator[](int index) { |
| 221 if (JS("bool", "# >>> 0 !== # || # >= #", index, |
| 222 index, index, length)) |
| 223 throw new RangeError.index(index, this); |
| 224 return this.item(index); |
| 225 } |
| 226 void operator[]=(int index, Map value) { |
| 227 throw new UnsupportedError("Cannot assign element of immutable List."); |
| 228 } |
| 229 // -- start List<Map> mixins. |
| 230 // Map is the element type. |
| 231 |
| 232 |
| 233 set length(int value) { |
| 234 throw new UnsupportedError("Cannot resize immutable List."); |
| 235 } |
| 236 |
| 237 Map get first { |
| 238 if (this.length > 0) { |
| 239 return JS('Map', '#[0]', this); |
| 240 } |
| 241 throw new StateError("No elements"); |
| 242 } |
| 243 |
| 244 Map get last { |
| 245 int len = this.length; |
| 246 if (len > 0) { |
| 247 return JS('Map', '#[#]', this, len - 1); |
| 248 } |
| 249 throw new StateError("No elements"); |
| 250 } |
| 251 |
| 252 Map get single { |
| 253 int len = this.length; |
| 254 if (len == 1) { |
| 255 return JS('Map', '#[0]', this); |
| 256 } |
| 257 if (len == 0) throw new StateError("No elements"); |
| 258 throw new StateError("More than one element"); |
| 259 } |
| 260 |
| 261 Map elementAt(int index) => this[index]; |
| 262 // -- end List<Map> mixins. |
| 263 |
| 264 @DomName('SQLResultSetRowList.item') |
| 265 @DocsEditable() |
| 266 @Creates('=Object') |
| 267 Map item(int index) { |
| 268 return convertNativeToDart_Dictionary(_item_1(index)); |
| 269 } |
| 270 @JSName('item') |
| 271 @DomName('SQLResultSetRowList.item') |
| 272 @DocsEditable() |
| 273 @Creates('=Object') |
| 274 _item_1(index) native; |
| 275 } |
| 276 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 277 // for details. All rights reserved. Use of this source code is governed by a |
| 278 // BSD-style license that can be found in the LICENSE file. |
| 279 |
| 280 |
| 281 @DocsEditable() |
| 282 @DomName('SQLTransaction') |
| 283 @SupportedBrowser(SupportedBrowser.CHROME) |
| 284 @SupportedBrowser(SupportedBrowser.SAFARI) |
| 285 @Experimental() |
| 286 // http://www.w3.org/TR/webdatabase/#sqltransaction |
| 287 @deprecated // deprecated |
| 288 @Native("SQLTransaction") |
| 289 class SqlTransaction extends Interceptor { |
| 290 // To suppress missing implicit constructor warnings. |
| 291 factory SqlTransaction._() { throw new UnsupportedError("Not supported"); } |
| 292 |
| 293 @DomName('SQLTransaction.executeSql') |
| 294 @DocsEditable() |
| 295 void executeSql(String sqlStatement, List<Object> arguments, [SqlStatementCall
back callback, SqlStatementErrorCallback errorCallback]) native; |
| 296 } |
OLD | NEW |