OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 library libraries; |
| 6 |
| 7 /** |
| 8 * A bit flag used by [LibraryInfo] indicating that a library is used by dart2js |
| 9 */ |
| 10 const int DART2JS_PLATFORM = 1; |
| 11 |
| 12 /** |
| 13 * A bit flag used by [LibraryInfo] indicating that a library is used by the VM |
| 14 */ |
| 15 const int VM_PLATFORM = 2; |
| 16 |
| 17 /// The contexts that a library can be used from. |
| 18 enum Category { |
| 19 /// Indicates that a library can be used in a browser context. |
| 20 client, |
| 21 /// Indicates that a library can be used in a command line context. |
| 22 server, |
| 23 /// Indicates that a library can be used from embedded devices. |
| 24 embedded |
| 25 } |
| 26 |
| 27 Category parseCategory(String name) { |
| 28 switch (name) { |
| 29 case "Client": return Category.client; |
| 30 case "Server": return Category.server; |
| 31 case "Embedded": return Category.embedded; |
| 32 } |
| 33 return null; |
| 34 } |
| 35 |
| 36 /// Mapping of "dart:" library name (e.g. "core") to information about that |
| 37 /// library. |
| 38 const Map<String, LibraryInfo> libraries = const { |
| 39 "async": const LibraryInfo( |
| 40 "async/async.dart", |
| 41 categories: "Client,Server", |
| 42 maturity: Maturity.STABLE, |
| 43 dart2jsPatchPath: "_internal/js_runtime/lib/async_patch.dart"), |
| 44 |
| 45 "_blink": const LibraryInfo( |
| 46 "_blink/dartium/_blink_dartium.dart", |
| 47 categories: "Client", |
| 48 implementation: true, |
| 49 documented: false, |
| 50 platforms: VM_PLATFORM), |
| 51 |
| 52 "_chrome": const LibraryInfo( |
| 53 "_chrome/dart2js/chrome_dart2js.dart", |
| 54 categories: "Client", |
| 55 documented: false), |
| 56 |
| 57 "collection": const LibraryInfo( |
| 58 "collection/collection.dart", |
| 59 categories: "Client,Server,Embedded", |
| 60 maturity: Maturity.STABLE, |
| 61 dart2jsPatchPath: "_internal/js_runtime/lib/collection_patch.dart"), |
| 62 |
| 63 "convert": const LibraryInfo( |
| 64 "convert/convert.dart", |
| 65 categories: "Client,Server", |
| 66 maturity: Maturity.STABLE, |
| 67 dart2jsPatchPath: "_internal/js_runtime/lib/convert_patch.dart"), |
| 68 |
| 69 "core": const LibraryInfo( |
| 70 "core/core.dart", |
| 71 categories: "Client,Server,Embedded", |
| 72 maturity: Maturity.STABLE, |
| 73 dart2jsPatchPath: "_internal/js_runtime/lib/core_patch.dart"), |
| 74 |
| 75 "developer": const LibraryInfo( |
| 76 "developer/developer.dart", |
| 77 categories: "Client,Server,Embedded", |
| 78 maturity: Maturity.UNSTABLE, |
| 79 dart2jsPatchPath: "_internal/js_runtime/lib/developer_patch.dart"), |
| 80 |
| 81 "html": const LibraryInfo( |
| 82 "html/dartium/html_dartium.dart", |
| 83 categories: "Client", |
| 84 maturity: Maturity.WEB_STABLE, |
| 85 dart2jsPath: "html/dart2js/html_dart2js.dart"), |
| 86 |
| 87 "html_common": const LibraryInfo( |
| 88 "html/html_common/html_common.dart", |
| 89 categories: "Client", |
| 90 maturity: Maturity.WEB_STABLE, |
| 91 dart2jsPath: "html/html_common/html_common_dart2js.dart", |
| 92 documented: false, |
| 93 implementation: true), |
| 94 |
| 95 "indexed_db": const LibraryInfo( |
| 96 "indexed_db/dartium/indexed_db_dartium.dart", |
| 97 categories: "Client", |
| 98 maturity: Maturity.WEB_STABLE, |
| 99 dart2jsPath: "indexed_db/dart2js/indexed_db_dart2js.dart"), |
| 100 |
| 101 "io": const LibraryInfo( |
| 102 "io/io.dart", |
| 103 categories: "Server", |
| 104 dart2jsPatchPath: "_internal/js_runtime/lib/io_patch.dart"), |
| 105 |
| 106 "isolate": const LibraryInfo( |
| 107 "isolate/isolate.dart", |
| 108 categories: "Client,Server", |
| 109 maturity: Maturity.STABLE, |
| 110 dart2jsPatchPath: "_internal/js_runtime/lib/isolate_patch.dart"), |
| 111 |
| 112 "js": const LibraryInfo( |
| 113 "js/dartium/js_dartium.dart", |
| 114 categories: "Client", |
| 115 maturity: Maturity.STABLE, |
| 116 dart2jsPath: "js/dart2js/js_dart2js.dart"), |
| 117 |
| 118 "js_util": const LibraryInfo( |
| 119 "js_util/dartium/js_util_dartium.dart", |
| 120 categories: "Client", |
| 121 maturity: Maturity.STABLE, |
| 122 dart2jsPath: "js_util/dart2js/js_util_dart2js.dart"), |
| 123 |
| 124 "math": const LibraryInfo( |
| 125 "math/math.dart", |
| 126 categories: "Client,Server,Embedded", |
| 127 maturity: Maturity.STABLE, |
| 128 dart2jsPatchPath: "_internal/js_runtime/lib/math_patch.dart"), |
| 129 |
| 130 "mirrors": const LibraryInfo( |
| 131 "mirrors/mirrors.dart", |
| 132 categories: "Client,Server", |
| 133 maturity: Maturity.UNSTABLE, |
| 134 dart2jsPatchPath: "_internal/js_runtime/lib/mirrors_patch.dart"), |
| 135 |
| 136 "typed_data": const LibraryInfo( |
| 137 "typed_data/typed_data.dart", |
| 138 categories: "Client,Server,Embedded", |
| 139 maturity: Maturity.STABLE, |
| 140 dart2jsPatchPath: "_internal/js_runtime/lib/typed_data_patch.dart"), |
| 141 |
| 142 "_native_typed_data": const LibraryInfo( |
| 143 "_internal/js_runtime/lib/native_typed_data.dart", |
| 144 categories: "", |
| 145 implementation: true, |
| 146 documented: false, |
| 147 platforms: DART2JS_PLATFORM), |
| 148 |
| 149 "svg": const LibraryInfo( |
| 150 "svg/dartium/svg_dartium.dart", |
| 151 categories: "Client", |
| 152 maturity: Maturity.WEB_STABLE, |
| 153 dart2jsPath: "svg/dart2js/svg_dart2js.dart"), |
| 154 |
| 155 "web_audio": const LibraryInfo( |
| 156 "web_audio/dartium/web_audio_dartium.dart", |
| 157 categories: "Client", |
| 158 maturity: Maturity.WEB_STABLE, |
| 159 dart2jsPath: "web_audio/dart2js/web_audio_dart2js.dart"), |
| 160 |
| 161 "web_gl": const LibraryInfo( |
| 162 "web_gl/dartium/web_gl_dartium.dart", |
| 163 categories: "Client", |
| 164 maturity: Maturity.WEB_STABLE, |
| 165 dart2jsPath: "web_gl/dart2js/web_gl_dart2js.dart"), |
| 166 |
| 167 "web_sql": const LibraryInfo( |
| 168 "web_sql/dartium/web_sql_dartium.dart", |
| 169 categories: "Client", |
| 170 maturity: Maturity.WEB_STABLE, |
| 171 dart2jsPath: "web_sql/dart2js/web_sql_dart2js.dart"), |
| 172 |
| 173 "_internal": const LibraryInfo( |
| 174 "internal/internal.dart", |
| 175 categories: "", |
| 176 documented: false, |
| 177 dart2jsPatchPath: "_internal/js_runtime/lib/internal_patch.dart"), |
| 178 |
| 179 "_js_helper": const LibraryInfo( |
| 180 "_internal/js_runtime/lib/js_helper.dart", |
| 181 categories: "", |
| 182 documented: false, |
| 183 platforms: DART2JS_PLATFORM), |
| 184 |
| 185 "_interceptors": const LibraryInfo( |
| 186 "_internal/js_runtime/lib/interceptors.dart", |
| 187 categories: "", |
| 188 documented: false, |
| 189 platforms: DART2JS_PLATFORM), |
| 190 |
| 191 "_foreign_helper": const LibraryInfo( |
| 192 "_internal/js_runtime/lib/foreign_helper.dart", |
| 193 categories: "", |
| 194 documented: false, |
| 195 platforms: DART2JS_PLATFORM), |
| 196 |
| 197 "_isolate_helper": const LibraryInfo( |
| 198 "_internal/js_runtime/lib/isolate_helper.dart", |
| 199 categories: "", |
| 200 documented: false, |
| 201 platforms: DART2JS_PLATFORM), |
| 202 |
| 203 "_js_mirrors": const LibraryInfo( |
| 204 "_internal/js_runtime/lib/js_mirrors.dart", |
| 205 categories: "", |
| 206 documented: false, |
| 207 platforms: DART2JS_PLATFORM), |
| 208 |
| 209 "_js_names": const LibraryInfo( |
| 210 "_internal/js_runtime/lib/js_names.dart", |
| 211 categories: "", |
| 212 documented: false, |
| 213 platforms: DART2JS_PLATFORM), |
| 214 |
| 215 "_js_primitives": const LibraryInfo( |
| 216 "_internal/js_runtime/lib/js_primitives.dart", |
| 217 categories: "", |
| 218 documented: false, |
| 219 platforms: DART2JS_PLATFORM), |
| 220 |
| 221 "_js_embedded_names": const LibraryInfo( |
| 222 "_internal/js_runtime/lib/shared/embedded_names.dart", |
| 223 categories: "", |
| 224 documented: false, |
| 225 platforms: DART2JS_PLATFORM), |
| 226 |
| 227 "_async_await_error_codes": const LibraryInfo( |
| 228 "_internal/js_runtime/lib/shared/async_await_error_codes.dart", |
| 229 categories: "", |
| 230 documented: false, |
| 231 platforms: DART2JS_PLATFORM), |
| 232 |
| 233 "_metadata": const LibraryInfo( |
| 234 "html/html_common/metadata.dart", |
| 235 categories: "", |
| 236 documented: false, |
| 237 platforms: DART2JS_PLATFORM), |
| 238 |
| 239 "_debugger": const LibraryInfo( |
| 240 "_internal/js_runtime/lib/debugger.dart", |
| 241 category: "", |
| 242 documented: false, |
| 243 platforms: DART2JS_PLATFORM), |
| 244 |
| 245 "_runtime": const LibraryInfo( |
| 246 "_internal/js_runtime/lib/ddc_runtime/runtime.dart", |
| 247 category: "", |
| 248 documented: false, |
| 249 platforms: DART2JS_PLATFORM), |
| 250 }; |
| 251 |
| 252 /** |
| 253 * Information about a "dart:" library. |
| 254 */ |
| 255 class LibraryInfo { |
| 256 /** |
| 257 * Path to the library's *.dart file relative to this file. |
| 258 */ |
| 259 final String path; |
| 260 |
| 261 /** |
| 262 * The categories in which the library can be used encoded as a |
| 263 * comma-separated String. |
| 264 */ |
| 265 final String _categories; |
| 266 |
| 267 /** |
| 268 * Path to the dart2js library's *.dart file relative to this file |
| 269 * or null if dart2js uses the common library path defined above. |
| 270 * Access using the [#getDart2JsPath()] method. |
| 271 */ |
| 272 final String dart2jsPath; |
| 273 |
| 274 /** |
| 275 * Path to the dart2js library's patch file relative to this file |
| 276 * or null if no dart2js patch file associated with this library. |
| 277 * Access using the [#getDart2JsPatchPath()] method. |
| 278 */ |
| 279 final String dart2jsPatchPath; |
| 280 |
| 281 /** |
| 282 * True if this library is documented and should be shown to the user. |
| 283 */ |
| 284 final bool documented; |
| 285 |
| 286 /** |
| 287 * Bit flags indicating which platforms consume this library. |
| 288 * See [DART2JS_LIBRARY] and [VM_LIBRARY]. |
| 289 */ |
| 290 final int platforms; |
| 291 |
| 292 /** |
| 293 * True if the library contains implementation details for another library. |
| 294 * The implication is that these libraries are less commonly used |
| 295 * and that tools like Dart Editor should not show these libraries |
| 296 * in a list of all libraries unless the user specifically asks the tool to |
| 297 * do so. |
| 298 */ |
| 299 final bool implementation; |
| 300 |
| 301 /** |
| 302 * States the current maturity of this library. |
| 303 */ |
| 304 final Maturity maturity; |
| 305 |
| 306 const LibraryInfo(this.path, { |
| 307 String categories: "", |
| 308 this.dart2jsPath, |
| 309 this.dart2jsPatchPath, |
| 310 this.implementation: false, |
| 311 this.documented: true, |
| 312 this.maturity: Maturity.UNSPECIFIED, |
| 313 this.platforms: DART2JS_PLATFORM | VM_PLATFORM}) |
| 314 : _categories = categories; |
| 315 |
| 316 bool get isDart2jsLibrary => (platforms & DART2JS_PLATFORM) != 0; |
| 317 bool get isVmLibrary => (platforms & VM_PLATFORM) != 0; |
| 318 |
| 319 /** |
| 320 * The categories in which the library can be used. |
| 321 * |
| 322 * If no categories are specified, the library is internal and can not be |
| 323 * loaded by user code. |
| 324 */ |
| 325 List<Category> get categories { |
| 326 // `"".split(,)` returns [""] not [], so we handle that case separately. |
| 327 if (_categories == "") return const <Category>[]; |
| 328 return _categories.split(",").map(parseCategory).toList(); |
| 329 } |
| 330 |
| 331 bool get isInternal => categories.isEmpty; |
| 332 |
| 333 /// The original "categories" String that was passed to the constructor. |
| 334 /// |
| 335 /// Can be used to construct a slightly modified copy of this LibraryInfo. |
| 336 String get categoriesString { |
| 337 return _categories; |
| 338 } |
| 339 } |
| 340 |
| 341 /** |
| 342 * Abstraction to capture the maturity of a library. |
| 343 */ |
| 344 class Maturity { |
| 345 final int level; |
| 346 final String name; |
| 347 final String description; |
| 348 |
| 349 const Maturity(this.level, this.name, this.description); |
| 350 |
| 351 String toString() => "$name: $level\n$description\n"; |
| 352 |
| 353 static const Maturity DEPRECATED = const Maturity(0, "Deprecated", |
| 354 "This library will be remove before next major release."); |
| 355 |
| 356 static const Maturity EXPERIMENTAL = const Maturity(1, "Experimental", |
| 357 "This library is experimental and will likely change or be removed\n" |
| 358 "in future versions."); |
| 359 |
| 360 static const Maturity UNSTABLE = const Maturity(2, "Unstable", |
| 361 "This library is in still changing and have not yet endured\n" |
| 362 "sufficient real-world testing.\n" |
| 363 "Backwards-compatibility is NOT guaranteed."); |
| 364 |
| 365 static const Maturity WEB_STABLE = const Maturity(3, "Web Stable", |
| 366 "This library is tracking the DOM evolution as defined by WC3.\n" |
| 367 "Backwards-compatibility is NOT guaranteed."); |
| 368 |
| 369 static const Maturity STABLE = const Maturity(4, "Stable", |
| 370 "The library is stable. API backwards-compatibility is guaranteed.\n" |
| 371 "However implementation details might change."); |
| 372 |
| 373 static const Maturity LOCKED = const Maturity(5, "Locked", |
| 374 "This library will not change except when serious bugs are encountered."); |
| 375 |
| 376 static const Maturity UNSPECIFIED = const Maturity(-1, "Unspecified", |
| 377 "The maturity for this library has not been specified."); |
| 378 } |
OLD | NEW |