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