From 4b673f21b16476e1bfc5d9277615c2a1483d97ae Mon Sep 17 00:00:00 2001 From: kevmoo Date: Sat, 13 Jun 2026 12:40:09 -0700 Subject: [PATCH 1/9] refactor(node-interop): migrate hand-rolled Node.js bindings to generated Migrates the hand-rolled Node.js interop bindings in `js_interop_gen` to 100% generated bindings, dogfooding the generator on itself. - Added `tool/node_entry.d.ts` declaring the curated Node.js APIs we use. - Added `tool/node_gen.yaml` configuration for generating Node bindings. - Added `tool/update_node_bindings.dart` runner script. - Replaced hand-rolled `fs` and `process` bindings in `lib/src/js/filesystem_api.dart` and `lib/src/js/node.dart` with the generated `lib/src/js/generated/node_api.dart`. - Defined safe options creator helpers in `filesystem_api.dart` to avoid calling non-existent JS constructors at runtime. - Refactored all internal callers of `fs` to use the new generated bindings and helpers, removing extensive manual `.toJS` and `.toDart` conversions for strings and booleans. - Updated integration test expectation `web_types_expected.dart` to match updated JSDoc comments from the new TypeScript package. --- js_interop_gen/lib/src/bcd.dart | 6 +- js_interop_gen/lib/src/dart_main.dart | 41 +++++------- js_interop_gen/lib/src/doc_provider.dart | 15 ++--- js_interop_gen/lib/src/generate_bindings.dart | 24 +++---- .../interop_gen/transform/type_resolver.dart | 16 ++--- js_interop_gen/lib/src/js/filesystem_api.dart | 64 +++++-------------- .../lib/src/js/generated/node_api.dart | 54 ++++++++++++++++ js_interop_gen/lib/src/js/node.dart | 11 ++-- js_interop_gen/lib/src/package-lock.json | 16 +++++ js_interop_gen/lib/src/package.json | 1 + js_interop_gen/lib/src/util.dart | 6 +- .../interop_gen/web_types_expected.dart | 24 +++++++ js_interop_gen/tool/node_entry.d.ts | 41 ++++++++++++ js_interop_gen/tool/node_gen.yaml | 7 ++ js_interop_gen/tool/update_node_bindings.dart | 34 ++++++++++ 15 files changed, 238 insertions(+), 122 deletions(-) create mode 100644 js_interop_gen/lib/src/js/generated/node_api.dart create mode 100644 js_interop_gen/tool/node_entry.d.ts create mode 100644 js_interop_gen/tool/node_gen.yaml create mode 100644 js_interop_gen/tool/update_node_bindings.dart diff --git a/js_interop_gen/lib/src/bcd.dart b/js_interop_gen/lib/src/bcd.dart index bca37405..fb54e4ce 100644 --- a/js_interop_gen/lib/src/bcd.dart +++ b/js_interop_gen/lib/src/bcd.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert' hide json; -import 'dart:js_interop'; import 'js/filesystem_api.dart'; @@ -22,10 +21,7 @@ class BrowserCompatData { required bool generateAll, required String path, }) { - final content = - (fs.readFileSync(path.toJS, JSReadFileOptions(encoding: 'utf8'.toJS)) - as JSString) - .toDart; + final content = fs.readFileSync(path, readFileOptions(encoding: 'utf8')); final contentMap = jsonDecode(content) as Map; final api = (contentMap['api'] as Map).cast(); diff --git a/js_interop_gen/lib/src/dart_main.dart b/js_interop_gen/lib/src/dart_main.dart index 330273ec..d7a814d6 100644 --- a/js_interop_gen/lib/src/dart_main.dart +++ b/js_interop_gen/lib/src/dart_main.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert'; -import 'dart:js_interop'; import 'package:args/args.dart'; import 'package:code_builder/code_builder.dart' as code; @@ -54,13 +53,11 @@ void main(List args) async { if (argResult.wasParsed('config')) { final filename = argResult['config'] as String; - final configContent = - fs.readFileSync( - filename.toJS, - JSReadFileOptions(encoding: 'utf8'.toJS), - ) - as JSString; - final yaml = loadYamlDocument(configContent.toDart); + final configContent = fs.readFileSync( + filename, + readFileOptions(encoding: 'utf8'), + ); + final yaml = loadYamlDocument(configContent); config = YamlConfig.fromYaml( yaml.contents as YamlMap, filename: filename, @@ -109,17 +106,17 @@ Future generateJSInteropBindings(Config config) async { if (dartDeclarations.multiFileOutput) { for (final entry in generatedCodeMap.entries) { fs.writeFileSync( - p.join(configOutput, p.basename(entry.key)).toJS, - entry.value.toJS, + p.join(configOutput, p.basename(entry.key)), + entry.value, ); } } else { final entry = generatedCodeMap.entries.first; - fs.writeFileSync(configOutput.toJS, entry.value.toJS); + fs.writeFileSync(configOutput, entry.value); for (final entry in generatedCodeMap.entries.skip(1)) { fs.writeFileSync( - p.join(p.dirname(configOutput), p.basename(entry.key)).toJS, - entry.value.toJS, + p.join(p.dirname(configOutput), p.basename(entry.key)), + entry.value, ); } } @@ -152,15 +149,15 @@ Future generateIDLBindings({ if (renameMap.isNotEmpty) { final jsonStr = jsonEncode(renameMap); - fs.writeFileSync(renameMapPath.toJS, jsonStr.toJS); + fs.writeFileSync(renameMapPath, jsonStr); } for (var entry in bindings.entries) { final libraryPath = entry.key; final library = entry.value; - final contents = _emitLibrary(library, languageVersion).toJS; - fs.writeFileSync('$output/$libraryPath'.toJS, contents); + final contents = _emitLibrary(library, languageVersion); + fs.writeFileSync('$output/$libraryPath', contents); } } else { final allInputFiles = expandGlobs(input.toList(), extension: '.idl'); @@ -170,13 +167,7 @@ Future generateIDLBindings({ final bindings = await generateBindingsForFiles( { for (final file in allInputFiles) - file: - (fs.readFileSync( - file.toJS, - JSReadFileOptions(encoding: 'utf-8'.toJS), - ) - as JSString) - .toDart, + file: fs.readFileSync(file, readFileOptions(encoding: 'utf-8')), }, output, bcdJsonPath: bcdJsonPath, @@ -186,8 +177,8 @@ Future generateIDLBindings({ final libraryPath = entry.key; final library = entry.value; - final contents = _emitLibrary(library, languageVersion).toJS; - fs.writeFileSync('$output/$libraryPath'.toJS, contents); + final contents = _emitLibrary(library, languageVersion); + fs.writeFileSync('$output/$libraryPath', contents); } } } diff --git a/js_interop_gen/lib/src/doc_provider.dart b/js_interop_gen/lib/src/doc_provider.dart index 109a41e7..8ea752e5 100644 --- a/js_interop_gen/lib/src/doc_provider.dart +++ b/js_interop_gen/lib/src/doc_provider.dart @@ -3,7 +3,6 @@ // BSD-style license that can be found in the LICENSE file. import 'dart:convert'; -import 'dart:js_interop'; import 'package:path/path.dart' as p; @@ -12,14 +11,12 @@ import 'js/filesystem_api.dart'; class DocProvider { static DocProvider create() { - final content = - fs.readFileSync( - p.join('..', '..', '..', 'third_party', 'mdn', 'mdn.json').toJS, - JSReadFileOptions(encoding: 'utf8'.toJS), - ) - as JSString; - - return DocProvider(jsonDecode(content.toDart) as Map); + final content = fs.readFileSync( + p.join('..', '..', '..', 'third_party', 'mdn', 'mdn.json'), + readFileOptions(encoding: 'utf8'), + ); + + return DocProvider(jsonDecode(content) as Map); } final List interfaces = []; diff --git a/js_interop_gen/lib/src/generate_bindings.dart b/js_interop_gen/lib/src/generate_bindings.dart index e658608b..5e91af86 100644 --- a/js_interop_gen/lib/src/generate_bindings.dart +++ b/js_interop_gen/lib/src/generate_bindings.dart @@ -84,14 +84,11 @@ Future<(TranslationResult, Map)> generateBindings( }) async { var renameMap = {}; if (renameMapPath != null) { - if (fs.existsSync(renameMapPath.toJS).toDart) { - final jsonStr = - (fs.readFileSync( - renameMapPath.toJS, - JSReadFileOptions(encoding: 'utf8'.toJS), - ) - as JSString) - .toDart; + if (fs.existsSync(renameMapPath)) { + final jsonStr = fs.readFileSync( + renameMapPath, + readFileOptions(encoding: 'utf8'), + ); final json = jsonDecode(jsonStr) as Map; renameMap = json.map((k, v) => MapEntry(k, v as String)); } @@ -101,13 +98,10 @@ Future<(TranslationResult, Map)> generateBindings( JSObject? elementsData; if (idlJsonPath != null) { - final jsonStr = - (fs.readFileSync( - idlJsonPath.toJS, - JSReadFileOptions(encoding: 'utf8'.toJS), - ) - as JSString) - .toDart; + final jsonStr = fs.readFileSync( + idlJsonPath, + readFileOptions(encoding: 'utf8'), + ); final json = jsonDecode(jsonStr) as Map; idlData = (json['idl'] as Map?)?.jsify() as JSObject?; diff --git a/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart b/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart index 979c06e4..4a5b2ed2 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart @@ -568,17 +568,11 @@ class TypeResolver { // if import there and not this file, imported from specified file final importUrl = !nameImport.endsWith('.d.ts') && - fs - .existsSync( - (p.isAbsolute('$nameImport.d.ts') - ? '$nameImport.d.ts' - : p.join( - p.dirname(transformer.file), - '$nameImport.d.ts', - )) - .toJS, - ) - .toDart + fs.existsSync( + p.isAbsolute('$nameImport.d.ts') + ? '$nameImport.d.ts' + : p.join(p.dirname(transformer.file), '$nameImport.d.ts'), + ) ? '$nameImport.d.ts' : nameImport; final relativePath = diff --git a/js_interop_gen/lib/src/js/filesystem_api.dart b/js_interop_gen/lib/src/js/filesystem_api.dart index e05d9e04..f09781ec 100644 --- a/js_interop_gen/lib/src/js/filesystem_api.dart +++ b/js_interop_gen/lib/src/js/filesystem_api.dart @@ -2,58 +2,28 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -// TODO(srujzs): Remove this workaround once we use an SDK version that contains -// https://github.com/dart-lang/sdk/issues/54801. -@JS() -library; - import 'dart:js_interop'; +import 'generated/node_api.dart' as gen; -@JS() -external FileSystem get fs; - -extension type JSMkdirOptions._(JSObject _) implements JSObject { - external factory JSMkdirOptions({JSBoolean? recursive}); -} - -extension type JSReadFileOptions._(JSObject _) implements JSObject { - external factory JSReadFileOptions({JSString? encoding}); -} - -extension type FileSystem._(JSObject _) implements JSObject { - external JSBoolean existsSync(JSString path); +export 'generated/node_api.dart' + show GlobSyncOptions, MkdirOptions, ReadFileOptions, fs; - @JS('mkdirSync') - external void mkdirSyncOneArg(JSString path); - - @JS('mkdirSync') - external void mkdirSyncTwoArg(JSString path, JSMkdirOptions options); - - void mkdirSync(JSString path, [JSMkdirOptions? options]) { - if (options == null) { - return mkdirSyncOneArg(path); - } else { - return mkdirSyncTwoArg(path, options); - } - } - - external JSAny readFileSync(JSString path, [JSReadFileOptions options]); - - external void writeFileSync(JSString path, JSString contents); - - external JSArray globSync( - JSArray patterns, [ - FSGlobSyncOptions? options, - ]); +// Safe creator helpers for options bags to avoid calling non-existent JS +// constructors. +gen.MkdirOptions mkdirOptions({bool? recursive}) { + final obj = JSObject() as gen.MkdirOptions; + if (recursive != null) obj.recursive = recursive; + return obj; } -extension type FSGlobSyncOptions._(JSObject _) implements JSObject { - external FSGlobSyncOptions({JSString cwd, FSGlobSyncExcludeFunc? exclude}); - - external JSString get cwd; - external JSArray? get exclude; +gen.ReadFileOptions readFileOptions({String? encoding}) { + final obj = JSObject() as gen.ReadFileOptions; + if (encoding != null) obj.encoding = encoding; + return obj; } -extension type FSGlobSyncExcludeFunc(JSFunction _) implements JSFunction { - external bool call(String entry); +gen.GlobSyncOptions globSyncOptions({String? cwd}) { + final obj = JSObject() as gen.GlobSyncOptions; + if (cwd != null) obj.cwd = cwd; + return obj; } diff --git a/js_interop_gen/lib/src/js/generated/node_api.dart b/js_interop_gen/lib/src/js/generated/node_api.dart new file mode 100644 index 00000000..68d10d9b --- /dev/null +++ b/js_interop_gen/lib/src/js/generated/node_api.dart @@ -0,0 +1,54 @@ +// ignore_for_file: camel_case_types, constant_identifier_names +// ignore_for_file: library_private_types_in_public_api +// ignore_for_file: lines_longer_than_80_chars, non_constant_identifier_names +// ignore_for_file: unnecessary_ignore, unnecessary_parenthesis + +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:js_interop' as _i1; + +extension type MkdirOptions._(_i1.JSObject _) implements _i1.JSObject { + external MkdirOptions(); + + external bool? recursive; +} +extension type ReadFileOptions._(_i1.JSObject _) implements _i1.JSObject { + external ReadFileOptions(); + + external String? encoding; +} +extension type GlobSyncOptions._(_i1.JSObject _) implements _i1.JSObject { + external GlobSyncOptions(); + + external String? cwd; + + external _AnonymousFunction_1801294? exclude; +} +extension type fs._(_i1.JSObject _) implements _i1.JSObject { + @_i1.JS() + external static bool existsSync(String path); + @_i1.JS() + external static void mkdirSync(String path, [MkdirOptions? options]); + @_i1.JS() + external static String readFileSync(String path, [ReadFileOptions? options]); + @_i1.JS() + external static void writeFileSync(String path, String contents); + @_i1.JS() + external static _i1.JSArray<_i1.JSString> globSync( + _i1.JSArray<_i1.JSString> patterns, [ + GlobSyncOptions? options, + ]); +} +extension type process._(_i1.JSObject _) implements _i1.JSObject { + @_i1.JS() + external static void exit(num code); +} +extension type console._(_i1.JSObject _) implements _i1.JSObject { + @_i1.JS() + external static void error(String message); +} +@_i1.JS() +external String get url; +extension type _AnonymousFunction_1801294._(_i1.JSFunction _) + implements _i1.JSFunction { + external bool call(String entry); +} diff --git a/js_interop_gen/lib/src/js/node.dart b/js_interop_gen/lib/src/js/node.dart index 81c1ead1..1cffce8b 100644 --- a/js_interop_gen/lib/src/js/node.dart +++ b/js_interop_gen/lib/src/js/node.dart @@ -2,13 +2,10 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -import 'dart:js_interop'; +import 'generated/node_api.dart' as gen; -@JS() -external String get url; +export 'generated/node_api.dart' show url; -@JS('process.exit') -external void exit(int code); +void exit(int code) => gen.process.exit(code); -@JS('console.error') -external void printErr(String message); +void printErr(String message) => gen.console.error(message); diff --git a/js_interop_gen/lib/src/package-lock.json b/js_interop_gen/lib/src/package-lock.json index d33bd22c..048e94c9 100644 --- a/js_interop_gen/lib/src/package-lock.json +++ b/js_interop_gen/lib/src/package-lock.json @@ -9,11 +9,21 @@ "version": "0.0.1", "license": "BSD 3", "dependencies": { + "@types/node": "^22.0.0", "@types/webidl2": "^24.4.4", "typescript": "^5.9.3", "webidl2": "^24.4.1" } }, + "node_modules/@types/node": { + "version": "22.19.21", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.19.21.tgz", + "integrity": "sha512-VMeFBSCKQKmm2swI2kW51SFusDqekC6q9trBCvJ/JliDchFSuoYYKN7yVNjPthP1HKZcx3U1gI/wTcEBjEFKTA==", + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, "node_modules/@types/webidl2": { "version": "24.4.4", "resolved": "https://registry.npmjs.org/@types/webidl2/-/webidl2-24.4.4.tgz", @@ -33,6 +43,12 @@ "node": ">=14.17" } }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "license": "MIT" + }, "node_modules/webidl2": { "version": "24.5.0", "resolved": "https://registry.npmjs.org/webidl2/-/webidl2-24.5.0.tgz", diff --git a/js_interop_gen/lib/src/package.json b/js_interop_gen/lib/src/package.json index 35679be8..6d08f6c9 100644 --- a/js_interop_gen/lib/src/package.json +++ b/js_interop_gen/lib/src/package.json @@ -9,6 +9,7 @@ "author": "Dart project authors", "license": "BSD 3", "dependencies": { + "@types/node": "^22.0.0", "@types/webidl2": "^24.4.4", "typescript": "^5.9.3", "webidl2": "^24.4.1" diff --git a/js_interop_gen/lib/src/util.dart b/js_interop_gen/lib/src/util.dart index 3a4651e8..8e82e541 100644 --- a/js_interop_gen/lib/src/util.dart +++ b/js_interop_gen/lib/src/util.dart @@ -13,8 +13,8 @@ import 'js/filesystem_api.dart'; external JSArray objectEntries(JSObject o); void ensureDirectoryExists(String dir) { - if (!fs.existsSync(dir.toJS).toDart) { - fs.mkdirSync(dir.toJS, JSMkdirOptions(recursive: true.toJS)); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, mkdirOptions(recursive: true)); } } @@ -58,7 +58,7 @@ List expandGlobs( cwd ??= p.current; final globSync = fs.globSync( input.map((i) => i.toJS).toList().toJS, - FSGlobSyncOptions(cwd: cwd.toJS), + globSyncOptions(cwd: cwd), ); return globSync.toDart .map((i) => i.toDart) diff --git a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart index d07d393b..608f7943 100644 --- a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart @@ -101,6 +101,14 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. + /// - [locales]: A locale string, array of locale strings, Intl.Locale + /// object, or array of Intl.Locale objects that contain one or more + /// language or locale tags. If you include more than one locale string, + /// list them in descending order of priority so that the first entry is the + /// preferred locale. If you omit this parameter, the default locale of the + /// JavaScript runtime is used. + /// - [options]: An object that contains one or more properties that specify + /// comparison options. external String toLocaleString(); /// Returns a date as a string value appropriate to the host environment's @@ -113,6 +121,14 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. + /// - [locales]: A locale string, array of locale strings, Intl.Locale + /// object, or array of Intl.Locale objects that contain one or more + /// language or locale tags. If you include more than one locale string, + /// list them in descending order of priority so that the first entry is the + /// preferred locale. If you omit this parameter, the default locale of the + /// JavaScript runtime is used. + /// - [options]: An object that contains one or more properties that specify + /// comparison options. external String toLocaleDateString(); /// Returns a time as a string value appropriate to the host environment's @@ -125,6 +141,14 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. + /// - [locales]: A locale string, array of locale strings, Intl.Locale + /// object, or array of Intl.Locale objects that contain one or more + /// language or locale tags. If you include more than one locale string, + /// list them in descending order of priority so that the first entry is the + /// preferred locale. If you omit this parameter, the default locale of the + /// JavaScript runtime is used. + /// - [options]: An object that contains one or more properties that specify + /// comparison options. external String toLocaleTimeString(); /// Returns the stored time value in milliseconds since midnight, January 1, diff --git a/js_interop_gen/tool/node_entry.d.ts b/js_interop_gen/tool/node_entry.d.ts new file mode 100644 index 00000000..d127ecef --- /dev/null +++ b/js_interop_gen/tool/node_entry.d.ts @@ -0,0 +1,41 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +export class MkdirOptions { + recursive?: boolean; +} + +export class ReadFileOptions { + encoding?: string; +} + +export class GlobSyncOptions { + cwd?: string; + exclude?: (entry: string) => boolean; +} + +// Export curated fs namespace +export namespace fs { + export function existsSync(path: string): boolean; + export function mkdirSync(path: string, options?: MkdirOptions): void; + export function readFileSync(path: string, options?: ReadFileOptions): string; + export function writeFileSync(path: string, contents: string): void; + export function globSync( + patterns: string[], + options?: GlobSyncOptions + ): string[]; +} + +// Export curated process namespace +export namespace process { + export function exit(code: number): void; +} + +// Export curated console namespace +export namespace console { + export function error(message: string): void; +} + +// Export global url (import.meta.url) +export const url: string; diff --git a/js_interop_gen/tool/node_gen.yaml b/js_interop_gen/tool/node_gen.yaml new file mode 100644 index 00000000..f3ad9295 --- /dev/null +++ b/js_interop_gen/tool/node_gen.yaml @@ -0,0 +1,7 @@ +# Configuration file for dogfooded Node.js API bindings generation +name: node_api +description: Pure Node.js bindings generated from curated TypeScript definitions + +input: node_entry.d.ts +output: ../lib/src/js/generated/node_api.dart +language_version: 3.10.0 diff --git a/js_interop_gen/tool/update_node_bindings.dart b/js_interop_gen/tool/update_node_bindings.dart new file mode 100644 index 00000000..ab6adc7b --- /dev/null +++ b/js_interop_gen/tool/update_node_bindings.dart @@ -0,0 +1,34 @@ +// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:io'; +import 'package:js_interop_gen/src/cli.dart'; +import 'package:path/path.dart' as p; + +Future main() async { + final generatorRoot = p.dirname(p.dirname(bindingsGeneratorPath)); + final outputPath = p.join( + bindingsGeneratorPath, + 'js', + 'generated', + 'node_api.dart', + ); + + final outputDir = Directory(p.dirname(outputPath)); + if (!outputDir.existsSync()) { + outputDir.createSync(recursive: true); + } + + print('Generating Node.js interop bindings...'); + print('Config: ${p.join(generatorRoot, 'tool', 'node_gen.yaml')}'); + print('Output: $outputPath'); + + await runProc(Platform.executable, [ + p.join(generatorRoot, 'bin', 'js_interop_gen.dart'), + '--config', + p.join(generatorRoot, 'tool', 'node_gen.yaml'), + ], workingDirectory: generatorRoot); + + print('Done! Pure Node.js bindings successfully generated.'); +} From 531404f504fd75ac78f5ce43b7e15ce8c9b9c59a Mon Sep 17 00:00:00 2001 From: kevmoo Date: Sat, 13 Jun 2026 20:04:52 -0700 Subject: [PATCH 2/9] fix(node-interop): convert options bags from class to interface in node_entry.d.ts --- js_interop_gen/lib/src/js/generated/node_api.dart | 6 ------ js_interop_gen/lib/src/js_type_supertypes.dart | 13 +++++++++---- .../test/integration/idl/methods_expected.dart | 2 +- .../test/integration/idl/union_docs_expected.dart | 2 +- js_interop_gen/tool/node_entry.d.ts | 6 +++--- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/js_interop_gen/lib/src/js/generated/node_api.dart b/js_interop_gen/lib/src/js/generated/node_api.dart index 68d10d9b..45b619e0 100644 --- a/js_interop_gen/lib/src/js/generated/node_api.dart +++ b/js_interop_gen/lib/src/js/generated/node_api.dart @@ -7,18 +7,12 @@ import 'dart:js_interop' as _i1; extension type MkdirOptions._(_i1.JSObject _) implements _i1.JSObject { - external MkdirOptions(); - external bool? recursive; } extension type ReadFileOptions._(_i1.JSObject _) implements _i1.JSObject { - external ReadFileOptions(); - external String? encoding; } extension type GlobSyncOptions._(_i1.JSObject _) implements _i1.JSObject { - external GlobSyncOptions(); - external String? cwd; external _AnonymousFunction_1801294? exclude; diff --git a/js_interop_gen/lib/src/js_type_supertypes.dart b/js_interop_gen/lib/src/js_type_supertypes.dart index 43250215..be240f2f 100644 --- a/js_interop_gen/lib/src/js_type_supertypes.dart +++ b/js_interop_gen/lib/src/js_type_supertypes.dart @@ -3,12 +3,12 @@ // BSD-style license that can be found in the LICENSE file. // Generated code. Do not modify by hand. -// Generated from Dart SDK 3.10.0 -// To update run: dart run tool/update_supertypes.dart +// Generated from Dart SDK 3.13.0-184.0.dev +// To update run: dart run js_interop_gen/tool/update_supertypes.dart const Map jsTypeSupertypes = { 'JSAny': null, - 'JSArray': 'JSObject', + 'JSArray': 'JSIterable', 'JSArrayBuffer': 'JSObject', 'JSBigInt': 'JSAny', 'JSBoolean': 'JSAny', @@ -21,10 +21,15 @@ const Map jsTypeSupertypes = { 'JSInt16Array': 'JSTypedArray', 'JSInt32Array': 'JSTypedArray', 'JSInt8Array': 'JSTypedArray', + 'JSIterable': 'JSIterableProtocol', + 'JSIterableProtocol': 'JSAny', + 'JSIterator': 'JSIterable', + 'JSIteratorProtocol': 'JSAny', + 'JSIteratorResult': 'JSObject', 'JSNumber': 'JSAny', 'JSObject': 'JSAny', 'JSPromise': 'JSObject', - 'JSString': 'JSAny', + 'JSString': 'JSIterable', 'JSSymbol': 'JSAny', 'JSTypedArray': 'JSObject', 'JSUint16Array': 'JSTypedArray', diff --git a/js_interop_gen/test/integration/idl/methods_expected.dart b/js_interop_gen/test/integration/idl/methods_expected.dart index e71a0ec4..857f74a8 100644 --- a/js_interop_gen/test/integration/idl/methods_expected.dart +++ b/js_interop_gen/test/integration/idl/methods_expected.dart @@ -19,7 +19,7 @@ extension type MyMethodExamples._(JSObject _) implements JSObject { JSAny? extra3, JSAny? extra4, ]); - external void update(JSAny keyOrKeys, [String value]); + external void update(JSIterable keyOrKeys, [String value]); external JSPromise fetchRemoteValue([String? endpoint]); external void init(); } diff --git a/js_interop_gen/test/integration/idl/union_docs_expected.dart b/js_interop_gen/test/integration/idl/union_docs_expected.dart index ddc410bf..8bf97d71 100644 --- a/js_interop_gen/test/integration/idl/union_docs_expected.dart +++ b/js_interop_gen/test/integration/idl/union_docs_expected.dart @@ -31,7 +31,7 @@ typedef PrimitiveUnion = JSAny; /// /// - [JSArray]\<[JSString]\> /// - [JSObject]\<[JSString], [JSString]\> -typedef GenericUnion = JSObject; +typedef GenericUnion = JSAny; /// Union of: [JSInt16Array], [JSInt32Array], [JSInt8Array], [JSString] typedef NonCollapsingLongUnion = JSAny; diff --git a/js_interop_gen/tool/node_entry.d.ts b/js_interop_gen/tool/node_entry.d.ts index d127ecef..92b44078 100644 --- a/js_interop_gen/tool/node_entry.d.ts +++ b/js_interop_gen/tool/node_entry.d.ts @@ -2,15 +2,15 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. -export class MkdirOptions { +export interface MkdirOptions { recursive?: boolean; } -export class ReadFileOptions { +export interface ReadFileOptions { encoding?: string; } -export class GlobSyncOptions { +export interface GlobSyncOptions { cwd?: string; exclude?: (entry: string) => boolean; } From 9451292fe49cdc8d1a04b2d2dac5cf98baf64538 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Tue, 30 Jun 2026 16:15:47 -0700 Subject: [PATCH 3/9] fix(js_interop_gen): emit UpperCamelCase types and interface constructors - Updated generator to emit UpperCamelCase extension type names (Fs, Process, Console) with explicit @JS(...) namespace annotations for TypeScript namespaces. - Updated generator to automatically emit external factory constructors for TypeScript interface extension types. - Removed hand-rolled helper functions in favor of direct options bag constructors and direct imports. - Updated test expectation goldens. --- js_interop_gen/lib/src/ast/declarations.dart | 27 ++++++++++------- js_interop_gen/lib/src/bcd.dart | 4 +-- js_interop_gen/lib/src/dart_main.dart | 21 +++++++------- js_interop_gen/lib/src/doc_provider.dart | 6 ++-- js_interop_gen/lib/src/generate_bindings.dart | 12 ++++---- .../lib/src/interop_gen/parser.dart | 12 ++++---- .../transform/namespace_flattener.dart | 3 +- .../interop_gen/transform/transformer.dart | 1 + .../interop_gen/transform/type_resolver.dart | 4 +-- js_interop_gen/lib/src/js/filesystem_api.dart | 29 ------------------- .../lib/src/js/generated/node_api.dart | 15 ++++++++-- js_interop_gen/lib/src/js/node.dart | 11 ------- js_interop_gen/lib/src/util.dart | 10 +++---- .../test/assets/test_overrides_golden.dart | 4 +++ .../assets/unsupported_test_expected.dart | 4 +++ .../boolean_literal_union_expected.dart | 7 +++++ .../interop_gen/classes_expected.dart | 20 ++++++++++++- .../duplicate_implements_expected.dart | 8 +++++ .../duplicate_references_expected.dart | 18 +++++++++--- .../empty_deprecation_expected.dart | 2 ++ .../generic_builtin_arguments_expected.dart | 2 ++ .../generic_builtin_blindspot_expected.dart | 7 +++++ .../generic_interface_merge_expected.dart | 2 ++ .../generic_parameter_padding_expected.dart | 7 +++++ ...ic_type_arguments_dependency_expected.dart | 6 +++- .../generic_union_casting_expected.dart | 9 +++++- .../interop_gen/generic_union_expected.dart | 11 ++++++- .../homogeneous_union_arrays_expected.dart | 6 ++++ .../interop_gen/import_export_expected.dart | 24 ++++++++++++++- .../indexed_access_test_expected.dart | 6 ++++ .../interop_gen/interfaces_expected.dart | 22 ++++++++++++++ ...intersection_member_conflict_expected.dart | 12 ++++++++ ...tion_object_literal_conflict_expected.dart | 2 ++ .../interop_gen/jsdoc_expected.dart | 10 +++++++ .../module_generic_param_expected.dart | 5 +++- .../interop_gen/namespaces_expected.dart | 21 +++++++++++++- .../nullable_union_typearg_expected.dart | 4 +++ .../interop_gen/overload_expected.dart | 16 ++++++++-- .../private_names_escaping_expected.dart | 4 +++ .../interop_gen/project/output/a.dart | 14 ++++++++- .../interop_gen/project/output/b.dart | 24 +++++++++++++-- .../interop_gen/project/output/c.dart | 20 +++++++++++++ ...resentation_type_inheritance_expected.dart | 4 +++ .../interop_gen/rescope_dedup_expected.dart | 2 ++ .../string_literal_module_expected.dart | 2 ++ .../interop_gen/string_literals_expected.dart | 8 +++++ .../interop_gen/ts_typing_expected.dart | 5 +++- .../type_arguments_nullability_expected.dart | 4 +++ .../interop_gen/typealias_expected.dart | 2 ++ .../typealias_namespace_nested_expected.dart | 22 ++++++++------ .../union_constraint_override_expected.dart | 9 +++++- .../unsupported_properties_expected.dart | 2 ++ .../void_generic_bounds_expected.dart | 4 +++ .../vscode_flattening_expected.dart | 29 ++++++++++++------- .../interop_gen/web_types_expected.dart | 13 +++++++++ 55 files changed, 430 insertions(+), 128 deletions(-) delete mode 100644 js_interop_gen/lib/src/js/filesystem_api.dart delete mode 100644 js_interop_gen/lib/src/js/node.dart diff --git a/js_interop_gen/lib/src/ast/declarations.dart b/js_interop_gen/lib/src/ast/declarations.dart index c1d6f2ca..56d066da 100644 --- a/js_interop_gen/lib/src/ast/declarations.dart +++ b/js_interop_gen/lib/src/ast/declarations.dart @@ -177,21 +177,26 @@ sealed class TypeDeclaration extends NestableDeclaration typeParameters.map((t) => t.emit(options?.toTypeOptions())), ) ..constructors.addAll([ - if (objectLiteralConstructor) + if (objectLiteralConstructor && + !constructors.any((c) => c.name == null || c.name!.isEmpty)) Constructor( (c) => c ..external = true ..optionalParameters.addAll( - properties - .where((p) => p.scope == DeclScope.public) - .map( - (p) => Parameter( - (param) => param - ..named = true - ..name = p.name - ..type = p.type.emit(options?.toTypeOptions()), - ), - ), + properties.where((p) => p.scope == DeclScope.public).map((p) { + final paramName = + p.dartName ?? UniqueNamer.makeNonConflicting(p.name); + return Parameter( + (param) => param + ..named = true + ..name = paramName + ..annotations.addAll([ + if (p.dartName != null && p.dartName != p.name) + generateJSAnnotation(p.name), + ]) + ..type = p.type.emit(options?.toTypeOptions()), + ); + }), ), ), if (!abstract) diff --git a/js_interop_gen/lib/src/bcd.dart b/js_interop_gen/lib/src/bcd.dart index fb54e4ce..3705fe06 100644 --- a/js_interop_gen/lib/src/bcd.dart +++ b/js_interop_gen/lib/src/bcd.dart @@ -4,7 +4,7 @@ import 'dart:convert' hide json; -import 'js/filesystem_api.dart'; +import 'js/generated/node_api.dart'; /// A class to read from the browser-compat-data files and parse interface and /// property status (standards track, experimental, deprecated) and supported @@ -21,7 +21,7 @@ class BrowserCompatData { required bool generateAll, required String path, }) { - final content = fs.readFileSync(path, readFileOptions(encoding: 'utf8')); + final content = Fs.readFileSync(path, ReadFileOptions(encoding: 'utf8')); final contentMap = jsonDecode(content) as Map; final api = (contentMap['api'] as Map).cast(); diff --git a/js_interop_gen/lib/src/dart_main.dart b/js_interop_gen/lib/src/dart_main.dart index d7a814d6..2b5405cf 100644 --- a/js_interop_gen/lib/src/dart_main.dart +++ b/js_interop_gen/lib/src/dart_main.dart @@ -15,8 +15,7 @@ import 'config.dart'; import 'generate_bindings.dart'; import 'interop_gen/parser.dart'; import 'interop_gen/transform.dart'; -import 'js/filesystem_api.dart'; -import 'js/node.dart'; +import 'js/generated/node_api.dart'; import 'util.dart'; // Generates DOM and JS interop bindings for Dart. @@ -53,9 +52,9 @@ void main(List args) async { if (argResult.wasParsed('config')) { final filename = argResult['config'] as String; - final configContent = fs.readFileSync( + final configContent = Fs.readFileSync( filename, - readFileOptions(encoding: 'utf8'), + ReadFileOptions(encoding: 'utf8'), ); final yaml = loadYamlDocument(configContent); config = YamlConfig.fromYaml( @@ -105,16 +104,16 @@ Future generateJSInteropBindings(Config config) async { // write code to file if (dartDeclarations.multiFileOutput) { for (final entry in generatedCodeMap.entries) { - fs.writeFileSync( + Fs.writeFileSync( p.join(configOutput, p.basename(entry.key)), entry.value, ); } } else { final entry = generatedCodeMap.entries.first; - fs.writeFileSync(configOutput, entry.value); + Fs.writeFileSync(configOutput, entry.value); for (final entry in generatedCodeMap.entries.skip(1)) { - fs.writeFileSync( + Fs.writeFileSync( p.join(p.dirname(configOutput), p.basename(entry.key)), entry.value, ); @@ -149,7 +148,7 @@ Future generateIDLBindings({ if (renameMap.isNotEmpty) { final jsonStr = jsonEncode(renameMap); - fs.writeFileSync(renameMapPath, jsonStr); + Fs.writeFileSync(renameMapPath, jsonStr); } for (var entry in bindings.entries) { @@ -157,7 +156,7 @@ Future generateIDLBindings({ final library = entry.value; final contents = _emitLibrary(library, languageVersion); - fs.writeFileSync('$output/$libraryPath', contents); + Fs.writeFileSync('$output/$libraryPath', contents); } } else { final allInputFiles = expandGlobs(input.toList(), extension: '.idl'); @@ -167,7 +166,7 @@ Future generateIDLBindings({ final bindings = await generateBindingsForFiles( { for (final file in allInputFiles) - file: fs.readFileSync(file, readFileOptions(encoding: 'utf-8')), + file: Fs.readFileSync(file, ReadFileOptions(encoding: 'utf-8')), }, output, bcdJsonPath: bcdJsonPath, @@ -178,7 +177,7 @@ Future generateIDLBindings({ final library = entry.value; final contents = _emitLibrary(library, languageVersion); - fs.writeFileSync('$output/$libraryPath', contents); + Fs.writeFileSync('$output/$libraryPath', contents); } } } diff --git a/js_interop_gen/lib/src/doc_provider.dart b/js_interop_gen/lib/src/doc_provider.dart index 8ea752e5..2450f264 100644 --- a/js_interop_gen/lib/src/doc_provider.dart +++ b/js_interop_gen/lib/src/doc_provider.dart @@ -7,13 +7,13 @@ import 'dart:convert'; import 'package:path/path.dart' as p; import 'formatting.dart'; -import 'js/filesystem_api.dart'; +import 'js/generated/node_api.dart'; class DocProvider { static DocProvider create() { - final content = fs.readFileSync( + final content = Fs.readFileSync( p.join('..', '..', '..', 'third_party', 'mdn', 'mdn.json'), - readFileOptions(encoding: 'utf8'), + ReadFileOptions(encoding: 'utf8'), ); return DocProvider(jsonDecode(content) as Map); diff --git a/js_interop_gen/lib/src/generate_bindings.dart b/js_interop_gen/lib/src/generate_bindings.dart index 5e91af86..7e226b82 100644 --- a/js_interop_gen/lib/src/generate_bindings.dart +++ b/js_interop_gen/lib/src/generate_bindings.dart @@ -6,7 +6,7 @@ import 'dart:convert'; import 'dart:js_interop'; import 'package:path/path.dart' as p; -import 'js/filesystem_api.dart'; +import 'js/generated/node_api.dart'; import 'js/webidl2.dart' as webidl2; import 'js/webidl_api.dart' as webidl; import 'js/webref_css_api.dart'; @@ -84,10 +84,10 @@ Future<(TranslationResult, Map)> generateBindings( }) async { var renameMap = {}; if (renameMapPath != null) { - if (fs.existsSync(renameMapPath)) { - final jsonStr = fs.readFileSync( + if (Fs.existsSync(renameMapPath)) { + final jsonStr = Fs.readFileSync( renameMapPath, - readFileOptions(encoding: 'utf8'), + ReadFileOptions(encoding: 'utf8'), ); final json = jsonDecode(jsonStr) as Map; renameMap = json.map((k, v) => MapEntry(k, v as String)); @@ -98,9 +98,9 @@ Future<(TranslationResult, Map)> generateBindings( JSObject? elementsData; if (idlJsonPath != null) { - final jsonStr = fs.readFileSync( + final jsonStr = Fs.readFileSync( idlJsonPath, - readFileOptions(encoding: 'utf8'), + ReadFileOptions(encoding: 'utf8'), ); final json = jsonDecode(jsonStr) as Map; diff --git a/js_interop_gen/lib/src/interop_gen/parser.dart b/js_interop_gen/lib/src/interop_gen/parser.dart index 837e4d9c..25a61b34 100644 --- a/js_interop_gen/lib/src/interop_gen/parser.dart +++ b/js_interop_gen/lib/src/interop_gen/parser.dart @@ -7,7 +7,7 @@ import 'dart:js_interop'; import 'package:path/path.dart' as p; import '../config.dart'; -import '../js/node.dart'; +import '../js/generated/node_api.dart'; import '../js/typescript.dart' as ts; class ParserResult { @@ -48,7 +48,7 @@ ParserResult parseDeclarationFiles(Config config) { // handle any diagnostics handleDiagnostics(diagnostics); if (!ignoreErrors && diagnostics.isNotEmpty) { - exit(1); + Process.exit(1); } } } else if (config.tsConfig case final tsConfig? @@ -67,7 +67,7 @@ ParserResult parseDeclarationFiles(Config config) { // handle any diagnostics handleDiagnostics(diagnostics); if (!ignoreErrors && diagnostics.isNotEmpty) { - exit(1); + Process.exit(1); } } @@ -88,7 +88,7 @@ ParserResult parseDeclarationFiles(Config config) { if (diagnostics.isNotEmpty && !ignoreErrors) { // exit - exit(1); + Process.exit(1); } return ParserResult(program: program, files: files); @@ -103,7 +103,7 @@ void handleDiagnostics(List diagnostics) { diagnostic.messageText, '\n', ); - printErr( + Console.error( '${diagnosticFile.fileName} ' '(${line.toDartInt + 1},${char.toDartInt + 1}): $message', ); @@ -112,7 +112,7 @@ void handleDiagnostics(List diagnostics) { diagnostic.messageText, '\n', ); - printErr('(anonymous): $message'); + Console.error('(anonymous): $message'); } } } diff --git a/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart b/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart index 0fd73293..4335362a 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart @@ -7,6 +7,7 @@ import 'dart:js_interop'; import '../../ast/declarations.dart'; import '../../js/helpers.dart'; import '../../js/typescript.types.dart'; +import '../../util.dart'; import '../namer.dart'; import 'transformer.dart'; @@ -39,7 +40,7 @@ class NamespaceFlattener { .whereType(); final (name: dartName, :id) = currentNamespaces.isEmpty - ? namer.makeUnique(namespaceName, 'namespace') + ? namer.makeUnique(capitalize(namespaceName), 'namespace') : (name: null, id: null); final scopedNamer = ScopedUniqueNamer(); diff --git a/js_interop_gen/lib/src/interop_gen/transform/transformer.dart b/js_interop_gen/lib/src/interop_gen/transform/transformer.dart index fda3b42a..ed808563 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/transformer.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/transformer.dart @@ -387,6 +387,7 @@ class Transformer { operators: [], constructors: [], documentation: _parseAndTransformDocumentation(typeDecl), + objectLiteralConstructor: true, ) : ClassDeclaration( name: name, diff --git a/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart b/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart index 4a5b2ed2..48241287 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart @@ -14,7 +14,7 @@ import '../../ast/helpers.dart'; import '../../ast/merger.dart'; import '../../ast/types.dart'; import '../../js/annotations.dart'; -import '../../js/filesystem_api.dart'; +import '../../js/generated/node_api.dart'; import '../../js/typescript.dart' as ts; import '../../js/typescript.types.dart'; import '../../translator.dart'; @@ -568,7 +568,7 @@ class TypeResolver { // if import there and not this file, imported from specified file final importUrl = !nameImport.endsWith('.d.ts') && - fs.existsSync( + Fs.existsSync( p.isAbsolute('$nameImport.d.ts') ? '$nameImport.d.ts' : p.join(p.dirname(transformer.file), '$nameImport.d.ts'), diff --git a/js_interop_gen/lib/src/js/filesystem_api.dart b/js_interop_gen/lib/src/js/filesystem_api.dart deleted file mode 100644 index f09781ec..00000000 --- a/js_interop_gen/lib/src/js/filesystem_api.dart +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'dart:js_interop'; -import 'generated/node_api.dart' as gen; - -export 'generated/node_api.dart' - show GlobSyncOptions, MkdirOptions, ReadFileOptions, fs; - -// Safe creator helpers for options bags to avoid calling non-existent JS -// constructors. -gen.MkdirOptions mkdirOptions({bool? recursive}) { - final obj = JSObject() as gen.MkdirOptions; - if (recursive != null) obj.recursive = recursive; - return obj; -} - -gen.ReadFileOptions readFileOptions({String? encoding}) { - final obj = JSObject() as gen.ReadFileOptions; - if (encoding != null) obj.encoding = encoding; - return obj; -} - -gen.GlobSyncOptions globSyncOptions({String? cwd}) { - final obj = JSObject() as gen.GlobSyncOptions; - if (cwd != null) obj.cwd = cwd; - return obj; -} diff --git a/js_interop_gen/lib/src/js/generated/node_api.dart b/js_interop_gen/lib/src/js/generated/node_api.dart index 45b619e0..9ca19132 100644 --- a/js_interop_gen/lib/src/js/generated/node_api.dart +++ b/js_interop_gen/lib/src/js/generated/node_api.dart @@ -7,17 +7,24 @@ import 'dart:js_interop' as _i1; extension type MkdirOptions._(_i1.JSObject _) implements _i1.JSObject { + external MkdirOptions({bool recursive}); + external bool? recursive; } extension type ReadFileOptions._(_i1.JSObject _) implements _i1.JSObject { + external ReadFileOptions({String encoding}); + external String? encoding; } extension type GlobSyncOptions._(_i1.JSObject _) implements _i1.JSObject { + external GlobSyncOptions({String cwd, _AnonymousFunction_1801294 exclude}); + external String? cwd; external _AnonymousFunction_1801294? exclude; } -extension type fs._(_i1.JSObject _) implements _i1.JSObject { +@_i1.JS('fs') +extension type Fs._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static bool existsSync(String path); @_i1.JS() @@ -32,11 +39,13 @@ extension type fs._(_i1.JSObject _) implements _i1.JSObject { GlobSyncOptions? options, ]); } -extension type process._(_i1.JSObject _) implements _i1.JSObject { +@_i1.JS('process') +extension type Process._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static void exit(num code); } -extension type console._(_i1.JSObject _) implements _i1.JSObject { +@_i1.JS('console') +extension type Console._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static void error(String message); } diff --git a/js_interop_gen/lib/src/js/node.dart b/js_interop_gen/lib/src/js/node.dart deleted file mode 100644 index 1cffce8b..00000000 --- a/js_interop_gen/lib/src/js/node.dart +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file -// for details. All rights reserved. Use of this source code is governed by a -// BSD-style license that can be found in the LICENSE file. - -import 'generated/node_api.dart' as gen; - -export 'generated/node_api.dart' show url; - -void exit(int code) => gen.process.exit(code); - -void printErr(String message) => gen.console.error(message); diff --git a/js_interop_gen/lib/src/util.dart b/js_interop_gen/lib/src/util.dart index 8e82e541..bd7927c1 100644 --- a/js_interop_gen/lib/src/util.dart +++ b/js_interop_gen/lib/src/util.dart @@ -6,15 +6,15 @@ import 'dart:js_interop'; import 'package:path/path.dart' as p; -import 'js/filesystem_api.dart'; +import 'js/generated/node_api.dart'; // TODO(joshualitt): Let's find a better place for these. @JS('Object.entries') external JSArray objectEntries(JSObject o); void ensureDirectoryExists(String dir) { - if (!fs.existsSync(dir)) { - fs.mkdirSync(dir, mkdirOptions(recursive: true)); + if (!Fs.existsSync(dir)) { + Fs.mkdirSync(dir, MkdirOptions(recursive: true)); } } @@ -56,9 +56,9 @@ List expandGlobs( required String extension, }) { cwd ??= p.current; - final globSync = fs.globSync( + final globSync = Fs.globSync( input.map((i) => i.toJS).toList().toJS, - globSyncOptions(cwd: cwd), + GlobSyncOptions(cwd: cwd), ); return globSync.toDart .map((i) => i.toDart) diff --git a/js_interop_gen/test/assets/test_overrides_golden.dart b/js_interop_gen/test/assets/test_overrides_golden.dart index 889a150e..dbcbb1aa 100644 --- a/js_interop_gen/test/assets/test_overrides_golden.dart +++ b/js_interop_gen/test/assets/test_overrides_golden.dart @@ -12,11 +12,15 @@ import 'dart:js_interop' as _i1; extension type ConfigDetails._(_i1.JSObject _) implements _i1.JSObject { + external ConfigDetails({Role role, AnonymousUnion_2683278 conflictProp}); + external Role role; external String conflictProp; } extension type RHS._(_i1.JSObject _) implements _i1.JSObject { + external RHS({AnonymousUnion_3235362 value}); + external String value; } extension type const Role._(int _) { diff --git a/js_interop_gen/test/assets/unsupported_test_expected.dart b/js_interop_gen/test/assets/unsupported_test_expected.dart index ae918572..ce696d28 100644 --- a/js_interop_gen/test/assets/unsupported_test_expected.dart +++ b/js_interop_gen/test/assets/unsupported_test_expected.dart @@ -5,6 +5,8 @@ import 'dart:js_interop' as _i1; extension type Foo._(_i1.JSObject _) implements _i1.JSObject { + external Foo({String name, double length, _i1.JSArrayBuffer raw}); + external String name; external double length; @@ -12,5 +14,7 @@ extension type Foo._(_i1.JSObject _) implements _i1.JSObject { external _i1.JSArrayBuffer raw; } extension type Fee._(_i1.JSObject _) implements _i1.JSObject { + external Fee({_i1.JSAny raw}); + external _i1.JSAny raw; } diff --git a/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart b/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart index db59b0ea..45bca9d9 100644 --- a/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart @@ -7,6 +7,13 @@ import 'dart:js_interop' as _i1; extension type PresentationOptions._(_i1.JSObject _) implements _i1.JSObject { + external PresentationOptions({ + AnonymousUnion_3982518 createIfNone, + AnonymousUnion_3062264 stringUnion, + AnonymousUnion_2379119 intUnion, + AnonymousUnion_8514031 doubleUnion, + }); + external AnonymousUnion_3982518 createIfNone; external AnonymousUnion_3062264 stringUnion; diff --git a/js_interop_gen/test/integration/interop_gen/classes_expected.dart b/js_interop_gen/test/integration/interop_gen/classes_expected.dart index b5cad8c5..6da3be4c 100644 --- a/js_interop_gen/test/integration/interop_gen/classes_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/classes_expected.dart @@ -9,12 +9,18 @@ import 'dart:js_interop' as _i1; import 'package:meta/meta.dart' as _i2; extension type Point2D._(_i1.JSObject _) implements _i1.JSObject { + external Point2D({double x, double y}); + external double x; external double y; } -extension type Shape._(_i1.JSObject _) implements _i1.JSObject {} +extension type Shape._(_i1.JSObject _) implements _i1.JSObject { + external Shape(); +} extension type Shape2D._(_i1.JSObject _) implements Shape { + external Shape2D({double sides}); + external double? get sides; external double get perimeter; external double get area; @@ -53,6 +59,8 @@ extension type Square._(_i1.JSObject _) implements Rectangle { @_i1.JS() external Square drawSquare(Point2D start, num length, [num? angle]); extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { + external Point3D({double x, double y, double z}); + external double x; external double y; @@ -60,6 +68,8 @@ extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { external double z; } extension type Shape3D._(_i1.JSObject _) implements Shape { + external Shape3D(); + external double get volume; external double surfaceArea(); } @@ -174,6 +184,8 @@ external Point2D get origin2D; @_i1.JS() external Point3D get origin3D; extension type Vector._(_i1.JSObject _) implements _i1.JSObject { + external Vector(); + external double get magnitude; external double get directionAngle; } @@ -213,6 +225,8 @@ extension type Vector3D._(_i1.JSObject _) implements Vector { external static Vector3D fromPoints(Point3D start, Point3D end); } extension type DirectionAngles._(_i1.JSObject _) implements _i1.JSObject { + external DirectionAngles({double alpha, double beta, double gamma}); + external double alpha; external double beta; @@ -266,6 +280,8 @@ extension type const AnonymousUnion_7177595._(String _) { } extension type Epahs._(_i1.JSObject _) implements _i1.JSObject { + external Epahs({String id, String name}); + external String name; external String get id; @@ -281,5 +297,7 @@ extension type const AnonymousUnion_4033716._(String _) { } extension type Container._(_i1.JSObject _) implements _i1.JSObject { + external Container({T value}); + external T value; } diff --git a/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart b/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart index ef841d8f..6bfd35fc 100644 --- a/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart @@ -7,15 +7,23 @@ import 'dart:js_interop' as _i1; extension type Grandparent._(_i1.JSObject _) implements _i1.JSObject { + external Grandparent({String grandparentProp}); + external String grandparentProp; } extension type ParentA._(_i1.JSObject _) implements Grandparent { + external ParentA({String aProp}); + external String aProp; } extension type ParentB._(_i1.JSObject _) implements Grandparent { + external ParentB({String bProp}); + external String bProp; } extension type Child._(_i1.JSObject _) implements ParentA, ParentB { + external Child({String childProp}); + external String childProp; } typedef UnionWithDuplicates = AnonymousUnion_2488765; diff --git a/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart b/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart index bdce1fe1..493319af 100644 --- a/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart @@ -12,6 +12,8 @@ import 'dart:js_interop' as _i1; extension type Thenable._(_i1.JSObject _) implements _i1.JSObject { + external Thenable(); + external Thenable> then([ _AnonymousFunction_2123872? onfulfilled, @@ -24,12 +26,17 @@ extension type Uri._(_i1.JSObject _) implements _i1.JSObject { external static Uri parse(String value); } extension type TextDocument._(_i1.JSObject _) implements _i1.JSObject { + external TextDocument({Uri uri}); + external Uri get uri; } extension type TextEditor._(_i1.JSObject _) implements _i1.JSObject { + external TextEditor({TextDocument document}); + external TextDocument get document; } -extension type workspace._(_i1.JSObject _) implements _i1.JSObject { +@_i1.JS('workspace') +extension type Workspace._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static Thenable openTextDocument(Uri uri); } @@ -41,12 +48,14 @@ extension type _AnonymousFunction_2123872< } extension type _AnonymousFunction_1873223._( _i1.JSFunction _ -) implements _i1.JSFunction { +) + implements _i1.JSFunction { external AnonymousUnion_3247291 call(_i1.JSAny? reason); } extension type AnonymousUnion_3247291._( _i1.JSAny _ -) implements _i1.JSAny { +) + implements _i1.JSAny { TResult2 get asTResult2 => (_ as TResult2); Thenable get asThenableOfTResult2 => (_ as Thenable); @@ -61,7 +70,8 @@ extension type AnonymousUnion_3555654< } extension type AnonymousUnion_2658987._( _i1.JSAny _ -) implements _i1.JSAny { +) + implements _i1.JSAny { TResult1 get asTResult1 => (_ as TResult1); Thenable get asThenableOfTResult1 => (_ as Thenable); diff --git a/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart b/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart index 1c854fce..2ff85436 100644 --- a/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart @@ -8,5 +8,7 @@ import 'dart:js_interop' as _i1; 'This declaration has been marked as deprecated in the original JS/TS code', ) extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { + external Wrapper({String value}); + external String value; } diff --git a/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart index 6cf20884..b86b40d6 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart @@ -5,5 +5,7 @@ import 'dart:js_interop' as _i1; extension type Resource._(_i1.JSObject _) implements _i1.JSObject { + external Resource({_i1.JSPromise<_i1.JSString> promise}); + external _i1.JSPromise<_i1.JSString> promise; } diff --git a/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart index 230d5fa8..ac3a238f 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart @@ -5,9 +5,16 @@ import 'dart:js_interop' as _i1; extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { + external Wrapper({String value}); + external String value; } extension type Container._(_i1.JSObject _) implements _i1.JSObject { + external Container({ + _i1.JSArray arrays, + _i1.JSPromise promises, + }); + external _i1.JSArray arrays; external _i1.JSPromise promises; diff --git a/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart index c70a5189..7d5b6e5f 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart @@ -6,6 +6,8 @@ import 'dart:js_interop' as _i1; extension type Container._(_i1.JSObject _) implements _i1.JSObject { + external Container({T value, T originalVal, T anotherVal}); + external T value; external T originalVal; diff --git a/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart index 1b361171..81d56551 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart @@ -9,11 +9,18 @@ extension type Wrapper< TReturn extends _i1.JSAny?, TNext extends _i1.JSAny? >._(_i1.JSObject _) implements _i1.JSObject { + external Wrapper({ + T value, + Wrapper<_i1.JSString, _i1.JSAny?, _i1.JSAny?> stream, + }); + external T value; external Wrapper<_i1.JSString, _i1.JSAny?, _i1.JSAny?> stream; } extension type BoundWrapper._(_i1.JSObject _) implements _i1.JSObject { + external BoundWrapper({BoundWrapper<_i1.JSString> value}); + external BoundWrapper<_i1.JSString> value; } diff --git a/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart index 2c1a8d15..ddd63540 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart @@ -8,13 +8,17 @@ import 'dart:js_interop' as _i1; extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { + external Wrapper({T value}); + external T value; external Wrapper> map( _AnonymousFunction_2569989 onfulfilled, ); } -extension type Container._(_i1.JSObject _) implements Wrapper<_i1.JSString> {} +extension type Container._(_i1.JSObject _) implements Wrapper<_i1.JSString> { + external Container(); +} extension type _AnonymousFunction_2569989< R extends _i1.JSAny?, T extends _i1.JSAny? diff --git a/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart index a59ecaeb..1afc87f8 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart @@ -8,20 +8,27 @@ import 'dart:js_interop' as _i1; extension type Event._(_i1.JSObject _) implements _i1.JSObject { + external Event({T listener}); + external T listener; } extension type CustomEventA._(_i1.JSObject _) implements _i1.JSObject { + external CustomEventA({T data}); + external T data; } extension type CustomEventB._(_i1.JSObject _) implements _i1.JSObject { + external CustomEventB({T data}); + external T data; } typedef MixedEventUnion = AnonymousUnion_3597781; extension type AnonymousUnion_3597781._( Event> _ -) implements Event> { +) + implements Event> { Event> get asEventOfCustomEventAOfT => _; Event> get asEventOfCustomEventBOfT => diff --git a/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart index 618fb20c..9c1d7b24 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart @@ -8,18 +8,27 @@ import 'dart:js_interop' as _i1; extension type GenericContainer._(_i1.JSObject _) implements _i1.JSObject { + external GenericContainer({T value}); + external T value; } extension type TargetClass._(_i1.JSObject _) implements _i1.JSObject { + external TargetClass({GenericContainer field}); + external GenericContainer field; } extension type OtherContainer._(_i1.JSObject _) implements _i1.JSObject { + external OtherContainer({T otherValue}); + external T otherValue; } extension type TargetClassWithGenericUnion._( _i1.JSObject _ -) implements _i1.JSObject { +) + implements _i1.JSObject { + external TargetClassWithGenericUnion({AnonymousUnion_3899151 field}); + external AnonymousUnion_3899151 field; } extension type AnonymousUnion_3063943._(_i1.JSAny _) implements _i1.JSAny { diff --git a/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart b/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart index 3b251435..5768818b 100644 --- a/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart @@ -7,6 +7,12 @@ import 'dart:js_interop' as _i1; extension type Container._(_i1.JSObject _) implements _i1.JSObject { + external Container({ + AnonymousUnion_3057876 arrayUnion, + AnonymousUnion_9545617 nestedGenericUnion, + AnonymousUnion_1757671 deepArrayUnion, + }); + external AnonymousUnion_3057876 arrayUnion; external AnonymousUnion_9545617 nestedGenericUnion; diff --git a/js_interop_gen/test/integration/interop_gen/import_export_expected.dart b/js_interop_gen/test/integration/interop_gen/import_export_expected.dart index f684c660..f2e57aab 100644 --- a/js_interop_gen/test/integration/interop_gen/import_export_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/import_export_expected.dart @@ -18,20 +18,28 @@ external Vector3D vectorProduct(Vector3D v1, Vector3D v2); external Vector3D mapTo3D(Vector2D v); extension type TransformerMatrix._(_i1.JSObject _) implements Matrix { + external TransformerMatrix(); + external V call(V v); } extension type ComparatorMatrix._(_i1.JSObject _) - implements Matrix, Comparator {} + implements Matrix, Comparator { + external ComparatorMatrix(); +} @_i1.JS() external _i1.JSArray get unitVectors; @_i1.JS('PolarPoint') extension type PolarCoordinate._(_i1.JSObject _) implements _i1.JSObject { + external PolarCoordinate({double magnitude, double angle}); + external double magnitude; external double angle; } @_i1.JS('CylindricalPoint') extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { + external CylindricalCoordinate({double radius, double angle, double z}); + external double radius; external double angle; @@ -40,6 +48,8 @@ extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { } @_i1.JS('SphericalPoint') extension type SphericalCoordinate._(_i1.JSObject _) implements _i1.JSObject { + external SphericalCoordinate({double magnitude, double theta, double tau}); + external double magnitude; external double theta; @@ -67,11 +77,15 @@ external Vector3D get unitJ3D; @_i1.JS() external Vector3D get unitK3D; extension type Point2D._(_i1.JSObject _) implements _i1.JSObject { + external Point2D({double x, double y}); + external double x; external double y; } extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { + external Point3D({double x, double y, double z}); + external double x; external double y; @@ -79,6 +93,8 @@ extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { external double z; } extension type Vector._(_i1.JSObject _) implements _i1.JSObject { + external Vector(); + external double get magnitude; external double get directionAngle; } @@ -102,6 +118,8 @@ extension type Vector3D._(_i1.JSObject _) implements Vector { external static Vector3D fromPoints(Point3D start, Point3D end); } extension type DirectionAngles._(_i1.JSObject _) implements _i1.JSObject { + external DirectionAngles({double alpha, double beta, double gamma}); + external double alpha; external double beta; @@ -125,6 +143,8 @@ extension type Vector2D._(_i1.JSObject _) implements Vector { external static Vector2D fromPoints(Point2D start, Point2D end); } extension type Matrix._(_i1.JSObject _) implements _i1.JSObject { + external Matrix({double rows, double columns}); + external double rows; external double columns; @@ -133,5 +153,7 @@ extension type Matrix._(_i1.JSObject _) implements _i1.JSObject { } extension type Comparator._(_i1.JSObject _) implements _i1.JSObject { + external Comparator(); + external double call(T a, T b); } diff --git a/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart b/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart index d7b8daa6..23b59c74 100644 --- a/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart @@ -7,6 +7,8 @@ import 'dart:js_interop' as _i1; extension type Person._(_i1.JSObject _) implements _i1.JSObject { + external Person({String name, double age}); + external String name; external double age; @@ -18,9 +20,13 @@ typedef PersonKeys = KeyOf_Person; typedef KeyValues = AnonymousUnion_2683278; typedef Missing = _i1.JSAny; extension type Foo._(_i1.JSObject _) implements _i1.JSObject { + external Foo({bool baseProp}); + external bool baseProp; } extension type Fee._(_i1.JSObject _) implements Foo { + external Fee({double bar}); + external double bar; } typedef Fee200 = _i1.JSAny; diff --git a/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart b/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart index 6768f169..04b9f961 100644 --- a/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart @@ -9,6 +9,8 @@ import 'dart:js_interop' as _i1; import 'package:meta/meta.dart' as _i2; extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { + external ILogger({String name, AnonymousUnion_1885558 level}); + external AnonymousUnion_1885558? level; external String get name; @@ -17,14 +19,20 @@ extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { external _i1.JSFunction? get flush; } extension type Dictionary._(_i1.JSObject _) implements _i1.JSObject { + external Dictionary(); + external String operator [](String key); } extension type Comparator._(_i1.JSObject _) implements _i1.JSObject { + external Comparator(); + external double call(T a, T b); } extension type Repository._(_i1.JSObject _) implements _i1.JSObject { + external Repository(); + external T findById(String id); external void save(T entity); } @@ -32,10 +40,14 @@ extension type RepoConstructor._(_i1.JSObject _) implements _i1.JSObject { external RepoConstructor(_i1.JSArray<_i1.JSString> args); } extension type AsyncService._(_i1.JSObject _) implements _i1.JSObject { + external AsyncService(); + external _i1.JSPromise<_i1.JSAny?> fetchData(String url); external _i1.JSPromise<_i1.JSBoolean> updateData(String id, String payload); } extension type User._(_i1.JSObject _) implements _i1.JSObject { + external User({String id, String email}); + external String id; external String email; @@ -43,16 +55,22 @@ extension type User._(_i1.JSObject _) implements _i1.JSObject { external _i1.JSFunction? get describe; } extension type Admin._(_i1.JSObject _) implements User, ILogger { + external Admin({String role}); + external String role; external void grantPermission(String permission); } extension type Config._(_i1.JSObject _) implements _i1.JSObject { + external Config({String env, bool debug}); + external String env; external bool debug; } extension type SecureResource._(_i1.JSObject _) implements _i1.JSObject { + external SecureResource({String accessToken}); + external String accessToken; external bool authenticate(); @@ -64,6 +82,8 @@ external LinkedList get rootList; @_i1.JS() external Comparator<_i1.JSNumber> get compareNumbers; extension type ErrorReporter._(_i1.JSObject _) implements _i1.JSObject { + external ErrorReporter(); + @_i2.doNotStore external _i1.JSAny? reportError(String msg); } @@ -77,5 +97,7 @@ extension type const AnonymousUnion_1885558._(String _) { static const AnonymousUnion_1885558 error = AnonymousUnion_1885558._('error'); } extension type LinkedList._(_i1.JSObject _) implements _i1.JSObject { + external LinkedList(); + external LinkedList next(); } diff --git a/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart b/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart index 9a99d0da..89e639cb 100644 --- a/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart @@ -7,6 +7,12 @@ import 'dart:js_interop' as _i1; extension type A._(_i1.JSObject _) implements _i1.JSObject { + external A({ + String conflictProperty, + @_i1.JS('_priv') String $_priv, + @_i1.JS('dashed-prop') String dashedProp, + }); + external String conflictProperty; @_i1.JS('_priv') @@ -18,6 +24,12 @@ extension type A._(_i1.JSObject _) implements _i1.JSObject { external bool conflictMethod(num param); } extension type B._(_i1.JSObject _) implements _i1.JSObject { + external B({ + double conflictProperty, + @_i1.JS('_priv') double $_priv, + @_i1.JS('dashed-prop') double dashedProp, + }); + external double conflictProperty; @_i1.JS('_priv') diff --git a/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart b/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart index cc81ddd3..3e3271b7 100644 --- a/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart @@ -7,6 +7,8 @@ import 'dart:js_interop' as _i1; extension type OptionHolder._(_i1.JSObject _) implements _i1.JSObject { + external OptionHolder({bool canPickMany}); + external bool? canPickMany; } typedef IntersectWithLiteral = AnonymousIntersection_3818894; diff --git a/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart b/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart index b1dd04f9..74649978 100644 --- a/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart @@ -8,6 +8,8 @@ import 'package:meta/meta.dart' as _i2; /// Represents a user in the system. extension type User._(_i1.JSObject _) implements _i1.JSObject { + external User({String id, String name, String email, double age}); + /// Unique identifier for the user. external String id; @@ -50,6 +52,12 @@ external void logEvent(String event, _i1.JSObject payload); /// Represents a configuration object for the app. extension type AppConfig._(_i1.JSObject _) implements _i1.JSObject { + external AppConfig({ + String env, + bool debug, + _i1.JSArray<_i1.JSString> features, + }); + /// The environment name (e.g., 'dev', 'prod'). external String env; @@ -82,6 +90,8 @@ external void cleanup(); @_i1.JS() external _i1.JSPromise<_i1.JSAny?> shutdownSystem(); extension type Logger._(_i1.JSObject _) implements _i1.JSObject { + external Logger(); + external void info(String msg); external void warn(String msg); external void error(String msg); diff --git a/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart b/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart index 077cfaa9..d21d68e8 100644 --- a/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart @@ -12,10 +12,13 @@ import 'dart:js_interop' as _i1; extension type Event._(_i1.JSObject _) implements _i1.JSObject { + external Event(); + external _i1.JSAny? call(_AnonymousFunction_6204725 listener); } extension type _AnonymousFunction_6204725._( _i1.JSFunction _ -) implements _i1.JSFunction { +) + implements _i1.JSFunction { external _i1.JSAny? call(T e); } diff --git a/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart b/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart index d9e8dc48..f70a4355 100644 --- a/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart @@ -73,6 +73,8 @@ extension type Core_LogEntry._(_i1.JSObject _) implements _i1.JSObject { /// This interface is used across multiple services and modules. @_i1.JS('Core.IAppConfig') extension type Core_IAppConfig._(_i1.JSObject _) implements _i1.JSObject { + external Core_IAppConfig({String apiEndpoint, bool authRequired}); + external String apiEndpoint; external bool authRequired; @@ -98,6 +100,8 @@ extension type const AnonymousUnion_3129258._(String _) { } @_i1.JS('Security.IAuthToken') extension type Security_IAuthToken._(_i1.JSObject _) implements _i1.JSObject { + external Security_IAuthToken({String token, double expiresIn, double userId}); + external String token; external double expiresIn; @@ -119,6 +123,8 @@ extension type Security_AuthService._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('Data.IRepository') extension type Data_IRepository._(_i1.JSObject _) implements _i1.JSObject { + external Data_IRepository(); + external T? findById(num id); external _i1.JSArray findAll(); external void save(T entity); @@ -147,6 +153,8 @@ extension type Data_Models_User._(_i1.JSObject _) implements Data_Models_IUser { } @_i1.JS('Data.Models.IUser') extension type Data_Models_IUser._(_i1.JSObject _) implements _i1.JSObject { + external Data_Models_IUser({double id, String name, String email}); + external double id; external String name; @@ -175,6 +183,8 @@ extension type EnterpriseApp_Models._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('EnterpriseApp.Models.IUser') extension type EnterpriseApp_Models_IUser._(_i1.JSObject _) implements _i1.JSObject { + external EnterpriseApp_Models_IUser({double id, String name, String email}); + external double id; external String name; @@ -199,6 +209,12 @@ extension type EnterpriseApp_Models_User._(_i1.JSObject _) @_i1.JS('EnterpriseApp.Models.IProduct') extension type EnterpriseApp_Models_IProduct._(_i1.JSObject _) implements _i1.JSObject { + external EnterpriseApp_Models_IProduct({ + String sku, + String title, + double price, + }); + external String sku; external String title; @@ -248,7 +264,10 @@ extension type EnterpriseApp_DataServices._(_i1.JSObject _) @_i1.JS('EnterpriseApp.DataServices.IDataService') extension type EnterpriseApp_DataServices_IDataService._( _i1.JSObject _ -) implements _i1.JSObject { +) + implements _i1.JSObject { + external EnterpriseApp_DataServices_IDataService(); + external _i1.JSArray getAll(); external T getById(String id); external void save(T item); diff --git a/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart b/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart index 773bc752..e6ae81f4 100644 --- a/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart @@ -6,8 +6,12 @@ import 'dart:js_interop' as _i1; extension type Holder._(_i1.JSObject _) implements _i1.JSObject { + external Holder({T value}); + external T value; } extension type Consumer._(_i1.JSObject _) implements _i1.JSObject { + external Consumer({Holder<_i1.JSString> useHolder}); + external Holder<_i1.JSString> useHolder; } diff --git a/js_interop_gen/test/integration/interop_gen/overload_expected.dart b/js_interop_gen/test/integration/interop_gen/overload_expected.dart index 05bea1d0..41a2faaa 100644 --- a/js_interop_gen/test/integration/interop_gen/overload_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/overload_expected.dart @@ -23,13 +23,15 @@ extension type foo._(_i1.JSObject _) implements _i1.JSObject { external String name; external static String get version; - external static foo_fum get fum; + external static foo_Fum get fum; external static bool isFoo(_i1.JSAny? obj); external String greet(); } @_i1.JS() external foo get f; extension type bar._(_i1.JSObject _) implements baz { + external bar({double id, String name, bool active}); + external double id; external String name; @@ -105,10 +107,14 @@ extension type SomeNamespace._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('SomeNamespace.BytesView') extension type SomeNamespace_BytesView._(_i1.JSObject _) implements _i1.JSObject { + external SomeNamespace_BytesView({_i1.JSArrayBuffer buffer}); + external _i1.JSArrayBuffer get buffer; } @_i1.JS('fooHelper.Options') extension type fooHelper_Options._(_i1.JSObject _) implements _i1.JSObject { + external fooHelper_Options({bool round}); + external bool? round; } @_i1.JS('fooHelper.OptionsImpl') @@ -119,11 +125,13 @@ extension type fooHelper_OptionsImpl._(_i1.JSObject _) external bool? round; } @_i1.JS('foo.fum') -extension type foo_fum._(_i1.JSObject _) implements _i1.JSObject { +extension type foo_Fum._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static bool get blownByWolf; } extension type baz._(_i1.JSObject _) implements _i1.JSObject { + external baz({String debugString}); + external String get debugString; } @_i1.JS('SomeNamespace.NestedNamespace') @@ -146,6 +154,10 @@ extension type SomeNamespace_NestedNamespace_ByteBuffer._(_i1.JSObject _) @_i1.JS('SomeNamespace.NestedNamespace.ByteBuilder') extension type SomeNamespace_NestedNamespace_ByteBuilder._(_i1.JSObject _) implements _i1.JSObject { + external SomeNamespace_NestedNamespace_ByteBuilder({ + SomeNamespace_NestedNamespace_ByteBuffer buffer, + }); + external SomeNamespace_NestedNamespace_ByteBuffer buffer; external void addByte(num byte); diff --git a/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart b/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart index 05580621..1a347d19 100644 --- a/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart @@ -5,6 +5,10 @@ import 'dart:js_interop' as _i1; extension type InternalSettings._(_i1.JSObject _) implements _i1.JSObject { + external InternalSettings({ + @_i1.JS('__electricCharacterSupport') String $__electricCharacterSupport, + }); + @_i1.JS('__electricCharacterSupport') external String? $__electricCharacterSupport; diff --git a/js_interop_gen/test/integration/interop_gen/project/output/a.dart b/js_interop_gen/test/integration/interop_gen/project/output/a.dart index 72b8dbb8..024c9a33 100644 --- a/js_interop_gen/test/integration/interop_gen/project/output/a.dart +++ b/js_interop_gen/test/integration/interop_gen/project/output/a.dart @@ -41,19 +41,25 @@ external _i2.Vector3D mapTo3D(_i2.Vector2D v); /// Type Name [V]: Vector2D subtype extension type TransformerMatrix._(_i1.JSObject _) implements Matrix { + external TransformerMatrix(); + external V call(V v); } /// A matrix that includes vector comparison capabilities. /// Type Name [V]: Vector2D subtype extension type ComparatorMatrix._(_i1.JSObject _) - implements Matrix, _i3.Comparator {} + implements Matrix, _i3.Comparator { + external ComparatorMatrix(); +} /// Represents a point in 2D space using polar coordinates. /// - `magnitude`: radial distance from the origin. /// - `angle`: angle in radians from the positive x-axis. @_i1.JS('PolarPoint') extension type PolarCoordinate._(_i1.JSObject _) implements _i1.JSObject { + external PolarCoordinate({double magnitude, double angle}); + external double magnitude; external double angle; @@ -65,6 +71,8 @@ extension type PolarCoordinate._(_i1.JSObject _) implements _i1.JSObject { /// - `z`: height along the z-axis. @_i1.JS('CylindricalPoint') extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { + external CylindricalCoordinate({double radius, double angle, double z}); + external double radius; external double angle; @@ -78,6 +86,8 @@ extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { /// - `tau`: azimuthal angle from the x-axis in the xy-plane. @_i1.JS('SphericalPoint') extension type SphericalCoordinate._(_i1.JSObject _) implements _i1.JSObject { + external SphericalCoordinate({double magnitude, double theta, double tau}); + external double magnitude; external double theta; @@ -209,6 +219,8 @@ external _i2.Vector3D get unitK3D; /// - `columns`: number of columns. /// - Numeric index maps to an array of numbers (row data). extension type Matrix._(_i1.JSObject _) implements _i1.JSObject { + external Matrix({double rows, double columns}); + external double rows; external double columns; diff --git a/js_interop_gen/test/integration/interop_gen/project/output/b.dart b/js_interop_gen/test/integration/interop_gen/project/output/b.dart index 276261cf..887c34dc 100644 --- a/js_interop_gen/test/integration/interop_gen/project/output/b.dart +++ b/js_interop_gen/test/integration/interop_gen/project/output/b.dart @@ -10,12 +10,16 @@ import 'package:meta/meta.dart' as _i2; extension type CoordinateSystem

._(_i1.JSObject _) implements _i1.JSObject { + external CoordinateSystem({P origin, _i1.JSArray

points}); + external _i1.JSArray

points; external P get origin; external void addPoint(P point); } extension type Point2D._(_i1.JSObject _) implements Point { + external Point2D({double x, double y}); + external double x; external double y; @@ -23,6 +27,8 @@ extension type Point2D._(_i1.JSObject _) implements Point { @_i1.JS() external Point2D get origin2D; extension type Vector._(_i1.JSObject _) implements _i1.JSObject { + external Vector(); + external double get magnitude; external double get directionAngle; } @@ -43,6 +49,8 @@ extension type Vector2D._(_i1.JSObject _) implements Vector { external static Vector2D fromPoints(Point2D start, Point2D end); } extension type Point3D._(_i1.JSObject _) implements Point { + external Point3D({double x, double y, double z}); + external double x; external double y; @@ -71,14 +79,20 @@ extension type Vector3D._(_i1.JSObject _) implements Vector { external static Vector3D fromPoints(Point3D start, Point3D end); } extension type DirectionAngles._(_i1.JSObject _) implements _i1.JSObject { + external DirectionAngles({double alpha, double beta, double gamma}); + external double alpha; external double beta; external double gamma; } -extension type Shape._(_i1.JSObject _) implements _i1.JSObject {} +extension type Shape._(_i1.JSObject _) implements _i1.JSObject { + external Shape(); +} extension type Shape2D._(_i1.JSObject _) implements Shape { + external Shape2D({double sides}); + external double? get sides; external double get perimeter; external double get area; @@ -117,6 +131,8 @@ extension type Square._(_i1.JSObject _) implements Rectangle { @_i1.JS() external Square drawSquare(Point2D start, num length, [num? angle]); extension type Shape3D._(_i1.JSObject _) implements Shape { + external Shape3D(); + external double get volume; external double surfaceArea(); } @@ -228,7 +244,9 @@ extension type EpahsImpl._(_i1.JSObject _) @_i1.JS('toString') external String toString$(); } -extension type Point._(_i1.JSObject _) implements _i1.JSObject {} +extension type Point._(_i1.JSObject _) implements _i1.JSObject { + external Point(); +} extension type const AnonymousUnion_7177595._(String _) { static const AnonymousUnion_7177595 circle = AnonymousUnion_7177595._( 'circle', @@ -244,6 +262,8 @@ extension type const AnonymousUnion_7177595._(String _) { } extension type Epahs._(_i1.JSObject _) implements _i1.JSObject { + external Epahs({String id, String name}); + external String name; external String get id; diff --git a/js_interop_gen/test/integration/interop_gen/project/output/c.dart b/js_interop_gen/test/integration/interop_gen/project/output/c.dart index 81ca52f6..fcc96053 100644 --- a/js_interop_gen/test/integration/interop_gen/project/output/c.dart +++ b/js_interop_gen/test/integration/interop_gen/project/output/c.dart @@ -14,11 +14,15 @@ import 'package:meta/meta.dart' as _i2; /// - `> 0` if `a > b` extension type Comparator._(_i1.JSObject _) implements _i1.JSObject { + external Comparator(); + external double call(T a, T b); } /// Represents a basic logger interface with optional flush capability. extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { + external ILogger({String name, AnonymousUnion_1885558 level}); + /// Logging level. Defaults to "info" if unspecified. external AnonymousUnion_1885558? level; @@ -41,12 +45,16 @@ extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { /// A key-value map of strings. extension type Dictionary._(_i1.JSObject _) implements _i1.JSObject { + external Dictionary(); + external String operator [](String key); } /// A simple repository abstraction. extension type Repository._(_i1.JSObject _) implements _i1.JSObject { + external Repository(); + /// Finds an entity by its ID. /// - [id]: - The unique identifier. external T findById(String id); @@ -66,6 +74,8 @@ extension type RepoConstructor._(_i1.JSObject _) implements _i1.JSObject { /// **EXPERIMENTAL**: This API is under evaluation and may change. @_i2.experimental extension type AsyncService._(_i1.JSObject _) implements _i1.JSObject { + external AsyncService(); + /// Fetches remote data from a URL. /// - [url]: - The resource endpoint. external _i1.JSPromise<_i1.JSAny?> fetchData(String url); @@ -80,6 +90,8 @@ extension type AsyncService._(_i1.JSObject _) implements _i1.JSObject { /// Represents a basic user. extension type User._(_i1.JSObject _) implements _i1.JSObject { + external User({String id, String email}); + /// Unique identifier. external String id; @@ -92,6 +104,8 @@ extension type User._(_i1.JSObject _) implements _i1.JSObject { /// An administrator user with logging capabilities. extension type Admin._(_i1.JSObject _) implements User, ILogger { + external Admin({String role}); + /// Admin role label. external String role; @@ -102,6 +116,8 @@ extension type Admin._(_i1.JSObject _) implements User, ILogger { /// Configuration environment. extension type Config._(_i1.JSObject _) implements _i1.JSObject { + external Config({String env, bool debug}); + /// Environment name (e.g., 'production', 'dev'). external String env; @@ -111,6 +127,8 @@ extension type Config._(_i1.JSObject _) implements _i1.JSObject { /// Represents a resource that requires authentication. extension type SecureResource._(_i1.JSObject _) implements _i1.JSObject { + external SecureResource({String accessToken}); + /// A token used for authentication. external String accessToken; @@ -141,6 +159,8 @@ extension type const AnonymousUnion_1885558._(String _) { /// A basic self-referencing linked list node. extension type LinkedList._(_i1.JSObject _) implements _i1.JSObject { + external LinkedList(); + /// Returns the next node in the list. external LinkedList next(); } diff --git a/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart b/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart index 785eea92..cab964f3 100644 --- a/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart @@ -5,9 +5,13 @@ import 'dart:js_interop' as _i1; extension type Parent._(_i1.JSObject _) implements _i1.JSObject { + external Parent({String parentProp}); + external String parentProp; } extension type SpecialArray._(_i1.JSArray<_i1.JSString> _) implements _i1.JSArray<_i1.JSString>, Parent { + external SpecialArray({double specialLength}); + external double specialLength; } diff --git a/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart b/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart index e4fb6be7..2f4470a4 100644 --- a/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart @@ -5,5 +5,7 @@ import 'dart:js_interop' as _i1; extension type Position._(_i1.JSObject _) implements _i1.JSObject { + external Position({double line}); + external double get line; } diff --git a/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart b/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart index 16170321..81f4ee73 100644 --- a/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart @@ -9,5 +9,7 @@ library; import 'dart:js_interop' as _i1; extension type TextLine._(_i1.JSObject _) implements _i1.JSObject { + external TextLine({String text}); + external String get text; } diff --git a/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart b/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart index 2ede2784..5a58c282 100644 --- a/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart @@ -5,6 +5,14 @@ import 'dart:js_interop' as _i1; extension type Headers._(_i1.JSObject _) implements _i1.JSObject { + external Headers({ + @_i1.JS('content-type') String contentType, + @_i1.JS('Content-type') String contentType$1, + @_i1.JS('content-Type') String contentType$2, + @_i1.JS('Content-Type') String contentType$3, + @_i1.JS('content=type') String contentType$4, + }); + @_i1.JS('content-type') external String contentType; diff --git a/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart b/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart index 1b32e6f6..8667d9bf 100644 --- a/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart @@ -231,11 +231,14 @@ extension type const KeyOf_TypeOf_MyEnum._(String _) { } extension type _AnonymousFunction_3794666._( _i1.JSFunction _ -) implements _i1.JSFunction { +) + implements _i1.JSFunction { external ComposedType call(T object); } extension type ComposedType._(_i1.JSObject _) implements _i1.JSObject { + external ComposedType({T enclosed}); + external T enclosed; } extension type AnonymousUnion_8168791._(_i1.JSAny _) implements _i1.JSAny { diff --git a/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart b/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart index c88f96c8..87a4a14c 100644 --- a/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart @@ -6,8 +6,12 @@ import 'dart:js_interop' as _i1; extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { + external Wrapper({T value}); + external T value; } extension type Container._(_i1.JSObject _) implements _i1.JSObject { + external Container({Wrapper<_i1.JSString> optionalWrapper}); + external Wrapper<_i1.JSString>? optionalWrapper; } diff --git a/js_interop_gen/test/integration/interop_gen/typealias_expected.dart b/js_interop_gen/test/integration/interop_gen/typealias_expected.dart index a8524f71..ff43f87f 100644 --- a/js_interop_gen/test/integration/interop_gen/typealias_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/typealias_expected.dart @@ -86,6 +86,8 @@ extension type const AnonymousUnion_2375200._(String _) { } @_i1.JS('Space.Planet') extension type Space_Planet._(_i1.JSObject _) implements _i1.JSObject { + external Space_Planet({double radius}); + external double radius; } typedef LoggerContainer = _i1.JSArray; diff --git a/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart b/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart index 250c27ec..e307c7a6 100644 --- a/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart @@ -8,25 +8,29 @@ import 'dart:js_interop' as _i1; import 'package:meta/meta.dart' as _i2; -extension type symlink._(_i1.JSObject _) implements _i1.JSObject {} +@_i1.JS('symlink') +extension type Symlink._(_i1.JSObject _) implements _i1.JSObject {} @_i1.JS() -external void mySymlink(symlink_Type type); -extension type stream._(_i1.JSObject _) implements _i1.JSObject { +external void mySymlink(Symlink_Type type); +@_i1.JS('stream') +extension type Stream._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('stream.Readable') - static stream_Readable Readable() => stream_Readable(); + static Stream_Readable Readable() => Stream_Readable(); } @_i1.JS('stream.Readable') -extension type stream_Readable._(_i1.JSObject _) implements _i1.JSObject { - external stream_Readable(); +extension type Stream_Readable._(_i1.JSObject _) implements _i1.JSObject { + external Stream_Readable(); } -extension type MyReadable._(_i1.JSObject _) implements stream_Readable { +extension type MyReadable._(_i1.JSObject _) implements Stream_Readable { external MyReadable(); } -extension type Empty._(_i1.JSObject _) implements _i1.JSObject {} +extension type Empty._(_i1.JSObject _) implements _i1.JSObject { + external Empty(); +} @_i2.doNotStore @_i1.JS() external _i1.JSAny? get emptyKey; -typedef symlink_Type = AnonymousUnion_3598178; +typedef Symlink_Type = AnonymousUnion_3598178; extension type const AnonymousUnion_3598178._(String _) { static const AnonymousUnion_3598178 dir = AnonymousUnion_3598178._('dir'); diff --git a/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart b/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart index bdbea1b9..c637d406 100644 --- a/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart @@ -7,20 +7,27 @@ import 'dart:js_interop' as _i1; extension type SpecializedBound._(_i1.JSObject _) implements _i1.JSObject { + external SpecializedBound({String tag}); + external String tag; } extension type HolderA._(_i1.JSObject _) implements _i1.JSObject { + external HolderA({T value}); + external T value; } extension type HolderB._(_i1.JSObject _) implements _i1.JSObject { + external HolderB({T value}); + external T value; } typedef ConstraintUnion = AnonymousUnion_7450886; extension type AnonymousUnion_7450886._( _i1.JSObject _ -) implements _i1.JSObject { +) + implements _i1.JSObject { HolderA get asHolderAOfT => (_ as HolderA); HolderB get asHolderBOfT => (_ as HolderB); diff --git a/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart b/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart index b77746c7..d17ed469 100644 --- a/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart @@ -5,5 +5,7 @@ import 'dart:js_interop' as _i1; extension type UnsupportedProperties._(_i1.JSObject _) implements _i1.JSObject { + external UnsupportedProperties({String normal}); + external String normal; } diff --git a/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart b/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart index a0ff755a..ff367a8e 100644 --- a/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart @@ -6,8 +6,12 @@ import 'dart:js_interop' as _i1; extension type Event._(_i1.JSObject _) implements _i1.JSObject { + external Event(); + external void fire(T value); } extension type TargetClass._(_i1.JSObject _) implements _i1.JSObject { + external TargetClass({Event<_i1.JSAny?> onEvent}); + external Event<_i1.JSAny?> onEvent; } diff --git a/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart b/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart index 3cff65f0..6f87bb57 100644 --- a/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart @@ -6,29 +6,36 @@ import 'dart:js_interop' as _i1; extension type Range._(_i1.JSObject _) implements _i1.JSObject { + external Range({String globalField}); + external String globalField; } extension type Position._(_i1.JSObject _) implements _i1.JSObject { + external Position({String globalField}); + external String globalField; } -extension type vscode._(_i1.JSObject _) implements _i1.JSObject { +@_i1.JS('vscode') +extension type Vscode._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('vscode.Position') - static vscode_Position Position(num line, num character) => - vscode_Position(line, character); + static Vscode_Position Position(num line, num character) => + Vscode_Position(line, character); @_i1.JS('vscode.Range') - static vscode_Range Range(vscode_Position start, vscode_Position end) => - vscode_Range(start, end); + static Vscode_Range Range(Vscode_Position start, Vscode_Position end) => + Vscode_Range(start, end); } @_i1.JS('vscode.TextLine') -extension type vscode_TextLine._(_i1.JSObject _) implements _i1.JSObject { - external vscode_Range get range; +extension type Vscode_TextLine._(_i1.JSObject _) implements _i1.JSObject { + external Vscode_TextLine({Vscode_Range range}); + + external Vscode_Range get range; } @_i1.JS('vscode.Range') -extension type vscode_Range._(_i1.JSObject _) implements _i1.JSObject { - external vscode_Range(vscode_Position start, vscode_Position end); +extension type Vscode_Range._(_i1.JSObject _) implements _i1.JSObject { + external Vscode_Range(Vscode_Position start, Vscode_Position end); } @_i1.JS('vscode.Position') -extension type vscode_Position._(_i1.JSObject _) implements _i1.JSObject { - external vscode_Position(num line, num character); +extension type Vscode_Position._(_i1.JSObject _) implements _i1.JSObject { + external Vscode_Position(num line, num character); } diff --git a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart index 608f7943..e1f4d2e6 100644 --- a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart @@ -35,6 +35,13 @@ external _i1.JSAny? handleEvents( ); extension type ElementStamp._(_i1.JSObject _) implements _i1.JSObject { + external ElementStamp({ + T target, + Date stampedAt, + String id, + AnonymousUnion_2036258 stampType, + }); + external String id; external AnonymousUnion_2036258 stampType; @@ -71,14 +78,20 @@ extension type HTMLTransformFunc< T extends _i2.HTMLElement, R extends _i2.HTMLElement >._(_i1.JSObject _) implements _i1.JSObject { + external HTMLTransformFunc(); + external R call(T element); } extension type EventManipulationFunc._(_i1.JSObject _) implements _i1.JSObject { + external EventManipulationFunc(); + external _i1.JSAny? call(_i2.Event event); } /// Enables basic storage and retrieval of dates and times. extension type Date._(_i1.JSObject _) implements _i1.JSObject { + external Date(); + /// Returns a string representation of a date. The format of the string /// depends on the locale. @_i1.JS('toString') From 26162d7f6f0e64db19b8239ac0574d46ebaa6493 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Tue, 30 Jun 2026 16:35:06 -0700 Subject: [PATCH 4/9] test(js_interop_gen): update integration goldens for Dart 3.12 formatting --- .../interop_gen/duplicate_references_expected.dart | 9 +++------ .../interop_gen/generic_union_casting_expected.dart | 3 +-- .../integration/interop_gen/generic_union_expected.dart | 3 +-- .../interop_gen/module_generic_param_expected.dart | 3 +-- .../integration/interop_gen/namespaces_expected.dart | 3 +-- .../test/integration/interop_gen/ts_typing_expected.dart | 3 +-- .../interop_gen/union_constraint_override_expected.dart | 3 +-- 7 files changed, 9 insertions(+), 18 deletions(-) diff --git a/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart b/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart index 493319af..638d49de 100644 --- a/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart @@ -48,14 +48,12 @@ extension type _AnonymousFunction_2123872< } extension type _AnonymousFunction_1873223._( _i1.JSFunction _ -) - implements _i1.JSFunction { +) implements _i1.JSFunction { external AnonymousUnion_3247291 call(_i1.JSAny? reason); } extension type AnonymousUnion_3247291._( _i1.JSAny _ -) - implements _i1.JSAny { +) implements _i1.JSAny { TResult2 get asTResult2 => (_ as TResult2); Thenable get asThenableOfTResult2 => (_ as Thenable); @@ -70,8 +68,7 @@ extension type AnonymousUnion_3555654< } extension type AnonymousUnion_2658987._( _i1.JSAny _ -) - implements _i1.JSAny { +) implements _i1.JSAny { TResult1 get asTResult1 => (_ as TResult1); Thenable get asThenableOfTResult1 => (_ as Thenable); diff --git a/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart index 1afc87f8..80335fd8 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart @@ -27,8 +27,7 @@ extension type CustomEventB._(_i1.JSObject _) typedef MixedEventUnion = AnonymousUnion_3597781; extension type AnonymousUnion_3597781._( Event> _ -) - implements Event> { +) implements Event> { Event> get asEventOfCustomEventAOfT => _; Event> get asEventOfCustomEventBOfT => diff --git a/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart index 9c1d7b24..9b838750 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart @@ -25,8 +25,7 @@ extension type OtherContainer._(_i1.JSObject _) } extension type TargetClassWithGenericUnion._( _i1.JSObject _ -) - implements _i1.JSObject { +) implements _i1.JSObject { external TargetClassWithGenericUnion({AnonymousUnion_3899151 field}); external AnonymousUnion_3899151 field; diff --git a/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart b/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart index d21d68e8..6ba9ce08 100644 --- a/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart @@ -18,7 +18,6 @@ extension type Event._(_i1.JSObject _) } extension type _AnonymousFunction_6204725._( _i1.JSFunction _ -) - implements _i1.JSFunction { +) implements _i1.JSFunction { external _i1.JSAny? call(T e); } diff --git a/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart b/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart index f70a4355..279fb9ff 100644 --- a/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart @@ -264,8 +264,7 @@ extension type EnterpriseApp_DataServices._(_i1.JSObject _) @_i1.JS('EnterpriseApp.DataServices.IDataService') extension type EnterpriseApp_DataServices_IDataService._( _i1.JSObject _ -) - implements _i1.JSObject { +) implements _i1.JSObject { external EnterpriseApp_DataServices_IDataService(); external _i1.JSArray getAll(); diff --git a/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart b/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart index 8667d9bf..7dc5d2a0 100644 --- a/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart @@ -231,8 +231,7 @@ extension type const KeyOf_TypeOf_MyEnum._(String _) { } extension type _AnonymousFunction_3794666._( _i1.JSFunction _ -) - implements _i1.JSFunction { +) implements _i1.JSFunction { external ComposedType call(T object); } extension type ComposedType._(_i1.JSObject _) diff --git a/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart b/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart index c637d406..493593cc 100644 --- a/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart @@ -26,8 +26,7 @@ extension type HolderB._(_i1.JSObject _) typedef ConstraintUnion = AnonymousUnion_7450886; extension type AnonymousUnion_7450886._( _i1.JSObject _ -) - implements _i1.JSObject { +) implements _i1.JSObject { HolderA get asHolderAOfT => (_ as HolderA); HolderB get asHolderBOfT => (_ as HolderB); From 7692bc0adbdbef8423f0122a749b614892908795 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Tue, 30 Jun 2026 16:57:39 -0700 Subject: [PATCH 5/9] chore(js_interop_gen): revert changes to js_type_supertypes.dart --- js_interop_gen/lib/src/js_type_supertypes.dart | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/js_interop_gen/lib/src/js_type_supertypes.dart b/js_interop_gen/lib/src/js_type_supertypes.dart index be240f2f..43250215 100644 --- a/js_interop_gen/lib/src/js_type_supertypes.dart +++ b/js_interop_gen/lib/src/js_type_supertypes.dart @@ -3,12 +3,12 @@ // BSD-style license that can be found in the LICENSE file. // Generated code. Do not modify by hand. -// Generated from Dart SDK 3.13.0-184.0.dev -// To update run: dart run js_interop_gen/tool/update_supertypes.dart +// Generated from Dart SDK 3.10.0 +// To update run: dart run tool/update_supertypes.dart const Map jsTypeSupertypes = { 'JSAny': null, - 'JSArray': 'JSIterable', + 'JSArray': 'JSObject', 'JSArrayBuffer': 'JSObject', 'JSBigInt': 'JSAny', 'JSBoolean': 'JSAny', @@ -21,15 +21,10 @@ const Map jsTypeSupertypes = { 'JSInt16Array': 'JSTypedArray', 'JSInt32Array': 'JSTypedArray', 'JSInt8Array': 'JSTypedArray', - 'JSIterable': 'JSIterableProtocol', - 'JSIterableProtocol': 'JSAny', - 'JSIterator': 'JSIterable', - 'JSIteratorProtocol': 'JSAny', - 'JSIteratorResult': 'JSObject', 'JSNumber': 'JSAny', 'JSObject': 'JSAny', 'JSPromise': 'JSObject', - 'JSString': 'JSIterable', + 'JSString': 'JSAny', 'JSSymbol': 'JSAny', 'JSTypedArray': 'JSObject', 'JSUint16Array': 'JSTypedArray', From bb064836963b760fb52efedffcbcd99c130ad493 Mon Sep 17 00:00:00 2001 From: kevmoo Date: Tue, 30 Jun 2026 17:20:04 -0700 Subject: [PATCH 6/9] test(js_interop_gen): update IDL test goldens for reverted supertypes map --- js_interop_gen/test/integration/idl/methods_expected.dart | 2 +- js_interop_gen/test/integration/idl/union_docs_expected.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/js_interop_gen/test/integration/idl/methods_expected.dart b/js_interop_gen/test/integration/idl/methods_expected.dart index 857f74a8..e71a0ec4 100644 --- a/js_interop_gen/test/integration/idl/methods_expected.dart +++ b/js_interop_gen/test/integration/idl/methods_expected.dart @@ -19,7 +19,7 @@ extension type MyMethodExamples._(JSObject _) implements JSObject { JSAny? extra3, JSAny? extra4, ]); - external void update(JSIterable keyOrKeys, [String value]); + external void update(JSAny keyOrKeys, [String value]); external JSPromise fetchRemoteValue([String? endpoint]); external void init(); } diff --git a/js_interop_gen/test/integration/idl/union_docs_expected.dart b/js_interop_gen/test/integration/idl/union_docs_expected.dart index 8bf97d71..ddc410bf 100644 --- a/js_interop_gen/test/integration/idl/union_docs_expected.dart +++ b/js_interop_gen/test/integration/idl/union_docs_expected.dart @@ -31,7 +31,7 @@ typedef PrimitiveUnion = JSAny; /// /// - [JSArray]\<[JSString]\> /// - [JSObject]\<[JSString], [JSString]\> -typedef GenericUnion = JSAny; +typedef GenericUnion = JSObject; /// Union of: [JSInt16Array], [JSInt32Array], [JSInt8Array], [JSString] typedef NonCollapsingLongUnion = JSAny; From d5e21862f3ef3c9495e7f1f8eab995daac7bfe2e Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 20 Sep 2026 16:40:03 +0000 Subject: [PATCH 7/9] chore(web): revert unrelated formatting changes in package:web --- web/lib/src/helpers/extensions.dart | 7 +++---- web/test/helpers_test.dart | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/web/lib/src/helpers/extensions.dart b/web/lib/src/helpers/extensions.dart index 4f7c07f9..b81c8420 100644 --- a/web/lib/src/helpers/extensions.dart +++ b/web/lib/src/helpers/extensions.dart @@ -149,10 +149,9 @@ extension DOMRectExtension on DOMRect { } extension DOMRectListExtension on DOMRectList { - List asList() => - JSImmutableListWrapper(this) - .map((rect) => rect.asRectangle()) - .toList(); + List asList() => JSImmutableListWrapper( + this, + ).map((rect) => rect.asRectangle()).toList(); } extension DOMStringMapExtension on DOMStringMap { diff --git a/web/test/helpers_test.dart b/web/test/helpers_test.dart index f82b16be..7a748cb1 100644 --- a/web/test/helpers_test.dart +++ b/web/test/helpers_test.dart @@ -312,8 +312,9 @@ void main() { }); test('converts from a JS to a Dart URL', () { - final url = URL('https://foo:bar@example.org:1234/path?query#fragment') - .toDart; + final url = URL( + 'https://foo:bar@example.org:1234/path?query#fragment', + ).toDart; expect(url.scheme, equals('https')); expect(url.userInfo, equals('foo:bar')); expect(url.host, equals('example.org')); @@ -398,8 +399,9 @@ void main() { .forElement(div) .listen( ((dynamic e) { - eventFired = true; - }) as void Function(Event), + eventFired = true; + }) + as void Function(Event), ); div.click(); From 673029075b7ce08cfc1bd1c40b11696c9431f2be Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sun, 20 Sep 2026 17:12:43 +0000 Subject: [PATCH 8/9] refactor(js_interop_gen): isolate PR #559 to Node.js bindings and thin shims --- js_interop_gen/lib/src/ast/declarations.dart | 27 ++++++-------- js_interop_gen/lib/src/bcd.dart | 4 +- js_interop_gen/lib/src/dart_main.dart | 21 ++++++----- js_interop_gen/lib/src/doc_provider.dart | 6 +-- js_interop_gen/lib/src/generate_bindings.dart | 12 +++--- .../lib/src/interop_gen/parser.dart | 12 +++--- .../transform/namespace_flattener.dart | 3 +- .../interop_gen/transform/transformer.dart | 1 - .../interop_gen/transform/type_resolver.dart | 4 +- js_interop_gen/lib/src/js/filesystem_api.dart | 29 +++++++++++++++ .../lib/src/js/generated/node_api.dart | 15 ++------ js_interop_gen/lib/src/js/node.dart | 11 ++++++ js_interop_gen/lib/src/util.dart | 10 ++--- .../test/assets/test_overrides_golden.dart | 4 -- .../assets/unsupported_test_expected.dart | 4 -- .../boolean_literal_union_expected.dart | 7 ---- .../interop_gen/classes_expected.dart | 20 +--------- .../duplicate_implements_expected.dart | 8 ---- .../duplicate_references_expected.dart | 9 +---- .../empty_deprecation_expected.dart | 2 - .../generic_builtin_arguments_expected.dart | 2 - .../generic_builtin_blindspot_expected.dart | 7 ---- .../generic_interface_merge_expected.dart | 2 - .../generic_parameter_padding_expected.dart | 7 ---- ...ic_type_arguments_dependency_expected.dart | 6 +-- .../generic_union_casting_expected.dart | 6 --- .../interop_gen/generic_union_expected.dart | 8 ---- .../homogeneous_union_arrays_expected.dart | 6 --- .../interop_gen/import_export_expected.dart | 24 +----------- .../indexed_access_test_expected.dart | 6 --- .../interop_gen/interfaces_expected.dart | 22 ----------- ...intersection_member_conflict_expected.dart | 12 ------ ...tion_object_literal_conflict_expected.dart | 2 - .../interop_gen/jsdoc_expected.dart | 10 ----- .../module_generic_param_expected.dart | 2 - .../interop_gen/namespaces_expected.dart | 18 --------- .../nullable_union_typearg_expected.dart | 4 -- .../interop_gen/overload_expected.dart | 16 +------- .../private_names_escaping_expected.dart | 4 -- .../interop_gen/project/output/a.dart | 14 +------ .../interop_gen/project/output/b.dart | 24 +----------- .../interop_gen/project/output/c.dart | 20 ---------- ...resentation_type_inheritance_expected.dart | 4 -- .../interop_gen/rescope_dedup_expected.dart | 2 - .../string_literal_module_expected.dart | 2 - .../interop_gen/string_literals_expected.dart | 8 ---- .../interop_gen/ts_typing_expected.dart | 2 - .../type_arguments_nullability_expected.dart | 4 -- .../interop_gen/typealias_expected.dart | 2 - .../typealias_namespace_nested_expected.dart | 22 +++++------ .../union_constraint_override_expected.dart | 6 --- .../unsupported_properties_expected.dart | 2 - .../void_generic_bounds_expected.dart | 4 -- .../vscode_flattening_expected.dart | 29 ++++++--------- .../interop_gen/web_types_expected.dart | 37 ------------------- 55 files changed, 119 insertions(+), 436 deletions(-) create mode 100644 js_interop_gen/lib/src/js/filesystem_api.dart create mode 100644 js_interop_gen/lib/src/js/node.dart diff --git a/js_interop_gen/lib/src/ast/declarations.dart b/js_interop_gen/lib/src/ast/declarations.dart index 56d066da..c1d6f2ca 100644 --- a/js_interop_gen/lib/src/ast/declarations.dart +++ b/js_interop_gen/lib/src/ast/declarations.dart @@ -177,26 +177,21 @@ sealed class TypeDeclaration extends NestableDeclaration typeParameters.map((t) => t.emit(options?.toTypeOptions())), ) ..constructors.addAll([ - if (objectLiteralConstructor && - !constructors.any((c) => c.name == null || c.name!.isEmpty)) + if (objectLiteralConstructor) Constructor( (c) => c ..external = true ..optionalParameters.addAll( - properties.where((p) => p.scope == DeclScope.public).map((p) { - final paramName = - p.dartName ?? UniqueNamer.makeNonConflicting(p.name); - return Parameter( - (param) => param - ..named = true - ..name = paramName - ..annotations.addAll([ - if (p.dartName != null && p.dartName != p.name) - generateJSAnnotation(p.name), - ]) - ..type = p.type.emit(options?.toTypeOptions()), - ); - }), + properties + .where((p) => p.scope == DeclScope.public) + .map( + (p) => Parameter( + (param) => param + ..named = true + ..name = p.name + ..type = p.type.emit(options?.toTypeOptions()), + ), + ), ), ), if (!abstract) diff --git a/js_interop_gen/lib/src/bcd.dart b/js_interop_gen/lib/src/bcd.dart index 3705fe06..fb54e4ce 100644 --- a/js_interop_gen/lib/src/bcd.dart +++ b/js_interop_gen/lib/src/bcd.dart @@ -4,7 +4,7 @@ import 'dart:convert' hide json; -import 'js/generated/node_api.dart'; +import 'js/filesystem_api.dart'; /// A class to read from the browser-compat-data files and parse interface and /// property status (standards track, experimental, deprecated) and supported @@ -21,7 +21,7 @@ class BrowserCompatData { required bool generateAll, required String path, }) { - final content = Fs.readFileSync(path, ReadFileOptions(encoding: 'utf8')); + final content = fs.readFileSync(path, readFileOptions(encoding: 'utf8')); final contentMap = jsonDecode(content) as Map; final api = (contentMap['api'] as Map).cast(); diff --git a/js_interop_gen/lib/src/dart_main.dart b/js_interop_gen/lib/src/dart_main.dart index 2b5405cf..d7a814d6 100644 --- a/js_interop_gen/lib/src/dart_main.dart +++ b/js_interop_gen/lib/src/dart_main.dart @@ -15,7 +15,8 @@ import 'config.dart'; import 'generate_bindings.dart'; import 'interop_gen/parser.dart'; import 'interop_gen/transform.dart'; -import 'js/generated/node_api.dart'; +import 'js/filesystem_api.dart'; +import 'js/node.dart'; import 'util.dart'; // Generates DOM and JS interop bindings for Dart. @@ -52,9 +53,9 @@ void main(List args) async { if (argResult.wasParsed('config')) { final filename = argResult['config'] as String; - final configContent = Fs.readFileSync( + final configContent = fs.readFileSync( filename, - ReadFileOptions(encoding: 'utf8'), + readFileOptions(encoding: 'utf8'), ); final yaml = loadYamlDocument(configContent); config = YamlConfig.fromYaml( @@ -104,16 +105,16 @@ Future generateJSInteropBindings(Config config) async { // write code to file if (dartDeclarations.multiFileOutput) { for (final entry in generatedCodeMap.entries) { - Fs.writeFileSync( + fs.writeFileSync( p.join(configOutput, p.basename(entry.key)), entry.value, ); } } else { final entry = generatedCodeMap.entries.first; - Fs.writeFileSync(configOutput, entry.value); + fs.writeFileSync(configOutput, entry.value); for (final entry in generatedCodeMap.entries.skip(1)) { - Fs.writeFileSync( + fs.writeFileSync( p.join(p.dirname(configOutput), p.basename(entry.key)), entry.value, ); @@ -148,7 +149,7 @@ Future generateIDLBindings({ if (renameMap.isNotEmpty) { final jsonStr = jsonEncode(renameMap); - Fs.writeFileSync(renameMapPath, jsonStr); + fs.writeFileSync(renameMapPath, jsonStr); } for (var entry in bindings.entries) { @@ -156,7 +157,7 @@ Future generateIDLBindings({ final library = entry.value; final contents = _emitLibrary(library, languageVersion); - Fs.writeFileSync('$output/$libraryPath', contents); + fs.writeFileSync('$output/$libraryPath', contents); } } else { final allInputFiles = expandGlobs(input.toList(), extension: '.idl'); @@ -166,7 +167,7 @@ Future generateIDLBindings({ final bindings = await generateBindingsForFiles( { for (final file in allInputFiles) - file: Fs.readFileSync(file, ReadFileOptions(encoding: 'utf-8')), + file: fs.readFileSync(file, readFileOptions(encoding: 'utf-8')), }, output, bcdJsonPath: bcdJsonPath, @@ -177,7 +178,7 @@ Future generateIDLBindings({ final library = entry.value; final contents = _emitLibrary(library, languageVersion); - Fs.writeFileSync('$output/$libraryPath', contents); + fs.writeFileSync('$output/$libraryPath', contents); } } } diff --git a/js_interop_gen/lib/src/doc_provider.dart b/js_interop_gen/lib/src/doc_provider.dart index 2450f264..8ea752e5 100644 --- a/js_interop_gen/lib/src/doc_provider.dart +++ b/js_interop_gen/lib/src/doc_provider.dart @@ -7,13 +7,13 @@ import 'dart:convert'; import 'package:path/path.dart' as p; import 'formatting.dart'; -import 'js/generated/node_api.dart'; +import 'js/filesystem_api.dart'; class DocProvider { static DocProvider create() { - final content = Fs.readFileSync( + final content = fs.readFileSync( p.join('..', '..', '..', 'third_party', 'mdn', 'mdn.json'), - ReadFileOptions(encoding: 'utf8'), + readFileOptions(encoding: 'utf8'), ); return DocProvider(jsonDecode(content) as Map); diff --git a/js_interop_gen/lib/src/generate_bindings.dart b/js_interop_gen/lib/src/generate_bindings.dart index 7e226b82..5e91af86 100644 --- a/js_interop_gen/lib/src/generate_bindings.dart +++ b/js_interop_gen/lib/src/generate_bindings.dart @@ -6,7 +6,7 @@ import 'dart:convert'; import 'dart:js_interop'; import 'package:path/path.dart' as p; -import 'js/generated/node_api.dart'; +import 'js/filesystem_api.dart'; import 'js/webidl2.dart' as webidl2; import 'js/webidl_api.dart' as webidl; import 'js/webref_css_api.dart'; @@ -84,10 +84,10 @@ Future<(TranslationResult, Map)> generateBindings( }) async { var renameMap = {}; if (renameMapPath != null) { - if (Fs.existsSync(renameMapPath)) { - final jsonStr = Fs.readFileSync( + if (fs.existsSync(renameMapPath)) { + final jsonStr = fs.readFileSync( renameMapPath, - ReadFileOptions(encoding: 'utf8'), + readFileOptions(encoding: 'utf8'), ); final json = jsonDecode(jsonStr) as Map; renameMap = json.map((k, v) => MapEntry(k, v as String)); @@ -98,9 +98,9 @@ Future<(TranslationResult, Map)> generateBindings( JSObject? elementsData; if (idlJsonPath != null) { - final jsonStr = Fs.readFileSync( + final jsonStr = fs.readFileSync( idlJsonPath, - ReadFileOptions(encoding: 'utf8'), + readFileOptions(encoding: 'utf8'), ); final json = jsonDecode(jsonStr) as Map; diff --git a/js_interop_gen/lib/src/interop_gen/parser.dart b/js_interop_gen/lib/src/interop_gen/parser.dart index 25a61b34..837e4d9c 100644 --- a/js_interop_gen/lib/src/interop_gen/parser.dart +++ b/js_interop_gen/lib/src/interop_gen/parser.dart @@ -7,7 +7,7 @@ import 'dart:js_interop'; import 'package:path/path.dart' as p; import '../config.dart'; -import '../js/generated/node_api.dart'; +import '../js/node.dart'; import '../js/typescript.dart' as ts; class ParserResult { @@ -48,7 +48,7 @@ ParserResult parseDeclarationFiles(Config config) { // handle any diagnostics handleDiagnostics(diagnostics); if (!ignoreErrors && diagnostics.isNotEmpty) { - Process.exit(1); + exit(1); } } } else if (config.tsConfig case final tsConfig? @@ -67,7 +67,7 @@ ParserResult parseDeclarationFiles(Config config) { // handle any diagnostics handleDiagnostics(diagnostics); if (!ignoreErrors && diagnostics.isNotEmpty) { - Process.exit(1); + exit(1); } } @@ -88,7 +88,7 @@ ParserResult parseDeclarationFiles(Config config) { if (diagnostics.isNotEmpty && !ignoreErrors) { // exit - Process.exit(1); + exit(1); } return ParserResult(program: program, files: files); @@ -103,7 +103,7 @@ void handleDiagnostics(List diagnostics) { diagnostic.messageText, '\n', ); - Console.error( + printErr( '${diagnosticFile.fileName} ' '(${line.toDartInt + 1},${char.toDartInt + 1}): $message', ); @@ -112,7 +112,7 @@ void handleDiagnostics(List diagnostics) { diagnostic.messageText, '\n', ); - Console.error('(anonymous): $message'); + printErr('(anonymous): $message'); } } } diff --git a/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart b/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart index 4335362a..0fd73293 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/namespace_flattener.dart @@ -7,7 +7,6 @@ import 'dart:js_interop'; import '../../ast/declarations.dart'; import '../../js/helpers.dart'; import '../../js/typescript.types.dart'; -import '../../util.dart'; import '../namer.dart'; import 'transformer.dart'; @@ -40,7 +39,7 @@ class NamespaceFlattener { .whereType(); final (name: dartName, :id) = currentNamespaces.isEmpty - ? namer.makeUnique(capitalize(namespaceName), 'namespace') + ? namer.makeUnique(namespaceName, 'namespace') : (name: null, id: null); final scopedNamer = ScopedUniqueNamer(); diff --git a/js_interop_gen/lib/src/interop_gen/transform/transformer.dart b/js_interop_gen/lib/src/interop_gen/transform/transformer.dart index 173377ef..a5b04b88 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/transformer.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/transformer.dart @@ -388,7 +388,6 @@ class Transformer { operators: [], constructors: [], documentation: _parseAndTransformDocumentation(typeDecl), - objectLiteralConstructor: true, ) : ClassDeclaration( name: name, diff --git a/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart b/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart index 48241287..4a5b2ed2 100644 --- a/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart +++ b/js_interop_gen/lib/src/interop_gen/transform/type_resolver.dart @@ -14,7 +14,7 @@ import '../../ast/helpers.dart'; import '../../ast/merger.dart'; import '../../ast/types.dart'; import '../../js/annotations.dart'; -import '../../js/generated/node_api.dart'; +import '../../js/filesystem_api.dart'; import '../../js/typescript.dart' as ts; import '../../js/typescript.types.dart'; import '../../translator.dart'; @@ -568,7 +568,7 @@ class TypeResolver { // if import there and not this file, imported from specified file final importUrl = !nameImport.endsWith('.d.ts') && - Fs.existsSync( + fs.existsSync( p.isAbsolute('$nameImport.d.ts') ? '$nameImport.d.ts' : p.join(p.dirname(transformer.file), '$nameImport.d.ts'), diff --git a/js_interop_gen/lib/src/js/filesystem_api.dart b/js_interop_gen/lib/src/js/filesystem_api.dart new file mode 100644 index 00000000..f09781ec --- /dev/null +++ b/js_interop_gen/lib/src/js/filesystem_api.dart @@ -0,0 +1,29 @@ +// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'dart:js_interop'; +import 'generated/node_api.dart' as gen; + +export 'generated/node_api.dart' + show GlobSyncOptions, MkdirOptions, ReadFileOptions, fs; + +// Safe creator helpers for options bags to avoid calling non-existent JS +// constructors. +gen.MkdirOptions mkdirOptions({bool? recursive}) { + final obj = JSObject() as gen.MkdirOptions; + if (recursive != null) obj.recursive = recursive; + return obj; +} + +gen.ReadFileOptions readFileOptions({String? encoding}) { + final obj = JSObject() as gen.ReadFileOptions; + if (encoding != null) obj.encoding = encoding; + return obj; +} + +gen.GlobSyncOptions globSyncOptions({String? cwd}) { + final obj = JSObject() as gen.GlobSyncOptions; + if (cwd != null) obj.cwd = cwd; + return obj; +} diff --git a/js_interop_gen/lib/src/js/generated/node_api.dart b/js_interop_gen/lib/src/js/generated/node_api.dart index 9ca19132..45b619e0 100644 --- a/js_interop_gen/lib/src/js/generated/node_api.dart +++ b/js_interop_gen/lib/src/js/generated/node_api.dart @@ -7,24 +7,17 @@ import 'dart:js_interop' as _i1; extension type MkdirOptions._(_i1.JSObject _) implements _i1.JSObject { - external MkdirOptions({bool recursive}); - external bool? recursive; } extension type ReadFileOptions._(_i1.JSObject _) implements _i1.JSObject { - external ReadFileOptions({String encoding}); - external String? encoding; } extension type GlobSyncOptions._(_i1.JSObject _) implements _i1.JSObject { - external GlobSyncOptions({String cwd, _AnonymousFunction_1801294 exclude}); - external String? cwd; external _AnonymousFunction_1801294? exclude; } -@_i1.JS('fs') -extension type Fs._(_i1.JSObject _) implements _i1.JSObject { +extension type fs._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static bool existsSync(String path); @_i1.JS() @@ -39,13 +32,11 @@ extension type Fs._(_i1.JSObject _) implements _i1.JSObject { GlobSyncOptions? options, ]); } -@_i1.JS('process') -extension type Process._(_i1.JSObject _) implements _i1.JSObject { +extension type process._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static void exit(num code); } -@_i1.JS('console') -extension type Console._(_i1.JSObject _) implements _i1.JSObject { +extension type console._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static void error(String message); } diff --git a/js_interop_gen/lib/src/js/node.dart b/js_interop_gen/lib/src/js/node.dart new file mode 100644 index 00000000..1cffce8b --- /dev/null +++ b/js_interop_gen/lib/src/js/node.dart @@ -0,0 +1,11 @@ +// Copyright (c) 2025, the Dart project authors. Please see the AUTHORS file +// for details. All rights reserved. Use of this source code is governed by a +// BSD-style license that can be found in the LICENSE file. + +import 'generated/node_api.dart' as gen; + +export 'generated/node_api.dart' show url; + +void exit(int code) => gen.process.exit(code); + +void printErr(String message) => gen.console.error(message); diff --git a/js_interop_gen/lib/src/util.dart b/js_interop_gen/lib/src/util.dart index bd7927c1..8e82e541 100644 --- a/js_interop_gen/lib/src/util.dart +++ b/js_interop_gen/lib/src/util.dart @@ -6,15 +6,15 @@ import 'dart:js_interop'; import 'package:path/path.dart' as p; -import 'js/generated/node_api.dart'; +import 'js/filesystem_api.dart'; // TODO(joshualitt): Let's find a better place for these. @JS('Object.entries') external JSArray objectEntries(JSObject o); void ensureDirectoryExists(String dir) { - if (!Fs.existsSync(dir)) { - Fs.mkdirSync(dir, MkdirOptions(recursive: true)); + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, mkdirOptions(recursive: true)); } } @@ -56,9 +56,9 @@ List expandGlobs( required String extension, }) { cwd ??= p.current; - final globSync = Fs.globSync( + final globSync = fs.globSync( input.map((i) => i.toJS).toList().toJS, - GlobSyncOptions(cwd: cwd), + globSyncOptions(cwd: cwd), ); return globSync.toDart .map((i) => i.toDart) diff --git a/js_interop_gen/test/assets/test_overrides_golden.dart b/js_interop_gen/test/assets/test_overrides_golden.dart index d61dfb26..ff9552a4 100644 --- a/js_interop_gen/test/assets/test_overrides_golden.dart +++ b/js_interop_gen/test/assets/test_overrides_golden.dart @@ -13,15 +13,11 @@ import 'dart:js_interop' as _i1; extension type ConfigDetails._(_i1.JSObject _) implements _i1.JSObject { - external ConfigDetails({Role role, AnonymousUnion_2683278 conflictProp}); - external Role role; external String conflictProp; } extension type RHS._(_i1.JSObject _) implements _i1.JSObject { - external RHS({AnonymousUnion_3235362 value}); - external String value; } extension type const Role._(int _) { diff --git a/js_interop_gen/test/assets/unsupported_test_expected.dart b/js_interop_gen/test/assets/unsupported_test_expected.dart index f87a66b9..815430cb 100644 --- a/js_interop_gen/test/assets/unsupported_test_expected.dart +++ b/js_interop_gen/test/assets/unsupported_test_expected.dart @@ -5,8 +5,6 @@ import 'dart:js_interop' as _i1; extension type Foo._(_i1.JSObject _) implements _i1.JSObject { - external Foo({String name, double length, _i1.JSArrayBuffer raw}); - external String name; external double length; @@ -14,7 +12,5 @@ extension type Foo._(_i1.JSObject _) implements _i1.JSObject { external _i1.JSArrayBuffer raw; } extension type Fee._(_i1.JSObject _) implements _i1.JSObject { - external Fee({_i1.JSAny raw}); - external _i1.JSAny raw; } diff --git a/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart b/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart index 9b62bd74..5448927f 100644 --- a/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/boolean_literal_union_expected.dart @@ -8,13 +8,6 @@ import 'dart:js_interop' as _i1; extension type PresentationOptions._(_i1.JSObject _) implements _i1.JSObject { - external PresentationOptions({ - AnonymousUnion_3982518 createIfNone, - AnonymousUnion_3062264 stringUnion, - AnonymousUnion_2379119 intUnion, - AnonymousUnion_8514031 doubleUnion, - }); - external AnonymousUnion_3982518 createIfNone; external AnonymousUnion_3062264 stringUnion; diff --git a/js_interop_gen/test/integration/interop_gen/classes_expected.dart b/js_interop_gen/test/integration/interop_gen/classes_expected.dart index ea990886..94777894 100644 --- a/js_interop_gen/test/integration/interop_gen/classes_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/classes_expected.dart @@ -10,18 +10,12 @@ import 'dart:js_interop' as _i1; import 'package:meta/meta.dart' as _i2; extension type Point2D._(_i1.JSObject _) implements _i1.JSObject { - external Point2D({double x, double y}); - external double x; external double y; } -extension type Shape._(_i1.JSObject _) implements _i1.JSObject { - external Shape(); -} +extension type Shape._(_i1.JSObject _) implements _i1.JSObject {} extension type Shape2D._(_i1.JSObject _) implements Shape { - external Shape2D({double sides}); - external double? get sides; external double get perimeter; external double get area; @@ -60,8 +54,6 @@ extension type Square._(_i1.JSObject _) implements Rectangle { @_i1.JS() external Square drawSquare(Point2D start, num length, [num? angle]); extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { - external Point3D({double x, double y, double z}); - external double x; external double y; @@ -69,8 +61,6 @@ extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { external double z; } extension type Shape3D._(_i1.JSObject _) implements Shape { - external Shape3D(); - external double get volume; external double surfaceArea(); } @@ -185,8 +175,6 @@ external Point2D get origin2D; @_i1.JS() external Point3D get origin3D; extension type Vector._(_i1.JSObject _) implements _i1.JSObject { - external Vector(); - external double get magnitude; external double get directionAngle; } @@ -226,8 +214,6 @@ extension type Vector3D._(_i1.JSObject _) implements Vector { external static Vector3D fromPoints(Point3D start, Point3D end); } extension type DirectionAngles._(_i1.JSObject _) implements _i1.JSObject { - external DirectionAngles({double alpha, double beta, double gamma}); - external double alpha; external double beta; @@ -281,8 +267,6 @@ extension type const AnonymousUnion_7177595._(String _) { } extension type Epahs._(_i1.JSObject _) implements _i1.JSObject { - external Epahs({String id, String name}); - external String name; external String get id; @@ -298,7 +282,5 @@ extension type const AnonymousUnion_4033716._(String _) { } extension type Container._(_i1.JSObject _) implements _i1.JSObject { - external Container({T value}); - external T value; } diff --git a/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart b/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart index a863fc5c..b67770a5 100644 --- a/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/duplicate_implements_expected.dart @@ -8,23 +8,15 @@ import 'dart:js_interop' as _i1; extension type Grandparent._(_i1.JSObject _) implements _i1.JSObject { - external Grandparent({String grandparentProp}); - external String grandparentProp; } extension type ParentA._(_i1.JSObject _) implements Grandparent { - external ParentA({String aProp}); - external String aProp; } extension type ParentB._(_i1.JSObject _) implements Grandparent { - external ParentB({String bProp}); - external String bProp; } extension type Child._(_i1.JSObject _) implements ParentA, ParentB { - external Child({String childProp}); - external String childProp; } typedef UnionWithDuplicates = AnonymousUnion_2488765; diff --git a/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart b/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart index 45f3f5f7..e047bd09 100644 --- a/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/duplicate_references_expected.dart @@ -12,8 +12,6 @@ import 'dart:js_interop' as _i1; extension type Thenable._(_i1.JSObject _) implements _i1.JSObject { - external Thenable(); - external Thenable> then([ _AnonymousFunction_2123872? onfulfilled, @@ -26,17 +24,12 @@ extension type Uri._(_i1.JSObject _) implements _i1.JSObject { external static Uri parse(String value); } extension type TextDocument._(_i1.JSObject _) implements _i1.JSObject { - external TextDocument({Uri uri}); - external Uri get uri; } extension type TextEditor._(_i1.JSObject _) implements _i1.JSObject { - external TextEditor({TextDocument document}); - external TextDocument get document; } -@_i1.JS('workspace') -extension type Workspace._(_i1.JSObject _) implements _i1.JSObject { +extension type workspace._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static Thenable openTextDocument(Uri uri); } diff --git a/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart b/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart index 5b2221ba..8145edea 100644 --- a/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/empty_deprecation_expected.dart @@ -8,7 +8,5 @@ import 'dart:js_interop' as _i1; 'This declaration has been marked as deprecated in the original JS/TS code', ) extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { - external Wrapper({String value}); - external String value; } diff --git a/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart index c2ac8f55..9968b96a 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_builtin_arguments_expected.dart @@ -5,7 +5,5 @@ import 'dart:js_interop' as _i1; extension type Resource._(_i1.JSObject _) implements _i1.JSObject { - external Resource({_i1.JSPromise<_i1.JSString> promise}); - external _i1.JSPromise<_i1.JSString> promise; } diff --git a/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart index b2a74679..8fdfd668 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_builtin_blindspot_expected.dart @@ -5,16 +5,9 @@ import 'dart:js_interop' as _i1; extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { - external Wrapper({String value}); - external String value; } extension type Container._(_i1.JSObject _) implements _i1.JSObject { - external Container({ - _i1.JSArray arrays, - _i1.JSPromise promises, - }); - external _i1.JSArray arrays; external _i1.JSPromise promises; diff --git a/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart index cfd4283e..466958d4 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_interface_merge_expected.dart @@ -6,8 +6,6 @@ import 'dart:js_interop' as _i1; extension type Container._(_i1.JSObject _) implements _i1.JSObject { - external Container({T value, T originalVal, T anotherVal}); - external T value; external T originalVal; diff --git a/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart index 78aafdd3..31d4ecd9 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_parameter_padding_expected.dart @@ -9,18 +9,11 @@ extension type Wrapper< TReturn extends _i1.JSAny?, TNext extends _i1.JSAny? >._(_i1.JSObject _) implements _i1.JSObject { - external Wrapper({ - T value, - Wrapper<_i1.JSString, _i1.JSAny?, _i1.JSAny?> stream, - }); - external T value; external Wrapper<_i1.JSString, _i1.JSAny?, _i1.JSAny?> stream; } extension type BoundWrapper._(_i1.JSObject _) implements _i1.JSObject { - external BoundWrapper({BoundWrapper<_i1.JSString> value}); - external BoundWrapper<_i1.JSString> value; } diff --git a/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart index 7e3a85b8..ec726baa 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_type_arguments_dependency_expected.dart @@ -9,17 +9,13 @@ import 'dart:js_interop' as _i1; extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { - external Wrapper({T value}); - external T value; external Wrapper> map( _AnonymousFunction_2569989 onfulfilled, ); } -extension type Container._(_i1.JSObject _) implements Wrapper<_i1.JSString> { - external Container(); -} +extension type Container._(_i1.JSObject _) implements Wrapper<_i1.JSString> {} extension type _AnonymousFunction_2569989< R extends _i1.JSAny?, T extends _i1.JSAny? diff --git a/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart index 3a398085..4d804e7a 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_union_casting_expected.dart @@ -9,20 +9,14 @@ import 'dart:js_interop' as _i1; extension type Event._(_i1.JSObject _) implements _i1.JSObject { - external Event({T listener}); - external T listener; } extension type CustomEventA._(_i1.JSObject _) implements _i1.JSObject { - external CustomEventA({T data}); - external T data; } extension type CustomEventB._(_i1.JSObject _) implements _i1.JSObject { - external CustomEventB({T data}); - external T data; } typedef MixedEventUnion = AnonymousUnion_3597781; diff --git a/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart b/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart index 2f0cebb7..d4f87ddf 100644 --- a/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/generic_union_expected.dart @@ -9,27 +9,19 @@ import 'dart:js_interop' as _i1; extension type GenericContainer._(_i1.JSObject _) implements _i1.JSObject { - external GenericContainer({T value}); - external T value; } extension type TargetClass._(_i1.JSObject _) implements _i1.JSObject { - external TargetClass({GenericContainer field}); - external GenericContainer field; } extension type OtherContainer._(_i1.JSObject _) implements _i1.JSObject { - external OtherContainer({T otherValue}); - external T otherValue; } extension type TargetClassWithGenericUnion._( _i1.JSObject _ ) implements _i1.JSObject { - external TargetClassWithGenericUnion({AnonymousUnion_3899151 field}); - external AnonymousUnion_3899151 field; } extension type AnonymousUnion_3063943._(_i1.JSAny _) implements _i1.JSAny { diff --git a/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart b/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart index 5e74418c..ae201eef 100644 --- a/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/homogeneous_union_arrays_expected.dart @@ -8,12 +8,6 @@ import 'dart:js_interop' as _i1; extension type Container._(_i1.JSObject _) implements _i1.JSObject { - external Container({ - AnonymousUnion_3057876 arrayUnion, - AnonymousUnion_9545617 nestedGenericUnion, - AnonymousUnion_1757671 deepArrayUnion, - }); - external AnonymousUnion_3057876 arrayUnion; external AnonymousUnion_9545617 nestedGenericUnion; diff --git a/js_interop_gen/test/integration/interop_gen/import_export_expected.dart b/js_interop_gen/test/integration/interop_gen/import_export_expected.dart index f47f650d..c76a88df 100644 --- a/js_interop_gen/test/integration/interop_gen/import_export_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/import_export_expected.dart @@ -18,28 +18,20 @@ external Vector3D vectorProduct(Vector3D v1, Vector3D v2); external Vector3D mapTo3D(Vector2D v); extension type TransformerMatrix._(_i1.JSObject _) implements Matrix { - external TransformerMatrix(); - external V call(V v); } extension type ComparatorMatrix._(_i1.JSObject _) - implements Matrix, Comparator { - external ComparatorMatrix(); -} + implements Matrix, Comparator {} @_i1.JS() external _i1.JSArray get unitVectors; @_i1.JS('PolarPoint') extension type PolarCoordinate._(_i1.JSObject _) implements _i1.JSObject { - external PolarCoordinate({double magnitude, double angle}); - external double magnitude; external double angle; } @_i1.JS('CylindricalPoint') extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { - external CylindricalCoordinate({double radius, double angle, double z}); - external double radius; external double angle; @@ -48,8 +40,6 @@ extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { } @_i1.JS('SphericalPoint') extension type SphericalCoordinate._(_i1.JSObject _) implements _i1.JSObject { - external SphericalCoordinate({double magnitude, double theta, double tau}); - external double magnitude; external double theta; @@ -77,15 +67,11 @@ external Vector3D get unitJ3D; @_i1.JS() external Vector3D get unitK3D; extension type Point2D._(_i1.JSObject _) implements _i1.JSObject { - external Point2D({double x, double y}); - external double x; external double y; } extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { - external Point3D({double x, double y, double z}); - external double x; external double y; @@ -93,8 +79,6 @@ extension type Point3D._(_i1.JSObject _) implements _i1.JSObject { external double z; } extension type Vector._(_i1.JSObject _) implements _i1.JSObject { - external Vector(); - external double get magnitude; external double get directionAngle; } @@ -118,8 +102,6 @@ extension type Vector3D._(_i1.JSObject _) implements Vector { external static Vector3D fromPoints(Point3D start, Point3D end); } extension type DirectionAngles._(_i1.JSObject _) implements _i1.JSObject { - external DirectionAngles({double alpha, double beta, double gamma}); - external double alpha; external double beta; @@ -143,8 +125,6 @@ extension type Vector2D._(_i1.JSObject _) implements Vector { external static Vector2D fromPoints(Point2D start, Point2D end); } extension type Matrix._(_i1.JSObject _) implements _i1.JSObject { - external Matrix({double rows, double columns}); - external double rows; external double columns; @@ -153,7 +133,5 @@ extension type Matrix._(_i1.JSObject _) implements _i1.JSObject { } extension type Comparator._(_i1.JSObject _) implements _i1.JSObject { - external Comparator(); - external double call(T a, T b); } diff --git a/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart b/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart index 71f68560..d3f499af 100644 --- a/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/indexed_access_test_expected.dart @@ -8,8 +8,6 @@ import 'dart:js_interop' as _i1; extension type Person._(_i1.JSObject _) implements _i1.JSObject { - external Person({String name, double age}); - external String name; external double age; @@ -21,13 +19,9 @@ typedef PersonKeys = KeyOf_Person; typedef KeyValues = AnonymousUnion_2683278; typedef Missing = _i1.JSAny; extension type Foo._(_i1.JSObject _) implements _i1.JSObject { - external Foo({bool baseProp}); - external bool baseProp; } extension type Fee._(_i1.JSObject _) implements Foo { - external Fee({double bar}); - external double bar; } typedef Fee200 = _i1.JSAny; diff --git a/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart b/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart index 31e6159f..6f4db4df 100644 --- a/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/interfaces_expected.dart @@ -10,8 +10,6 @@ import 'dart:js_interop' as _i1; import 'package:meta/meta.dart' as _i2; extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { - external ILogger({String name, AnonymousUnion_1885558 level}); - external AnonymousUnion_1885558? level; external String get name; @@ -20,20 +18,14 @@ extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { external _i1.JSFunction? get flush; } extension type Dictionary._(_i1.JSObject _) implements _i1.JSObject { - external Dictionary(); - external String operator [](String key); } extension type Comparator._(_i1.JSObject _) implements _i1.JSObject { - external Comparator(); - external double call(T a, T b); } extension type Repository._(_i1.JSObject _) implements _i1.JSObject { - external Repository(); - external T findById(String id); external void save(T entity); } @@ -41,14 +33,10 @@ extension type RepoConstructor._(_i1.JSObject _) implements _i1.JSObject { external RepoConstructor(_i1.JSArray<_i1.JSString> args); } extension type AsyncService._(_i1.JSObject _) implements _i1.JSObject { - external AsyncService(); - external _i1.JSPromise<_i1.JSAny?> fetchData(String url); external _i1.JSPromise<_i1.JSBoolean> updateData(String id, String payload); } extension type User._(_i1.JSObject _) implements _i1.JSObject { - external User({String id, String email}); - external String id; external String email; @@ -56,22 +44,16 @@ extension type User._(_i1.JSObject _) implements _i1.JSObject { external _i1.JSFunction? get describe; } extension type Admin._(_i1.JSObject _) implements User, ILogger { - external Admin({String role}); - external String role; external void grantPermission(String permission); } extension type Config._(_i1.JSObject _) implements _i1.JSObject { - external Config({String env, bool debug}); - external String env; external bool debug; } extension type SecureResource._(_i1.JSObject _) implements _i1.JSObject { - external SecureResource({String accessToken}); - external String accessToken; external bool authenticate(); @@ -83,8 +65,6 @@ external LinkedList get rootList; @_i1.JS() external Comparator<_i1.JSNumber> get compareNumbers; extension type ErrorReporter._(_i1.JSObject _) implements _i1.JSObject { - external ErrorReporter(); - @_i2.doNotStore external _i1.JSAny? reportError(String msg); } @@ -98,7 +78,5 @@ extension type const AnonymousUnion_1885558._(String _) { static const AnonymousUnion_1885558 error = AnonymousUnion_1885558._('error'); } extension type LinkedList._(_i1.JSObject _) implements _i1.JSObject { - external LinkedList(); - external LinkedList next(); } diff --git a/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart b/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart index 74acac12..ec996066 100644 --- a/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/intersection_member_conflict_expected.dart @@ -8,12 +8,6 @@ import 'dart:js_interop' as _i1; extension type A._(_i1.JSObject _) implements _i1.JSObject { - external A({ - String conflictProperty, - @_i1.JS('_priv') String $_priv, - @_i1.JS('dashed-prop') String dashedProp, - }); - external String conflictProperty; @_i1.JS('_priv') @@ -25,12 +19,6 @@ extension type A._(_i1.JSObject _) implements _i1.JSObject { external bool conflictMethod(num param); } extension type B._(_i1.JSObject _) implements _i1.JSObject { - external B({ - double conflictProperty, - @_i1.JS('_priv') double $_priv, - @_i1.JS('dashed-prop') double dashedProp, - }); - external double conflictProperty; @_i1.JS('_priv') diff --git a/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart b/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart index 9bb35d44..18338e78 100644 --- a/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/intersection_object_literal_conflict_expected.dart @@ -8,8 +8,6 @@ import 'dart:js_interop' as _i1; extension type OptionHolder._(_i1.JSObject _) implements _i1.JSObject { - external OptionHolder({bool canPickMany}); - external bool? canPickMany; } typedef IntersectWithLiteral = AnonymousIntersection_3818894; diff --git a/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart b/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart index 7f212441..6a96fd6f 100644 --- a/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/jsdoc_expected.dart @@ -8,8 +8,6 @@ import 'package:meta/meta.dart' as _i2; /// Represents a user in the system. extension type User._(_i1.JSObject _) implements _i1.JSObject { - external User({String id, String name, String email, double age}); - /// Unique identifier for the user. external String id; @@ -52,12 +50,6 @@ external void logEvent(String event, _i1.JSObject payload); /// Represents a configuration object for the app. extension type AppConfig._(_i1.JSObject _) implements _i1.JSObject { - external AppConfig({ - String env, - bool debug, - _i1.JSArray<_i1.JSString> features, - }); - /// The environment name (e.g., 'dev', 'prod'). external String env; @@ -90,8 +82,6 @@ external void cleanup(); @_i1.JS() external _i1.JSPromise<_i1.JSAny?> shutdownSystem(); extension type Logger._(_i1.JSObject _) implements _i1.JSObject { - external Logger(); - external void info(String msg); external void warn(String msg); external void error(String msg); diff --git a/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart b/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart index e3263218..44aa2810 100644 --- a/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/module_generic_param_expected.dart @@ -12,8 +12,6 @@ import 'dart:js_interop' as _i1; extension type Event._(_i1.JSObject _) implements _i1.JSObject { - external Event(); - external _i1.JSAny? call(_AnonymousFunction_6204725 listener); } extension type _AnonymousFunction_6204725._( diff --git a/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart b/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart index 6348928e..eac63b47 100644 --- a/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/namespaces_expected.dart @@ -74,8 +74,6 @@ extension type Core_LogEntry._(_i1.JSObject _) implements _i1.JSObject { /// This interface is used across multiple services and modules. @_i1.JS('Core.IAppConfig') extension type Core_IAppConfig._(_i1.JSObject _) implements _i1.JSObject { - external Core_IAppConfig({String apiEndpoint, bool authRequired}); - external String apiEndpoint; external bool authRequired; @@ -101,8 +99,6 @@ extension type const AnonymousUnion_3129258._(String _) { } @_i1.JS('Security.IAuthToken') extension type Security_IAuthToken._(_i1.JSObject _) implements _i1.JSObject { - external Security_IAuthToken({String token, double expiresIn, double userId}); - external String token; external double expiresIn; @@ -124,8 +120,6 @@ extension type Security_AuthService._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('Data.IRepository') extension type Data_IRepository._(_i1.JSObject _) implements _i1.JSObject { - external Data_IRepository(); - external T? findById(num id); external _i1.JSArray findAll(); external void save(T entity); @@ -154,8 +148,6 @@ extension type Data_Models_User._(_i1.JSObject _) implements Data_Models_IUser { } @_i1.JS('Data.Models.IUser') extension type Data_Models_IUser._(_i1.JSObject _) implements _i1.JSObject { - external Data_Models_IUser({double id, String name, String email}); - external double id; external String name; @@ -184,8 +176,6 @@ extension type EnterpriseApp_Models._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('EnterpriseApp.Models.IUser') extension type EnterpriseApp_Models_IUser._(_i1.JSObject _) implements _i1.JSObject { - external EnterpriseApp_Models_IUser({double id, String name, String email}); - external double id; external String name; @@ -210,12 +200,6 @@ extension type EnterpriseApp_Models_User._(_i1.JSObject _) @_i1.JS('EnterpriseApp.Models.IProduct') extension type EnterpriseApp_Models_IProduct._(_i1.JSObject _) implements _i1.JSObject { - external EnterpriseApp_Models_IProduct({ - String sku, - String title, - double price, - }); - external String sku; external String title; @@ -267,8 +251,6 @@ extension type EnterpriseApp_DataServices_IDataService._( _i1.JSObject _ ) implements _i1.JSObject { - external EnterpriseApp_DataServices_IDataService(); - external _i1.JSArray getAll(); external T getById(String id); external void save(T item); diff --git a/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart b/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart index a4e3a5d4..1f98c2a9 100644 --- a/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/nullable_union_typearg_expected.dart @@ -6,12 +6,8 @@ import 'dart:js_interop' as _i1; extension type Holder._(_i1.JSObject _) implements _i1.JSObject { - external Holder({T value}); - external T value; } extension type Consumer._(_i1.JSObject _) implements _i1.JSObject { - external Consumer({Holder<_i1.JSString> useHolder}); - external Holder<_i1.JSString> useHolder; } diff --git a/js_interop_gen/test/integration/interop_gen/overload_expected.dart b/js_interop_gen/test/integration/interop_gen/overload_expected.dart index 2d153628..289879fb 100644 --- a/js_interop_gen/test/integration/interop_gen/overload_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/overload_expected.dart @@ -23,15 +23,13 @@ extension type foo._(_i1.JSObject _) implements _i1.JSObject { external String name; external static String get version; - external static foo_Fum get fum; + external static foo_fum get fum; external static bool isFoo(_i1.JSAny? obj); external String greet(); } @_i1.JS() external foo get f; extension type bar._(_i1.JSObject _) implements baz { - external bar({double id, String name, bool active}); - external double id; external String name; @@ -107,14 +105,10 @@ extension type SomeNamespace._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('SomeNamespace.BytesView') extension type SomeNamespace_BytesView._(_i1.JSObject _) implements _i1.JSObject { - external SomeNamespace_BytesView({_i1.JSArrayBuffer buffer}); - external _i1.JSArrayBuffer get buffer; } @_i1.JS('fooHelper.Options') extension type fooHelper_Options._(_i1.JSObject _) implements _i1.JSObject { - external fooHelper_Options({bool round}); - external bool? round; } @_i1.JS('fooHelper.OptionsImpl') @@ -125,13 +119,11 @@ extension type fooHelper_OptionsImpl._(_i1.JSObject _) external bool? round; } @_i1.JS('foo.fum') -extension type foo_Fum._(_i1.JSObject _) implements _i1.JSObject { +extension type foo_fum._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS() external static bool get blownByWolf; } extension type baz._(_i1.JSObject _) implements _i1.JSObject { - external baz({String debugString}); - external String get debugString; } @_i1.JS('SomeNamespace.NestedNamespace') @@ -154,10 +146,6 @@ extension type SomeNamespace_NestedNamespace_ByteBuffer._(_i1.JSObject _) @_i1.JS('SomeNamespace.NestedNamespace.ByteBuilder') extension type SomeNamespace_NestedNamespace_ByteBuilder._(_i1.JSObject _) implements _i1.JSObject { - external SomeNamespace_NestedNamespace_ByteBuilder({ - SomeNamespace_NestedNamespace_ByteBuffer buffer, - }); - external SomeNamespace_NestedNamespace_ByteBuffer buffer; external void addByte(num byte); diff --git a/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart b/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart index 5ce51df5..2ab97956 100644 --- a/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/private_names_escaping_expected.dart @@ -5,10 +5,6 @@ import 'dart:js_interop' as _i1; extension type InternalSettings._(_i1.JSObject _) implements _i1.JSObject { - external InternalSettings({ - @_i1.JS('__electricCharacterSupport') String $__electricCharacterSupport, - }); - @_i1.JS('__electricCharacterSupport') external String? $__electricCharacterSupport; diff --git a/js_interop_gen/test/integration/interop_gen/project/output/a.dart b/js_interop_gen/test/integration/interop_gen/project/output/a.dart index 3ec6818d..1f09bbfc 100644 --- a/js_interop_gen/test/integration/interop_gen/project/output/a.dart +++ b/js_interop_gen/test/integration/interop_gen/project/output/a.dart @@ -41,25 +41,19 @@ external _i2.Vector3D mapTo3D(_i2.Vector2D v); /// Type Name [V]: Vector2D subtype extension type TransformerMatrix._(_i1.JSObject _) implements Matrix { - external TransformerMatrix(); - external V call(V v); } /// A matrix that includes vector comparison capabilities. /// Type Name [V]: Vector2D subtype extension type ComparatorMatrix._(_i1.JSObject _) - implements Matrix, _i3.Comparator { - external ComparatorMatrix(); -} + implements Matrix, _i3.Comparator {} /// Represents a point in 2D space using polar coordinates. /// - `magnitude`: radial distance from the origin. /// - `angle`: angle in radians from the positive x-axis. @_i1.JS('PolarPoint') extension type PolarCoordinate._(_i1.JSObject _) implements _i1.JSObject { - external PolarCoordinate({double magnitude, double angle}); - external double magnitude; external double angle; @@ -71,8 +65,6 @@ extension type PolarCoordinate._(_i1.JSObject _) implements _i1.JSObject { /// - `z`: height along the z-axis. @_i1.JS('CylindricalPoint') extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { - external CylindricalCoordinate({double radius, double angle, double z}); - external double radius; external double angle; @@ -86,8 +78,6 @@ extension type CylindricalCoordinate._(_i1.JSObject _) implements _i1.JSObject { /// - `tau`: azimuthal angle from the x-axis in the xy-plane. @_i1.JS('SphericalPoint') extension type SphericalCoordinate._(_i1.JSObject _) implements _i1.JSObject { - external SphericalCoordinate({double magnitude, double theta, double tau}); - external double magnitude; external double theta; @@ -219,8 +209,6 @@ external _i2.Vector3D get unitK3D; /// - `columns`: number of columns. /// - Numeric index maps to an array of numbers (row data). extension type Matrix._(_i1.JSObject _) implements _i1.JSObject { - external Matrix({double rows, double columns}); - external double rows; external double columns; diff --git a/js_interop_gen/test/integration/interop_gen/project/output/b.dart b/js_interop_gen/test/integration/interop_gen/project/output/b.dart index 0d2956d2..2c79e12c 100644 --- a/js_interop_gen/test/integration/interop_gen/project/output/b.dart +++ b/js_interop_gen/test/integration/interop_gen/project/output/b.dart @@ -11,16 +11,12 @@ import 'package:meta/meta.dart' as _i2; extension type CoordinateSystem

._(_i1.JSObject _) implements _i1.JSObject { - external CoordinateSystem({P origin, _i1.JSArray

points}); - external _i1.JSArray

points; external P get origin; external void addPoint(P point); } extension type Point2D._(_i1.JSObject _) implements Point { - external Point2D({double x, double y}); - external double x; external double y; @@ -28,8 +24,6 @@ extension type Point2D._(_i1.JSObject _) implements Point { @_i1.JS() external Point2D get origin2D; extension type Vector._(_i1.JSObject _) implements _i1.JSObject { - external Vector(); - external double get magnitude; external double get directionAngle; } @@ -50,8 +44,6 @@ extension type Vector2D._(_i1.JSObject _) implements Vector { external static Vector2D fromPoints(Point2D start, Point2D end); } extension type Point3D._(_i1.JSObject _) implements Point { - external Point3D({double x, double y, double z}); - external double x; external double y; @@ -80,20 +72,14 @@ extension type Vector3D._(_i1.JSObject _) implements Vector { external static Vector3D fromPoints(Point3D start, Point3D end); } extension type DirectionAngles._(_i1.JSObject _) implements _i1.JSObject { - external DirectionAngles({double alpha, double beta, double gamma}); - external double alpha; external double beta; external double gamma; } -extension type Shape._(_i1.JSObject _) implements _i1.JSObject { - external Shape(); -} +extension type Shape._(_i1.JSObject _) implements _i1.JSObject {} extension type Shape2D._(_i1.JSObject _) implements Shape { - external Shape2D({double sides}); - external double? get sides; external double get perimeter; external double get area; @@ -132,8 +118,6 @@ extension type Square._(_i1.JSObject _) implements Rectangle { @_i1.JS() external Square drawSquare(Point2D start, num length, [num? angle]); extension type Shape3D._(_i1.JSObject _) implements Shape { - external Shape3D(); - external double get volume; external double surfaceArea(); } @@ -245,9 +229,7 @@ extension type EpahsImpl._(_i1.JSObject _) @_i1.JS('toString') external String toString$(); } -extension type Point._(_i1.JSObject _) implements _i1.JSObject { - external Point(); -} +extension type Point._(_i1.JSObject _) implements _i1.JSObject {} extension type const AnonymousUnion_7177595._(String _) { static const AnonymousUnion_7177595 circle = AnonymousUnion_7177595._( 'circle', @@ -263,8 +245,6 @@ extension type const AnonymousUnion_7177595._(String _) { } extension type Epahs._(_i1.JSObject _) implements _i1.JSObject { - external Epahs({String id, String name}); - external String name; external String get id; diff --git a/js_interop_gen/test/integration/interop_gen/project/output/c.dart b/js_interop_gen/test/integration/interop_gen/project/output/c.dart index 9a49086a..7d188430 100644 --- a/js_interop_gen/test/integration/interop_gen/project/output/c.dart +++ b/js_interop_gen/test/integration/interop_gen/project/output/c.dart @@ -15,15 +15,11 @@ import 'package:meta/meta.dart' as _i2; /// - `> 0` if `a > b` extension type Comparator._(_i1.JSObject _) implements _i1.JSObject { - external Comparator(); - external double call(T a, T b); } /// Represents a basic logger interface with optional flush capability. extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { - external ILogger({String name, AnonymousUnion_1885558 level}); - /// Logging level. Defaults to "info" if unspecified. external AnonymousUnion_1885558? level; @@ -46,16 +42,12 @@ extension type ILogger._(_i1.JSObject _) implements _i1.JSObject { /// A key-value map of strings. extension type Dictionary._(_i1.JSObject _) implements _i1.JSObject { - external Dictionary(); - external String operator [](String key); } /// A simple repository abstraction. extension type Repository._(_i1.JSObject _) implements _i1.JSObject { - external Repository(); - /// Finds an entity by its ID. /// - [id]: - The unique identifier. external T findById(String id); @@ -75,8 +67,6 @@ extension type RepoConstructor._(_i1.JSObject _) implements _i1.JSObject { /// **EXPERIMENTAL**: This API is under evaluation and may change. @_i2.experimental extension type AsyncService._(_i1.JSObject _) implements _i1.JSObject { - external AsyncService(); - /// Fetches remote data from a URL. /// - [url]: - The resource endpoint. external _i1.JSPromise<_i1.JSAny?> fetchData(String url); @@ -91,8 +81,6 @@ extension type AsyncService._(_i1.JSObject _) implements _i1.JSObject { /// Represents a basic user. extension type User._(_i1.JSObject _) implements _i1.JSObject { - external User({String id, String email}); - /// Unique identifier. external String id; @@ -105,8 +93,6 @@ extension type User._(_i1.JSObject _) implements _i1.JSObject { /// An administrator user with logging capabilities. extension type Admin._(_i1.JSObject _) implements User, ILogger { - external Admin({String role}); - /// Admin role label. external String role; @@ -117,8 +103,6 @@ extension type Admin._(_i1.JSObject _) implements User, ILogger { /// Configuration environment. extension type Config._(_i1.JSObject _) implements _i1.JSObject { - external Config({String env, bool debug}); - /// Environment name (e.g., 'production', 'dev'). external String env; @@ -128,8 +112,6 @@ extension type Config._(_i1.JSObject _) implements _i1.JSObject { /// Represents a resource that requires authentication. extension type SecureResource._(_i1.JSObject _) implements _i1.JSObject { - external SecureResource({String accessToken}); - /// A token used for authentication. external String accessToken; @@ -160,8 +142,6 @@ extension type const AnonymousUnion_1885558._(String _) { /// A basic self-referencing linked list node. extension type LinkedList._(_i1.JSObject _) implements _i1.JSObject { - external LinkedList(); - /// Returns the next node in the list. external LinkedList next(); } diff --git a/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart b/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart index c7094846..d5b5420a 100644 --- a/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/representation_type_inheritance_expected.dart @@ -5,13 +5,9 @@ import 'dart:js_interop' as _i1; extension type Parent._(_i1.JSObject _) implements _i1.JSObject { - external Parent({String parentProp}); - external String parentProp; } extension type SpecialArray._(_i1.JSArray<_i1.JSString> _) implements _i1.JSArray<_i1.JSString>, Parent { - external SpecialArray({double specialLength}); - external double specialLength; } diff --git a/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart b/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart index a7b0dba9..27808833 100644 --- a/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/rescope_dedup_expected.dart @@ -5,7 +5,5 @@ import 'dart:js_interop' as _i1; extension type Position._(_i1.JSObject _) implements _i1.JSObject { - external Position({double line}); - external double get line; } diff --git a/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart b/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart index afa559bd..8872481f 100644 --- a/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/string_literal_module_expected.dart @@ -8,7 +8,5 @@ library; import 'dart:js_interop' as _i1; extension type TextLine._(_i1.JSObject _) implements _i1.JSObject { - external TextLine({String text}); - external String get text; } diff --git a/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart b/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart index 6c12440f..70cfe7bf 100644 --- a/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/string_literals_expected.dart @@ -5,14 +5,6 @@ import 'dart:js_interop' as _i1; extension type Headers._(_i1.JSObject _) implements _i1.JSObject { - external Headers({ - @_i1.JS('content-type') String contentType, - @_i1.JS('Content-type') String contentType$1, - @_i1.JS('content-Type') String contentType$2, - @_i1.JS('Content-Type') String contentType$3, - @_i1.JS('content=type') String contentType$4, - }); - @_i1.JS('content-type') external String contentType; diff --git a/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart b/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart index e5169b56..c15208b7 100644 --- a/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/ts_typing_expected.dart @@ -238,8 +238,6 @@ extension type _AnonymousFunction_3794666._( } extension type ComposedType._(_i1.JSObject _) implements _i1.JSObject { - external ComposedType({T enclosed}); - external T enclosed; } extension type AnonymousUnion_8168791._(_i1.JSAny _) implements _i1.JSAny { diff --git a/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart b/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart index 05416554..87bc5f37 100644 --- a/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/type_arguments_nullability_expected.dart @@ -6,12 +6,8 @@ import 'dart:js_interop' as _i1; extension type Wrapper._(_i1.JSObject _) implements _i1.JSObject { - external Wrapper({T value}); - external T value; } extension type Container._(_i1.JSObject _) implements _i1.JSObject { - external Container({Wrapper<_i1.JSString> optionalWrapper}); - external Wrapper<_i1.JSString>? optionalWrapper; } diff --git a/js_interop_gen/test/integration/interop_gen/typealias_expected.dart b/js_interop_gen/test/integration/interop_gen/typealias_expected.dart index c5d141f3..5b5a8c3f 100644 --- a/js_interop_gen/test/integration/interop_gen/typealias_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/typealias_expected.dart @@ -87,8 +87,6 @@ extension type const AnonymousUnion_2375200._(String _) { } @_i1.JS('Space.Planet') extension type Space_Planet._(_i1.JSObject _) implements _i1.JSObject { - external Space_Planet({double radius}); - external double radius; } typedef LoggerContainer = _i1.JSArray; diff --git a/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart b/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart index 6a6517e4..e9752451 100644 --- a/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/typealias_namespace_nested_expected.dart @@ -9,29 +9,25 @@ import 'dart:js_interop' as _i1; import 'package:meta/meta.dart' as _i2; -@_i1.JS('symlink') -extension type Symlink._(_i1.JSObject _) implements _i1.JSObject {} +extension type symlink._(_i1.JSObject _) implements _i1.JSObject {} @_i1.JS() -external void mySymlink(Symlink_Type type); -@_i1.JS('stream') -extension type Stream._(_i1.JSObject _) implements _i1.JSObject { +external void mySymlink(symlink_Type type); +extension type stream._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('stream.Readable') - static Stream_Readable Readable() => Stream_Readable(); + static stream_Readable Readable() => stream_Readable(); } @_i1.JS('stream.Readable') -extension type Stream_Readable._(_i1.JSObject _) implements _i1.JSObject { - external Stream_Readable(); +extension type stream_Readable._(_i1.JSObject _) implements _i1.JSObject { + external stream_Readable(); } -extension type MyReadable._(_i1.JSObject _) implements Stream_Readable { +extension type MyReadable._(_i1.JSObject _) implements stream_Readable { external MyReadable(); } -extension type Empty._(_i1.JSObject _) implements _i1.JSObject { - external Empty(); -} +extension type Empty._(_i1.JSObject _) implements _i1.JSObject {} @_i2.doNotStore @_i1.JS() external _i1.JSAny? get emptyKey; -typedef Symlink_Type = AnonymousUnion_3598178; +typedef symlink_Type = AnonymousUnion_3598178; extension type const AnonymousUnion_3598178._(String _) { static const AnonymousUnion_3598178 dir = AnonymousUnion_3598178._('dir'); diff --git a/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart b/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart index 58c28f90..3632b770 100644 --- a/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/union_constraint_override_expected.dart @@ -8,20 +8,14 @@ import 'dart:js_interop' as _i1; extension type SpecializedBound._(_i1.JSObject _) implements _i1.JSObject { - external SpecializedBound({String tag}); - external String tag; } extension type HolderA._(_i1.JSObject _) implements _i1.JSObject { - external HolderA({T value}); - external T value; } extension type HolderB._(_i1.JSObject _) implements _i1.JSObject { - external HolderB({T value}); - external T value; } typedef ConstraintUnion = AnonymousUnion_7450886; diff --git a/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart b/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart index b5dc8439..2944d48b 100644 --- a/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/unsupported_properties_expected.dart @@ -5,7 +5,5 @@ import 'dart:js_interop' as _i1; extension type UnsupportedProperties._(_i1.JSObject _) implements _i1.JSObject { - external UnsupportedProperties({String normal}); - external String normal; } diff --git a/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart b/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart index 72bb394d..2453db3a 100644 --- a/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/void_generic_bounds_expected.dart @@ -6,12 +6,8 @@ import 'dart:js_interop' as _i1; extension type Event._(_i1.JSObject _) implements _i1.JSObject { - external Event(); - external void fire(T value); } extension type TargetClass._(_i1.JSObject _) implements _i1.JSObject { - external TargetClass({Event<_i1.JSAny?> onEvent}); - external Event<_i1.JSAny?> onEvent; } diff --git a/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart b/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart index 271365b1..eb305f56 100644 --- a/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/vscode_flattening_expected.dart @@ -6,36 +6,29 @@ import 'dart:js_interop' as _i1; extension type Range._(_i1.JSObject _) implements _i1.JSObject { - external Range({String globalField}); - external String globalField; } extension type Position._(_i1.JSObject _) implements _i1.JSObject { - external Position({String globalField}); - external String globalField; } -@_i1.JS('vscode') -extension type Vscode._(_i1.JSObject _) implements _i1.JSObject { +extension type vscode._(_i1.JSObject _) implements _i1.JSObject { @_i1.JS('vscode.Position') - static Vscode_Position Position(num line, num character) => - Vscode_Position(line, character); + static vscode_Position Position(num line, num character) => + vscode_Position(line, character); @_i1.JS('vscode.Range') - static Vscode_Range Range(Vscode_Position start, Vscode_Position end) => - Vscode_Range(start, end); + static vscode_Range Range(vscode_Position start, vscode_Position end) => + vscode_Range(start, end); } @_i1.JS('vscode.TextLine') -extension type Vscode_TextLine._(_i1.JSObject _) implements _i1.JSObject { - external Vscode_TextLine({Vscode_Range range}); - - external Vscode_Range get range; +extension type vscode_TextLine._(_i1.JSObject _) implements _i1.JSObject { + external vscode_Range get range; } @_i1.JS('vscode.Range') -extension type Vscode_Range._(_i1.JSObject _) implements _i1.JSObject { - external Vscode_Range(Vscode_Position start, Vscode_Position end); +extension type vscode_Range._(_i1.JSObject _) implements _i1.JSObject { + external vscode_Range(vscode_Position start, vscode_Position end); } @_i1.JS('vscode.Position') -extension type Vscode_Position._(_i1.JSObject _) implements _i1.JSObject { - external Vscode_Position(num line, num character); +extension type vscode_Position._(_i1.JSObject _) implements _i1.JSObject { + external vscode_Position(num line, num character); } diff --git a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart index 71fcfabd..da3996cf 100644 --- a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart @@ -36,13 +36,6 @@ external _i1.JSAny? handleEvents( ); extension type ElementStamp._(_i1.JSObject _) implements _i1.JSObject { - external ElementStamp({ - T target, - Date stampedAt, - String id, - AnonymousUnion_2036258 stampType, - }); - external String id; external AnonymousUnion_2036258 stampType; @@ -79,20 +72,14 @@ extension type HTMLTransformFunc< T extends _i2.HTMLElement, R extends _i2.HTMLElement >._(_i1.JSObject _) implements _i1.JSObject { - external HTMLTransformFunc(); - external R call(T element); } extension type EventManipulationFunc._(_i1.JSObject _) implements _i1.JSObject { - external EventManipulationFunc(); - external _i1.JSAny? call(_i2.Event event); } /// Enables basic storage and retrieval of dates and times. extension type Date._(_i1.JSObject _) implements _i1.JSObject { - external Date(); - /// Returns a string representation of a date. The format of the string /// depends on the locale. @_i1.JS('toString') @@ -115,14 +102,6 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. - /// - [locales]: A locale string, array of locale strings, Intl.Locale - /// object, or array of Intl.Locale objects that contain one or more - /// language or locale tags. If you include more than one locale string, - /// list them in descending order of priority so that the first entry is the - /// preferred locale. If you omit this parameter, the default locale of the - /// JavaScript runtime is used. - /// - [options]: An object that contains one or more properties that specify - /// comparison options. external String toLocaleString(); /// Returns a date as a string value appropriate to the host environment's @@ -135,14 +114,6 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. - /// - [locales]: A locale string, array of locale strings, Intl.Locale - /// object, or array of Intl.Locale objects that contain one or more - /// language or locale tags. If you include more than one locale string, - /// list them in descending order of priority so that the first entry is the - /// preferred locale. If you omit this parameter, the default locale of the - /// JavaScript runtime is used. - /// - [options]: An object that contains one or more properties that specify - /// comparison options. external String toLocaleDateString(); /// Returns a time as a string value appropriate to the host environment's @@ -155,14 +126,6 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. - /// - [locales]: A locale string, array of locale strings, Intl.Locale - /// object, or array of Intl.Locale objects that contain one or more - /// language or locale tags. If you include more than one locale string, - /// list them in descending order of priority so that the first entry is the - /// preferred locale. If you omit this parameter, the default locale of the - /// JavaScript runtime is used. - /// - [options]: An object that contains one or more properties that specify - /// comparison options. external String toLocaleTimeString(); /// Returns the stored time value in milliseconds since midnight, January 1, From 00c2fdaa33141b3ffde598fb871c3b7bfb38df0b Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Mon, 21 Sep 2026 04:42:22 +0000 Subject: [PATCH 9/9] test(js_interop_gen): update web_types_expected.dart for @types/node Date overloads --- .../interop_gen/web_types_expected.dart | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart index da3996cf..9a4a5d01 100644 --- a/js_interop_gen/test/integration/interop_gen/web_types_expected.dart +++ b/js_interop_gen/test/integration/interop_gen/web_types_expected.dart @@ -102,6 +102,14 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. + /// - [locales]: A locale string, array of locale strings, Intl.Locale + /// object, or array of Intl.Locale objects that contain one or more + /// language or locale tags. If you include more than one locale string, + /// list them in descending order of priority so that the first entry is the + /// preferred locale. If you omit this parameter, the default locale of the + /// JavaScript runtime is used. + /// - [options]: An object that contains one or more properties that specify + /// comparison options. external String toLocaleString(); /// Returns a date as a string value appropriate to the host environment's @@ -114,6 +122,14 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. + /// - [locales]: A locale string, array of locale strings, Intl.Locale + /// object, or array of Intl.Locale objects that contain one or more + /// language or locale tags. If you include more than one locale string, + /// list them in descending order of priority so that the first entry is the + /// preferred locale. If you omit this parameter, the default locale of the + /// JavaScript runtime is used. + /// - [options]: An object that contains one or more properties that specify + /// comparison options. external String toLocaleDateString(); /// Returns a time as a string value appropriate to the host environment's @@ -126,6 +142,14 @@ extension type Date._(_i1.JSObject _) implements _i1.JSObject { /// locale of the JavaScript runtime is used. /// - [options]: An object that contains one or more properties that specify /// comparison options. + /// - [locales]: A locale string, array of locale strings, Intl.Locale + /// object, or array of Intl.Locale objects that contain one or more + /// language or locale tags. If you include more than one locale string, + /// list them in descending order of priority so that the first entry is the + /// preferred locale. If you omit this parameter, the default locale of the + /// JavaScript runtime is used. + /// - [options]: An object that contains one or more properties that specify + /// comparison options. external String toLocaleTimeString(); /// Returns the stored time value in milliseconds since midnight, January 1,