Skip to content

Commit

Permalink
Change terminology to refer to JS instead of Node.js (#2039)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nex3 committed Jul 21, 2023
1 parent 89bd36b commit b1d56a4
Show file tree
Hide file tree
Showing 55 changed files with 93 additions and 94 deletions.
4 changes: 2 additions & 2 deletions lib/src/async_compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Future<CompileResult> compileAsync(String path,
sourceMap,
charset);

deprecationLogger.summarize(node: nodeImporter != null);
deprecationLogger.summarize(js: nodeImporter != null);
return result;
}

Expand Down Expand Up @@ -130,7 +130,7 @@ Future<CompileResult> compileStringAsync(String source,
sourceMap,
charset);

deprecationLogger.summarize(node: nodeImporter != null);
deprecationLogger.summarize(js: nodeImporter != null);
return result;
}

Expand Down
6 changes: 3 additions & 3 deletions lib/src/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -87,7 +87,7 @@ CompileResult compile(String path,
sourceMap,
charset);

deprecationLogger.summarize(node: nodeImporter != null);
deprecationLogger.summarize(js: nodeImporter != null);
return result;
}

Expand Down Expand Up @@ -139,7 +139,7 @@ CompileResult compileString(String source,
sourceMap,
charset);

deprecationLogger.summarize(node: nodeImporter != null);
deprecationLogger.summarize(js: nodeImporter != null);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uri?> canonicalize(Uri url) async {
var result = _canonicalize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Uri?> canonicalize(Uri url) async {
if (url.scheme == 'file') return _filesystemImporter.canonicalize(url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions lib/src/importer/legacy_node/implementation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
4 changes: 2 additions & 2 deletions lib/src/io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <String, String>{};
Expand Down
2 changes: 1 addition & 1 deletion lib/src/io/node.dart → lib/src/io/js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions lib/src/node.dart → lib/src/js.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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', (_, __) {})));

Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 13 additions & 13 deletions lib/src/node/compile.dart → lib/src/js/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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());
Expand Down Expand Up @@ -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) ??
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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)),
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object?>? get importers;
external Object? get functions;
}
Expand Down
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions lib/src/node/exports.dart → lib/src/js/exports.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions lib/src/node/legacy.dart → lib/src/js/legacy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -88,8 +88,8 @@ Future<RenderResult> _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),
Expand All @@ -103,8 +103,8 @@ Future<RenderResult> _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.");
}
Expand Down Expand Up @@ -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,
Expand All @@ -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.");
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit b1d56a4

Please sign in to comment.