#include "third_party/blink/renderer/core/script/import_map.h"
#include <memory>
#include <utility>
#include "base/metrics/histogram_macros.h"
#include "third_party/blink/public/mojom/devtools/console_message.mojom-blink.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom-shared.h"
#include "third_party/blink/renderer/bindings/core/v8/script_value.h"
#include "third_party/blink/renderer/core/execution_context/execution_context.h"
#include "third_party/blink/renderer/core/script/import_map_error.h"
#include "third_party/blink/renderer/core/script/modulator.h"
#include "third_party/blink/renderer/core/script/parsed_specifier.h"
#include "third_party/blink/renderer/platform/json/json_parser.h"
#include "third_party/blink/renderer/platform/json/json_values.h"
#include "third_party/blink/renderer/platform/loader/fetch/console_logger.h"
#include "third_party/blink/renderer/platform/loader/subresource_integrity.h"
#include "third_party/blink/renderer/platform/runtime_enabled_features.h"
#include "third_party/blink/renderer/platform/weborigin/scheme_registry.h"
#include "third_party/blink/renderer/platform/wtf/text/string_builder.h"
namespace blink {
namespace {
void AddIgnoredKeyMessage(ConsoleLogger& logger,
const String& key,
const String& reason) { … }
void AddIgnoredValueMessage(ConsoleLogger& logger,
const String& key,
const String& reason) { … }
String NormalizeSpecifierKey(const String& key_string,
const KURL& base_url,
ConsoleLogger& logger) { … }
KURL NormalizeValue(const String& key,
const String& value_string,
const KURL& base_url,
ConsoleLogger& logger) { … }
void SpecifierMapToStringForTesting(
StringBuilder& builder,
const ImportMap::SpecifierMap& specifier_map) { … }
}
ImportMap* ImportMap::Parse(const String& input,
const KURL& base_url,
ExecutionContext& context,
std::optional<ImportMapError>* error_to_rethrow) { … }
ImportMap::SpecifierMap ImportMap::SortAndNormalizeSpecifierMap(
const JSONObject* imports,
const KURL& base_url,
ConsoleLogger& logger) { … }
std::optional<ImportMap::MatchResult> ImportMap::MatchPrefix(
const ParsedSpecifier& parsed_specifier,
const SpecifierMap& specifier_map) const { … }
ImportMap::ImportMap() = default;
ImportMap::ImportMap(SpecifierMap&& imports,
ScopeType&& scopes,
IntegrityMap&& integrity)
: … { … }
std::optional<KURL> ImportMap::Resolve(const ParsedSpecifier& parsed_specifier,
const KURL& base_url,
String* debug_message) const { … }
std::optional<KURL> ImportMap::ResolveImportsMatch(
const ParsedSpecifier& parsed_specifier,
const SpecifierMap& specifier_map,
String* debug_message) const { … }
KURL ImportMap::ResolveImportsMatchInternal(const String& key,
const MatchResult& matched,
String* debug_message) const { … }
String ImportMap::ToStringForTesting() const { … }
String ImportMap::GetIntegrity(const KURL& module_url) const { … }
}