2022-11-23 14:18:38 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2021-2022, David Tuin <davidot@serenityos.org>
|
2023-10-28 23:45:38 +02:00
|
|
|
* Copyright (c) 2023, networkException <networkexception@serenityos.org>
|
2022-11-23 14:18:38 +01:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2025-08-06 11:12:58 -04:00
|
|
|
#include <AK/Utf16FlyString.h>
|
2022-11-23 14:18:38 +01:00
|
|
|
#include <AK/Vector.h>
|
2023-10-28 23:45:38 +02:00
|
|
|
#include <LibJS/Module.h>
|
2022-11-23 14:18:38 +01:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
2023-10-28 23:45:38 +02:00
|
|
|
struct ModuleWithSpecifier {
|
2025-08-06 11:12:58 -04:00
|
|
|
Utf16String specifier; // [[Specifier]]
|
2024-11-15 04:01:23 +13:00
|
|
|
GC::Ref<Module> module; // [[Module]]
|
2023-10-28 23:45:38 +02:00
|
|
|
};
|
|
|
|
|
2025-04-28 15:03:56 -04:00
|
|
|
// https://tc39.es/ecma262/#importattribute-record
|
2023-12-02 16:20:01 +01:00
|
|
|
struct ImportAttribute {
|
2025-08-06 11:12:58 -04:00
|
|
|
Utf16String key;
|
|
|
|
Utf16String value;
|
2024-12-01 13:03:11 +13:00
|
|
|
|
|
|
|
bool operator==(ImportAttribute const&) const = default;
|
2023-12-02 16:20:01 +01:00
|
|
|
};
|
2022-11-23 14:18:38 +01:00
|
|
|
|
2025-04-28 15:03:56 -04:00
|
|
|
// https://tc39.es/ecma262/#modulerequest-record
|
2025-07-19 10:41:08 -07:00
|
|
|
struct ModuleRequest {
|
2022-11-23 14:18:38 +01:00
|
|
|
ModuleRequest() = default;
|
|
|
|
|
2025-08-06 11:12:58 -04:00
|
|
|
explicit ModuleRequest(Utf16FlyString specifier)
|
2022-11-23 14:18:38 +01:00
|
|
|
: module_specifier(move(specifier))
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2025-08-06 11:12:58 -04:00
|
|
|
ModuleRequest(Utf16FlyString specifier, Vector<ImportAttribute> attributes);
|
2022-11-23 14:18:38 +01:00
|
|
|
|
2025-08-06 11:12:58 -04:00
|
|
|
void add_attribute(Utf16String key, Utf16String value)
|
2022-11-23 14:18:38 +01:00
|
|
|
{
|
2023-12-02 16:20:01 +01:00
|
|
|
attributes.empend(move(key), move(value));
|
2022-11-23 14:18:38 +01:00
|
|
|
}
|
|
|
|
|
2025-08-06 11:12:58 -04:00
|
|
|
Utf16FlyString module_specifier; // [[Specifier]]
|
2025-03-18 18:08:02 -05:00
|
|
|
Vector<ImportAttribute> attributes; // [[Attributes]]
|
2024-12-01 13:03:11 +13:00
|
|
|
|
|
|
|
bool operator==(ModuleRequest const&) const = default;
|
2022-11-23 14:18:38 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|