chromium/third_party/blink/renderer/core/script/import_map.cc

// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#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 {

// TODO(https://crbug.com/928549): Audit and improve error messages throughout
// this file.

void AddIgnoredKeyMessage(ConsoleLogger& logger,
                          const String& key,
                          const String& reason) {}

void AddIgnoredValueMessage(ConsoleLogger& logger,
                            const String& key,
                            const String& reason) {}

// <specdef
// href="https://html.spec.whatwg.org/C#normalizing-a-specifier-key">
String NormalizeSpecifierKey(const String& key_string,
                             const KURL& base_url,
                             ConsoleLogger& logger) {}

// Step 2.4-2.7 of
// <specdef
// href="https://html.spec.whatwg.org/C#sorting-and-normalizing-a-module-specifier-map">
KURL NormalizeValue(const String& key,
                    const String& value_string,
                    const KURL& base_url,
                    ConsoleLogger& logger) {}

void SpecifierMapToStringForTesting(
    StringBuilder& builder,
    const ImportMap::SpecifierMap& specifier_map) {}

}  // namespace

// <specdef
// href="https://html.spec.whatwg.org/C#parse-an-import-map-string">
//
// Parse |input| as an import map. Errors (e.g. json parsing error, invalid
// keys/values, etc.) are basically ignored, except that they are reported to
// the console |logger|.
ImportMap* ImportMap::Parse(const String& input,
                            const KURL& base_url,
                            ExecutionContext& context,
                            std::optional<ImportMapError>* error_to_rethrow) {}

// <specdef
// href="https://html.spec.whatwg.org/C#sorting-and-normalizing-a-module-specifier-map">
ImportMap::SpecifierMap ImportMap::SortAndNormalizeSpecifierMap(
    const JSONObject* imports,
    const KURL& base_url,
    ConsoleLogger& logger) {}

// <specdef href="https://html.spec.whatwg.org/C#resolving-an-imports-match">
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)
    :{}

// <specdef
// href="https://https://html.spec.whatwg.org/C#resolve-a-module-specifier">
std::optional<KURL> ImportMap::Resolve(const ParsedSpecifier& parsed_specifier,
                                       const KURL& base_url,
                                       String* debug_message) const {}

// <specdef href="https://html.spec.whatwg.org/C#resolving-an-imports-match">
std::optional<KURL> ImportMap::ResolveImportsMatch(
    const ParsedSpecifier& parsed_specifier,
    const SpecifierMap& specifier_map,
    String* debug_message) const {}

// <specdef href="https://html.spec.whatwg.org/C#resolving-an-imports-match">
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 {}

}  // namespace blink