ImportMapParseResult.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibJS/Heap/Cell.h>
  8. #include <LibJS/Script.h>
  9. #include <LibURL/URL.h>
  10. #include <LibWeb/Forward.h>
  11. #include <LibWeb/HTML/Scripting/ImportMap.h>
  12. #include <LibWeb/WebIDL/ExceptionOr.h>
  13. namespace Web::HTML {
  14. // https://html.spec.whatwg.org/multipage/webappapis.html#import-map-parse-result
  15. class ImportMapParseResult
  16. : public JS::Cell
  17. , public JS::Script::HostDefined {
  18. GC_CELL(ImportMapParseResult, JS::Cell);
  19. GC_DECLARE_ALLOCATOR(ImportMapParseResult);
  20. public:
  21. virtual ~ImportMapParseResult() override;
  22. static GC::Ref<ImportMapParseResult> create(JS::Realm& realm, ByteString const& input, URL::URL base_url);
  23. [[nodiscard]] Optional<ImportMap> const& import_map() const { return m_import_map; }
  24. void set_import_map(ImportMap const& value) { m_import_map = value; }
  25. [[nodiscard]] Optional<WebIDL::Exception> const& error_to_rethrow() const { return m_error_to_rethrow; }
  26. void set_error_to_rethrow(WebIDL::Exception const& value) { m_error_to_rethrow = value; }
  27. void register_import_map(Window& global);
  28. protected:
  29. ImportMapParseResult();
  30. virtual void visit_edges(Visitor&) override;
  31. private:
  32. virtual void visit_host_defined_self(Visitor&) override;
  33. // https://html.spec.whatwg.org/multipage/webappapis.html#impr-import-map
  34. Optional<ImportMap> m_import_map;
  35. // https://html.spec.whatwg.org/multipage/webappapis.html#impr-error-to-rethrow
  36. Optional<WebIDL::Exception> m_error_to_rethrow;
  37. };
  38. }