ModuleRequest.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2021-2022, David Tuin <davidot@serenityos.org>
  3. * Copyright (c) 2023, networkException <networkexception@serenityos.org>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <AK/DeprecatedFlyString.h>
  9. #include <AK/Vector.h>
  10. #include <LibJS/Module.h>
  11. namespace JS {
  12. struct ModuleWithSpecifier {
  13. ByteString specifier; // [[Specifier]]
  14. NonnullGCPtr<Module> module; // [[Module]]
  15. };
  16. // https://tc39.es/proposal-import-attributes/#importattribute-record
  17. struct ImportAttribute {
  18. ByteString key;
  19. ByteString value;
  20. };
  21. // https://tc39.es/proposal-import-attributes/#modulerequest-record
  22. struct ModuleRequest {
  23. ModuleRequest() = default;
  24. explicit ModuleRequest(DeprecatedFlyString specifier)
  25. : module_specifier(move(specifier))
  26. {
  27. }
  28. ModuleRequest(DeprecatedFlyString specifier, Vector<ImportAttribute> attributes);
  29. void add_attribute(ByteString key, ByteString value)
  30. {
  31. attributes.empend(move(key), move(value));
  32. }
  33. DeprecatedFlyString module_specifier; // [[Specifier]]
  34. Vector<ImportAttribute> attributes; // [[Attributes]]
  35. };
  36. }