Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emit constants as Dart constants instead of external getters #294

Merged
merged 2 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion web/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
the `HttpStatus` from the `dart:_internal` library that's exposed only through
`dart:io` and `dart:html`.
- Added `JSImmutableListWrapper` which helps create a dart list from a JS list.
- Deprecated `TouchListWrapper` and `TouchListConvert` in favor of `JSImmutableListWrapper`.
- Deprecated `TouchListWrapper` and `TouchListConvert` in favor of
`JSImmutableListWrapper`.
- Added `[]` and `[]=` overloaded operators to types which define unnamed
`getter`s and `setter`s, respectively.
- Exposed constants with primitive values as non-`external` so they can be
`switch`ed over.

## 1.0.0

Expand Down
6 changes: 3 additions & 3 deletions analysis_options.yaml → web/analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ analyzer:
strict-inference: true
strict-raw-types: true
exclude:
- web/test_fixes/**
- test_fixes/**

errors:
# 43 instances in generated code.
Expand All @@ -18,8 +18,8 @@ analyzer:
lines_longer_than_80_chars: ignore
# 1,333 instances in generated code.
non_constant_identifier_names: ignore
# Consider removing from dart_flutter_team_lints.
unreachable_from_main: ignore
# 1,260 instances in generated code.
constant_identifier_names: ignore

linter:
rules:
Expand Down
2 changes: 1 addition & 1 deletion web/lib/src/dom/angle_instanced_arrays.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import 'webgl1.dart';
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/ANGLE_instanced_arrays).
extension type ANGLE_instanced_arrays._(JSObject _) implements JSObject {
external static GLenum get VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE;
static const GLenum VERTEX_ATTRIB_ARRAY_DIVISOR_ANGLE = 35070;

/// The **`ANGLE_instanced_arrays.drawArraysInstancedANGLE()`** method of the
/// [WebGL API](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API)
Expand Down
41 changes: 27 additions & 14 deletions web/lib/src/dom/cssom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -352,20 +352,33 @@ extension type CSSRuleList._(JSObject _) implements JSObject {
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/CSSRule).
extension type CSSRule._(JSObject _) implements JSObject {
external static int get KEYFRAMES_RULE;
external static int get KEYFRAME_RULE;
external static int get SUPPORTS_RULE;
external static int get COUNTER_STYLE_RULE;
external static int get FONT_FEATURE_VALUES_RULE;
external static int get VIEW_TRANSITION_RULE;
external static int get STYLE_RULE;
external static int get CHARSET_RULE;
external static int get IMPORT_RULE;
external static int get MEDIA_RULE;
external static int get FONT_FACE_RULE;
external static int get PAGE_RULE;
external static int get MARGIN_RULE;
external static int get NAMESPACE_RULE;
static const int KEYFRAMES_RULE = 7;

static const int KEYFRAME_RULE = 8;

static const int SUPPORTS_RULE = 12;

static const int COUNTER_STYLE_RULE = 11;

static const int FONT_FEATURE_VALUES_RULE = 14;

static const int VIEW_TRANSITION_RULE = 15;

static const int STYLE_RULE = 1;

static const int CHARSET_RULE = 2;

static const int IMPORT_RULE = 3;

static const int MEDIA_RULE = 4;

static const int FONT_FACE_RULE = 5;

static const int PAGE_RULE = 6;

static const int MARGIN_RULE = 9;

static const int NAMESPACE_RULE = 10;

/// The **`cssText`** property of the [CSSRule]
/// interface returns the actual text of a [CSSStyleSheet] style-rule.
Expand Down
104 changes: 68 additions & 36 deletions web/lib/src/dom/dom.dart
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ extension type Event._(JSObject _) implements JSObject {
EventInit eventInitDict,
]);

external static int get NONE;
external static int get CAPTURING_PHASE;
external static int get AT_TARGET;
external static int get BUBBLING_PHASE;
static const int NONE = 0;

static const int CAPTURING_PHASE = 1;

static const int AT_TARGET = 2;

static const int BUBBLING_PHASE = 3;

/// The **`composedPath()`** method of the [Event]
/// interface returns the event's path which is an array of the objects on
Expand Down Expand Up @@ -906,24 +909,41 @@ extension type MutationRecord._(JSObject _) implements JSObject {
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/Node).
extension type Node._(JSObject _) implements EventTarget, JSObject {
external static int get ELEMENT_NODE;
external static int get ATTRIBUTE_NODE;
external static int get TEXT_NODE;
external static int get CDATA_SECTION_NODE;
external static int get ENTITY_REFERENCE_NODE;
external static int get ENTITY_NODE;
external static int get PROCESSING_INSTRUCTION_NODE;
external static int get COMMENT_NODE;
external static int get DOCUMENT_NODE;
external static int get DOCUMENT_TYPE_NODE;
external static int get DOCUMENT_FRAGMENT_NODE;
external static int get NOTATION_NODE;
external static int get DOCUMENT_POSITION_DISCONNECTED;
external static int get DOCUMENT_POSITION_PRECEDING;
external static int get DOCUMENT_POSITION_FOLLOWING;
external static int get DOCUMENT_POSITION_CONTAINS;
external static int get DOCUMENT_POSITION_CONTAINED_BY;
external static int get DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC;
static const int ELEMENT_NODE = 1;

static const int ATTRIBUTE_NODE = 2;

static const int TEXT_NODE = 3;

static const int CDATA_SECTION_NODE = 4;

static const int ENTITY_REFERENCE_NODE = 5;

static const int ENTITY_NODE = 6;

static const int PROCESSING_INSTRUCTION_NODE = 7;

static const int COMMENT_NODE = 8;

static const int DOCUMENT_NODE = 9;

static const int DOCUMENT_TYPE_NODE = 10;

static const int DOCUMENT_FRAGMENT_NODE = 11;

static const int NOTATION_NODE = 12;

static const int DOCUMENT_POSITION_DISCONNECTED = 1;

static const int DOCUMENT_POSITION_PRECEDING = 2;

static const int DOCUMENT_POSITION_FOLLOWING = 4;

static const int DOCUMENT_POSITION_CONTAINS = 8;

static const int DOCUMENT_POSITION_CONTAINED_BY = 16;

static const int DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = 32;

/// The **`getRootNode()`** method of the [Node] interface
/// returns the context object's root,
Expand Down Expand Up @@ -4833,10 +4853,13 @@ extension type StaticRange._(JSObject _) implements AbstractRange, JSObject {
extension type Range._(JSObject _) implements AbstractRange, JSObject {
external factory Range();

external static int get START_TO_START;
external static int get START_TO_END;
external static int get END_TO_END;
external static int get END_TO_START;
static const int START_TO_START = 0;

static const int START_TO_END = 1;

static const int END_TO_END = 2;

static const int END_TO_START = 3;

/// The **`Range.getClientRects()`** method returns a list of [DOMRect]
/// objects representing the area of the screen occupied by the
Expand Down Expand Up @@ -5426,16 +5449,25 @@ extension type DOMTokenList._(JSObject _) implements JSObject {
/// API documentation sourced from
/// [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/API/XPathResult).
extension type XPathResult._(JSObject _) implements JSObject {
external static int get ANY_TYPE;
external static int get NUMBER_TYPE;
external static int get STRING_TYPE;
external static int get BOOLEAN_TYPE;
external static int get UNORDERED_NODE_ITERATOR_TYPE;
external static int get ORDERED_NODE_ITERATOR_TYPE;
external static int get UNORDERED_NODE_SNAPSHOT_TYPE;
external static int get ORDERED_NODE_SNAPSHOT_TYPE;
external static int get ANY_UNORDERED_NODE_TYPE;
external static int get FIRST_ORDERED_NODE_TYPE;
static const int ANY_TYPE = 0;

static const int NUMBER_TYPE = 1;

static const int STRING_TYPE = 2;

static const int BOOLEAN_TYPE = 3;

static const int UNORDERED_NODE_ITERATOR_TYPE = 4;

static const int ORDERED_NODE_ITERATOR_TYPE = 5;

static const int UNORDERED_NODE_SNAPSHOT_TYPE = 6;

static const int ORDERED_NODE_SNAPSHOT_TYPE = 7;

static const int ANY_UNORDERED_NODE_TYPE = 8;

static const int FIRST_ORDERED_NODE_TYPE = 9;

/// The **`iterateNext()`** method of the
/// [XPathResult] interface iterates over a node set result and returns the
Expand Down
5 changes: 3 additions & 2 deletions web/lib/src/dom/ext_blend_minmax.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import 'dart:js_interop';
import 'webgl1.dart';

extension type EXT_blend_minmax._(JSObject _) implements JSObject {
external static GLenum get MIN_EXT;
external static GLenum get MAX_EXT;
static const GLenum MIN_EXT = 32775;

static const GLenum MAX_EXT = 32776;
}
11 changes: 7 additions & 4 deletions web/lib/src/dom/ext_color_buffer_half_float.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import 'dart:js_interop';
import 'webgl1.dart';

extension type EXT_color_buffer_half_float._(JSObject _) implements JSObject {
external static GLenum get RGBA16F_EXT;
external static GLenum get RGB16F_EXT;
external static GLenum get FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT;
external static GLenum get UNSIGNED_NORMALIZED_EXT;
static const GLenum RGBA16F_EXT = 34842;

static const GLenum RGB16F_EXT = 34843;

static const GLenum FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE_EXT = 33297;

static const GLenum UNSIGNED_NORMALIZED_EXT = 35863;
}
21 changes: 14 additions & 7 deletions web/lib/src/dom/ext_disjoint_timer_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@ import 'webgl1.dart';

extension type WebGLTimerQueryEXT._(JSObject _) implements JSObject {}
extension type EXT_disjoint_timer_query._(JSObject _) implements JSObject {
external static GLenum get QUERY_COUNTER_BITS_EXT;
external static GLenum get CURRENT_QUERY_EXT;
external static GLenum get QUERY_RESULT_EXT;
external static GLenum get QUERY_RESULT_AVAILABLE_EXT;
external static GLenum get TIME_ELAPSED_EXT;
external static GLenum get TIMESTAMP_EXT;
external static GLenum get GPU_DISJOINT_EXT;
static const GLenum QUERY_COUNTER_BITS_EXT = 34916;

static const GLenum CURRENT_QUERY_EXT = 34917;

static const GLenum QUERY_RESULT_EXT = 34918;

static const GLenum QUERY_RESULT_AVAILABLE_EXT = 34919;

static const GLenum TIME_ELAPSED_EXT = 35007;

static const GLenum TIMESTAMP_EXT = 36392;

static const GLenum GPU_DISJOINT_EXT = 36795;

external WebGLTimerQueryEXT? createQueryEXT();
external void deleteQueryEXT(WebGLTimerQueryEXT? query);
external bool isQueryEXT(WebGLTimerQueryEXT? query);
Expand Down
12 changes: 8 additions & 4 deletions web/lib/src/dom/ext_disjoint_timer_query_webgl2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ import 'webgl2.dart';

extension type EXT_disjoint_timer_query_webgl2._(JSObject _)
implements JSObject {
external static GLenum get QUERY_COUNTER_BITS_EXT;
external static GLenum get TIME_ELAPSED_EXT;
external static GLenum get TIMESTAMP_EXT;
external static GLenum get GPU_DISJOINT_EXT;
static const GLenum QUERY_COUNTER_BITS_EXT = 34916;

static const GLenum TIME_ELAPSED_EXT = 35007;

static const GLenum TIMESTAMP_EXT = 36392;

static const GLenum GPU_DISJOINT_EXT = 36795;

external void queryCounterEXT(
WebGLQuery query,
GLenum target,
Expand Down
11 changes: 7 additions & 4 deletions web/lib/src/dom/ext_srgb.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import 'dart:js_interop';
import 'webgl1.dart';

extension type EXT_sRGB._(JSObject _) implements JSObject {
external static GLenum get SRGB_EXT;
external static GLenum get SRGB_ALPHA_EXT;
external static GLenum get SRGB8_ALPHA8_EXT;
external static GLenum get FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT;
static const GLenum SRGB_EXT = 35904;

static const GLenum SRGB_ALPHA_EXT = 35906;

static const GLenum SRGB8_ALPHA8_EXT = 35907;

static const GLenum FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING_EXT = 33296;
}
11 changes: 7 additions & 4 deletions web/lib/src/dom/ext_texture_compression_bptc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import 'dart:js_interop';
import 'webgl1.dart';

extension type EXT_texture_compression_bptc._(JSObject _) implements JSObject {
external static GLenum get COMPRESSED_RGBA_BPTC_UNORM_EXT;
external static GLenum get COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;
external static GLenum get COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT;
external static GLenum get COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT;
static const GLenum COMPRESSED_RGBA_BPTC_UNORM_EXT = 36492;

static const GLenum COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT = 36493;

static const GLenum COMPRESSED_RGB_BPTC_SIGNED_FLOAT_EXT = 36494;

static const GLenum COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_EXT = 36495;
}
11 changes: 7 additions & 4 deletions web/lib/src/dom/ext_texture_compression_rgtc.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ import 'dart:js_interop';
import 'webgl1.dart';

extension type EXT_texture_compression_rgtc._(JSObject _) implements JSObject {
external static GLenum get COMPRESSED_RED_RGTC1_EXT;
external static GLenum get COMPRESSED_SIGNED_RED_RGTC1_EXT;
external static GLenum get COMPRESSED_RED_GREEN_RGTC2_EXT;
external static GLenum get COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT;
static const GLenum COMPRESSED_RED_RGTC1_EXT = 36283;

static const GLenum COMPRESSED_SIGNED_RED_RGTC1_EXT = 36284;

static const GLenum COMPRESSED_RED_GREEN_RGTC2_EXT = 36285;

static const GLenum COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT = 36286;
}
5 changes: 3 additions & 2 deletions web/lib/src/dom/ext_texture_filter_anisotropic.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import 'webgl1.dart';

extension type EXT_texture_filter_anisotropic._(JSObject _)
implements JSObject {
external static GLenum get TEXTURE_MAX_ANISOTROPY_EXT;
external static GLenum get MAX_TEXTURE_MAX_ANISOTROPY_EXT;
static const GLenum TEXTURE_MAX_ANISOTROPY_EXT = 34046;

static const GLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 34047;
}
23 changes: 15 additions & 8 deletions web/lib/src/dom/ext_texture_norm16.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,19 @@ import 'dart:js_interop';
import 'webgl1.dart';

extension type EXT_texture_norm16._(JSObject _) implements JSObject {
external static GLenum get R16_EXT;
external static GLenum get RG16_EXT;
external static GLenum get RGB16_EXT;
external static GLenum get RGBA16_EXT;
external static GLenum get R16_SNORM_EXT;
external static GLenum get RG16_SNORM_EXT;
external static GLenum get RGB16_SNORM_EXT;
external static GLenum get RGBA16_SNORM_EXT;
static const GLenum R16_EXT = 33322;

static const GLenum RG16_EXT = 33324;

static const GLenum RGB16_EXT = 32852;

static const GLenum RGBA16_EXT = 32859;

static const GLenum R16_SNORM_EXT = 36760;

static const GLenum RG16_SNORM_EXT = 36761;

static const GLenum RGB16_SNORM_EXT = 36762;

static const GLenum RGBA16_SNORM_EXT = 36763;
}
8 changes: 5 additions & 3 deletions web/lib/src/dom/fileapi.dart
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,11 @@ extension type FileList._(JSObject _) implements JSObject {
extension type FileReader._(JSObject _) implements EventTarget, JSObject {
external factory FileReader();

external static int get EMPTY;
external static int get LOADING;
external static int get DONE;
static const int EMPTY = 0;

static const int LOADING = 1;

static const int DONE = 2;

/// The **`readAsArrayBuffer()`** method of the [FileReader] interface is used
/// to start reading the
Expand Down
Loading