ladybird/Userland/Libraries/LibJS/Runtime/ModuleRequest.h
Andreas Kling 07f567cd9f LibJS+LibWeb: Another round of bringing module loading closer to spec
In particular, this patch focuses on:
- Updating the old "import assertions" to the new "import attributes"
- Allowing realms as module import referrer
2023-12-03 20:46:55 +01:00

47 lines
1.1 KiB
C++

/*
* Copyright (c) 2021-2022, David Tuin <davidot@serenityos.org>
* Copyright (c) 2023, networkException <networkexception@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/DeprecatedFlyString.h>
#include <AK/Vector.h>
#include <LibJS/Module.h>
namespace JS {
struct ModuleWithSpecifier {
DeprecatedString specifier; // [[Specifier]]
NonnullGCPtr<Module> module; // [[Module]]
};
// https://tc39.es/proposal-import-attributes/#importattribute-record
struct ImportAttribute {
DeprecatedString key;
DeprecatedString value;
};
// https://tc39.es/proposal-import-attributes/#modulerequest-record
struct ModuleRequest {
ModuleRequest() = default;
explicit ModuleRequest(DeprecatedFlyString specifier)
: module_specifier(move(specifier))
{
}
ModuleRequest(DeprecatedFlyString specifier, Vector<ImportAttribute> attributes);
void add_attribute(DeprecatedString key, DeprecatedString value)
{
attributes.empend(move(key), move(value));
}
DeprecatedFlyString module_specifier; // [[Specifier]]
Vector<ImportAttribute> attributes; // [[Attributes]]
};
}