From b1d56a4f0782dcae4c646fc9397f680847802c8b Mon Sep 17 00:00:00 2001 From: Natalie Weizenbaum Date: Fri, 21 Jul 2023 14:36:12 -0700 Subject: [PATCH] Change terminology to refer to JS instead of Node.js (#2039) Now that we support running in a browser, saying "Node.js" is generally inaccurate. It's still preserved in places that are genuinely Node-specific. --- lib/src/async_compile.dart | 4 +-- lib/src/compile.dart | 6 ++--- .../{node_to_dart => js_to_dart}/async.dart | 10 +++---- .../async_file.dart | 12 ++++----- .../{node_to_dart => js_to_dart}/file.dart | 12 ++++----- .../{node_to_dart => js_to_dart}/sync.dart | 10 +++---- .../importer/legacy_node/implementation.dart | 8 +++--- lib/src/io.dart | 4 +-- lib/src/io/{node.dart => js.dart} | 2 +- lib/src/{node.dart => js.dart} | 24 ++++++++--------- lib/src/{node => js}/array.dart | 0 lib/src/{node => js}/chokidar.dart | 0 lib/src/{node => js}/compile.dart | 26 +++++++++---------- lib/src/{node => js}/compile_options.dart | 2 +- lib/src/{node => js}/compile_result.dart | 0 lib/src/{node => js}/exception.dart | 0 lib/src/{node => js}/exports.dart | 4 +-- lib/src/{node => js}/function.dart | 0 lib/src/{node => js}/immutable.dart | 0 lib/src/{node => js}/importer.dart | 0 lib/src/{node => js}/legacy.dart | 14 +++++----- lib/src/{node => js}/legacy/fiber.dart | 0 .../{node => js}/legacy/importer_result.dart | 0 .../{node => js}/legacy/render_context.dart | 0 .../{node => js}/legacy/render_options.dart | 4 +-- .../{node => js}/legacy/render_result.dart | 0 lib/src/{node => js}/legacy/types.dart | 0 lib/src/{node => js}/legacy/value.dart | 2 +- .../{node => js}/legacy/value/boolean.dart | 0 lib/src/{node => js}/legacy/value/color.dart | 0 lib/src/{node => js}/legacy/value/list.dart | 0 lib/src/{node => js}/legacy/value/map.dart | 0 lib/src/{node => js}/legacy/value/null.dart | 0 lib/src/{node => js}/legacy/value/number.dart | 0 lib/src/{node => js}/legacy/value/string.dart | 0 lib/src/{node => js}/logger.dart | 4 +-- lib/src/{node => js}/reflection.dart | 0 lib/src/{node => js}/source_span.dart | 0 lib/src/{node => js}/url.dart | 0 lib/src/{node => js}/utils.dart | 0 lib/src/{node => js}/value.dart | 0 lib/src/{node => js}/value/argument_list.dart | 0 lib/src/{node => js}/value/boolean.dart | 0 lib/src/{node => js}/value/calculation.dart | 4 +-- lib/src/{node => js}/value/color.dart | 0 lib/src/{node => js}/value/function.dart | 0 lib/src/{node => js}/value/list.dart | 0 lib/src/{node => js}/value/map.dart | 0 lib/src/{node => js}/value/number.dart | 0 lib/src/{node => js}/value/string.dart | 0 lib/src/logger/deprecation_handling.dart | 9 +++---- .../{node_to_dart.dart => js_to_dart.dart} | 12 ++++----- lib/src/visitor/serialize.dart | 4 +-- test/browser_test.dart | 8 +++--- tool/grind.dart | 2 +- 55 files changed, 93 insertions(+), 94 deletions(-) rename lib/src/importer/{node_to_dart => js_to_dart}/async.dart (89%) rename lib/src/importer/{node_to_dart => js_to_dart}/async_file.dart (88%) rename lib/src/importer/{node_to_dart => js_to_dart}/file.dart (88%) rename lib/src/importer/{node_to_dart => js_to_dart}/sync.dart (90%) rename lib/src/io/{node.dart => js.dart} (99%) rename lib/src/{node.dart => js.dart} (85%) rename lib/src/{node => js}/array.dart (100%) rename lib/src/{node => js}/chokidar.dart (100%) rename lib/src/{node => js}/compile.dart (93%) rename lib/src/{node => js}/compile_options.dart (96%) rename lib/src/{node => js}/compile_result.dart (100%) rename lib/src/{node => js}/exception.dart (100%) rename lib/src/{node => js}/exports.dart (94%) rename lib/src/{node => js}/function.dart (100%) rename lib/src/{node => js}/immutable.dart (100%) rename lib/src/{node => js}/importer.dart (100%) rename lib/src/{node => js}/legacy.dart (98%) rename lib/src/{node => js}/legacy/fiber.dart (100%) rename lib/src/{node => js}/legacy/importer_result.dart (100%) rename lib/src/{node => js}/legacy/render_context.dart (100%) rename lib/src/{node => js}/legacy/render_options.dart (96%) rename lib/src/{node => js}/legacy/render_result.dart (100%) rename lib/src/{node => js}/legacy/types.dart (100%) rename lib/src/{node => js}/legacy/value.dart (97%) rename lib/src/{node => js}/legacy/value/boolean.dart (100%) rename lib/src/{node => js}/legacy/value/color.dart (100%) rename lib/src/{node => js}/legacy/value/list.dart (100%) rename lib/src/{node => js}/legacy/value/map.dart (100%) rename lib/src/{node => js}/legacy/value/null.dart (100%) rename lib/src/{node => js}/legacy/value/number.dart (100%) rename lib/src/{node => js}/legacy/value/string.dart (100%) rename lib/src/{node => js}/logger.dart (94%) rename lib/src/{node => js}/reflection.dart (100%) rename lib/src/{node => js}/source_span.dart (100%) rename lib/src/{node => js}/url.dart (100%) rename lib/src/{node => js}/utils.dart (100%) rename lib/src/{node => js}/value.dart (100%) rename lib/src/{node => js}/value/argument_list.dart (100%) rename lib/src/{node => js}/value/boolean.dart (100%) rename lib/src/{node => js}/value/calculation.dart (98%) rename lib/src/{node => js}/value/color.dart (100%) rename lib/src/{node => js}/value/function.dart (100%) rename lib/src/{node => js}/value/list.dart (100%) rename lib/src/{node => js}/value/map.dart (100%) rename lib/src/{node => js}/value/number.dart (100%) rename lib/src/{node => js}/value/string.dart (100%) rename lib/src/logger/{node_to_dart.dart => js_to_dart.dart} (83%) diff --git a/lib/src/async_compile.dart b/lib/src/async_compile.dart index e21dfa5c1..f1c6ed4bb 100644 --- a/lib/src/async_compile.dart +++ b/lib/src/async_compile.dart @@ -78,7 +78,7 @@ Future compileAsync(String path, sourceMap, charset); - deprecationLogger.summarize(node: nodeImporter != null); + deprecationLogger.summarize(js: nodeImporter != null); return result; } @@ -130,7 +130,7 @@ Future compileStringAsync(String source, sourceMap, charset); - deprecationLogger.summarize(node: nodeImporter != null); + deprecationLogger.summarize(js: nodeImporter != null); return result; } diff --git a/lib/src/compile.dart b/lib/src/compile.dart index 25f8f2e09..af96a3bd0 100644 --- a/lib/src/compile.dart +++ b/lib/src/compile.dart @@ -5,7 +5,7 @@ // DO NOT EDIT. This file was generated from async_compile.dart. // See tool/grind/synchronize.dart for details. // -// Checksum: bac7360553f772bbf8243cca78f4f63e4bdf2755 +// Checksum: d6fc59fc731ebbba7d3a8cabc259e09fdc871764 // // ignore_for_file: unused_import @@ -87,7 +87,7 @@ CompileResult compile(String path, sourceMap, charset); - deprecationLogger.summarize(node: nodeImporter != null); + deprecationLogger.summarize(js: nodeImporter != null); return result; } @@ -139,7 +139,7 @@ CompileResult compileString(String source, sourceMap, charset); - deprecationLogger.summarize(node: nodeImporter != null); + deprecationLogger.summarize(js: nodeImporter != null); return result; } diff --git a/lib/src/importer/node_to_dart/async.dart b/lib/src/importer/js_to_dart/async.dart similarity index 89% rename from lib/src/importer/node_to_dart/async.dart rename to lib/src/importer/js_to_dart/async.dart index 5cf06e225..d11552885 100644 --- a/lib/src/importer/node_to_dart/async.dart +++ b/lib/src/importer/js_to_dart/async.dart @@ -7,23 +7,23 @@ import 'dart:async'; import 'package:node_interop/js.dart'; import 'package:node_interop/util.dart'; -import '../../node/importer.dart'; -import '../../node/url.dart'; -import '../../node/utils.dart'; +import '../../js/importer.dart'; +import '../../js/url.dart'; +import '../../js/utils.dart'; import '../../util/nullable.dart'; import '../async.dart'; import '../result.dart'; /// A wrapper for a potentially-asynchronous JS API importer that exposes it as /// a Dart [AsyncImporter]. -class NodeToDartAsyncImporter extends AsyncImporter { +class JSToDartAsyncImporter extends AsyncImporter { /// The wrapped canonicalize function. final Object? Function(String, CanonicalizeOptions) _canonicalize; /// The wrapped load function. final Object? Function(JSUrl) _load; - NodeToDartAsyncImporter(this._canonicalize, this._load); + JSToDartAsyncImporter(this._canonicalize, this._load); FutureOr canonicalize(Uri url) async { var result = _canonicalize( diff --git a/lib/src/importer/node_to_dart/async_file.dart b/lib/src/importer/js_to_dart/async_file.dart similarity index 88% rename from lib/src/importer/node_to_dart/async_file.dart rename to lib/src/importer/js_to_dart/async_file.dart index ddab82882..f7dadee18 100644 --- a/lib/src/importer/node_to_dart/async_file.dart +++ b/lib/src/importer/js_to_dart/async_file.dart @@ -7,27 +7,27 @@ import 'dart:async'; import 'package:node_interop/js.dart'; import 'package:node_interop/util.dart'; -import '../../node/importer.dart'; -import '../../node/url.dart'; -import '../../node/utils.dart'; +import '../../js/importer.dart'; +import '../../js/url.dart'; +import '../../js/utils.dart'; import '../async.dart'; import '../filesystem.dart'; import '../result.dart'; import '../utils.dart'; /// A filesystem importer to use for most implementation details of -/// [NodeToDartAsyncFileImporter]. +/// [JSToDartAsyncFileImporter]. /// /// This allows us to avoid duplicating logic between the two importers. final _filesystemImporter = FilesystemImporter('.'); /// A wrapper for a potentially-asynchronous JS API file importer that exposes /// it as a Dart [AsyncImporter]. -class NodeToDartAsyncFileImporter extends AsyncImporter { +class JSToDartAsyncFileImporter extends AsyncImporter { /// The wrapped `findFileUrl` function. final Object? Function(String, CanonicalizeOptions) _findFileUrl; - NodeToDartAsyncFileImporter(this._findFileUrl); + JSToDartAsyncFileImporter(this._findFileUrl); FutureOr canonicalize(Uri url) async { if (url.scheme == 'file') return _filesystemImporter.canonicalize(url); diff --git a/lib/src/importer/node_to_dart/file.dart b/lib/src/importer/js_to_dart/file.dart similarity index 88% rename from lib/src/importer/node_to_dart/file.dart rename to lib/src/importer/js_to_dart/file.dart index 15c2bad7f..78b65395f 100644 --- a/lib/src/importer/node_to_dart/file.dart +++ b/lib/src/importer/js_to_dart/file.dart @@ -5,24 +5,24 @@ import 'package:node_interop/js.dart'; import '../../importer.dart'; -import '../../node/importer.dart'; -import '../../node/url.dart'; -import '../../node/utils.dart'; +import '../../js/importer.dart'; +import '../../js/url.dart'; +import '../../js/utils.dart'; import '../utils.dart'; /// A filesystem importer to use for most implementation details of -/// [NodeToDartAsyncFileImporter]. +/// [JSToDartAsyncFileImporter]. /// /// This allows us to avoid duplicating logic between the two importers. final _filesystemImporter = FilesystemImporter('.'); /// A wrapper for a potentially-asynchronous JS API file importer that exposes /// it as a Dart [AsyncImporter]. -class NodeToDartFileImporter extends Importer { +class JSToDartFileImporter extends Importer { /// The wrapped `findFileUrl` function. final Object? Function(String, CanonicalizeOptions) _findFileUrl; - NodeToDartFileImporter(this._findFileUrl); + JSToDartFileImporter(this._findFileUrl); Uri? canonicalize(Uri url) { if (url.scheme == 'file') return _filesystemImporter.canonicalize(url); diff --git a/lib/src/importer/node_to_dart/sync.dart b/lib/src/importer/js_to_dart/sync.dart similarity index 90% rename from lib/src/importer/node_to_dart/sync.dart rename to lib/src/importer/js_to_dart/sync.dart index 4352d8d3e..7f2339d6e 100644 --- a/lib/src/importer/node_to_dart/sync.dart +++ b/lib/src/importer/js_to_dart/sync.dart @@ -5,21 +5,21 @@ import 'package:node_interop/js.dart'; import '../../importer.dart'; -import '../../node/importer.dart'; -import '../../node/url.dart'; -import '../../node/utils.dart'; +import '../../js/importer.dart'; +import '../../js/url.dart'; +import '../../js/utils.dart'; import '../../util/nullable.dart'; /// A wrapper for a synchronous JS API importer that exposes it as a Dart /// [Importer]. -class NodeToDartImporter extends Importer { +class JSToDartImporter extends Importer { /// The wrapped canonicalize function. final Object? Function(String, CanonicalizeOptions) _canonicalize; /// The wrapped load function. final Object? Function(JSUrl) _load; - NodeToDartImporter(this._canonicalize, this._load); + JSToDartImporter(this._canonicalize, this._load); Uri? canonicalize(Uri url) { var result = _canonicalize( diff --git a/lib/src/importer/legacy_node/implementation.dart b/lib/src/importer/legacy_node/implementation.dart index c08d5a30e..3175648b7 100644 --- a/lib/src/importer/legacy_node/implementation.dart +++ b/lib/src/importer/legacy_node/implementation.dart @@ -9,10 +9,10 @@ import 'package:path/path.dart' as p; import 'package:tuple/tuple.dart'; import '../../io.dart'; -import '../../node/function.dart'; -import '../../node/legacy/importer_result.dart'; -import '../../node/legacy/render_context.dart'; -import '../../node/utils.dart'; +import '../../js/function.dart'; +import '../../js/legacy/importer_result.dart'; +import '../../js/legacy/render_context.dart'; +import '../../js/utils.dart'; import '../../util/nullable.dart'; import '../utils.dart'; diff --git a/lib/src/io.dart b/lib/src/io.dart index c96f7a25a..f8e299e86 100644 --- a/lib/src/io.dart +++ b/lib/src/io.dart @@ -6,13 +6,13 @@ import 'package:path/path.dart' as p; import 'io/interface.dart' if (dart.library.io) 'io/vm.dart' - if (dart.library.js) 'io/node.dart'; + if (dart.library.js) 'io/js.dart'; import 'utils.dart'; import 'util/character.dart'; export 'io/interface.dart' if (dart.library.io) 'io/vm.dart' - if (dart.library.js) 'io/node.dart'; + if (dart.library.js) 'io/js.dart'; /// A cache of return values for directories in [_realCasePath]. final _realCaseCache = {}; diff --git a/lib/src/io/node.dart b/lib/src/io/js.dart similarity index 99% rename from lib/src/io/node.dart rename to lib/src/io/js.dart index da58048a2..5fd3db3e3 100644 --- a/lib/src/io/node.dart +++ b/lib/src/io/js.dart @@ -14,7 +14,7 @@ import 'package:source_span/source_span.dart'; import 'package:watcher/watcher.dart'; import '../exception.dart'; -import '../node/chokidar.dart'; +import '../js/chokidar.dart'; @JS('process') external final Process? process; // process is null in the browser diff --git a/lib/src/node.dart b/lib/src/js.dart similarity index 85% rename from lib/src/node.dart rename to lib/src/js.dart index 31df5acc8..cd1480719 100644 --- a/lib/src/node.dart +++ b/lib/src/js.dart @@ -2,19 +2,19 @@ // MIT-style license that can be found in the LICENSE file or at // https://opensource.org/licenses/MIT. -import 'node/exception.dart'; -import 'node/exports.dart'; -import 'node/compile.dart'; -import 'node/legacy.dart'; -import 'node/legacy/types.dart'; -import 'node/legacy/value.dart'; -import 'node/logger.dart'; -import 'node/source_span.dart'; -import 'node/utils.dart'; -import 'node/value.dart'; +import 'js/exception.dart'; +import 'js/exports.dart'; +import 'js/compile.dart'; +import 'js/legacy.dart'; +import 'js/legacy/types.dart'; +import 'js/legacy/value.dart'; +import 'js/logger.dart'; +import 'js/source_span.dart'; +import 'js/utils.dart'; +import 'js/value.dart'; import 'value.dart'; -/// The entrypoint for the Node.js module. +/// The entrypoint for the JavaScript module. /// /// This sets up exports that can be called from JS. void main() { @@ -41,7 +41,7 @@ void main() { exports.sassFalse = sassFalse; exports.Exception = exceptionClass; exports.Logger = LoggerNamespace( - silent: NodeLogger( + silent: JSLogger( warn: allowInteropNamed('sass.Logger.silent.warn', (_, __) {}), debug: allowInteropNamed('sass.Logger.silent.debug', (_, __) {}))); diff --git a/lib/src/node/array.dart b/lib/src/js/array.dart similarity index 100% rename from lib/src/node/array.dart rename to lib/src/js/array.dart diff --git a/lib/src/node/chokidar.dart b/lib/src/js/chokidar.dart similarity index 100% rename from lib/src/node/chokidar.dart rename to lib/src/js/chokidar.dart diff --git a/lib/src/node/compile.dart b/lib/src/js/compile.dart similarity index 93% rename from lib/src/node/compile.dart rename to lib/src/js/compile.dart index 1c2178741..fb863161d 100644 --- a/lib/src/node/compile.dart +++ b/lib/src/js/compile.dart @@ -8,12 +8,12 @@ import 'package:term_glyph/term_glyph.dart' as glyph; import '../../sass.dart'; import '../importer/no_op.dart'; -import '../importer/node_to_dart/async.dart'; -import '../importer/node_to_dart/async_file.dart'; -import '../importer/node_to_dart/file.dart'; -import '../importer/node_to_dart/sync.dart'; +import '../importer/js_to_dart/async.dart'; +import '../importer/js_to_dart/async_file.dart'; +import '../importer/js_to_dart/file.dart'; +import '../importer/js_to_dart/sync.dart'; import '../io.dart'; -import '../logger/node_to_dart.dart'; +import '../logger/js_to_dart.dart'; import '../util/nullable.dart'; import 'compile_options.dart'; import 'compile_result.dart'; @@ -40,7 +40,7 @@ NodeCompileResult compile(String path, [CompileOptions? options]) { verbose: options?.verbose ?? false, charset: options?.charset ?? true, sourceMap: options?.sourceMap ?? false, - logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color), + logger: JSToDartLogger(options?.logger, Logger.stderr(color: color), ascii: ascii), importers: options?.importers?.map(_parseImporter), functions: _parseFunctions(options?.functions).cast()); @@ -69,7 +69,7 @@ NodeCompileResult compileString(String text, [CompileStringOptions? options]) { verbose: options?.verbose ?? false, charset: options?.charset ?? true, sourceMap: options?.sourceMap ?? false, - logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color), + logger: JSToDartLogger(options?.logger, Logger.stderr(color: color), ascii: ascii), importers: options?.importers?.map(_parseImporter), importer: options?.importer.andThen(_parseImporter) ?? @@ -101,7 +101,7 @@ Promise compileAsync(String path, [CompileOptions? options]) { verbose: options?.verbose ?? false, charset: options?.charset ?? true, sourceMap: options?.sourceMap ?? false, - logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color), + logger: JSToDartLogger(options?.logger, Logger.stderr(color: color), ascii: ascii), importers: options?.importers ?.map((importer) => _parseAsyncImporter(importer)), @@ -129,7 +129,7 @@ Promise compileStringAsync(String text, [CompileStringOptions? options]) { verbose: options?.verbose ?? false, charset: options?.charset ?? true, sourceMap: options?.sourceMap ?? false, - logger: NodeToDartLogger(options?.logger, Logger.stderr(color: color), + logger: JSToDartLogger(options?.logger, Logger.stderr(color: color), ascii: ascii), importers: options?.importers ?.map((importer) => _parseAsyncImporter(importer)), @@ -193,12 +193,12 @@ AsyncImporter _parseAsyncImporter(Object? importer) { "An importer must have either canonicalize and load methods, or a " "findFileUrl method.")); } - return NodeToDartAsyncImporter(canonicalize, load); + return JSToDartAsyncImporter(canonicalize, load); } else if (canonicalize != null || load != null) { jsThrow(JsError("An importer may not have a findFileUrl method as well as " "canonicalize and load methods.")); } else { - return NodeToDartAsyncFileImporter(findFileUrl); + return JSToDartAsyncFileImporter(findFileUrl); } } @@ -216,12 +216,12 @@ Importer _parseImporter(Object? importer) { "An importer must have either canonicalize and load methods, or a " "findFileUrl method.")); } - return NodeToDartImporter(canonicalize, load); + return JSToDartImporter(canonicalize, load); } else if (canonicalize != null || load != null) { jsThrow(JsError("An importer may not have a findFileUrl method as well as " "canonicalize and load methods.")); } else { - return NodeToDartFileImporter(findFileUrl); + return JSToDartFileImporter(findFileUrl); } } diff --git a/lib/src/node/compile_options.dart b/lib/src/js/compile_options.dart similarity index 96% rename from lib/src/node/compile_options.dart rename to lib/src/js/compile_options.dart index 911ee2132..603adba4e 100644 --- a/lib/src/node/compile_options.dart +++ b/lib/src/js/compile_options.dart @@ -20,7 +20,7 @@ class CompileOptions { external bool? get charset; external bool? get sourceMap; external bool? get sourceMapIncludeSources; - external NodeLogger? get logger; + external JSLogger? get logger; external List? get importers; external Object? get functions; } diff --git a/lib/src/node/compile_result.dart b/lib/src/js/compile_result.dart similarity index 100% rename from lib/src/node/compile_result.dart rename to lib/src/js/compile_result.dart diff --git a/lib/src/node/exception.dart b/lib/src/js/exception.dart similarity index 100% rename from lib/src/node/exception.dart rename to lib/src/js/exception.dart diff --git a/lib/src/node/exports.dart b/lib/src/js/exports.dart similarity index 94% rename from lib/src/node/exports.dart rename to lib/src/js/exports.dart index 936b63e2a..0dff13698 100644 --- a/lib/src/node/exports.dart +++ b/lib/src/js/exports.dart @@ -52,9 +52,9 @@ class Exports { @JS() @anonymous class LoggerNamespace { - external NodeLogger get silent; + external JSLogger get silent; - external factory LoggerNamespace({required NodeLogger silent}); + external factory LoggerNamespace({required JSLogger silent}); } @JS() diff --git a/lib/src/node/function.dart b/lib/src/js/function.dart similarity index 100% rename from lib/src/node/function.dart rename to lib/src/js/function.dart diff --git a/lib/src/node/immutable.dart b/lib/src/js/immutable.dart similarity index 100% rename from lib/src/node/immutable.dart rename to lib/src/js/immutable.dart diff --git a/lib/src/node/importer.dart b/lib/src/js/importer.dart similarity index 100% rename from lib/src/node/importer.dart rename to lib/src/js/importer.dart diff --git a/lib/src/node/legacy.dart b/lib/src/js/legacy.dart similarity index 98% rename from lib/src/node/legacy.dart rename to lib/src/js/legacy.dart index 85f48e982..5f948650a 100644 --- a/lib/src/node/legacy.dart +++ b/lib/src/js/legacy.dart @@ -17,7 +17,7 @@ import '../exception.dart'; import '../importer/legacy_node.dart'; import '../io.dart'; import '../logger.dart'; -import '../logger/node_to_dart.dart'; +import '../logger/js_to_dart.dart'; import '../syntax.dart'; import '../util/nullable.dart'; import '../utils.dart'; @@ -88,8 +88,8 @@ Future _renderAsync(RenderOptions options) async { verbose: options.verbose ?? false, charset: options.charset ?? true, sourceMap: _enableSourceMaps(options), - logger: NodeToDartLogger( - options.logger, Logger.stderr(color: hasTerminal))); + logger: + JSToDartLogger(options.logger, Logger.stderr(color: hasTerminal))); } else if (file != null) { result = await compileAsync(file, nodeImporter: _parseImporter(options, start), @@ -103,8 +103,8 @@ Future _renderAsync(RenderOptions options) async { verbose: options.verbose ?? false, charset: options.charset ?? true, sourceMap: _enableSourceMaps(options), - logger: NodeToDartLogger( - options.logger, Logger.stderr(color: hasTerminal))); + logger: + JSToDartLogger(options.logger, Logger.stderr(color: hasTerminal))); } else { throw ArgumentError("Either options.data or options.file must be set."); } @@ -142,7 +142,7 @@ RenderResult renderSync(RenderOptions options) { verbose: options.verbose ?? false, charset: options.charset ?? true, sourceMap: _enableSourceMaps(options), - logger: NodeToDartLogger( + logger: JSToDartLogger( options.logger, Logger.stderr(color: hasTerminal))); } else if (file != null) { result = compile(file, @@ -157,7 +157,7 @@ RenderResult renderSync(RenderOptions options) { verbose: options.verbose ?? false, charset: options.charset ?? true, sourceMap: _enableSourceMaps(options), - logger: NodeToDartLogger( + logger: JSToDartLogger( options.logger, Logger.stderr(color: hasTerminal))); } else { throw ArgumentError("Either options.data or options.file must be set."); diff --git a/lib/src/node/legacy/fiber.dart b/lib/src/js/legacy/fiber.dart similarity index 100% rename from lib/src/node/legacy/fiber.dart rename to lib/src/js/legacy/fiber.dart diff --git a/lib/src/node/legacy/importer_result.dart b/lib/src/js/legacy/importer_result.dart similarity index 100% rename from lib/src/node/legacy/importer_result.dart rename to lib/src/js/legacy/importer_result.dart diff --git a/lib/src/node/legacy/render_context.dart b/lib/src/js/legacy/render_context.dart similarity index 100% rename from lib/src/node/legacy/render_context.dart rename to lib/src/js/legacy/render_context.dart diff --git a/lib/src/node/legacy/render_options.dart b/lib/src/js/legacy/render_options.dart similarity index 96% rename from lib/src/node/legacy/render_options.dart rename to lib/src/js/legacy/render_options.dart index 2223ce359..3357166de 100644 --- a/lib/src/node/legacy/render_options.dart +++ b/lib/src/js/legacy/render_options.dart @@ -30,7 +30,7 @@ class RenderOptions { external bool? get quietDeps; external bool? get verbose; external bool? get charset; - external NodeLogger? get logger; + external JSLogger? get logger; external factory RenderOptions( {String? file, @@ -53,5 +53,5 @@ class RenderOptions { bool? quietDeps, bool? verbose, bool? charset, - NodeLogger? logger}); + JSLogger? logger}); } diff --git a/lib/src/node/legacy/render_result.dart b/lib/src/js/legacy/render_result.dart similarity index 100% rename from lib/src/node/legacy/render_result.dart rename to lib/src/js/legacy/render_result.dart diff --git a/lib/src/node/legacy/types.dart b/lib/src/js/legacy/types.dart similarity index 100% rename from lib/src/node/legacy/types.dart rename to lib/src/js/legacy/types.dart diff --git a/lib/src/node/legacy/value.dart b/lib/src/js/legacy/value.dart similarity index 97% rename from lib/src/node/legacy/value.dart rename to lib/src/js/legacy/value.dart index 4843e4e6f..2c45f3c2c 100644 --- a/lib/src/node/legacy/value.dart +++ b/lib/src/js/legacy/value.dart @@ -4,7 +4,7 @@ import 'dart:js_util'; -import 'package:sass/src/node/utils.dart'; +import 'package:sass/src/js/utils.dart'; import '../../value.dart'; import 'value/color.dart'; diff --git a/lib/src/node/legacy/value/boolean.dart b/lib/src/js/legacy/value/boolean.dart similarity index 100% rename from lib/src/node/legacy/value/boolean.dart rename to lib/src/js/legacy/value/boolean.dart diff --git a/lib/src/node/legacy/value/color.dart b/lib/src/js/legacy/value/color.dart similarity index 100% rename from lib/src/node/legacy/value/color.dart rename to lib/src/js/legacy/value/color.dart diff --git a/lib/src/node/legacy/value/list.dart b/lib/src/js/legacy/value/list.dart similarity index 100% rename from lib/src/node/legacy/value/list.dart rename to lib/src/js/legacy/value/list.dart diff --git a/lib/src/node/legacy/value/map.dart b/lib/src/js/legacy/value/map.dart similarity index 100% rename from lib/src/node/legacy/value/map.dart rename to lib/src/js/legacy/value/map.dart diff --git a/lib/src/node/legacy/value/null.dart b/lib/src/js/legacy/value/null.dart similarity index 100% rename from lib/src/node/legacy/value/null.dart rename to lib/src/js/legacy/value/null.dart diff --git a/lib/src/node/legacy/value/number.dart b/lib/src/js/legacy/value/number.dart similarity index 100% rename from lib/src/node/legacy/value/number.dart rename to lib/src/js/legacy/value/number.dart diff --git a/lib/src/node/legacy/value/string.dart b/lib/src/js/legacy/value/string.dart similarity index 100% rename from lib/src/node/legacy/value/string.dart rename to lib/src/js/legacy/value/string.dart diff --git a/lib/src/node/logger.dart b/lib/src/js/logger.dart similarity index 94% rename from lib/src/node/logger.dart rename to lib/src/js/logger.dart index a312e535f..fb28030d5 100644 --- a/lib/src/node/logger.dart +++ b/lib/src/js/logger.dart @@ -7,11 +7,11 @@ import 'package:source_span/source_span.dart'; @JS() @anonymous -class NodeLogger { +class JSLogger { external void Function(String message, WarnOptions options)? get warn; external void Function(String message, DebugOptions options)? get debug; - external factory NodeLogger( + external factory JSLogger( {void Function(String message, WarnOptions options)? warn, void Function(String message, DebugOptions options)? debug}); } diff --git a/lib/src/node/reflection.dart b/lib/src/js/reflection.dart similarity index 100% rename from lib/src/node/reflection.dart rename to lib/src/js/reflection.dart diff --git a/lib/src/node/source_span.dart b/lib/src/js/source_span.dart similarity index 100% rename from lib/src/node/source_span.dart rename to lib/src/js/source_span.dart diff --git a/lib/src/node/url.dart b/lib/src/js/url.dart similarity index 100% rename from lib/src/node/url.dart rename to lib/src/js/url.dart diff --git a/lib/src/node/utils.dart b/lib/src/js/utils.dart similarity index 100% rename from lib/src/node/utils.dart rename to lib/src/js/utils.dart diff --git a/lib/src/node/value.dart b/lib/src/js/value.dart similarity index 100% rename from lib/src/node/value.dart rename to lib/src/js/value.dart diff --git a/lib/src/node/value/argument_list.dart b/lib/src/js/value/argument_list.dart similarity index 100% rename from lib/src/node/value/argument_list.dart rename to lib/src/js/value/argument_list.dart diff --git a/lib/src/node/value/boolean.dart b/lib/src/js/value/boolean.dart similarity index 100% rename from lib/src/node/value/boolean.dart rename to lib/src/js/value/boolean.dart diff --git a/lib/src/node/value/calculation.dart b/lib/src/js/value/calculation.dart similarity index 98% rename from lib/src/node/value/calculation.dart rename to lib/src/js/value/calculation.dart index ae3a8bd88..6154de77b 100644 --- a/lib/src/node/value/calculation.dart +++ b/lib/src/js/value/calculation.dart @@ -4,8 +4,8 @@ import 'package:collection/collection.dart'; import 'package:node_interop/js.dart'; -import 'package:sass/src/node/immutable.dart'; -import 'package:sass/src/node/utils.dart'; +import 'package:sass/src/js/immutable.dart'; +import 'package:sass/src/js/utils.dart'; import '../../value.dart'; import '../reflection.dart'; diff --git a/lib/src/node/value/color.dart b/lib/src/js/value/color.dart similarity index 100% rename from lib/src/node/value/color.dart rename to lib/src/js/value/color.dart diff --git a/lib/src/node/value/function.dart b/lib/src/js/value/function.dart similarity index 100% rename from lib/src/node/value/function.dart rename to lib/src/js/value/function.dart diff --git a/lib/src/node/value/list.dart b/lib/src/js/value/list.dart similarity index 100% rename from lib/src/node/value/list.dart rename to lib/src/js/value/list.dart diff --git a/lib/src/node/value/map.dart b/lib/src/js/value/map.dart similarity index 100% rename from lib/src/node/value/map.dart rename to lib/src/js/value/map.dart diff --git a/lib/src/node/value/number.dart b/lib/src/js/value/number.dart similarity index 100% rename from lib/src/node/value/number.dart rename to lib/src/js/value/number.dart diff --git a/lib/src/node/value/string.dart b/lib/src/js/value/string.dart similarity index 100% rename from lib/src/node/value/string.dart rename to lib/src/js/value/string.dart diff --git a/lib/src/logger/deprecation_handling.dart b/lib/src/logger/deprecation_handling.dart index 284602042..b477b07b1 100644 --- a/lib/src/logger/deprecation_handling.dart +++ b/lib/src/logger/deprecation_handling.dart @@ -86,17 +86,16 @@ class DeprecationHandlingLogger implements Logger { /// Prints a warning indicating the number of deprecation warnings that were /// omitted due to repetition. /// - /// The [node] flag indicates whether this is running in Node.js mode, in - /// which case it doesn't mention "verbose mode" because the Node API doesn't - /// support that. - void summarize({required bool node}) { + /// The [js] flag indicates whether this is running in JS mode, in which case + /// it doesn't mention "verbose mode" because the JS API doesn't support that. + void summarize({required bool js}) { var total = _warningCounts.values .where((count) => count > _maxRepetitions) .map((count) => count - _maxRepetitions) .sum; if (total > 0) { _inner.warn("$total repetitive deprecation warnings omitted." + - (node ? "" : "\nRun in verbose mode to see all warnings.")); + (js ? "" : "\nRun in verbose mode to see all warnings.")); } } } diff --git a/lib/src/logger/node_to_dart.dart b/lib/src/logger/js_to_dart.dart similarity index 83% rename from lib/src/logger/node_to_dart.dart rename to lib/src/logger/js_to_dart.dart index bb16798fc..ef9f3d5a5 100644 --- a/lib/src/logger/node_to_dart.dart +++ b/lib/src/logger/js_to_dart.dart @@ -8,14 +8,14 @@ import 'package:stack_trace/stack_trace.dart'; import 'package:term_glyph/term_glyph.dart' as glyph; import '../logger.dart'; -import '../node/logger.dart'; +import '../js/logger.dart'; -/// A wrapper around a [NodeLogger] that exposes it as a Dart [Logger]. -class NodeToDartLogger implements Logger { +/// A wrapper around a [JSLogger] that exposes it as a Dart [Logger]. +class JSToDartLogger implements Logger { /// The wrapped logger object. - final NodeLogger? _node; + final JSLogger? _node; - /// The fallback logger to use if the [NodeLogger] doesn't define a method. + /// The fallback logger to use if the [JSLogger] doesn't define a method. final Logger _fallback; /// Whether to use only ASCII characters when highlighting sections of source @@ -24,7 +24,7 @@ class NodeToDartLogger implements Logger { /// This defaults to [glyph.ascii]. final bool _ascii; - NodeToDartLogger(this._node, this._fallback, {bool? ascii}) + JSToDartLogger(this._node, this._fallback, {bool? ascii}) : _ascii = ascii ?? glyph.ascii; void warn(String message, diff --git a/lib/src/visitor/serialize.dart b/lib/src/visitor/serialize.dart index f7e54a209..36d92e716 100644 --- a/lib/src/visitor/serialize.dart +++ b/lib/src/visitor/serialize.dart @@ -821,8 +821,8 @@ class _SerializeVisitor // have to do is clamp doubles that are close to being integers. var integer = fuzzyAsInt(number); if (integer != null) { - // Node.js still uses exponential notation for integers, so we have to - // handle it here. + // JS still uses exponential notation for integers, so we have to handle + // it here. _buffer.write(_removeExponent(integer.toString())); return; } diff --git a/test/browser_test.dart b/test/browser_test.dart index 244c839df..4e4aa4af8 100644 --- a/test/browser_test.dart +++ b/test/browser_test.dart @@ -3,12 +3,12 @@ import 'package:js/js.dart'; import 'package:node_interop/js.dart'; import 'package:node_interop/util.dart'; -import 'package:sass/src/node/compile_options.dart'; -import 'package:sass/src/node/legacy/render_options.dart'; -import 'package:sass/src/node/legacy/render_result.dart'; +import 'package:sass/src/js/compile_options.dart'; +import 'package:sass/src/js/legacy/render_options.dart'; +import 'package:sass/src/js/legacy/render_result.dart'; import 'package:test/test.dart'; import 'ensure_npm_package.dart'; -import 'package:sass/src/node/compile_result.dart'; +import 'package:sass/src/js/compile_result.dart'; @JS() external Sass get sass; diff --git a/tool/grind.dart b/tool/grind.dart index 76f0b66e1..5992988f2 100644 --- a/tool/grind.dart +++ b/tool/grind.dart @@ -37,7 +37,7 @@ void main(List args) { pkg.JSRequire("stream", target: pkg.JSRequireTarget.node), pkg.JSRequire("util", target: pkg.JSRequireTarget.node), ]; - pkg.jsModuleMainLibrary.value = "lib/src/node.dart"; + pkg.jsModuleMainLibrary.value = "lib/src/js.dart"; pkg.npmPackageJson.fn = () => json.decode(File("package/package.json").readAsStringSync()) as Map;