2022-11-23 13:18:38 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021-2022, David Tuin <davidot@serenityos.org>
|
2023-10-28 21:45:38 +00:00
|
|
|
* Copyright (c) 2023, networkException <networkexception@serenityos.org>
|
2022-11-23 13:18:38 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-01-09 00:23:00 +00:00
|
|
|
#include <AK/DeprecatedFlyString.h>
|
2022-11-23 13:18:38 +00:00
|
|
|
#include <AK/Vector.h>
|
2023-10-28 21:45:38 +00:00
|
|
|
#include <LibJS/Module.h>
|
2022-11-23 13:18:38 +00:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2023-10-28 21:45:38 +00:00
|
|
|
struct ModuleWithSpecifier {
|
2024-11-14 15:01:23 +00:00
|
|
|
ByteString specifier; // [[Specifier]]
|
|
|
|
GC::Ref<Module> module; // [[Module]]
|
2023-10-28 21:45:38 +00:00
|
|
|
};
|
|
|
|
|
2023-12-02 15:20:01 +00:00
|
|
|
// https://tc39.es/proposal-import-attributes/#importattribute-record
|
|
|
|
struct ImportAttribute {
|
2023-12-16 14:19:34 +00:00
|
|
|
ByteString key;
|
|
|
|
ByteString value;
|
2023-12-02 15:20:01 +00:00
|
|
|
};
|
2022-11-23 13:18:38 +00:00
|
|
|
|
2023-12-02 15:20:01 +00:00
|
|
|
// https://tc39.es/proposal-import-attributes/#modulerequest-record
|
|
|
|
struct ModuleRequest {
|
2022-11-23 13:18:38 +00:00
|
|
|
ModuleRequest() = default;
|
|
|
|
|
2023-01-09 00:23:00 +00:00
|
|
|
explicit ModuleRequest(DeprecatedFlyString specifier)
|
2022-11-23 13:18:38 +00:00
|
|
|
: module_specifier(move(specifier))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-02 15:20:01 +00:00
|
|
|
ModuleRequest(DeprecatedFlyString specifier, Vector<ImportAttribute> attributes);
|
2022-11-23 13:18:38 +00:00
|
|
|
|
2023-12-16 14:19:34 +00:00
|
|
|
void add_attribute(ByteString key, ByteString value)
|
2022-11-23 13:18:38 +00:00
|
|
|
{
|
2023-12-02 15:20:01 +00:00
|
|
|
attributes.empend(move(key), move(value));
|
2022-11-23 13:18:38 +00:00
|
|
|
}
|
|
|
|
|
2023-01-09 00:23:00 +00:00
|
|
|
DeprecatedFlyString module_specifier; // [[Specifier]]
|
2023-12-02 15:20:01 +00:00
|
|
|
Vector<ImportAttribute> attributes; // [[Attributes]]
|
2022-11-23 13:18:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|