From 29d441b12a4014a151b914ce4400e3b6b9533965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=AA=E3=81=A4=E3=81=8D?= Date: Sat, 27 Jul 2024 11:17:40 -0700 Subject: [PATCH] Pass containingUrl to embedded host legacy API --- lib/src/embedded/compilation_dispatcher.dart | 4 ++-- lib/src/embedded/importer/host.dart | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/src/embedded/compilation_dispatcher.dart b/lib/src/embedded/compilation_dispatcher.dart index 8f69b2553..259605c5f 100644 --- a/lib/src/embedded/compilation_dispatcher.dart +++ b/lib/src/embedded/compilation_dispatcher.dart @@ -257,8 +257,8 @@ final class CompilationDispatcher { return sass.FilesystemImporter(importer.path); case InboundMessage_CompileRequest_Importer_Importer.importerId: - return HostImporter( - this, importer.importerId, importer.nonCanonicalScheme); + return HostImporter(this, importer.importerId, + importer.nonCanonicalScheme, importer.invertNonCanonicalScheme); case InboundMessage_CompileRequest_Importer_Importer.fileImporterId: _checkNoNonCanonicalScheme(importer); diff --git a/lib/src/embedded/importer/host.dart b/lib/src/embedded/importer/host.dart index e5342dc31..35e3fbeef 100644 --- a/lib/src/embedded/importer/host.dart +++ b/lib/src/embedded/importer/host.dart @@ -19,8 +19,12 @@ final class HostImporter extends ImporterBase { /// [canonicalize]. final Set _nonCanonicalSchemes; - HostImporter( - super.dispatcher, this._importerId, Iterable nonCanonicalSchemes) + /// Invert the meaning of [_nonCanonicalSchemes] to treat the schemes in the + /// set as canonical and other schemes not in the set as non-canonical. + final bool _invertNonCanonicalScheme; + + HostImporter(super.dispatcher, this._importerId, + Iterable nonCanonicalSchemes, this._invertNonCanonicalScheme) : _nonCanonicalSchemes = Set.unmodifiable(nonCanonicalSchemes) { for (var scheme in _nonCanonicalSchemes) { if (isValidUrlScheme(scheme)) continue; @@ -68,7 +72,7 @@ final class HostImporter extends ImporterBase { } bool isNonCanonicalScheme(String scheme) => - _nonCanonicalSchemes.contains(scheme); + _invertNonCanonicalScheme ^ _nonCanonicalSchemes.contains(scheme); String toString() => "HostImporter"; }