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