Skip to content

armgit / moli

Public Imported from GitHub
0

Best headless browser for AI agents. Lite, Fast, High-Compatibility. Built in Rust

refactor(webapi): make object roles and receiver identity explicit

ldm02e6167f12777
diff --git a/moli-renderer-v8/src/blob.rs b/moli-renderer-v8/src/blob.rs
index 8852d14df..865eeddc9 100644
--- a/moli-renderer-v8/src/blob.rs
+++ b/moli-renderer-v8/src/blob.rs
@@ -315,7 +315,7 @@ pub(super) fn is_blob_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "Blob")
+ web_api_interfaces::Blob::is_instance(scope, object)
}
pub(super) fn blob_mime_type_from_object<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap.rs b/moli-renderer-v8/src/context_bootstrap.rs
index 348b135b2..71ef84a9a 100644
--- a/moli-renderer-v8/src/context_bootstrap.rs
+++ b/moli-renderer-v8/src/context_bootstrap.rs
@@ -659,7 +659,7 @@ fn worker_unsupported_constructor_callback(
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
pub(in crate::context_bootstrap) struct GlobalCachesAccessorDeclaration {
#[webapi(
accessor_property,
@@ -670,7 +670,7 @@ pub(in crate::context_bootstrap) struct GlobalCachesAccessorDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerBase64OperationsDeclaration {
#[webapi(
method,
@@ -784,7 +784,7 @@ struct WorkerAbortControllerTemplateDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "WorkerGlobalScope", enumerable)]
+#[webapi(fragment, prototype = "WorkerGlobalScope", enumerable)]
struct WorkerGlobalScopeCryptoPrototypeDeclaration {
#[webapi(accessor_property, getter = worker_crypto_getter_callback)]
crypto: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/animation_runtime.rs b/moli-renderer-v8/src/context_bootstrap/animation_runtime.rs
index 08aef780f..9738831a4 100644
--- a/moli-renderer-v8/src/context_bootstrap/animation_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/animation_runtime.rs
@@ -27,7 +27,7 @@ const KEYFRAME_EFFECT_TARGET_SLOT: &str = "__moliKeyframeEffectTarget";
const KEYFRAME_EFFECT_KEYFRAMES_SLOT: &str = "__moliKeyframeEffectKeyframes";
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AnimationPromiseEntryDeclaration {
#[webapi(slot = ANIMATION_PROMISE_RESOLVE_SLOT, init = "undefined")]
resolve: (),
@@ -156,7 +156,7 @@ struct ElementAnimationPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AnimationFinishMicrotaskPayloadDeclaration<'s> {
#[webapi(slot = ANIMATION_MICROTASK_ANIMATION_SLOT)]
animation: v8::Local<'s, v8::Object>,
@@ -165,7 +165,7 @@ struct AnimationFinishMicrotaskPayloadDeclaration<'s> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AnimationPromiseResolverDeclaration<'s> {
#[webapi(slot = ANIMATION_PROMISE_RESOLVE_SLOT)]
resolve: v8::Local<'s, v8::Value>,
@@ -275,7 +275,7 @@ fn require_animation_receiver<'s>(
receiver: v8::Local<'s, v8::Object>,
member: &str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, "Animation") {
+ if web_api_interfaces::Animation::is_instance(scope, receiver) {
return true;
}
throw_type_error(
diff --git a/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs b/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs
index ab1c8d0a3..362e48eea 100644
--- a/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs
+++ b/moli-renderer-v8/src/context_bootstrap/broadcast_channel.rs
@@ -112,7 +112,7 @@ struct BroadcastChannelPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct BroadcastChannelMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
@@ -345,7 +345,7 @@ fn broadcast_channel_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "BroadcastChannel")
+ web_api_interfaces::BroadcastChannel::is_instance(scope, receiver)
}
fn broadcast_channel_event_target_add_event_listener_callback<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/canvas/backing_store.rs b/moli-renderer-v8/src/context_bootstrap/canvas/backing_store.rs
index 4f5df3000..65f7a7a77 100644
--- a/moli-renderer-v8/src/context_bootstrap/canvas/backing_store.rs
+++ b/moli-renderer-v8/src/context_bootstrap/canvas/backing_store.rs
@@ -15,7 +15,7 @@ const CANVAS_HAS_CONTEXT_SLOT: &str = "__moliCanvasHasContext";
const CANVAS_2D_CONTEXT_SLOT: &str = "__moliCanvas2DContext";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CanvasContextOwnerDeclaration<'scope> {
#[webapi(data_property)]
canvas: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/canvas/context2d.rs b/moli-renderer-v8/src/context_bootstrap/canvas/context2d.rs
index 3cd7557c4..134c1a1d8 100644
--- a/moli-renderer-v8/src/context_bootstrap/canvas/context2d.rs
+++ b/moli-renderer-v8/src/context_bootstrap/canvas/context2d.rs
@@ -308,12 +308,8 @@ fn require_canvas_context_receiver<'s>(
receiver: v8::Local<'s, v8::Object>,
member: &str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, "CanvasRenderingContext2D")
- || moli_webapi_declare::implements_interface(
- scope,
- receiver,
- "OffscreenCanvasRenderingContext2D",
- )
+ if web_api_interfaces::CanvasRenderingContext2D::is_instance(scope, receiver)
+ || web_api_interfaces::OffscreenCanvasRenderingContext2D::is_instance(scope, receiver)
{
return true;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/canvas/helpers.rs b/moli-renderer-v8/src/context_bootstrap/canvas/helpers.rs
index 688331464..270d0e83f 100644
--- a/moli-renderer-v8/src/context_bootstrap/canvas/helpers.rs
+++ b/moli-renderer-v8/src/context_bootstrap/canvas/helpers.rs
@@ -4,7 +4,7 @@ use moli_canvas::{DEFAULT_FILL_STYLE, DEFAULT_FONT};
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "CanvasRenderingContext2D")]
+#[webapi(fragment, prototype = "CanvasRenderingContext2D")]
struct CanvasLikeContextObjectDeclaration {
#[webapi(
slot = CANVAS_CONTEXT_FILL_STYLE_SLOT,
diff --git a/moli-renderer-v8/src/context_bootstrap/canvas/image_bitmap.rs b/moli-renderer-v8/src/context_bootstrap/canvas/image_bitmap.rs
index bacab8ed7..f6bfafb26 100644
--- a/moli-renderer-v8/src/context_bootstrap/canvas/image_bitmap.rs
+++ b/moli-renderer-v8/src/context_bootstrap/canvas/image_bitmap.rs
@@ -181,5 +181,5 @@ fn image_bitmap_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "ImageBitmap")
+ web_api_interfaces::ImageBitmap::is_instance(scope, receiver)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/canvas/offscreen.rs b/moli-renderer-v8/src/context_bootstrap/canvas/offscreen.rs
index 865420fc7..6cbad8d03 100644
--- a/moli-renderer-v8/src/context_bootstrap/canvas/offscreen.rs
+++ b/moli-renderer-v8/src/context_bootstrap/canvas/offscreen.rs
@@ -229,5 +229,5 @@ pub(super) fn offscreen_canvas_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "OffscreenCanvas")
+ web_api_interfaces::OffscreenCanvas::is_instance(scope, receiver)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/canvas/webgl.rs b/moli-renderer-v8/src/context_bootstrap/canvas/webgl.rs
index 688e4104d..f273b3591 100644
--- a/moli-renderer-v8/src/context_bootstrap/canvas/webgl.rs
+++ b/moli-renderer-v8/src/context_bootstrap/canvas/webgl.rs
@@ -55,7 +55,7 @@ struct WebGlViewportArgs {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebGlContextStateDeclaration<'s> {
#[webapi(slot = WEBGL_VIEWPORT_SLOT)]
viewport: v8::Local<'s, v8::Array>,
@@ -90,7 +90,6 @@ struct WebGl2GetInternalformatParameterArgs {
#[derive(WebApiObject)]
#[webapi(
- allow_empty,
interface = web_api_interfaces::WebGLBuffer,
fallback_to_string_tag = "WebGLBuffer"
)]
@@ -98,7 +97,6 @@ struct WebGlBufferHandleDeclaration {}
#[derive(WebApiObject)]
#[webapi(
- allow_empty,
interface = web_api_interfaces::WebGLProgram,
fallback_to_string_tag = "WebGLProgram"
)]
@@ -106,7 +104,6 @@ struct WebGlProgramHandleDeclaration {}
#[derive(WebApiObject)]
#[webapi(
- allow_empty,
interface = web_api_interfaces::WebGLShader,
fallback_to_string_tag = "WebGLShader"
)]
@@ -114,7 +111,6 @@ struct WebGlShaderHandleDeclaration {}
#[derive(WebApiObject)]
#[webapi(
- allow_empty,
interface = web_api_interfaces::WebGLUniformLocation,
fallback_to_string_tag = "WebGLUniformLocation"
)]
@@ -122,7 +118,6 @@ struct WebGlUniformLocationHandleDeclaration {}
#[derive(WebApiObject)]
#[webapi(
- allow_empty,
interface = web_api_interfaces::WebGLFramebuffer,
fallback_to_string_tag = "WebGLFramebuffer"
)]
@@ -130,7 +125,6 @@ struct WebGlFramebufferHandleDeclaration {}
#[derive(WebApiObject)]
#[webapi(
- allow_empty,
interface = web_api_interfaces::WebGLRenderbuffer,
fallback_to_string_tag = "WebGLRenderbuffer"
)]
@@ -738,7 +732,7 @@ pub(crate) fn webgl_get_context_attributes_callback(
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WebGlContextAttributes {
alpha: bool,
antialias: bool,
@@ -834,7 +828,7 @@ fn is_webgl2_context<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "WebGL2RenderingContext")
+ web_api_interfaces::WebGL2RenderingContext::is_instance(scope, object)
}
pub(crate) fn webgl2_color_space_getter_callback<'s>(
@@ -842,7 +836,7 @@ pub(crate) fn webgl2_color_space_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "WebGL2RenderingContext") {
+ if !web_api_interfaces::WebGL2RenderingContext::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -871,7 +865,7 @@ pub(crate) fn webgl2_color_space_setter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "WebGL2RenderingContext") {
+ if !web_api_interfaces::WebGL2RenderingContext::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/chrome_runtime.rs b/moli-renderer-v8/src/context_bootstrap/chrome_runtime.rs
index ad32503d6..0f77c9387 100644
--- a/moli-renderer-v8/src/context_bootstrap/chrome_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/chrome_runtime.rs
@@ -19,7 +19,7 @@ const INSTALL_STATE_NOT_INSTALLED: &str = "not_installed";
const RUNNING_STATE_CANNOT_RUN: &str = "cannot_run";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ChromeInstallStateDeclaration {
#[webapi(data_property = "DISABLED")]
disabled: &'static str,
@@ -30,7 +30,7 @@ struct ChromeInstallStateDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ChromeRunningStateDeclaration {
#[webapi(data_property = "CANNOT_RUN")]
cannot_run: &'static str,
@@ -41,7 +41,7 @@ struct ChromeRunningStateDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct ChromeAppDeclaration<'scope> {
#[webapi(
native_data_property = "isInstalled",
diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs b/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs
index 69478b8d2..9e6f4252f 100644
--- a/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs
+++ b/moli-renderer-v8/src/context_bootstrap/constructors/dom_exception.rs
@@ -211,7 +211,7 @@ fn dom_exception_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, "DOMException") {
+ if web_api_interfaces::DOMException::is_instance(scope, receiver) {
Some(receiver)
} else {
throw_type_error(
@@ -226,7 +226,7 @@ fn dom_error_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, "DOMError") {
+ if web_api_interfaces::DOMError::is_instance(scope, receiver) {
Some(receiver)
} else {
throw_type_error(scope, "DOMError getter called on incompatible receiver.");
@@ -238,7 +238,7 @@ pub(crate) fn dom_exception_clone_fields<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> Option<(String, String)> {
- moli_webapi_declare::implements_interface(scope, object, "DOMException").then_some(())?;
+ web_api_interfaces::DOMException::is_instance(scope, object).then_some(())?;
let message = get_private_value(scope, object, DOM_EXCEPTION_MESSAGE_SLOT)
.and_then(|value| value.to_string(scope))
.map(|value| value.to_rust_string_lossy(scope))
@@ -254,7 +254,7 @@ pub(crate) fn quota_exceeded_error_clone_fields<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> Option<(String, Option<f64>, Option<f64>)> {
- moli_webapi_declare::implements_interface(scope, object, "QuotaExceededError").then_some(())?;
+ web_api_interfaces::QuotaExceededError::is_instance(scope, object).then_some(())?;
let (message, _) = dom_exception_clone_fields(scope, object)?;
let quota = nullable_double_clone_slot(scope, object, QUOTA_EXCEEDED_ERROR_QUOTA_SLOT)?;
let requested = nullable_double_clone_slot(scope, object, QUOTA_EXCEEDED_ERROR_REQUESTED_SLOT)?;
@@ -383,7 +383,9 @@ fn dom_exception_subclass_receiver<'s>(
receiver: v8::Local<'s, v8::Object>,
interface_name: &'static str,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, interface_name) {
+ if web_api_interfaces::descriptor(interface_name)
+ .is_some_and(|interface| interface.is_instance(scope, receiver))
+ {
Some(receiver)
} else {
throw_type_error(
@@ -722,7 +724,7 @@ pub(crate) fn websocket_error_close_info<'s>(
value: v8::Local<'s, v8::Value>,
) -> Option<(Option<u16>, String)> {
let object = v8::Local::<v8::Object>::try_from(value).ok()?;
- moli_webapi_declare::implements_interface(scope, object, "WebSocketError").then_some(())?;
+ web_api_interfaces::WebSocketError::is_instance(scope, object).then_some(())?;
let close_code_value = get_private_value(scope, object, WEBSOCKET_ERROR_CLOSE_CODE_SLOT)?;
let reason_value = get_private_value(scope, object, WEBSOCKET_ERROR_REASON_SLOT)?;
let close_code = if close_code_value.is_null_or_undefined() {
diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/elements.rs b/moli-renderer-v8/src/context_bootstrap/constructors/elements.rs
index a97b94f4a..3baadedbb 100644
--- a/moli-renderer-v8/src/context_bootstrap/constructors/elements.rs
+++ b/moli-renderer-v8/src/context_bootstrap/constructors/elements.rs
@@ -3,7 +3,7 @@ use crate::webidl;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct HtmlElementConstructorTrapHandlerDeclaration<'scope> {
#[webapi(data_property)]
construct: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs b/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs
index 1de76ba78..327f26893 100644
--- a/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs
+++ b/moli-renderer-v8/src/context_bootstrap/constructors/text_codecs.rs
@@ -79,7 +79,7 @@ struct TextDecoderPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TextEncoderEncodeIntoResultDeclaration {
read: usize,
written: usize,
@@ -422,14 +422,14 @@ fn text_encoder_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "TextEncoder")
+ web_api_interfaces::TextEncoder::is_instance(scope, receiver)
}
fn text_decoder_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "TextDecoder")
+ web_api_interfaces::TextDecoder::is_instance(scope, receiver)
}
fn init_text_decoder_state(
diff --git a/moli-renderer-v8/src/context_bootstrap/crypto/install.rs b/moli-renderer-v8/src/context_bootstrap/crypto/install.rs
index 557602ada..d73ad166e 100644
--- a/moli-renderer-v8/src/context_bootstrap/crypto/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/crypto/install.rs
@@ -21,15 +21,15 @@ const CRYPTO_SUBTLE_AVAILABLE_SLOT: &str = "__moliCryptoSubtleAvailable";
const WINDOW_CRYPTO_SUBTLE_AVAILABLE_SLOT: &str = "__moliWindowCryptoSubtleAvailable";
#[derive(Default, WebApiObject)]
-#[webapi(allow_empty, interface = web_api_interfaces::Crypto)]
+#[webapi(interface = web_api_interfaces::Crypto)]
struct CryptoObjectDeclaration {}
#[derive(Default, WebApiObject)]
-#[webapi(allow_empty, interface = web_api_interfaces::SubtleCrypto)]
+#[webapi(interface = web_api_interfaces::SubtleCrypto)]
struct SubtleCryptoObjectDeclaration {}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Crypto")]
+#[webapi(fragment, prototype = "Crypto")]
struct CryptoPrototypeAccessorsDeclaration {
#[webapi(
accessor_property,
@@ -53,7 +53,7 @@ struct CryptoPrototypeOperationsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Crypto")]
+#[webapi(fragment, prototype = "Crypto")]
struct CryptoSecurePrototypeOperationsDeclaration {
#[webapi(
method = "randomUUID",
@@ -234,7 +234,7 @@ fn crypto_attribute_getter_callback<'s>(
rv.set_undefined();
return;
};
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Crypto") {
+ if !web_api_interfaces::Crypto::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/crypto/keys.rs b/moli-renderer-v8/src/context_bootstrap/crypto/keys.rs
index c510c9db2..1375d3b10 100644
--- a/moli-renderer-v8/src/context_bootstrap/crypto/keys.rs
+++ b/moli-renderer-v8/src/context_bootstrap/crypto/keys.rs
@@ -7,19 +7,19 @@ use crate::web_api_interfaces;
use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NamedAlgorithmDeclaration<'scope> {
name: Option<v8::Local<'scope, v8::String>>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct AlgorithmNameCloneDeclaration<'scope> {
name: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct AlgorithmCloneDeclaration<'scope> {
name: v8::Local<'scope, v8::Value>,
hash: Option<v8::Local<'scope, v8::Object>>,
@@ -30,7 +30,7 @@ struct AlgorithmCloneDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct HmacAlgorithmDeclaration<'scope> {
name: Option<v8::Local<'scope, v8::String>>,
hash: v8::Local<'scope, v8::Object>,
@@ -38,14 +38,14 @@ struct HmacAlgorithmDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct SymmetricAlgorithmDeclaration<'scope> {
name: Option<v8::Local<'scope, v8::String>>,
length: usize,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct RsaAlgorithmDeclaration<'scope> {
name: Option<v8::Local<'scope, v8::String>>,
hash: v8::Local<'scope, v8::Object>,
@@ -54,7 +54,7 @@ struct RsaAlgorithmDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NamedCurveAlgorithmDeclaration<'scope> {
name: Option<v8::Local<'scope, v8::String>>,
named_curve: Option<v8::Local<'scope, v8::String>>,
@@ -275,7 +275,7 @@ pub(crate) fn is_crypto_key_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
key: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, key, "CryptoKey")
+ web_api_interfaces::CryptoKey::is_instance(scope, key)
}
pub(crate) fn crypto_key_clone_payload_from_object<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/crypto/random.rs b/moli-renderer-v8/src/context_bootstrap/crypto/random.rs
index 6487b48ff..6d571354d 100644
--- a/moli-renderer-v8/src/context_bootstrap/crypto/random.rs
+++ b/moli-renderer-v8/src/context_bootstrap/crypto/random.rs
@@ -1,3 +1,4 @@
+use crate::web_api_interfaces;
use std::ptr;
use moli_crypto::fill_secure_random;
@@ -13,7 +14,7 @@ pub(super) fn crypto_get_random_values_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Crypto") {
+ if !web_api_interfaces::Crypto::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -87,7 +88,7 @@ pub(super) fn crypto_random_uuid_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Crypto") {
+ if !web_api_interfaces::Crypto::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/crypto/subtle/key_gen.rs b/moli-renderer-v8/src/context_bootstrap/crypto/subtle/key_gen.rs
index 0074f9245..88747a98d 100644
--- a/moli-renderer-v8/src/context_bootstrap/crypto/subtle/key_gen.rs
+++ b/moli-renderer-v8/src/context_bootstrap/crypto/subtle/key_gen.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CryptoKeyPairDeclaration<'scope> {
#[webapi(data_property, enumerable)]
private_key: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/crypto/subtle/params.rs b/moli-renderer-v8/src/context_bootstrap/crypto/subtle/params.rs
index ca56248c8..4e11e369b 100644
--- a/moli-renderer-v8/src/context_bootstrap/crypto/subtle/params.rs
+++ b/moli-renderer-v8/src/context_bootstrap/crypto/subtle/params.rs
@@ -1,11 +1,12 @@
use super::*;
+use crate::web_api_interfaces;
pub(crate) fn subtle_crypto_receiver_is_valid<'s>(
scope: &mut v8::PinScope<'s, '_>,
args: &v8::FunctionCallbackArguments<'s>,
rv: &mut v8::ReturnValue<'_, v8::Value>,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, args.this(), "SubtleCrypto") {
+ if web_api_interfaces::SubtleCrypto::is_instance(scope, args.this()) {
true
} else {
set_rejected_webcrypto_promise(scope, rv, WebCryptoRejection::Type);
diff --git a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs
index 117c5382c..a0a08fedf 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_fontface_runtime/storage.rs
@@ -308,7 +308,7 @@ pub(super) fn is_font_face_value<'s>(
let Ok(object) = v8::Local::<v8::Object>::try_from(value) else {
return false;
};
- moli_webapi_declare::implements_interface(scope, object, "FontFace")
+ web_api_interfaces::FontFace::is_instance(scope, object)
}
pub(super) fn array_contains_value(
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/highlights.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/highlights.rs
index 242bca1a9..06c4a6e90 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/highlights.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/highlights.rs
@@ -13,7 +13,7 @@ const HIGHLIGHT_ITERATOR_PROTOTYPE_SLOT: &str = "__moliHighlightIteratorPrototyp
const HIGHLIGHT_REGISTRY_ITERATOR_PROTOTYPE_SLOT: &str = "__moliHighlightRegistryIteratorPrototype";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct HighlightIteratorObjectDeclaration<'s> {
#[webapi(slot = HIGHLIGHT_ITERATOR_RECORDS_SLOT)]
records: v8::Local<'s, v8::Array>,
@@ -24,7 +24,7 @@ struct HighlightIteratorObjectDeclaration<'s> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct HighlightIteratorResultDeclaration<'s> {
value: v8::Local<'s, v8::Value>,
done: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/install.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/install.rs
index 8b28d683d..d9b5f7263 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/install.rs
@@ -8,11 +8,7 @@ use crate::native_bridge::document::install_adopted_style_sheets_array_primordia
use moli_webapi_declare::WebApiObject;
#[derive(Default, WebApiObject)]
-#[webapi(
- interface = "Object",
- own_to_string_tag = "CSS",
- readonly_to_string_tag
-)]
+#[webapi(record, own_to_string_tag = "CSS", readonly_to_string_tag)]
struct CssNamespaceObjectDeclaration {
#[webapi(
method,
diff --git a/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs b/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs
index bc98c0a83..a318edd50 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_runtime/typed_om/values.rs
@@ -357,7 +357,7 @@ fn css_style_value_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "CSSStyleValue")
+ web_api_interfaces::CSSStyleValue::is_instance(scope, receiver)
}
fn css_unit_value_number<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/media_list.rs b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/media_list.rs
index 87ce9a655..af51869d8 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/media_list.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/media_list.rs
@@ -1,11 +1,12 @@
use super::*;
+use crate::web_api_interfaces;
pub(crate) fn ensure_media_list_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
member: &'static str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "MediaList") {
+ if web_api_interfaces::MediaList::is_instance(scope, object) {
return true;
}
throw_type_error(
diff --git a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_callbacks.rs b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_callbacks.rs
index 8d7d57c54..e4b71113f 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_callbacks.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_callbacks.rs
@@ -440,7 +440,7 @@ pub(crate) fn ensure_css_rule_object<'s>(
interface: &'static str,
member: &'static str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "CSSRule") {
+ if web_api_interfaces::CSSRule::is_instance(scope, object) {
return true;
}
throw_type_error(
@@ -457,7 +457,7 @@ pub(crate) fn ensure_css_rule_type_object<'s>(
member: &str,
expected_type: u32,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "CSSRule")
+ if web_api_interfaces::CSSRule::is_instance(scope, object)
&& css_rule_type_from_object(scope, object) == Some(expected_type)
{
return true;
@@ -734,7 +734,7 @@ pub(crate) fn css_rule_type_from_object<'s>(
return Some(css_rule_type);
}
}
- moli_webapi_declare::implements_interface(scope, object, "CSSRule").then_some(())?;
+ web_api_interfaces::CSSRule::is_instance(scope, object).then_some(())?;
Some(private_u32(scope, object, CSS_AT_RULE_TYPE_SLOT).unwrap_or(CSS_RULE_UNKNOWN_RULE_TYPE))
}
diff --git a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_list.rs b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_list.rs
index e1e55f523..075fb3110 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_list.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/rule_list.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::web_api_interfaces;
use moli_webapi_declare::DataPropertyDescriptorDeclaration;
#[cfg(test)]
@@ -415,7 +416,7 @@ pub(crate) fn ensure_css_rule_list_object<'s>(
object: v8::Local<'s, v8::Object>,
member: &'static str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "CSSRuleList") {
+ if web_api_interfaces::CSSRuleList::is_instance(scope, object) {
return true;
}
throw_type_error(
diff --git a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/style_sheet.rs b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/style_sheet.rs
index d85ff1b9a..ee5ba788f 100644
--- a/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/style_sheet.rs
+++ b/moli-renderer-v8/src/context_bootstrap/css_stylesheet_runtime/style_sheet.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::web_api_interfaces;
#[cfg(test)]
thread_local! {
@@ -273,8 +274,7 @@ pub(crate) fn adopted_style_sheet_objects_from_array_object<'s>(
(0..length)
.filter_map(|index| {
let object = array.get_index(scope, index)?.try_into().ok()?;
- moli_webapi_declare::implements_interface(scope, object, "CSSStyleSheet")
- .then_some(object)
+ web_api_interfaces::CSSStyleSheet::is_instance(scope, object).then_some(object)
})
.collect()
}
@@ -947,7 +947,7 @@ pub(crate) fn css_style_sheet_replace_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "CSSStyleSheet") {
+ if !web_api_interfaces::CSSStyleSheet::is_instance(scope, args.this()) {
let promise = rejected_type_error_promise(
scope,
"Failed to execute 'replace' on 'CSSStyleSheet': Illegal invocation.",
@@ -1034,7 +1034,7 @@ pub(crate) fn ensure_css_style_sheet_object<'s>(
interface: &'static str,
member: &'static str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "CSSStyleSheet") {
+ if web_api_interfaces::CSSStyleSheet::is_instance(scope, object) {
return true;
}
throw_type_error(
@@ -1095,7 +1095,7 @@ pub(crate) fn ensure_style_sheet_list_object<'s>(
object: v8::Local<'s, v8::Object>,
member: &'static str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "StyleSheetList") {
+ if web_api_interfaces::StyleSheetList::is_instance(scope, object) {
return true;
}
throw_type_error(
diff --git a/moli-renderer-v8/src/context_bootstrap/date_locale_runtime.rs b/moli-renderer-v8/src/context_bootstrap/date_locale_runtime.rs
index 706d94efe..eee903092 100644
--- a/moli-renderer-v8/src/context_bootstrap/date_locale_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/date_locale_runtime.rs
@@ -11,7 +11,7 @@ const ORIGINAL_INTL_DATETIME_FORMAT_RESOLVED_OPTIONS_SLOT: &str =
"__moliOriginalIntlDateTimeFormatResolvedOptions";
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Date")]
+#[webapi(fragment, prototype = "Date")]
struct DateLocalePrototypeDeclaration {
#[webapi(method, length = 0, callback = date_to_locale_string_callback)]
to_locale_string: (),
@@ -22,7 +22,7 @@ struct DateLocalePrototypeDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Intl.DateTimeFormat")]
+#[webapi(fragment, prototype = "Intl.DateTimeFormat")]
struct IntlDateTimeFormatPrototypeDeclaration {
#[webapi(
method = "resolvedOptions",
diff --git a/moli-renderer-v8/src/context_bootstrap/dom_rect.rs b/moli-renderer-v8/src/context_bootstrap/dom_rect.rs
index c81fb7b2f..da80d4716 100644
--- a/moli-renderer-v8/src/context_bootstrap/dom_rect.rs
+++ b/moli-renderer-v8/src/context_bootstrap/dom_rect.rs
@@ -158,7 +158,7 @@ struct DomRectConstructorDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DomRectJsonDeclaration {
#[webapi(data_property, enumerable)]
x: f64,
@@ -558,7 +558,7 @@ fn dom_rect_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "DOMRectReadOnly")
+ web_api_interfaces::DOMRectReadOnly::is_instance(scope, receiver)
}
const DOM_RECT_WRITABLE_ATTRIBUTE_SLOTS: &[&str] = &[
diff --git a/moli-renderer-v8/src/context_bootstrap/event_legacy.rs b/moli-renderer-v8/src/context_bootstrap/event_legacy.rs
index 36a8e7c04..67dbc2aea 100644
--- a/moli-renderer-v8/src/context_bootstrap/event_legacy.rs
+++ b/moli-renderer-v8/src/context_bootstrap/event_legacy.rs
@@ -184,14 +184,14 @@ struct KeyboardEventGetModifierStateArgs {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct LegacyUiEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: i32,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct LegacyTextEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
@@ -199,7 +199,7 @@ struct LegacyTextEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct LegacyMouseEventBaseInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: i32,
@@ -219,7 +219,7 @@ struct LegacyMouseEventBaseInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct LegacyMouseEventTailInitDeclaration<'scope> {
#[webapi(constructor_default = 0)]
buttons: i32,
@@ -231,7 +231,7 @@ struct LegacyMouseEventTailInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct LegacyKeyboardEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
#[webapi(constructor_default = 0)]
@@ -253,7 +253,7 @@ struct LegacyKeyboardEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct LegacyCustomEventInitDeclaration<'scope> {
detail: v8::Local<'scope, v8::Value>,
}
diff --git a/moli-renderer-v8/src/context_bootstrap/event_template.rs b/moli-renderer-v8/src/context_bootstrap/event_template.rs
index e24e1edf6..46c8aa539 100644
--- a/moli-renderer-v8/src/context_bootstrap/event_template.rs
+++ b/moli-renderer-v8/src/context_bootstrap/event_template.rs
@@ -33,7 +33,7 @@ pub(in crate::context_bootstrap) fn object_is_event_target<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "EventTarget")
+ web_api_interfaces::EventTarget::is_instance(scope, object)
}
#[derive(WebApiFunctionTemplate)]
diff --git a/moli-renderer-v8/src/context_bootstrap/events.rs b/moli-renderer-v8/src/context_bootstrap/events.rs
index b506ab6d4..b7ba2cbba 100644
--- a/moli-renderer-v8/src/context_bootstrap/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/events.rs
@@ -16,14 +16,14 @@ const FORM_DATA_EVENT_FORM_DATA_SLOT: &str = "__moliFormDataEventFormData";
const TRACK_EVENT_TRACK_SLOT: &str = "__moliTrackEventTrack";
const EVENT_SUBCLASS_KIND_SLOT: &str = "__moliEventSubclassKind";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PageTransitionEventInitDeclaration {
#[webapi(data_property, enumerable)]
persisted: bool,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct StorageEventStateDeclaration<'scope> {
#[webapi(data_property)]
key: v8::Local<'scope, v8::Value>,
@@ -38,7 +38,7 @@ struct StorageEventStateDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "PointerEvent", enumerable)]
+#[webapi(fragment, prototype = "PointerEvent", enumerable)]
struct SecurePointerEventPrototypeRuntimeDeclaration {
#[webapi(
method = "getCoalescedEvents",
diff --git a/moli-renderer-v8/src/context_bootstrap/events/base.rs b/moli-renderer-v8/src/context_bootstrap/events/base.rs
index 36a32ec69..5858dec15 100644
--- a/moli-renderer-v8/src/context_bootstrap/events/base.rs
+++ b/moli-renderer-v8/src/context_bootstrap/events/base.rs
@@ -17,7 +17,7 @@ const EVENT_TIMESTAMP_PRIVATE_SLOT: &str = "__moliEventTimeStamp";
const EVENT_IS_TRUSTED_GETTER_FUNCTION_SLOT: &str = "__moliEventIsTrustedGetterFunction";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct InitializedEventHeaderDeclaration<'scope> {
#[webapi(data_property = "type")]
event_type: v8::Local<'scope, v8::String>,
@@ -49,7 +49,7 @@ struct InitializedEventStateDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct InitializedEventIsTrustedAccessorDeclaration {
#[webapi(
accessor_property,
@@ -61,7 +61,7 @@ struct InitializedEventIsTrustedAccessorDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct InitializedEventTailDeclaration {
#[webapi(init = false)]
composed: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/basic.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/basic.rs
index 898fd4a4c..4a764a8e1 100644
--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/basic.rs
+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/basic.rs
@@ -2,14 +2,14 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct UiEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct FocusEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
@@ -19,7 +19,7 @@ struct FocusEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TextEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
@@ -27,7 +27,7 @@ struct TextEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CustomEventInitDeclaration<'scope> {
detail: v8::Local<'scope, v8::Value>,
}
diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs
index f919c447d..a070cc252 100644
--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs
+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/data.rs
@@ -128,26 +128,26 @@ struct NavigateEventMethodsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DragEventInitDeclaration<'scope> {
data_transfer: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ClipboardEventInitDeclaration<'scope> {
clipboard_data: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CapturedMouseEventInitDeclaration {
surface_x: i32,
surface_y: i32,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct MessageEventInitDeclaration<'scope> {
data: v8::Local<'scope, v8::Value>,
origin: v8::Local<'scope, v8::String>,
@@ -157,7 +157,7 @@ struct MessageEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct InputEventInitDeclaration<'scope> {
data: v8::Local<'scope, v8::Value>,
input_type: v8::Local<'scope, v8::String>,
@@ -165,20 +165,20 @@ struct InputEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CommandEventInitDeclaration<'scope> {
source: v8::Local<'scope, v8::Value>,
command: String,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct InterestEventInitDeclaration<'scope> {
source: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ToggleEventStateDeclaration<'scope> {
#[webapi(data_property = "oldState", readonly, dont_delete)]
old_state: String,
@@ -189,7 +189,7 @@ struct ToggleEventStateDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PopStateEventInitDeclaration<'scope> {
state: v8::Local<'scope, v8::Value>,
#[webapi(data_property = "hasUAVisualTransition")]
@@ -197,13 +197,13 @@ struct PopStateEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PageTransitionEventOwnInitDeclaration {
persisted: bool,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ErrorEventInitDeclaration<'scope> {
message: v8::Local<'scope, v8::String>,
filename: v8::Local<'scope, v8::String>,
@@ -213,7 +213,7 @@ struct ErrorEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PromiseRejectionEventInitDeclaration<'scope> {
promise: v8::Local<'scope, v8::Value>,
reason: v8::Local<'scope, v8::Value>,
@@ -258,14 +258,14 @@ struct SecurityPolicyViolationEventInitMembers {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NavigationCurrentEntryChangeEventInitDeclaration<'scope> {
from: v8::Local<'scope, v8::Value>,
navigation_type: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NavigateEventInitDeclaration<'scope> {
navigation_type: v8::Local<'scope, v8::String>,
destination: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/keyboard.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/keyboard.rs
index 90f2b6bb8..eb1ebaa72 100644
--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/keyboard.rs
+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/keyboard.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct KeyboardEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
diff --git a/moli-renderer-v8/src/context_bootstrap/events/subclasses/pointer.rs b/moli-renderer-v8/src/context_bootstrap/events/subclasses/pointer.rs
index de3be3b61..f3ac9e586 100644
--- a/moli-renderer-v8/src/context_bootstrap/events/subclasses/pointer.rs
+++ b/moli-renderer-v8/src/context_bootstrap/events/subclasses/pointer.rs
@@ -29,7 +29,7 @@ impl<'scope> webidl::WebIdlConverter<'scope> for PointerEventReference<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct MouseEventBaseInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
@@ -48,7 +48,7 @@ struct MouseEventBaseInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct MouseEventModifierInitDeclaration {
ctrl_key: bool,
shift_key: bool,
@@ -57,13 +57,13 @@ struct MouseEventModifierInitDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct MouseEventRelatedTargetDeclaration<'scope> {
related_target: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WheelEventDeltaInitDeclaration {
delta_x: f64,
delta_y: f64,
@@ -72,7 +72,7 @@ struct WheelEventDeltaInitDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PointerEventNumberInitDeclaration {
pointer_id: f64,
width: f64,
@@ -87,7 +87,7 @@ struct PointerEventNumberInitDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PointerEventTailInitDeclaration<'scope> {
is_primary: bool,
pointer_type: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs b/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs
index 39c4b026b..6eb2c00f2 100644
--- a/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs
+++ b/moli-renderer-v8/src/context_bootstrap/file_api/data_transfer.rs
@@ -64,7 +64,7 @@ pub(crate) fn is_branded_data_transfer_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "DataTransfer")
+ web_api_interfaces::DataTransfer::is_instance(scope, object)
}
#[derive(Default, WebApiObject)]
diff --git a/moli-renderer-v8/src/context_bootstrap/file_api/file.rs b/moli-renderer-v8/src/context_bootstrap/file_api/file.rs
index bb6936b1b..8505e247a 100644
--- a/moli-renderer-v8/src/context_bootstrap/file_api/file.rs
+++ b/moli-renderer-v8/src/context_bootstrap/file_api/file.rs
@@ -223,7 +223,7 @@ pub(crate) fn selected_file_from_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> Option<SelectedFile> {
- if !moli_webapi_declare::implements_interface(scope, object, "File") {
+ if !web_api_interfaces::File::is_instance(scope, object) {
return None;
}
let bytes = blob::blob_bytes_from_object(scope, object)?;
diff --git a/moli-renderer-v8/src/context_bootstrap/file_api/install.rs b/moli-renderer-v8/src/context_bootstrap/file_api/install.rs
index 1d46cca3d..69863dd3b 100644
--- a/moli-renderer-v8/src/context_bootstrap/file_api/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/file_api/install.rs
@@ -15,7 +15,7 @@ struct FileReaderConstantsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct FileApiRuntimeQueuesDeclaration {
#[webapi(slot = FILE_READER_QUEUE_SLOT, init = "array")]
file_reader_queue: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/callbacks.rs b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/callbacks.rs
index b710e33e6..6edbd2ecf 100644
--- a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/callbacks.rs
+++ b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/callbacks.rs
@@ -18,7 +18,7 @@ use crate::{
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct FormDataEventInitDeclaration<'scope> {
form_data: v8::Local<'scope, v8::Object>,
bubbles: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/iterators.rs b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/iterators.rs
index b84476f70..8511127b7 100644
--- a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/iterators.rs
+++ b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/iterators.rs
@@ -37,7 +37,7 @@ struct FormDataIteratorPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct FormDataIteratorResultDeclaration<'scope> {
#[webapi(data_property, enumerable)]
done: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/serialize.rs b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/serialize.rs
index 2e1ced88f..29b5615db 100644
--- a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/serialize.rs
+++ b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/serialize.rs
@@ -13,7 +13,7 @@ use moli_encoding::is_charset_sentinel_name;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct EmptyFileOptionsDeclaration {
#[webapi(data_property, enumerable)]
r#type: &'static str,
diff --git a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/storage.rs b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/storage.rs
index 510cacca7..77627affe 100644
--- a/moli-renderer-v8/src/context_bootstrap/form_data_runtime/storage.rs
+++ b/moli-renderer-v8/src/context_bootstrap/form_data_runtime/storage.rs
@@ -15,7 +15,7 @@ pub(in crate::context_bootstrap) fn form_data_is_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "FormData")
+ web_api_interfaces::FormData::is_instance(scope, object)
}
pub(in crate::context_bootstrap) fn form_data_entries<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs b/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs
index 2f38a5d82..dcf2569a5 100644
--- a/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/geometry_runtime.rs
@@ -46,9 +46,12 @@ struct DomPointObjectDeclaration {
}
macro_rules! dom_matrix_object_declaration {
- ($name:ident, $interface:literal) => {
+ ($name:ident, $interface:ident) => {
#[derive(WebApiObject)]
- #[webapi(interface = $interface, fallback_to_string_tag = $interface)]
+ #[webapi(
+ interface = web_api_interfaces::$interface,
+ fallback_to_string_tag = <web_api_interfaces::$interface>::DESCRIPTOR.name()
+ )]
struct $name {
#[webapi(slot = DOM_MATRIX_M11_SLOT)]
m11: f64,
@@ -113,11 +116,11 @@ macro_rules! dom_matrix_object_declaration {
};
}
-dom_matrix_object_declaration!(DomMatrixObjectDeclaration, "DOMMatrix");
-dom_matrix_object_declaration!(DomMatrixReadOnlyObjectDeclaration, "DOMMatrixReadOnly");
+dom_matrix_object_declaration!(DomMatrixObjectDeclaration, DOMMatrix);
+dom_matrix_object_declaration!(DomMatrixReadOnlyObjectDeclaration, DOMMatrixReadOnly);
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DomPointJsonDeclaration {
x: f64,
y: f64,
@@ -126,7 +129,7 @@ struct DomPointJsonDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DomMatrixJsonDeclaration {
a: f64,
b: f64,
@@ -859,14 +862,14 @@ fn dom_point_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "DOMPoint")
+ web_api_interfaces::DOMPoint::is_instance(scope, receiver)
}
fn dom_matrix_require_readonly_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, "DOMMatrixReadOnly") {
+ if web_api_interfaces::DOMMatrixReadOnly::is_instance(scope, receiver) {
return true;
}
throw_type_error(scope, "Illegal invocation");
@@ -877,7 +880,7 @@ fn dom_matrix_require_mutable_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, "DOMMatrix") {
+ if web_api_interfaces::DOMMatrix::is_instance(scope, receiver) {
return true;
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/context_bootstrap/history_runtime/traversal.rs b/moli-renderer-v8/src/context_bootstrap/history_runtime/traversal.rs
index 98a66ebb9..6a0306123 100644
--- a/moli-renderer-v8/src/context_bootstrap/history_runtime/traversal.rs
+++ b/moli-renderer-v8/src/context_bootstrap/history_runtime/traversal.rs
@@ -46,7 +46,7 @@ const TRAVERSAL_INTERCEPT_PROMISE_SLOT: &str = "__lmTraversalInterceptPromise";
const NAVIGATION_ACTIVE_TRAVERSAL_INTERCEPT_SLOT: &str = "__lmNavigationActiveTraversalIntercept";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct TraversalPrecommitDataDeclaration<'scope> {
#[webapi(slot = TRAVERSAL_PRECOMMIT_ACTIVE_SLOT)]
active: bool,
@@ -77,7 +77,7 @@ struct TraversalPrecommitDataDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct TraversalInterceptSettlementDataDeclaration<'scope> {
#[webapi(slot = TRAVERSAL_INTERCEPT_ACTIVE_SLOT)]
active: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/idle_detection.rs b/moli-renderer-v8/src/context_bootstrap/idle_detection.rs
index 4bab9c037..23cd6f333 100644
--- a/moli-renderer-v8/src/context_bootstrap/idle_detection.rs
+++ b/moli-renderer-v8/src/context_bootstrap/idle_detection.rs
@@ -112,7 +112,7 @@ fn idle_detector_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, "IdleDetector") {
+ if web_api_interfaces::IdleDetector::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/context_bootstrap/image_data.rs b/moli-renderer-v8/src/context_bootstrap/image_data.rs
index ba720fc37..cd059a963 100644
--- a/moli-renderer-v8/src/context_bootstrap/image_data.rs
+++ b/moli-renderer-v8/src/context_bootstrap/image_data.rs
@@ -68,7 +68,7 @@ struct ImageDataPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ImageDataSettingsDeclaration<'scope> {
color_space: v8::Local<'scope, v8::String>,
}
@@ -168,7 +168,7 @@ fn image_data_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "ImageData")
+ web_api_interfaces::ImageData::is_instance(scope, receiver)
}
fn image_data_constructor_parts<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/cursors/entries.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/cursors/entries.rs
index 74fb6bd56..cb9490bed 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/cursors/entries.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/cursors/entries.rs
@@ -3,7 +3,7 @@ use crate::util::serialize_v8_iter_array;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CursorSnapshotEntryObjectDeclaration<'scope> {
#[webapi(data_property)]
key: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/metadata/descriptors/create.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/metadata/descriptors/create.rs
index 7fff71a97..c6c13cda0 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/metadata/descriptors/create.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/core/objects/metadata/descriptors/create.rs
@@ -3,7 +3,7 @@ use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
#[webapi(
- interface = "Object",
+ record,
scope_lifetime = 'scope,
data_properties,
enumerable
@@ -17,7 +17,7 @@ struct IndexDescriptorDeclaration<'scope, 'value> {
#[derive(WebApiObject)]
#[webapi(
- interface = "Object",
+ record,
scope_lifetime = 'scope,
data_properties,
enumerable
diff --git a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs
index 257c5ab68..3ec9462d0 100644
--- a/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs
+++ b/moli-renderer-v8/src/context_bootstrap/indexed_db/event_target/version_change.rs
@@ -4,7 +4,7 @@ use crate::webidl;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct IdbVersionChangeEventFieldsDeclaration<'scope> {
old_version: u64,
new_version: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/location_navigation.rs b/moli-renderer-v8/src/context_bootstrap/location_navigation.rs
index 376ccbdd5..74ee0afef 100644
--- a/moli-renderer-v8/src/context_bootstrap/location_navigation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/location_navigation.rs
@@ -823,7 +823,7 @@ const NAVIGATION_ACTIVE_LOCATION_INTERCEPT_SETTLEMENT_SLOT: &str =
"__lmNavigationActiveLocationInterceptSettlement";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct LocationInterceptSettlementDataDeclaration<'scope> {
#[webapi(slot = LOCATION_INTERCEPT_SETTLEMENT_ACTIVE_SLOT)]
active: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/location_runtime/surface.rs b/moli-renderer-v8/src/context_bootstrap/location_runtime/surface.rs
index 72fd20f9a..040bd7f5b 100644
--- a/moli-renderer-v8/src/context_bootstrap/location_runtime/surface.rs
+++ b/moli-renderer-v8/src/context_bootstrap/location_runtime/surface.rs
@@ -4,7 +4,7 @@ use crate::webidl;
use moli_webapi_declare::WebApiObject;
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WindowLocationAccessorDeclaration {
#[webapi(
accessor_property,
@@ -17,7 +17,7 @@ struct WindowLocationAccessorDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WindowHistoryAccessorDeclaration {
#[webapi(
accessor_property,
@@ -28,7 +28,7 @@ struct WindowHistoryAccessorDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WindowNavigationAccessorDeclaration {
#[webapi(
accessor_property,
@@ -40,7 +40,7 @@ struct WindowNavigationAccessorDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DocumentLocationAccessorDeclaration {
#[webapi(
accessor_property,
diff --git a/moli-renderer-v8/src/context_bootstrap/media_cues.rs b/moli-renderer-v8/src/context_bootstrap/media_cues.rs
index ef6a3be64..66a4f8043 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_cues.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_cues.rs
@@ -324,7 +324,7 @@ fn text_track_cue_receiver<'s>(
args: &v8::FunctionCallbackArguments<'s>,
) -> Option<v8::Local<'s, v8::Object>> {
let receiver = args.this();
- if moli_webapi_declare::implements_interface(scope, receiver, "TextTrackCue") {
+ if web_api_interfaces::TextTrackCue::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs
index deca318e1..11b5a2fc7 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/evaluation.rs
@@ -68,7 +68,7 @@ struct MediaQueryListPrototypeAccessorsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = web_api_interfaces::Event, allow_empty)]
+#[webapi(interface = web_api_interfaces::Event)]
struct MediaQueryListChangeEventObjectDeclaration {}
#[derive(WebApiObject)]
diff --git a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs
index c00cbe44b..1a11fe69f 100644
--- a/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs
+++ b/moli-renderer-v8/src/context_bootstrap/media_queries/events/simple_event_target/listeners.rs
@@ -25,7 +25,7 @@ const SIMPLE_EVENT_TARGET_LISTENER_TYPE_ORDER_SLOT: &str =
"__moliSimpleEventTargetListenerTypeOrder";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SimpleObjectAbortListenerDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
target: v8::Local<'scope, v8::Object>,
@@ -42,7 +42,7 @@ struct SimpleObjectAbortListenerDataDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SimpleObjectEventListenerEntryDeclaration<'scope> {
#[webapi(slot = SIMPLE_EVENT_TARGET_LISTENER_ORIGINAL_SLOT)]
original: v8::Local<'scope, v8::Value>,
@@ -63,7 +63,7 @@ struct SimpleObjectEventListenerEntryDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SimpleObjectEventHandlerEntryDeclaration<'scope> {
#[webapi(slot = SIMPLE_EVENT_TARGET_LISTENER_ORIGINAL_SLOT)]
original: Option<v8::Local<'scope, v8::String>>,
diff --git a/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs b/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs
index 842c4df20..07a8f1c2e 100644
--- a/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs
+++ b/moli-renderer-v8/src/context_bootstrap/message_ports/delivery.rs
@@ -11,7 +11,7 @@ use crate::worker::worker_message_port_wrapper;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct MessagePortMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs b/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs
index bcff58a7d..54fb97b3a 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_activation.rs
@@ -60,7 +60,7 @@ struct NavigationTransitionObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationTransitionSettleDataDeclaration<'scope> {
#[webapi(slot = NAVIGATION_TRANSITION_SETTLE_NAVIGATION_SLOT)]
navigation: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_callbacks/navigation.rs b/moli-renderer-v8/src/context_bootstrap/navigation_callbacks/navigation.rs
index 032836db7..c743b16dc 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_callbacks/navigation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_callbacks/navigation.rs
@@ -803,7 +803,7 @@ const PRECOMMIT_COMMIT_ATTEMPT_ID_SLOT: &str = "__lmPrecommitCommitAttemptId";
const NAVIGATION_PENDING_PRECOMMIT_COMMIT_SLOT: &str = "__lmNavigationPendingPrecommitCommit";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PrecommitCommitDataDeclaration<'scope> {
#[webapi(slot = PRECOMMIT_COMMIT_ACTIVE_SLOT)]
active: bool,
@@ -1340,7 +1340,7 @@ const INTERCEPT_SETTLEMENT_ATTEMPT_ID_SLOT: &str = "__lmInterceptSettlementAttem
const NAVIGATION_ACTIVE_INTERCEPT_SETTLEMENT_SLOT: &str = "__lmNavigationActiveInterceptSettlement";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct InterceptSettlementDataDeclaration<'scope> {
#[webapi(slot = INTERCEPT_SETTLEMENT_ACTIVE_SLOT)]
active: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_events.rs b/moli-renderer-v8/src/context_bootstrap/navigation_events.rs
index 0d05f0037..4da488554 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_events.rs
@@ -64,7 +64,7 @@ const ACTIVE_NAVIGATE_EVENT_SIGNAL_SLOT: &str = "__lmActiveNavigateEventSignal";
const ACTIVE_NAVIGATE_EVENT_HREF_SLOT: &str = "__lmActiveNavigateEventHref";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationCurrentEntryChangeEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
from: v8::Local<'scope, v8::Value>,
@@ -73,7 +73,7 @@ struct NavigationCurrentEntryChangeEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationErrorEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
message: v8::Local<'scope, v8::String>,
@@ -88,14 +88,14 @@ struct NavigationErrorEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PopStateEventStateDeclaration<'scope> {
#[webapi(data_property)]
state: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct HashChangeEventStateDeclaration {
#[webapi(data_property = "oldURL")]
old_url: String,
@@ -104,14 +104,14 @@ struct HashChangeEventStateDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PageTransitionEventStateDeclaration {
#[webapi(data_property)]
persisted: bool,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigateEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
navigation_type: v8::Local<'scope, v8::Value>,
@@ -138,7 +138,7 @@ struct NavigateEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ActiveNavigateEventDataDeclaration<'scope> {
#[webapi(slot = ACTIVE_NAVIGATE_EVENT_EVENT_SLOT)]
event: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs b/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs
index bfe6b26bf..34ea4fd03 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_lifecycle.rs
@@ -16,7 +16,7 @@ use crate::{native_bridge::NavigationAttemptId, util::get_private_value};
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationFinishedResolveDataDeclaration<'scope> {
#[webapi(slot = NAVIGATION_FINISH_RESOLVE_SLOT)]
resolve: v8::Local<'scope, v8::Function>,
@@ -26,7 +26,7 @@ struct NavigationFinishedResolveDataDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationFinishedRejectDataDeclaration<'scope> {
#[webapi(slot = NAVIGATION_FINISH_REJECT_SLOT)]
reject: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_result.rs b/moli-renderer-v8/src/context_bootstrap/navigation_result.rs
index 07774a945..d163aca1f 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_result.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_result.rs
@@ -24,7 +24,7 @@ const NAVIGATION_ACTIVE_CROSS_DOCUMENT_PENDING_SLOT: &str =
"__lmNavigationActiveCrossDocumentPending";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationResultDeclaration<'scope> {
#[webapi(data_property, enumerable)]
committed: v8::Local<'scope, v8::Promise>,
@@ -33,7 +33,7 @@ struct NavigationResultDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigationResultFallbackDeclaration {
#[webapi(data_property, enumerable, name = "committed", init = "undefined")]
committed: (),
@@ -42,7 +42,7 @@ struct NavigationResultFallbackDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CapturedPromiseResolverRecordDeclaration {
#[webapi(data_property = "resolve", init = "undefined")]
resolve: (),
@@ -51,7 +51,7 @@ struct CapturedPromiseResolverRecordDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CapturedPromiseResolverFunctionsDeclaration<'scope> {
#[webapi(data_property)]
resolve: v8::Local<'scope, v8::Value>,
@@ -60,7 +60,7 @@ struct CapturedPromiseResolverFunctionsDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossDocumentPendingNavigationDeclaration<'scope> {
#[webapi(
slot = CROSS_DOCUMENT_PENDING_ACTIVE_SLOT,
diff --git a/moli-renderer-v8/src/context_bootstrap/navigation_surface/accessors.rs b/moli-renderer-v8/src/context_bootstrap/navigation_surface/accessors.rs
index 520e9eb80..25ea95790 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigation_surface/accessors.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigation_surface/accessors.rs
@@ -27,7 +27,7 @@ impl ScrollRestoration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "History")]
+#[webapi(fragment, prototype = "History")]
struct HistoryPrototypeAccessorsDeclaration {
#[webapi(accessor_property, getter = history_length_getter_function, enumerable)]
length: (),
@@ -45,7 +45,7 @@ struct HistoryPrototypeAccessorsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Navigation")]
+#[webapi(fragment, prototype = "Navigation")]
struct NavigationPrototypeAccessorsDeclaration {
#[webapi(accessor_property = "canGoBack", getter = navigation_can_go_back_getter_function, enumerable)]
can_go_back: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs
index 448ef3838..70a05da40 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/clipboard.rs
@@ -409,14 +409,14 @@ fn clipboard_item_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "ClipboardItem")
+ web_api_interfaces::ClipboardItem::is_instance(scope, receiver)
}
fn clipboard_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "Clipboard")
+ web_api_interfaces::Clipboard::is_instance(scope, receiver)
}
fn clipboard_item_presentation_style_getter<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/collections.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/collections.rs
index 8cea56956..4bdc11287 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/collections.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/collections.rs
@@ -189,7 +189,9 @@ fn collection_length_getter_for<'s>(
mut rv: v8::ReturnValue<'s, v8::Value>,
interface: &'static str,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), interface) {
+ if !web_api_interfaces::descriptor(interface)
+ .is_some_and(|interface| interface.is_instance(scope, args.this()))
+ {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -256,7 +258,9 @@ fn collection_item_callback_for<'s>(
throw_type_error(scope, "Illegal invocation");
return;
};
- if !moli_webapi_declare::implements_interface(scope, this_obj, interface) {
+ if !web_api_interfaces::descriptor(interface)
+ .is_some_and(|interface| interface.is_instance(scope, this_obj))
+ {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -279,7 +283,9 @@ fn collection_named_item_callback_for<'s>(
throw_type_error(scope, "Illegal invocation");
return;
};
- if !moli_webapi_declare::implements_interface(scope, this_obj, interface) {
+ if !web_api_interfaces::descriptor(interface)
+ .is_some_and(|interface| interface.is_instance(scope, this_obj))
+ {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -302,7 +308,7 @@ fn plugin_array_refresh_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
_rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "PluginArray") {
+ if !web_api_interfaces::PluginArray::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
}
}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs
index 6018e99ac..8fdc662a4 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/geolocation.rs
@@ -301,7 +301,7 @@ fn geolocation_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "Geolocation")
+ web_api_interfaces::Geolocation::is_instance(scope, receiver)
}
fn take_next_watch_id<'s>(
@@ -439,7 +439,7 @@ fn geolocation_position_error_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, "GeolocationPositionError") {
+ if web_api_interfaces::GeolocationPositionError::is_instance(scope, receiver) {
Some(receiver)
} else {
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_capabilities.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_capabilities.rs
index 2b366a47d..c1755b737 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_capabilities.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_capabilities.rs
@@ -27,7 +27,7 @@ struct MediaCapabilitiesPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record)]
struct MediaCapabilitiesDecodingInfoDeclaration<'scope> {
#[webapi(data_property, enumerable)]
supported: bool,
@@ -46,7 +46,7 @@ struct MediaCapabilitiesDecodingInfoDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record)]
struct MediaCapabilitiesEncodingInfoDeclaration<'scope> {
#[webapi(data_property, enumerable)]
supported: bool,
@@ -475,7 +475,7 @@ fn media_capabilities_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "MediaCapabilities")
+ web_api_interfaces::MediaCapabilities::is_instance(scope, receiver)
}
fn media_capabilities_is_secure_context<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs
index 1e931e865..4e6b65cad 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/media_devices.rs
@@ -51,7 +51,7 @@ fn receiver_is_media_devices<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "MediaDevices")
+ web_api_interfaces::MediaDevices::is_instance(scope, receiver)
}
fn enumerate_devices_callback<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs
index 2d8186791..8f74b3350 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/navigator.rs
@@ -107,7 +107,7 @@ pub(in crate::context_bootstrap) const SERVICE_WORKER_OWNER_TOKEN_SLOT: &str =
"__moliServiceWorkerOwner";
#[derive(Default, WebApiObject)]
-#[webapi(interface = web_api_interfaces::Permissions, allow_empty)]
+#[webapi(interface = web_api_interfaces::Permissions)]
struct PermissionsObjectDeclaration {}
#[derive(Default, WebApiFunctionTemplate)]
@@ -323,7 +323,7 @@ struct NavigatorConnectionDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(allow_empty, interface = web_api_interfaces::StorageManager)]
+#[webapi(interface = web_api_interfaces::StorageManager)]
struct StorageManagerObjectDeclaration {}
#[derive(WebApiFunctionTemplate)]
@@ -377,7 +377,7 @@ pub(in crate::context_bootstrap) fn install_storage_manager_constructor_template
}
#[derive(WebApiObject)]
-#[webapi(allow_empty, interface = web_api_interfaces::StorageBucketManager)]
+#[webapi(interface = web_api_interfaces::StorageBucketManager)]
struct StorageBucketManagerObjectDeclaration {}
#[derive(Default, WebApiFunctionTemplate)]
@@ -468,7 +468,7 @@ struct UserActivationObjectDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record, scope_lifetime = 'scope)]
struct WindowNavigatorBackingDeclaration<'scope, 'profile> {
#[webapi(data_property, enumerable)]
user_agent: &'profile str,
@@ -571,7 +571,7 @@ struct WindowNavigatorBackingDeclaration<'scope, 'profile> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record, scope_lifetime = 'scope)]
struct WorkerNavigatorBackingDeclaration<'scope, 'profile> {
#[webapi(data_property, enumerable)]
user_agent: &'profile str,
@@ -694,7 +694,7 @@ pub(in crate::context_bootstrap) fn navigator_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
navigator: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, navigator, "Navigator")
+ web_api_interfaces::Navigator::is_instance(scope, navigator)
}
pub(crate) fn current_protocol_user_gesture_activation(scope: &mut v8::PinScope<'_, '_>) -> bool {
@@ -707,7 +707,7 @@ fn navigator_user_activation_state_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "UserActivation") {
+ if !web_api_interfaces::UserActivation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -782,7 +782,7 @@ fn navigator_connection_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "NetworkInformation")
+ web_api_interfaces::NetworkInformation::is_instance(scope, receiver)
}
pub(in crate::context_bootstrap) fn install_navigator_template_bindings<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs
index 785b3ce86..9a3554180 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/screen.rs
@@ -190,7 +190,7 @@ fn screen_orientation_lock_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -221,7 +221,7 @@ fn screen_orientation_unlock_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -233,7 +233,7 @@ fn screen_event_target_add_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Screen") {
+ if !web_api_interfaces::Screen::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -245,7 +245,7 @@ fn screen_event_target_remove_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Screen") {
+ if !web_api_interfaces::Screen::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -257,7 +257,7 @@ fn screen_event_target_dispatch_event_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Screen") {
+ if !web_api_interfaces::Screen::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -269,7 +269,7 @@ fn screen_orientation_event_target_add_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -281,7 +281,7 @@ fn screen_orientation_event_target_remove_event_listener_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -293,7 +293,7 @@ fn screen_orientation_event_target_dispatch_event_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -365,7 +365,7 @@ fn screen_attribute_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "Screen") {
+ if !web_api_interfaces::Screen::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -447,7 +447,7 @@ fn screen_orientation_attribute_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -485,7 +485,7 @@ fn screen_orientation_onchange_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
@@ -500,7 +500,7 @@ fn screen_orientation_onchange_setter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'s, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "ScreenOrientation") {
+ if !web_api_interfaces::ScreenOrientation::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs
index 16234c105..34871c029 100644
--- a/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs
+++ b/moli-renderer-v8/src/context_bootstrap/navigator_runtime/visual_viewport.rs
@@ -103,7 +103,7 @@ fn visual_viewport_attribute_getter_callback<'s>(
args: v8::FunctionCallbackArguments<'s>,
mut rv: v8::ReturnValue<'_, v8::Value>,
) {
- if !moli_webapi_declare::implements_interface(scope, args.this(), "VisualViewport") {
+ if !web_api_interfaces::VisualViewport::is_instance(scope, args.this()) {
throw_type_error(scope, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs b/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs
index d4a394d0a..457308601 100644
--- a/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/notification_runtime.rs
@@ -210,7 +210,7 @@ struct NotificationConstructorConstantsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NotificationConstructorPermissionDeclaration {
#[webapi(
accessor_property,
@@ -1301,7 +1301,7 @@ fn notification_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "Notification")
+ web_api_interfaces::Notification::is_instance(scope, receiver)
}
fn notification_event_target_add_event_listener_callback<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/opfs.rs b/moli-renderer-v8/src/context_bootstrap/opfs.rs
index a14181f3f..9a0b143f1 100644
--- a/moli-renderer-v8/src/context_bootstrap/opfs.rs
+++ b/moli-renderer-v8/src/context_bootstrap/opfs.rs
@@ -805,7 +805,7 @@ struct FileSystemWritableFileStreamPrototypeDeclaration {
#[derive(WebApiObject)]
// An internal UnderlyingSink record, not a Web IDL interface instance.
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct FileSystemWritableSinkObjectDeclaration {
#[webapi(slot = FILE_SYSTEM_WRITABLE_SINK_STATE_SLOT)]
state_json: String,
@@ -1225,7 +1225,7 @@ fn handle_state<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> Option<FileSystemHandleState> {
- let branded = moli_webapi_declare::implements_interface(scope, object, "FileSystemHandle");
+ let branded = web_api_interfaces::FileSystemHandle::is_instance(scope, object);
if !branded {
return None;
}
@@ -2180,11 +2180,8 @@ fn file_system_directory_iterator_next_callback<'s>(
return;
};
rv.set(resolver.get_promise(scope).into());
- if !moli_webapi_declare::implements_interface(
- scope,
- args.this(),
- "FileSystemDirectoryHandle AsyncIterator",
- ) {
+ if !web_api_interfaces::FileSystemDirectoryHandleAsyncIterator::is_instance(scope, args.this())
+ {
reject_type_error(scope, resolver, "Illegal invocation");
return;
}
@@ -2551,7 +2548,7 @@ fn sync_access_state<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> Option<FileSystemSyncAccessHandleState> {
- if !moli_webapi_declare::implements_interface(scope, object, "FileSystemSyncAccessHandle") {
+ if !web_api_interfaces::FileSystemSyncAccessHandle::is_instance(scope, object) {
return None;
}
let json = get_private_value(scope, object, FILE_SYSTEM_SYNC_ACCESS_STATE_SLOT)?
@@ -3075,7 +3072,7 @@ fn writable_stream_is_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
stream: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, stream, "FileSystemWritableFileStream")
+ web_api_interfaces::FileSystemWritableFileStream::is_instance(scope, stream)
}
fn file_system_writable_mode_getter_callback<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime/entries.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime/entries.rs
index d9775b0de..8728f5ddb 100644
--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime/entries.rs
+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime/entries.rs
@@ -45,7 +45,7 @@ struct PerformanceEntryObjectDeclaration<'scope, 'name, 'entry_type> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PerformanceEntryJsonSnapshotDeclaration {
name: String,
entry_type: String,
@@ -118,7 +118,7 @@ struct PerformanceResourceTimingSlotDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PerformanceResourceTimingJsonSnapshotDeclaration {
name: String,
entry_type: String,
diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs
index 922c04ef3..91edef008 100644
--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime/install.rs
@@ -78,7 +78,7 @@ struct PerformanceObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PerformanceJsonSnapshotDeclaration<'scope> {
time_origin: Option<v8::Local<'scope, v8::Value>>,
timing: Option<v8::Local<'scope, v8::Value>>,
@@ -86,7 +86,7 @@ struct PerformanceJsonSnapshotDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "PerformanceObserver")]
+#[webapi(fragment, prototype = "PerformanceObserver")]
struct PerformanceObserverConstructorDeclaration {
#[webapi(data_property = "supportedEntryTypes")]
supported_entry_types: &'static [&'static str],
diff --git a/moli-renderer-v8/src/context_bootstrap/performance_runtime/memory.rs b/moli-renderer-v8/src/context_bootstrap/performance_runtime/memory.rs
index 140a268f6..fdbf6e257 100644
--- a/moli-renderer-v8/src/context_bootstrap/performance_runtime/memory.rs
+++ b/moli-renderer-v8/src/context_bootstrap/performance_runtime/memory.rs
@@ -15,7 +15,7 @@ const MEMORY_SLOTS: &[&str] = &[TOTAL_HEAP_SLOT, USED_HEAP_SLOT, HEAP_LIMIT_SLOT
const SAMPLE_INTERVAL: Duration = Duration::from_secs(20 * 60);
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct MemoryInfoPrototypeDeclaration {
#[webapi(accessor_property, name = "totalJSHeapSize", enumerable, getter = memory_info_getter, data = callback_data_index_value(scope, 0))]
total_js_heap_size: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/resize_observer_runtime.rs b/moli-renderer-v8/src/context_bootstrap/resize_observer_runtime.rs
index d62305190..17674c1b4 100644
--- a/moli-renderer-v8/src/context_bootstrap/resize_observer_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/resize_observer_runtime.rs
@@ -42,7 +42,7 @@ struct ResizeObserverEntryDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ResizeObserverObservedRecordDeclaration<'scope> {
#[webapi(slot = RESIZE_OBSERVER_RECORD_TARGET_SLOT)]
target: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/runtime_state.rs b/moli-renderer-v8/src/context_bootstrap/runtime_state.rs
index f854e632b..e90bbdd23 100644
--- a/moli-renderer-v8/src/context_bootstrap/runtime_state.rs
+++ b/moli-renderer-v8/src/context_bootstrap/runtime_state.rs
@@ -70,14 +70,14 @@ struct HtmlScriptElementSupportsArgs {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "HTMLScriptElement", enumerable)]
+#[webapi(fragment, prototype = "HTMLScriptElement", enumerable)]
struct HtmlScriptElementStaticMethodsDeclaration {
#[webapi(method, length = 1, callback = html_script_element_supports_callback)]
supports: (),
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Document", enumerable)]
+#[webapi(fragment, prototype = "Document", enumerable)]
struct DocumentStaticMethodsDeclaration {
#[webapi(
method = "parseHTMLUnsafe",
@@ -88,7 +88,7 @@ struct DocumentStaticMethodsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Document", enumerable)]
+#[webapi(fragment, prototype = "Document", enumerable)]
struct DocumentPrototypeRuntimeDeclaration {
#[webapi(
accessor_property = "designMode",
@@ -135,7 +135,7 @@ struct DocumentPrototypeRuntimeDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WindowComputedStyleMethodDeclaration {
#[webapi(
method,
@@ -147,7 +147,7 @@ struct WindowComputedStyleMethodDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record)]
struct WindowPublicSurfaceAccessorsDeclaration<'scope> {
history_slot: v8::Local<'scope, v8::Value>,
navigation_slot: v8::Local<'scope, v8::Value>,
@@ -264,7 +264,7 @@ struct WindowPublicSurfaceAccessorsDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct WindowLegacyAliasAccessorsDeclaration {
#[webapi(
accessor_property,
@@ -289,7 +289,7 @@ struct WindowLegacyAliasAccessorsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "Window", enumerable)]
+#[webapi(fragment, prototype = "Window", enumerable)]
struct WindowAdditionalReplaceableAccessorsDeclaration<'scope> {
origin_name: v8::Local<'scope, v8::Value>,
inner_width_name: v8::Local<'scope, v8::Value>,
@@ -374,7 +374,7 @@ struct WindowAdditionalReplaceableAccessorsDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ConsoleObjectDeclaration {
#[webapi(method, callback = console_log_callback)]
log: (),
@@ -454,14 +454,14 @@ struct WindowBootstrapGlobalSlotsDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WindowEvalGlobalDeclaration<'scope> {
#[webapi(data_property = "eval")]
intrinsic_eval: v8::Local<'scope, v8::Value>,
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyNamespaceDeclaration {
#[webapi(method, length = 1, callback = webassembly_namespace_instance_callback)]
namespace_instance: (),
@@ -469,17 +469,12 @@ struct WebAssemblyNamespaceDeclaration {
#[cfg(feature = "wpt-extensions")]
#[derive(WebApiObject)]
-#[webapi(
- allow_empty,
- interface = "Object",
- prototype = "WebDriver",
- require_prototype
-)]
+#[webapi(record, prototype = "WebDriver", require_prototype)]
struct WebDriverObjectDeclaration {}
#[cfg(feature = "wpt-extensions")]
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebDriverPrototypeDeclaration {
#[webapi(method, length = 0, callback = webdriver_delete_all_cookies_callback)]
delete_all_cookies: (),
@@ -487,7 +482,7 @@ struct WebDriverPrototypeDeclaration {
#[cfg(feature = "wpt-extensions")]
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebDriverPrototypeMetadataDeclaration<'scope> {
#[webapi(data_property = "constructor")]
constructor: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/shared_installers/constants.rs b/moli-renderer-v8/src/context_bootstrap/shared_installers/constants.rs
index 6c9f8e608..7301eba81 100644
--- a/moli-renderer-v8/src/context_bootstrap/shared_installers/constants.rs
+++ b/moli-renderer-v8/src/context_bootstrap/shared_installers/constants.rs
@@ -3,7 +3,7 @@ use crate::web_api_interfaces;
use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct NodeFilterConstantsObjectDeclaration {
#[webapi(constant = "FILTER_ACCEPT", value = 1u32)]
_filter_accept: (),
@@ -40,7 +40,7 @@ struct NodeFilterConstantsObjectDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "Window")]
+#[webapi(fragment, prototype = "Window")]
struct NodeFilterGlobalDeclaration<'scope> {
#[webapi(data_property = "NodeFilter")]
node_filter: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/shared_installers/prototypes.rs b/moli-renderer-v8/src/context_bootstrap/shared_installers/prototypes.rs
index edf6d6ea4..5208d0efa 100644
--- a/moli-renderer-v8/src/context_bootstrap/shared_installers/prototypes.rs
+++ b/moli-renderer-v8/src/context_bootstrap/shared_installers/prototypes.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct InterfacePrototypeTagDeclaration<'tag> {
#[webapi(to_string_tag)]
tag: &'tag str,
diff --git a/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs b/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs
index 3fe54c707..66e4e3614 100644
--- a/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs
+++ b/moli-renderer-v8/src/context_bootstrap/shared_worker_host.rs
@@ -88,7 +88,7 @@ struct SharedWorkerObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SharedWorkerHostEventInitDeclaration {
#[webapi(data_property, enumerable)]
cancelable: bool,
@@ -104,7 +104,7 @@ struct SharedWorkerHostEventFallbackDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SharedWorkerHostErrorEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
message: v8::Local<'scope, v8::String>,
@@ -138,7 +138,7 @@ struct SharedWorkerHostErrorEventFallbackDeclaration<'scope, 'text> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope, data_properties, enumerable)]
+#[webapi(record, scope_lifetime = 'scope, data_properties, enumerable)]
struct SharedWorkerHostErrorEventDetailsDeclaration<'scope, 'text> {
message: &'text str,
filename: &'text str,
diff --git a/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs b/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs
index 59173a1e0..77ea1ee6e 100644
--- a/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs
+++ b/moli-renderer-v8/src/context_bootstrap/speech_synthesis.rs
@@ -448,7 +448,7 @@ fn speech_synthesis_speak_callback<'s>(
let branded = v8::Local::<v8::Object>::try_from(utterance)
.ok()
.is_some_and(|object| {
- moli_webapi_declare::implements_interface(scope, object, "SpeechSynthesisUtterance")
+ web_api_interfaces::SpeechSynthesisUtterance::is_instance(scope, object)
});
if !branded {
throw_type_error(
@@ -620,9 +620,7 @@ fn speech_utterance_voice_setter<'s>(
}
let valid = v8::Local::<v8::Object>::try_from(value)
.ok()
- .is_some_and(|object| {
- moli_webapi_declare::implements_interface(scope, object, "SpeechSynthesisVoice")
- });
+ .is_some_and(|object| web_api_interfaces::SpeechSynthesisVoice::is_instance(scope, object));
if !valid {
throw_type_error(
scope,
@@ -794,7 +792,9 @@ fn require_brand<'s>(
receiver: v8::Local<'s, v8::Object>,
slot: &'static str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, slot) {
+ if web_api_interfaces::descriptor(slot)
+ .is_some_and(|interface| interface.is_instance(scope, receiver))
+ {
return true;
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/context_bootstrap/storage_access.rs b/moli-renderer-v8/src/context_bootstrap/storage_access.rs
index 4172dadd2..2fbf17f1c 100644
--- a/moli-renderer-v8/src/context_bootstrap/storage_access.rs
+++ b/moli-renderer-v8/src/context_bootstrap/storage_access.rs
@@ -271,7 +271,7 @@ fn storage_access_handle_get_directory_callback<'s>(
return;
};
rv.set(resolver.get_promise(scope).into());
- if !moli_webapi_declare::implements_interface(scope, args.this(), "StorageAccessHandle") {
+ if !web_api_interfaces::StorageAccessHandle::is_instance(scope, args.this()) {
reject_type_error(scope, resolver, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/stream_adapter/construction.rs b/moli-renderer-v8/src/context_bootstrap/stream_adapter/construction.rs
index fc1be48ec..0914487b5 100644
--- a/moli-renderer-v8/src/context_bootstrap/stream_adapter/construction.rs
+++ b/moli-renderer-v8/src/context_bootstrap/stream_adapter/construction.rs
@@ -97,14 +97,14 @@ struct ReadableStreamObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ReadableStreamStartRejectedDataDeclaration<'scope> {
#[webapi(slot = READABLE_STREAM_START_REJECTED_STREAM_SLOT)]
stream: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ReadableStreamStartFulfilledDataDeclaration<'scope> {
#[webapi(slot = READABLE_STREAM_START_REJECTED_STREAM_SLOT)]
stream: v8::Local<'scope, v8::Object>,
@@ -146,7 +146,7 @@ struct WritableStreamObjectDeclaration<'scope, 'value> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "TransformStream", unbranded)]
+#[webapi(fragment, prototype = "TransformStream")]
struct TransformStreamObjectDeclaration<'scope> {
#[webapi(slot = TRANSFORM_STREAM_READABLE_SLOT)]
readable: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/stream_adapter/pipe_owner.rs b/moli-renderer-v8/src/context_bootstrap/stream_adapter/pipe_owner.rs
index 80f00b2c5..2a3b851f8 100644
--- a/moli-renderer-v8/src/context_bootstrap/stream_adapter/pipe_owner.rs
+++ b/moli-renderer-v8/src/context_bootstrap/stream_adapter/pipe_owner.rs
@@ -30,7 +30,7 @@ const PIPE_OWNER_SHUTDOWN_REASON_SLOT: &str = "__moliPipeOwnerShutdownReason";
const PIPE_OWNER_ABORT_REGISTRATION_SLOT: &str = "__moliPipeOwnerAbortRegistration";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PipeOwnerDeclaration<'scope> {
#[webapi(slot = PIPE_OWNER_SOURCE_SLOT)]
source: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/context_bootstrap/stream_adapter/read_request.rs b/moli-renderer-v8/src/context_bootstrap/stream_adapter/read_request.rs
index 3f0788423..4a339ef7b 100644
--- a/moli-renderer-v8/src/context_bootstrap/stream_adapter/read_request.rs
+++ b/moli-renderer-v8/src/context_bootstrap/stream_adapter/read_request.rs
@@ -16,7 +16,7 @@ const READ_REQUEST_CLOSE_STEPS_SLOT: &str = "__moliStreamReadRequestCloseSteps";
const READ_REQUEST_ERROR_STEPS_SLOT: &str = "__moliStreamReadRequestErrorSteps";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct InternalReadRequestDeclaration<'scope> {
#[webapi(slot = READ_REQUEST_CHUNK_STEPS_SLOT)]
chunk_steps: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/stream_adapter/utils.rs b/moli-renderer-v8/src/context_bootstrap/stream_adapter/utils.rs
index caa516b2e..9d66bd4a8 100644
--- a/moli-renderer-v8/src/context_bootstrap/stream_adapter/utils.rs
+++ b/moli-renderer-v8/src/context_bootstrap/stream_adapter/utils.rs
@@ -5,7 +5,7 @@ const DELAYED_PENDING_READ_REJECT_SLOT: &str = "__moliReadableStreamDelayedRejec
const DELAYED_PENDING_READ_REASON_SLOT: &str = "__moliReadableStreamDelayedReason";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct StreamIteratorResultDeclaration<'scope> {
#[webapi(data_property, enumerable)]
value: v8::Local<'scope, v8::Value>,
@@ -14,7 +14,7 @@ struct StreamIteratorResultDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PendingReadEntryDeclaration {
#[webapi(slot = READABLE_STREAM_PENDING_READ_PROMISE_SLOT, init = "undefined")]
promise: (),
@@ -25,14 +25,14 @@ struct PendingReadEntryDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PendingReadPromiseDeclaration<'scope> {
#[webapi(slot = READABLE_STREAM_PENDING_READ_PROMISE_SLOT)]
promise: v8::Local<'scope, v8::Promise>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PendingReadResolverDeclaration<'scope> {
#[webapi(slot = READABLE_STREAM_PENDING_READ_RESOLVE_SLOT)]
resolve: v8::Local<'scope, v8::Value>,
@@ -41,7 +41,7 @@ struct PendingReadResolverDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DelayedPendingReadRejectDeclaration<'scope> {
#[webapi(slot = DELAYED_PENDING_READ_REJECT_SLOT)]
reject: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/stream_objects/readable_reader.rs b/moli-renderer-v8/src/context_bootstrap/stream_objects/readable_reader.rs
index d5f772d58..d77297d39 100644
--- a/moli-renderer-v8/src/context_bootstrap/stream_objects/readable_reader.rs
+++ b/moli-renderer-v8/src/context_bootstrap/stream_objects/readable_reader.rs
@@ -516,6 +516,6 @@ fn readable_stream_reader_is_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
reader: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, reader, "ReadableStreamDefaultReader")
- || moli_webapi_declare::implements_interface(scope, reader, "ReadableStreamBYOBReader")
+ web_api_interfaces::ReadableStreamDefaultReader::is_instance(scope, reader)
+ || web_api_interfaces::ReadableStreamBYOBReader::is_instance(scope, reader)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/stream_objects/writable_writer.rs b/moli-renderer-v8/src/context_bootstrap/stream_objects/writable_writer.rs
index 35dd094dd..20e0c0eec 100644
--- a/moli-renderer-v8/src/context_bootstrap/stream_objects/writable_writer.rs
+++ b/moli-renderer-v8/src/context_bootstrap/stream_objects/writable_writer.rs
@@ -280,5 +280,5 @@ fn writable_stream_writer_is_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
writer: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, writer, "WritableStreamDefaultWriter")
+ web_api_interfaces::WritableStreamDefaultWriter::is_instance(scope, writer)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/streams.rs b/moli-renderer-v8/src/context_bootstrap/streams.rs
index 2b4106097..db33a5498 100644
--- a/moli-renderer-v8/src/context_bootstrap/streams.rs
+++ b/moli-renderer-v8/src/context_bootstrap/streams.rs
@@ -333,7 +333,7 @@ pub(crate) fn is_writable_stream_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "WritableStream")
+ web_api_interfaces::WritableStream::is_instance(scope, object)
}
pub(super) fn install_stream_template_bindings<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/streams/compression.rs b/moli-renderer-v8/src/context_bootstrap/streams/compression.rs
index 5e592c19d..b8a592c76 100644
--- a/moli-renderer-v8/src/context_bootstrap/streams/compression.rs
+++ b/moli-renderer-v8/src/context_bootstrap/streams/compression.rs
@@ -179,7 +179,9 @@ fn endpoint_getter<'s, const DECOMPRESS: bool, const READABLE: bool>(
} else {
"CompressionStream"
};
- if !moli_webapi_declare::implements_interface(scope, args.this(), interface) {
+ if !web_api_interfaces::descriptor(interface)
+ .is_some_and(|interface| interface.is_instance(scope, args.this()))
+ {
throw_type_error(scope, "Illegal invocation");
return;
}
diff --git a/moli-renderer-v8/src/context_bootstrap/streams/readable.rs b/moli-renderer-v8/src/context_bootstrap/streams/readable.rs
index ce9fc2a1f..b676d6963 100644
--- a/moli-renderer-v8/src/context_bootstrap/streams/readable.rs
+++ b/moli-renderer-v8/src/context_bootstrap/streams/readable.rs
@@ -73,7 +73,7 @@ pub(crate) fn is_readable_stream_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "ReadableStream")
+ web_api_interfaces::ReadableStream::is_instance(scope, object)
}
pub(crate) fn new_readable_stream_from_array_buffer<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs b/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs
index 390e16d6a..10e517ebf 100644
--- a/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs
+++ b/moli-renderer-v8/src/context_bootstrap/svg_runtime/builders.rs
@@ -972,7 +972,7 @@ pub(super) fn svg_transform_value_or_throw<'s>(
) -> Option<v8::Local<'s, v8::Object>> {
let object = v8::Local::<v8::Object>::try_from(value).ok();
if let Some(object) = object
- && moli_webapi_declare::implements_interface(scope, object, "SVGTransform")
+ && web_api_interfaces::SVGTransform::is_instance(scope, object)
{
return Some(object);
}
@@ -1004,7 +1004,7 @@ pub(super) fn svg_matrix_value_or_throw<'s>(
) -> Option<v8::Local<'s, v8::Object>> {
let object = v8::Local::<v8::Object>::try_from(value).ok();
if let Some(object) = object
- && moli_webapi_declare::implements_interface(scope, object, "SVGMatrix")
+ && web_api_interfaces::SVGMatrix::is_instance(scope, object)
{
return Some(object);
}
diff --git a/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs b/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs
index d845e4060..25810e58d 100644
--- a/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs
+++ b/moli-renderer-v8/src/context_bootstrap/svg_runtime/callbacks.rs
@@ -1,6 +1,7 @@
use super::builders::*;
use super::*;
use crate::util::serialize_v8_array;
+use crate::web_api_interfaces;
const SVG_RECT_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["x", "y", "width", "height", "rx", "ry"];
const SVG_CIRCLE_ANIMATED_LENGTH_ATTRIBUTES: &[&str] = &["cx", "cy", "r"];
@@ -35,7 +36,9 @@ fn require_svg_receiver<'s>(
interface: &str,
member: &str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, interface) {
+ if web_api_interfaces::descriptor(interface)
+ .is_some_and(|interface| interface.is_instance(scope, receiver))
+ {
return true;
}
webidl::throw_type_error(
diff --git a/moli-renderer-v8/src/context_bootstrap/touch_runtime.rs b/moli-renderer-v8/src/context_bootstrap/touch_runtime.rs
index b4e4035fc..78588034e 100644
--- a/moli-renderer-v8/src/context_bootstrap/touch_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/touch_runtime.rs
@@ -109,7 +109,7 @@ struct TouchListPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TouchUiEventInitDeclaration<'scope> {
view: v8::Local<'scope, v8::Value>,
detail: f64,
diff --git a/moli-renderer-v8/src/context_bootstrap/trusted_types.rs b/moli-renderer-v8/src/context_bootstrap/trusted_types.rs
index 1786f9a23..23f0e7708 100644
--- a/moli-renderer-v8/src/context_bootstrap/trusted_types.rs
+++ b/moli-renderer-v8/src/context_bootstrap/trusted_types.rs
@@ -42,14 +42,14 @@ struct TrustedTypesFactoryDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct TrustedTypeObjectDeclaration<'scope> {
#[webapi(slot = TRUSTED_TYPE_VALUE_SLOT)]
value: v8::Local<'scope, v8::String>,
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct TrustedTypePrototypeDeclaration {
#[webapi(method = "toString", callback = trusted_type_to_string_callback, length = 0)]
to_string: (),
@@ -572,7 +572,7 @@ fn trusted_type_string<'s>(
kind: TrustedTypeKind,
) -> Option<String> {
let object = v8::Local::<v8::Object>::try_from(value).ok()?;
- if !moli_webapi_declare::implements_interface(scope, object, kind.constructor_name()) {
+ if !kind.interface().is_instance(scope, object) {
return None;
}
let value = get_private_value(scope, object, TRUSTED_TYPE_VALUE_SLOT)?;
diff --git a/moli-renderer-v8/src/context_bootstrap/url_form/helpers.rs b/moli-renderer-v8/src/context_bootstrap/url_form/helpers.rs
index c4cef6919..53ec731ee 100644
--- a/moli-renderer-v8/src/context_bootstrap/url_form/helpers.rs
+++ b/moli-renderer-v8/src/context_bootstrap/url_form/helpers.rs
@@ -1,5 +1,6 @@
use super::*;
use crate::util::{get_private_value, set_private_value};
+use crate::web_api_interfaces;
pub(in crate::context_bootstrap) fn callback_value_string(
scope: &mut v8::PinScope<'_, '_>,
@@ -59,7 +60,7 @@ pub(in crate::context_bootstrap) fn require_url_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, object, "URL") {
+ if web_api_interfaces::URL::is_instance(scope, object) {
return Some(object);
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/iterators.rs b/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/iterators.rs
index 3eec31af7..72840cdf3 100644
--- a/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/iterators.rs
+++ b/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/iterators.rs
@@ -43,7 +43,7 @@ struct UrlSearchParamsIteratorPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct UrlSearchParamsIteratorResultDeclaration<'scope> {
#[webapi(data_property, enumerable)]
done: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/storage.rs b/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/storage.rs
index 0621d4385..fc905ec6a 100644
--- a/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/storage.rs
+++ b/moli-renderer-v8/src/context_bootstrap/url_search_params_runtime/storage.rs
@@ -103,7 +103,7 @@ pub(super) fn url_search_params_is_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "URLSearchParams")
+ web_api_interfaces::URLSearchParams::is_instance(scope, object)
}
pub(crate) fn url_search_params_request_body<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/lifecycle.rs b/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/lifecycle.rs
index 96be92323..f497d719b 100644
--- a/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/lifecycle.rs
+++ b/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/lifecycle.rs
@@ -243,7 +243,7 @@ fn require_view_transition_receiver<'s>(
receiver: v8::Local<'s, v8::Object>,
member: &str,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, receiver, "ViewTransition") {
+ if web_api_interfaces::ViewTransition::is_instance(scope, receiver) {
return true;
}
throw_type_error(
diff --git a/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/type_set.rs b/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/type_set.rs
index 24225e3eb..63956a09d 100644
--- a/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/type_set.rs
+++ b/moli-renderer-v8/src/context_bootstrap/view_transition_runtime/type_set.rs
@@ -42,8 +42,7 @@ fn require_view_transition_type_set_receiver<'s>(
receiver: v8::Local<'s, v8::Object>,
member: &str,
) -> Option<v8::Local<'s, v8::Set>> {
- let branded =
- moli_webapi_declare::implements_interface(scope, receiver, "ViewTransitionTypeSet");
+ let branded = web_api_interfaces::ViewTransitionTypeSet::is_instance(scope, receiver);
let backing = get_private_value(scope, receiver, VIEW_TRANSITION_TYPE_SET_BACKING_SLOT)
.and_then(|value| v8::Local::<v8::Set>::try_from(value).ok());
if branded && backing.is_some() {
diff --git a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs
index 8107a3543..eab98bd85 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_audio_runtime.rs
@@ -82,7 +82,7 @@ struct AudioWorkletNodeObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AudioWorkletModuleStateDeclaration<'scope> {
#[webapi(slot = AUDIO_WORKLET_MODULE_CONTEXT_SLOT)]
context: v8::Local<'scope, v8::Object>,
@@ -99,21 +99,21 @@ struct AudioWorkletModuleStateDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AudioWorkletWorkerCallbackDataDeclaration<'scope> {
#[webapi(slot = AUDIO_WORKLET_CALLBACK_MODULE_SLOT)]
module_state: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct AudioWorkletBlobOptionsDeclaration {
#[webapi(data_property = "type")]
kind: &'static str,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct AudioWorkletWorkerOptionsDeclaration {
#[webapi(data_property = "type")]
kind: &'static str,
@@ -121,7 +121,7 @@ struct AudioWorkletWorkerOptionsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct AudioWorkletProcessorConstructMessageDeclaration<'scope> {
#[webapi(data_property = "__moliAudioWorkletType")]
message_type: &'static str,
@@ -245,7 +245,7 @@ struct AnalyserNodePrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct OfflineAudioCompletePayloadDeclaration<'scope> {
#[webapi(slot = OFFLINE_AUDIO_COMPLETE_CONTEXT_SLOT)]
context: v8::Local<'scope, v8::Object>,
@@ -265,7 +265,7 @@ struct OfflineAudioCompletionEventDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = web_api_interfaces::AudioDestinationNode, allow_empty)]
+#[webapi(interface = web_api_interfaces::AudioDestinationNode)]
struct AudioDestinationNodeObjectDeclaration {}
#[derive(WebApiObject)]
@@ -552,7 +552,7 @@ pub(in crate::context_bootstrap) fn is_audio_context_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "AudioContext")
+ web_api_interfaces::AudioContext::is_instance(scope, object)
}
fn audio_context_close_callback<'s>(
@@ -1313,7 +1313,7 @@ fn require_base_audio_context<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- if moli_webapi_declare::implements_interface(scope, object, "BaseAudioContext") {
+ if web_api_interfaces::BaseAudioContext::is_instance(scope, object) {
return true;
}
throw_type_error(scope, "Illegal invocation: expected a BaseAudioContext.");
diff --git a/moli-renderer-v8/src/context_bootstrap/web_storage/helpers.rs b/moli-renderer-v8/src/context_bootstrap/web_storage/helpers.rs
index fa234e596..9d6f24c76 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_storage/helpers.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_storage/helpers.rs
@@ -15,7 +15,7 @@ pub(super) const STORAGE_OWNER_INTERNAL_FIELD_INDEX: usize = 1;
pub(super) const STORAGE_OWNER_CHILD_HANDLE_SLOT: &str = "__moliStorageOwnerChildHandle";
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", allow_empty)]
+#[webapi(record)]
struct StoragePrototypeIndexDescriptorStoreDeclaration {}
const STORAGE_INTERNAL_NAME_UNITS: &[u16] = &[
diff --git a/moli-renderer-v8/src/context_bootstrap/web_storage/install.rs b/moli-renderer-v8/src/context_bootstrap/web_storage/install.rs
index e257361d5..cf73d5b2e 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_storage/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_storage/install.rs
@@ -21,7 +21,7 @@ use crate::web_api_interfaces;
use moli_webapi_declare::{WebApiFunctionTemplate, WebApiObject};
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct StoragePrototypeMethodsDeclaration {
#[webapi(method, length = 1, callback = storage_get_item_callback)]
get_item: (),
@@ -38,14 +38,14 @@ struct StoragePrototypeMethodsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Storage")]
+#[webapi(fragment, prototype = "Storage")]
struct StoragePrototypeMetadataDeclaration {
#[webapi(to_string_tag, init = string("Storage"))]
to_string_tag: (),
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct StorageAliasesDeclaration<'scope> {
#[webapi(data_property = "localStorage")]
local_storage: v8::Local<'scope, v8::Object>,
@@ -54,7 +54,7 @@ struct StorageAliasesDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct StorageConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "Storage")]
constructor: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/context_bootstrap/web_storage/interceptors.rs b/moli-renderer-v8/src/context_bootstrap/web_storage/interceptors.rs
index 27cb9b296..cfd806cdf 100644
--- a/moli-renderer-v8/src/context_bootstrap/web_storage/interceptors.rs
+++ b/moli-renderer-v8/src/context_bootstrap/web_storage/interceptors.rs
@@ -9,7 +9,7 @@ use crate::util::{throw_type_error, v8_string_from_utf16_units, v8_string_to_u16
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct StorageValuePropertyDescriptorDeclaration<'scope> {
value: v8::Local<'scope, v8::Value>,
writable: bool,
@@ -18,7 +18,7 @@ struct StorageValuePropertyDescriptorDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct StorageAccessorPropertyDescriptorDeclaration<'scope> {
get: Option<v8::Local<'scope, v8::Value>>,
set: Option<v8::Local<'scope, v8::Value>>,
diff --git a/moli-renderer-v8/src/context_bootstrap/webassembly_runtime.rs b/moli-renderer-v8/src/context_bootstrap/webassembly_runtime.rs
index 58cf2867d..cc32b62f2 100644
--- a/moli-renderer-v8/src/context_bootstrap/webassembly_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/webassembly_runtime.rs
@@ -55,7 +55,7 @@ const WEBASSEMBLY_DEFAULT_PROTOTYPE_NAMES: &[&str] = &[
];
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyStreamingDataDeclaration<'scope> {
#[webapi(slot = STREAMING_OPTIONS_SLOT)]
options: v8::Local<'scope, v8::Value>,
@@ -64,7 +64,7 @@ struct WebAssemblyStreamingDataDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyInstantiateStreamingResultDeclaration<'scope> {
#[webapi(data_property, enumerable)]
module: v8::Local<'scope, v8::Object>,
@@ -73,7 +73,7 @@ struct WebAssemblyInstantiateStreamingResultDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyMemoryNativeDescriptorDeclaration<'scope> {
#[webapi(data_property, enumerable)]
initial: v8::Local<'scope, v8::Value>,
@@ -84,7 +84,7 @@ struct WebAssemblyMemoryNativeDescriptorDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyMemoryTypeDeclaration<'scope> {
#[webapi(data_property, enumerable)]
minimum: v8::Local<'scope, v8::Value>,
@@ -95,7 +95,7 @@ struct WebAssemblyMemoryTypeDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyMemoryTypeCloneDeclaration<'scope> {
#[webapi(data_property, enumerable)]
minimum: v8::Local<'scope, v8::Value>,
@@ -106,7 +106,7 @@ struct WebAssemblyMemoryTypeCloneDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyTableNativeDescriptorDeclaration<'scope> {
#[webapi(data_property, enumerable)]
element: v8::Local<'scope, v8::Value>,
@@ -117,7 +117,7 @@ struct WebAssemblyTableNativeDescriptorDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyTableTypeDeclaration<'scope> {
#[webapi(data_property, enumerable)]
minimum: v8::Local<'scope, v8::Value>,
@@ -128,7 +128,7 @@ struct WebAssemblyTableTypeDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyTableTypeCloneDeclaration<'scope> {
#[webapi(data_property, enumerable)]
minimum: v8::Local<'scope, v8::Value>,
@@ -139,7 +139,7 @@ struct WebAssemblyTableTypeCloneDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyGlobalNativeDescriptorDeclaration<'scope> {
#[webapi(data_property, enumerable)]
mutable: v8::Local<'scope, v8::Value>,
@@ -148,7 +148,7 @@ struct WebAssemblyGlobalNativeDescriptorDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyGlobalTypeDeclaration<'scope> {
#[webapi(data_property, enumerable)]
mutable: bool,
@@ -157,7 +157,7 @@ struct WebAssemblyGlobalTypeDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyGlobalTypeCloneDeclaration<'scope> {
#[webapi(data_property, enumerable)]
r#mutable: v8::Local<'scope, v8::Value>,
@@ -166,21 +166,21 @@ struct WebAssemblyGlobalTypeCloneDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyTagTypeDeclaration<'scope> {
#[webapi(data_property, enumerable)]
parameters: v8::Local<'scope, v8::Array>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyMemoryFallbackTypeDeclaration {
#[webapi(data_property, enumerable)]
minimum: f64,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyTableFallbackTypeDeclaration<'scope> {
#[webapi(data_property, enumerable)]
minimum: f64,
@@ -189,7 +189,7 @@ struct WebAssemblyTableFallbackTypeDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebAssemblyTagTypeCloneDeclaration<'scope> {
#[webapi(data_property, enumerable)]
parameters: Option<v8::Local<'scope, v8::Array>>,
diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc.rs b/moli-renderer-v8/src/context_bootstrap/webrtc.rs
index 660b48e68..d4a22e169 100644
--- a/moli-renderer-v8/src/context_bootstrap/webrtc.rs
+++ b/moli-renderer-v8/src/context_bootstrap/webrtc.rs
@@ -121,7 +121,7 @@ struct RtcDataChannelObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct RtcSessionDescriptionInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
r#type: v8::Local<'scope, v8::String>,
@@ -584,14 +584,14 @@ fn rtc_peer_connection_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "RTCPeerConnection")
+ web_api_interfaces::RTCPeerConnection::is_instance(scope, receiver)
}
fn rtc_data_channel_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "RTCDataChannel")
+ web_api_interfaces::RTCDataChannel::is_instance(scope, receiver)
}
fn build_signaling_only_offer(audio: bool, video: bool, data: bool) -> String {
diff --git a/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs b/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs
index 62f99226a..645e62a52 100644
--- a/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs
+++ b/moli-renderer-v8/src/context_bootstrap/webrtc/ice_candidate.rs
@@ -58,7 +58,7 @@ struct IceCandidatePrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct IceCandidateJsonDeclaration<'scope> {
candidate: v8::Local<'scope, v8::Value>,
sdp_mid: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs b/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs
index 044c5fce7..1e9657ab3 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/constructor.rs
@@ -95,14 +95,14 @@ struct WebSocketStreamRegisteredSocketDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamAbortListenerDataDeclaration<'scope> {
#[webapi(slot = WEBSOCKET_STREAM_ABORT_LISTENER_STREAM_SLOT)]
stream: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamAbortListenerOptionsDeclaration {
#[webapi(data_property, enumerable)]
once: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/events.rs b/moli-renderer-v8/src/context_bootstrap/websocket/events.rs
index 0cd5b722d..fc63fc50e 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/events.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/events.rs
@@ -10,7 +10,7 @@ struct WebSocketSimpleEventFallbackDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
@@ -19,7 +19,7 @@ struct WebSocketMessageEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WebSocketCloseEventInitDeclaration<'scope> {
code: u16,
reason: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/context_bootstrap/websocket/stream.rs b/moli-renderer-v8/src/context_bootstrap/websocket/stream.rs
index 07638a82a..98e975ff8 100644
--- a/moli-renderer-v8/src/context_bootstrap/websocket/stream.rs
+++ b/moli-renderer-v8/src/context_bootstrap/websocket/stream.rs
@@ -11,10 +11,11 @@ use crate::context_bootstrap::stream_adapter::{
new_lazy_readable_stream_object, new_writable_stream_object, readable_stream_queue_total_size,
};
use crate::util::{get_private_value, set_private_value};
+use crate::web_api_interfaces;
use moli_webapi_declare::WebApiObject;
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamPromiseResolverRecordDeclaration {
#[webapi(slot = WEBSOCKET_STREAM_PROMISE_RESOLVE_SLOT, init = "undefined")]
resolve: (),
@@ -23,7 +24,7 @@ struct WebSocketStreamPromiseResolverRecordDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamOpenInfoDeclaration<'scope> {
#[webapi(data_property, enumerable)]
readable: v8::Local<'scope, v8::Object>,
@@ -36,7 +37,7 @@ struct WebSocketStreamOpenInfoDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamWritableSinkDeclaration<'scope> {
#[webapi(slot = WEBSOCKET_ID_SLOT)]
socket_id: f64,
@@ -55,7 +56,7 @@ struct WebSocketStreamWritableSinkDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamReadableSourceDeclaration {
#[webapi(slot = WEBSOCKET_ID_SLOT)]
socket_id: f64,
@@ -66,7 +67,7 @@ struct WebSocketStreamReadableSourceDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WebSocketStreamPendingWriteDeclaration<'scope> {
#[webapi(slot = WEBSOCKET_STREAM_PROMISE_SLOT)]
promise: v8::Local<'scope, v8::Promise>,
@@ -77,7 +78,7 @@ struct WebSocketStreamPendingWriteDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WebSocketStreamCloseInfoDeclaration<'scope> {
close_code: f64,
reason: Option<v8::Local<'scope, v8::String>>,
@@ -651,7 +652,7 @@ pub(super) fn is_websocket_stream_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "WebSocketStream")
+ web_api_interfaces::WebSocketStream::is_instance(scope, object)
}
fn call_websocket_stream_function_slot<'s>(
diff --git a/moli-renderer-v8/src/context_bootstrap/window_events/error.rs b/moli-renderer-v8/src/context_bootstrap/window_events/error.rs
index ea05f9c5d..bf766e04e 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_events/error.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_events/error.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ErrorEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
cancelable: bool,
@@ -21,7 +21,7 @@ struct ErrorEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ErrorEventDetailsDeclaration<'scope> {
message: v8::Local<'scope, v8::Value>,
filename: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/window_events/install.rs b/moli-renderer-v8/src/context_bootstrap/window_events/install.rs
index 08a3a0c64..f44a58d8d 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_events/install.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_events/install.rs
@@ -11,7 +11,7 @@ use crate::util::v8str;
use moli_webapi_declare::WebApiObject;
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Window")]
+#[webapi(fragment, prototype = "Window")]
struct WindowGlobalEventHandlerAccessorsDeclaration {
#[webapi(
accessor_property,
diff --git a/moli-renderer-v8/src/context_bootstrap/window_events/promise.rs b/moli-renderer-v8/src/context_bootstrap/window_events/promise.rs
index 19e12fa40..b42504890 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_events/promise.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_events/promise.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PromiseRejectionEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
cancelable: bool,
diff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime.rs
index d934ebdee..ba582def2 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_runtime.rs
@@ -70,7 +70,7 @@ pub(super) use service_worker::{
pub(super) use structured_clone::window_structured_clone_callback;
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ChildWindowOwnMethodsDeclaration {
#[webapi(method, length = 0, callback = window_open_callback)]
open: (),
diff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs
index 43e2423bd..8f7afd6b5 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_runtime/navigator.rs
@@ -157,7 +157,7 @@ struct MidiPermissionDescriptorMembers {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigatorUaBrandEntryDeclaration {
#[webapi(data_property, enumerable)]
brand: String,
@@ -183,7 +183,7 @@ struct NavigatorUaDataObjectDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigatorUaDataSnapshotDeclaration {
#[webapi(data_property, enumerable)]
brands: Vec<NavigatorUaBrandEntryDeclaration>,
@@ -196,7 +196,7 @@ struct NavigatorUaDataSnapshotDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NavigatorUaDataHighEntropySnapshotDeclaration {
#[webapi(data_property, enumerable)]
architecture: Option<String>,
@@ -233,7 +233,7 @@ struct NavigatorUaDataHighEntropySnapshotDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "StorageEstimate")]
+#[webapi(fragment, prototype = "StorageEstimate")]
struct StorageEstimateObjectDeclaration<'scope> {
#[webapi(data_property, enumerable)]
quota: f64,
@@ -246,7 +246,7 @@ struct StorageEstimateObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct StorageUsageDetailsObjectDeclaration {
#[webapi(data_property = "indexedDB", enumerable)]
indexed_db: Option<f64>,
@@ -291,7 +291,7 @@ struct NavigatorBatteryStatusObjectDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(allow_empty, interface = web_api_interfaces::StorageBucket)]
+#[webapi(interface = web_api_interfaces::StorageBucket)]
struct StorageBucketObjectDeclaration {}
#[derive(Debug)]
@@ -323,7 +323,7 @@ struct CacheQueryOptions {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct StorageBucketCachePutPendingDataDeclaration<'scope> {
#[webapi(slot = STORAGE_BUCKET_CACHE_PUT_RESOLVER_SLOT)]
resolver: v8::Local<'scope, v8::PromiseResolver>,
@@ -552,7 +552,7 @@ fn battery_status_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "BatteryManager")
+ web_api_interfaces::BatteryManager::is_instance(scope, receiver)
}
pub(in crate::context_bootstrap) fn navigator_permissions_query_callback<'s>(
@@ -614,7 +614,7 @@ fn permissions_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "Permissions")
+ web_api_interfaces::Permissions::is_instance(scope, receiver)
}
fn build_permission_status_object<'s>(
@@ -2420,7 +2420,7 @@ fn storage_bucket_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "StorageBucket")
+ web_api_interfaces::StorageBucket::is_instance(scope, receiver)
}
fn build_storage_bucket_object<'s>(
@@ -2565,7 +2565,9 @@ fn branded_promise_resolver<'s>(
) -> Option<v8::Local<'s, v8::PromiseResolver>> {
let resolver = v8::PromiseResolver::new(scope)?;
rv.set(resolver.get_promise(scope).into());
- if !moli_webapi_declare::implements_interface(scope, args.this(), interface) {
+ if !web_api_interfaces::descriptor(interface)
+ .is_some_and(|interface| interface.is_instance(scope, args.this()))
+ {
reject_illegal_invocation(scope, resolver, interface, method);
return None;
}
@@ -3378,7 +3380,7 @@ fn navigator_ua_data_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "NavigatorUAData")
+ web_api_interfaces::NavigatorUAData::is_instance(scope, receiver)
}
pub(in crate::context_bootstrap) fn build_navigator_ua_data_object<'s>(
@@ -3525,5 +3527,5 @@ fn media_devices_receiver_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, receiver, "MediaDevices")
+ web_api_interfaces::MediaDevices::is_instance(scope, receiver)
}
diff --git a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
index 94f7de057..f5d93bcea 100644
--- a/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
+++ b/moli-renderer-v8/src/context_bootstrap/window_runtime/service_worker.rs
@@ -107,7 +107,7 @@ struct ServiceWorkerRegistrationObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerNavigationPreloadStateDeclaration {
#[webapi(data_property, enumerable)]
enabled: bool,
@@ -284,7 +284,7 @@ struct ServiceWorkerObjectDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs b/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs
index 02cedc30f..79a8620ea 100644
--- a/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs
+++ b/moli-renderer-v8/src/context_bootstrap/worker_host/dispatch.rs
@@ -15,7 +15,7 @@ use crate::util::v8str;
use crate::worker::{WorkerParentErrorEventKind, WorkerToParentMessage};
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerHostEventInitDeclaration {
#[webapi(data_property, enumerable)]
cancelable: bool,
@@ -31,7 +31,7 @@ struct WorkerHostEventFallbackDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerHostMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
@@ -51,7 +51,7 @@ struct WorkerHostMessageEventFallbackDeclaration<'scope, 'event> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerHostErrorEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
message: v8::Local<'scope, v8::String>,
@@ -85,7 +85,7 @@ struct WorkerHostErrorEventFallbackDeclaration<'scope, 'text> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope, data_properties, enumerable)]
+#[webapi(record, scope_lifetime = 'scope, data_properties, enumerable)]
struct WorkerHostErrorEventDetailsDeclaration<'scope, 'text> {
message: &'text str,
filename: &'text str,
diff --git a/moli-renderer-v8/src/context_bootstrap/worker_location_runtime.rs b/moli-renderer-v8/src/context_bootstrap/worker_location_runtime.rs
index b3c2a1258..6a8390d1d 100644
--- a/moli-renderer-v8/src/context_bootstrap/worker_location_runtime.rs
+++ b/moli-renderer-v8/src/context_bootstrap/worker_location_runtime.rs
@@ -17,14 +17,14 @@ struct WorkerLocationObjectDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerLocationGlobalDeclaration<'scope> {
#[webapi(data_property = "location")]
location: v8::Local<'scope, v8::Object>,
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "WorkerLocation", enumerable)]
+#[webapi(fragment, prototype = "WorkerLocation", enumerable)]
struct WorkerLocationPrototypeDeclaration {
#[webapi(
accessor_property,
@@ -94,7 +94,7 @@ struct WorkerLocationPrototypeDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerLocationBackingDeclaration {
#[webapi(data_property, enumerable)]
href: String,
diff --git a/moli-renderer-v8/src/custom_elements/registry_runtime.rs b/moli-renderer-v8/src/custom_elements/registry_runtime.rs
index 4667f2f54..087ce8e65 100644
--- a/moli-renderer-v8/src/custom_elements/registry_runtime.rs
+++ b/moli-renderer-v8/src/custom_elements/registry_runtime.rs
@@ -1,4 +1,5 @@
use super::{CustomElementRegistryAssociation, CustomElementRegistryKey};
+use crate::web_api_interfaces;
use crate::{
document_runtime::DomHandle,
native_bridge::JsContextHost,
@@ -49,7 +50,7 @@ pub(crate) fn registry_association_from_value<'s>(
return Some(CustomElementRegistryAssociation::Null);
}
let registry = v8::Local::<v8::Object>::try_from(value).ok()?;
- if !moli_webapi_declare::implements_interface(scope, registry, "CustomElementRegistry") {
+ if !web_api_interfaces::CustomElementRegistry::is_instance(scope, registry) {
return None;
}
Some(CustomElementRegistryAssociation::Registry(
diff --git a/moli-renderer-v8/src/detached_event_target.rs b/moli-renderer-v8/src/detached_event_target.rs
index 8682fe3ce..b50b7066c 100644
--- a/moli-renderer-v8/src/detached_event_target.rs
+++ b/moli-renderer-v8/src/detached_event_target.rs
@@ -2,7 +2,7 @@ use super::util::{call_script_visible_function, v8_string, v8str};
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DetachedFocusEventInitDeclaration<'scope> {
bubbles: bool,
#[webapi(constructor_default = false)]
@@ -13,7 +13,7 @@ struct DetachedFocusEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DetachedSimpleEventInitDeclaration {
bubbles: bool,
cancelable: bool,
diff --git a/moli-renderer-v8/src/host/events.rs b/moli-renderer-v8/src/host/events.rs
index 7130c31f5..cca6d1d44 100644
--- a/moli-renderer-v8/src/host/events.rs
+++ b/moli-renderer-v8/src/host/events.rs
@@ -11,7 +11,7 @@ use moli_webapi_declare::WebApiObject;
use std::collections::HashSet;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct HostErrorEventInitDeclaration<'scope> {
cancelable: bool,
bubbles: bool,
@@ -23,7 +23,7 @@ struct HostErrorEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct HostEventInitDeclaration {
bubbles: bool,
cancelable: bool,
diff --git a/moli-renderer-v8/src/host/timers.rs b/moli-renderer-v8/src/host/timers.rs
index 18bf88510..ba5fede91 100644
--- a/moli-renderer-v8/src/host/timers.rs
+++ b/moli-renderer-v8/src/host/timers.rs
@@ -25,7 +25,7 @@ use moli_time::{TimerId, TimerReadyAllowance, TimerScheduler};
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TimerErrorEventInitDeclaration<'scope> {
cancelable: bool,
bubbles: bool,
diff --git a/moli-renderer-v8/src/host_bindings.rs b/moli-renderer-v8/src/host_bindings.rs
index 20f2b34b1..0fb4f6a54 100644
--- a/moli-renderer-v8/src/host_bindings.rs
+++ b/moli-renderer-v8/src/host_bindings.rs
@@ -15,7 +15,7 @@ use super::{
use crate::{context_bootstrap::CHILD_BROWSING_CONTEXT_HANDLE_SLOT, util::get_private_value};
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct HostBindingsDeclaration<'scope> {
external: v8::Local<'scope, v8::External>,
@@ -612,7 +612,7 @@ fn host_selector_debug_stats_callback(
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct SelectorDebugStatsDeclaration {
query_selector: u32,
query_selector_all: u32,
diff --git a/moli-renderer-v8/src/module_runtime/host_callbacks.rs b/moli-renderer-v8/src/module_runtime/host_callbacks.rs
index 92316e827..5e0303a06 100644
--- a/moli-renderer-v8/src/module_runtime/host_callbacks.rs
+++ b/moli-renderer-v8/src/module_runtime/host_callbacks.rs
@@ -14,7 +14,7 @@ use crate::{
};
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ImportMetaDeclaration<'scope> {
#[webapi(data_property, enumerable)]
url: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/native_bridge/bindings.rs b/moli-renderer-v8/src/native_bridge/bindings.rs
index 7229499f2..17a21a4d9 100644
--- a/moli-renderer-v8/src/native_bridge/bindings.rs
+++ b/moli-renderer-v8/src/native_bridge/bindings.rs
@@ -18,7 +18,7 @@ use native_template::build_native_bridge_template;
use node_template::build_node_wrapper_template;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NativeBridgeGlobalDeclaration<'scope> {
#[webapi(data_property = "__moliNativeBridge")]
bridge: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/native_bridge/child_window_surface/webassembly_realm.rs b/moli-renderer-v8/src/native_bridge/child_window_surface/webassembly_realm.rs
index 2d1a87faa..1524c1b1c 100644
--- a/moli-renderer-v8/src/native_bridge/child_window_surface/webassembly_realm.rs
+++ b/moli-renderer-v8/src/native_bridge/child_window_surface/webassembly_realm.rs
@@ -5,14 +5,14 @@ use crate::{
use moli_webapi_declare::{ObjectLiteralDeclaration, WebApiObject};
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ChildWindowWebAssemblyConstructorDataDeclaration<'scope> {
name: v8::Local<'scope, v8::String>,
native_constructor: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ChildWindowInstancePrototypeDeclaration<'scope> {
#[webapi(data_property)]
constructor: v8::Local<'scope, v8::Function>,
diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs b/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs
index 15110dc04..99b8dffb9 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/document.rs
@@ -15,7 +15,7 @@ use url::Url;
pub(crate) const CHILD_DOCUMENT_CONTEXT_HANDLE_SLOT: &str = "__lmChildDocumentContextHandle";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ChildDocumentStreamMethodsDeclaration<'scope> {
handle: v8::Local<'scope, v8::Value>,
#[webapi(method, callback = child_document_open_callback, data = self.handle)]
diff --git a/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/window.rs b/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/window.rs
index ae65c7dce..6e84c21d5 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/window.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/child_frame_runtime/window.rs
@@ -686,7 +686,7 @@ struct CrossOriginLocationReplaceArgs {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossOriginWindowMethodsDeclaration {
#[webapi(
method,
@@ -705,7 +705,7 @@ struct CrossOriginWindowMethodsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CrossOriginPropertyDescriptorDeclaration<'scope> {
value: v8::Local<'scope, v8::Value>,
writable: bool,
@@ -714,7 +714,7 @@ struct CrossOriginPropertyDescriptorDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossOriginLocationMethodsDeclaration {
#[webapi(
method,
@@ -727,7 +727,7 @@ struct CrossOriginLocationMethodsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossOriginLocationProxyHandlerDeclaration {
#[webapi(method, length = 3, callback = cross_origin_location_proxy_get_callback)]
get: (),
@@ -740,7 +740,7 @@ struct CrossOriginLocationProxyHandlerDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossOriginWindowProxyHandlerDeclaration {
#[webapi(method, length = 2, callback = cross_origin_window_proxy_has_callback)]
has: (),
@@ -751,7 +751,7 @@ struct CrossOriginWindowProxyHandlerDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossOriginWindowLiveAccessorsDeclaration {
#[webapi(
accessor_property,
@@ -770,7 +770,7 @@ struct CrossOriginWindowLiveAccessorsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct CrossOriginWindowLocationAccessorDeclaration {
#[webapi(
accessor_property,
diff --git a/moli-renderer-v8/src/native_bridge/context_host/popups.rs b/moli-renderer-v8/src/native_bridge/context_host/popups.rs
index 503a85707..0d93e4fe0 100644
--- a/moli-renderer-v8/src/native_bridge/context_host/popups.rs
+++ b/moli-renderer-v8/src/native_bridge/context_host/popups.rs
@@ -113,7 +113,7 @@ pub(crate) enum PopupClassicScriptLoadApplication {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct LightweightPopupDocumentStreamMethodsDeclaration<'scope> {
popup_id: v8::Local<'scope, v8::BigInt>,
#[webapi(
@@ -156,14 +156,14 @@ struct LightweightPopupPopStateEventDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct LightweightPopupWindowMethodsDeclaration {
#[webapi(method, length = 0, callback = lightweight_popup_close_callback)]
close: (),
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct LightweightPopupComputedStyleMethodDeclaration<'scope> {
document: v8::Local<'scope, v8::BigInt>,
#[webapi(
diff --git a/moli-renderer-v8/src/native_bridge/document/attributes/attr_object/instance/builder.rs b/moli-renderer-v8/src/native_bridge/document/attributes/attr_object/instance/builder.rs
index 5ea2fcabc..8972aeaa3 100644
--- a/moli-renderer-v8/src/native_bridge/document/attributes/attr_object/instance/builder.rs
+++ b/moli-renderer-v8/src/native_bridge/document/attributes/attr_object/instance/builder.rs
@@ -5,7 +5,7 @@ use crate::web_api_interfaces;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct AttrStateDeclaration<'scope> {
name: v8::Local<'scope, v8::String>,
value: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/native_bridge/document/css_state/accessors.rs b/moli-renderer-v8/src/native_bridge/document/css_state/accessors.rs
index d9f992d6e..6a12c65b8 100644
--- a/moli-renderer-v8/src/native_bridge/document/css_state/accessors.rs
+++ b/moli-renderer-v8/src/native_bridge/document/css_state/accessors.rs
@@ -48,7 +48,7 @@ const ADOPTED_STYLE_SHEETS_ARRAY_OWNER_DOCUMENT: i32 = 1;
const ADOPTED_STYLE_SHEETS_ARRAY_OWNER_SHADOW_ROOT: i32 = 2;
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AdoptedStyleSheetsArrayMutationMethodsDeclaration {
#[webapi(
method,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_style.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_style.rs
index 011eaeaaf..e3f3e5238 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_style.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_style.rs
@@ -16,7 +16,7 @@ use super::super::super::detached_native_handle_for_runtime;
use super::iframe_style_viewport::detached_iframe_viewport_width;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DetachedIframeWindowComputedStyleMethodDeclaration<'scope> {
iframe: v8::Local<'scope, v8::Object>,
#[webapi(
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_message_event.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_message_event.rs
index c8e136a73..6d6531328 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_message_event.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_message_event.rs
@@ -3,7 +3,7 @@ use moli_webapi_declare::WebApiObject;
use url::Url;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DetachedWindowMessageEventInitDeclaration<'scope> {
data: v8::Local<'scope, v8::Value>,
source: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs
index d128ddc0e..e8b924aed 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/accessors/iframe_window_messaging.rs
@@ -12,7 +12,7 @@ use super::iframe_window_message_event::{detached_window_message_event, detached
const DETACHED_IFRAME_WINDOW_EVENT_LISTENERS_SLOT: &str = "__lmDetachedIframeWindowEventListeners";
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DetachedIframeWindowMethodsDeclaration {
#[webapi(method, length = 1, callback = detached_iframe_window_post_message)]
post_message: (),
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods.rs
index 31e4fb9b3..185ac2edd 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods.rs
@@ -13,7 +13,7 @@ use live_attribute_bridge::install_live_attribute_bridge_methods;
use node::{install_detached_node_methods, install_detached_parent_node_move_before};
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "ParentNode")]
+#[webapi(fragment, prototype = "ParentNode")]
struct DocumentFragmentParentNodeQueryMethodsDeclaration {
#[webapi(method, callback = node_query_selector_callback)]
query_selector: (),
@@ -23,7 +23,7 @@ struct DocumentFragmentParentNodeQueryMethodsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "DocumentFragment")]
+#[webapi(fragment, prototype = "DocumentFragment")]
struct DocumentFragmentGetElementByIdDeclaration {
#[webapi(method, length = 1, callback = document_fragment_get_element_by_id_callback)]
get_element_by_id: (),
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/document.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/document.rs
index 63fb489e6..3171df888 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/document.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/document.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "Document")]
+#[webapi(fragment, prototype = "Document")]
struct DetachedDocumentStateAccessorsDeclaration {
#[webapi(
accessor_property,
@@ -15,7 +15,7 @@ struct DetachedDocumentStateAccessorsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "HTMLDocument")]
+#[webapi(fragment, prototype = "HTMLDocument")]
struct DetachedHtmlDocumentCreationMethodsDeclaration {
#[webapi(method, callback = detached_create_html_element_method_callback)]
create_element: (),
@@ -37,7 +37,7 @@ struct DetachedHtmlDocumentCreationMethodsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "XMLDocument")]
+#[webapi(fragment, prototype = "XMLDocument")]
struct DetachedXmlDocumentCreationMethodsDeclaration {
#[webapi(method, callback = detached_create_xml_element_method_callback)]
create_element: (),
@@ -56,7 +56,7 @@ struct DetachedXmlDocumentCreationMethodsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "Document")]
+#[webapi(fragment, prototype = "Document")]
struct DetachedDocumentCommonMethodsDeclaration {
#[webapi(method, callback = detached_create_attribute_method_callback)]
create_attribute: (),
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/live_attribute_bridge.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/live_attribute_bridge.rs
index 236a73cda..344c63dcc 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/live_attribute_bridge.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/live_attribute_bridge.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct LiveAttributeBridgeMethodsDeclaration {
#[webapi(
method = "__setAttributeNodeForLiveElement",
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/node.rs b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/node.rs
index 1486f4b5d..a1ed72ea4 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/node.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_install/bridge_methods/node.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "Node")]
+#[webapi(fragment, prototype = "Node")]
struct DetachedNodeMethodsDeclaration {
#[webapi(method, callback = detached_append_child_method_callback)]
append_child: (),
@@ -73,7 +73,7 @@ pub(super) fn install_detached_parent_node_move_before<'s>(
prototype: v8::Local<'s, v8::Object>,
) {
#[derive(Default, WebApiObject)]
- #[webapi(unbranded, interface = "ParentNode")]
+ #[webapi(fragment, prototype = "ParentNode")]
struct DetachedParentNodeMoveBeforeDeclaration {
#[webapi(method, length = 2, callback = detached_move_before_method_callback)]
move_before: (),
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/attributes.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/attributes.rs
index a65f60c31..f17abaca5 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/attributes.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/attributes.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DetachedNamespaceAttributeRecordDeclaration<'scope> {
name: v8::Local<'scope, v8::String>,
value: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/documents.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/documents.rs
index aa4d08720..6a69b9ef5 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/documents.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/documents.rs
@@ -6,7 +6,7 @@ use moli_webapi_declare::WebApiObject;
use url::Url;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record, scope_lifetime = 'scope)]
struct DetachedDocumentObjectDeclaration<'scope, 'tag> {
#[webapi(prototype)]
prototype: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/elements.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/elements.rs
index b4719c58d..771e66d85 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/elements.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/builders/elements.rs
@@ -23,7 +23,7 @@ use moli_webapi_declare::WebApiObject;
const DETACHED_ELEMENT_BRIDGE_PROTOTYPE_SLOT: &str = "__moliDetachedElementBridgePrototype";
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct GenericHtmlElementProxyHandlerDeclaration {
#[webapi(method, length = 3, callback = generic_html_element_proxy_get_callback)]
get: (),
@@ -34,7 +34,7 @@ struct GenericHtmlElementProxyHandlerDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SelectHtmlElementProxyHandlerDeclaration {
#[webapi(method, length = 3, callback = select_html_element_proxy_get_callback)]
get: (),
@@ -45,7 +45,7 @@ struct SelectHtmlElementProxyHandlerDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record, scope_lifetime = 'scope)]
struct DetachedElementObjectDeclaration<'scope, 'tag> {
#[webapi(prototype)]
prototype: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/clone.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/clone.rs
index f9d7a56ce..2b08d215a 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/clone.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/clone.rs
@@ -6,7 +6,7 @@ use crate::{
use moli_webapi_declare::{ObjectLiteralDeclaration, WebApiObject};
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CloneShadowRootInitDeclaration<'scope> {
mode: String,
delegates_focus: Option<v8::Local<'scope, v8::Value>>,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/collections.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/collections.rs
index 3c5d4d7af..8677cf57c 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/collections.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/collections.rs
@@ -17,7 +17,7 @@ use moli_webapi_declare::{ObjectLiteralDeclaration, WebApiObject};
use super::*;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DetachedCollectionItemsAndNamedDataDeclaration<'scope> {
items: v8::Local<'scope, v8::Value>,
named: v8::Local<'scope, v8::Object>,
@@ -47,7 +47,7 @@ struct DetachedDocumentAllCollectionDeclaration<'scope> {
/// All fixed members come from the shared `NodeList` prototype. The wrapper
/// only carries its indexed values and private collection brand/length state.
#[derive(WebApiObject)]
-#[webapi(interface = web_api_interfaces::NodeList, require_prototype, allow_empty)]
+#[webapi(interface = web_api_interfaces::NodeList, require_prototype)]
struct DetachedNodeListDeclaration {}
/// Declares the detached `HTMLCollection` wrapper surface.
@@ -56,7 +56,7 @@ struct DetachedNodeListDeclaration {}
/// reusable interface template. Only indexed/named snapshot entries remain
/// own properties.
#[derive(WebApiObject)]
-#[webapi(interface = web_api_interfaces::HTMLCollection, require_prototype, allow_empty)]
+#[webapi(interface = web_api_interfaces::HTMLCollection, require_prototype)]
struct DetachedHtmlCollectionDeclaration {}
#[derive(webidl::WebIdlArgs)]
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/object_access.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/object_access.rs
index 108d0e7a0..4da4ee31c 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/object_access.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/object_access.rs
@@ -6,7 +6,7 @@ pub(in crate::native_bridge::document) use crate::util::{
use moli_webapi_declare::WebApiObject;
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ObjectArrayItemMethodDeclaration {
#[webapi(method, callback = object_array_item_callback)]
item: (),
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_objects/prototypes.rs b/moli-renderer-v8/src/native_bridge/document/detached_objects/prototypes.rs
index 17ba094e1..8f2dbbb80 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_objects/prototypes.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_objects/prototypes.rs
@@ -3,14 +3,14 @@ use crate::web_api_interfaces;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DetachedBridgePrototypeDeclaration<'scope> {
#[webapi(prototype)]
prototype: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record, scope_lifetime = 'scope)]
struct DetachedObjectWithPrototypeDeclaration<'scope, 'tag> {
#[webapi(prototype)]
prototype: v8::Local<'scope, v8::Object>,
@@ -20,7 +20,7 @@ struct DetachedObjectWithPrototypeDeclaration<'scope, 'tag> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DetachedObjectTagDeclaration {
#[webapi(to_string_tag)]
to_string_tag: String,
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_surface/creation/dom_implementation.rs b/moli-renderer-v8/src/native_bridge/document/detached_surface/creation/dom_implementation.rs
index e741ab4ac..cd72a7510 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_surface/creation/dom_implementation.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_surface/creation/dom_implementation.rs
@@ -1,12 +1,12 @@
use super::super::*;
+use crate::web_api_interfaces;
fn value_is_document_type<'s>(
scope: &mut v8::PinScope<'s, '_>,
value: v8::Local<'s, v8::Value>,
) -> bool {
- v8::Local::<v8::Object>::try_from(value).is_ok_and(|object| {
- moli_webapi_declare::implements_interface(scope, object, "DocumentType")
- })
+ v8::Local::<v8::Object>::try_from(value)
+ .is_ok_and(|object| web_api_interfaces::DocumentType::is_instance(scope, object))
}
pub(in crate::native_bridge) fn bridge_create_detached_document_callback<'a>(
diff --git a/moli-renderer-v8/src/native_bridge/document/detached_surface/element_attributes.rs b/moli-renderer-v8/src/native_bridge/document/detached_surface/element_attributes.rs
index d78ec4b2d..18d97d4c7 100644
--- a/moli-renderer-v8/src/native_bridge/document/detached_surface/element_attributes.rs
+++ b/moli-renderer-v8/src/native_bridge/document/detached_surface/element_attributes.rs
@@ -4,7 +4,7 @@ use crate::util::context_host_ptr_from_global_bridge;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DetachedSurfaceNamespaceAttributeRecordDeclaration<'scope> {
name: v8::Local<'scope, v8::String>,
value: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/native_bridge/document/live_collections/all/builder.rs b/moli-renderer-v8/src/native_bridge/document/live_collections/all/builder.rs
index 808bccb99..e702aeb40 100644
--- a/moli-renderer-v8/src/native_bridge/document/live_collections/all/builder.rs
+++ b/moli-renderer-v8/src/native_bridge/document/live_collections/all/builder.rs
@@ -13,7 +13,7 @@ use super::callbacks::{
use super::items::{document_all_items_array, document_all_named_lookup};
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DocumentAllCollectionDataDeclaration<'scope> {
items: v8::Local<'scope, v8::Array>,
named: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/native_bridge/element/events/constructors.rs b/moli-renderer-v8/src/native_bridge/element/events/constructors.rs
index c6fbd0b9d..454092eb0 100644
--- a/moli-renderer-v8/src/native_bridge/element/events/constructors.rs
+++ b/moli-renderer-v8/src/native_bridge/element/events/constructors.rs
@@ -5,7 +5,7 @@ use super::{construct_event, event_constructor};
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct MouseEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -23,7 +23,7 @@ struct MouseEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct PointerEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -50,7 +50,7 @@ struct PointerEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DragEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -65,7 +65,7 @@ struct DragEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WheelEventInitDeclaration {
bubbles: bool,
cancelable: bool,
@@ -83,7 +83,7 @@ struct WheelEventInitDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TouchEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -94,7 +94,7 @@ struct TouchEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TouchInitDeclaration<'scope> {
identifier: i32,
target: v8::Local<'scope, v8::Object>,
@@ -107,7 +107,7 @@ struct TouchInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct KeyboardEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -295,7 +295,7 @@ fn keyboard_event_key_code_for_printable_key(key: &str) -> Option<u32> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct FocusEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -304,7 +304,7 @@ struct FocusEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct SimpleEventInitDeclaration {
bubbles: bool,
cancelable: bool,
@@ -312,7 +312,7 @@ struct SimpleEventInitDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct SubmitEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -320,7 +320,7 @@ struct SubmitEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CommandEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -330,7 +330,7 @@ struct CommandEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ToggleEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
@@ -341,7 +341,7 @@ struct ToggleEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct InterestEventInitDeclaration<'scope> {
bubbles: bool,
cancelable: bool,
diff --git a/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs b/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs
index 740cacc4a..0ef62c1e0 100644
--- a/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs
+++ b/moli-renderer-v8/src/native_bridge/element/media/text_tracks.rs
@@ -195,7 +195,7 @@ struct TextTrackTemplateDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct TrackEventInitDeclaration<'scope> {
track: v8::Local<'scope, v8::Object>,
}
@@ -225,7 +225,7 @@ fn text_track_receiver<'s>(
args: &v8::FunctionCallbackArguments<'s>,
) -> Option<v8::Local<'s, v8::Object>> {
let receiver = args.this();
- if moli_webapi_declare::implements_interface(scope, receiver, "TextTrack") {
+ if web_api_interfaces::TextTrack::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
@@ -237,7 +237,7 @@ fn text_track_list_receiver<'s>(
args: &v8::FunctionCallbackArguments<'s>,
) -> Option<v8::Local<'s, v8::Object>> {
let receiver = args.this();
- if moli_webapi_declare::implements_interface(scope, receiver, "TextTrackList") {
+ if web_api_interfaces::TextTrackList::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
@@ -249,7 +249,7 @@ fn text_track_cue_list_receiver<'s>(
args: &v8::FunctionCallbackArguments<'s>,
) -> Option<v8::Local<'s, v8::Object>> {
let receiver = args.this();
- if moli_webapi_declare::implements_interface(scope, receiver, "TextTrackCueList") {
+ if web_api_interfaces::TextTrackCueList::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/native_bridge/history_queue.rs b/moli-renderer-v8/src/native_bridge/history_queue.rs
index c77bce53e..3579bc6a3 100644
--- a/moli-renderer-v8/src/native_bridge/history_queue.rs
+++ b/moli-renderer-v8/src/native_bridge/history_queue.rs
@@ -73,7 +73,7 @@ pub(crate) struct PendingChildCrossDocumentTraversal {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NavigationResultDeclaration<'scope> {
committed: v8::Local<'scope, v8::Promise>,
finished: v8::Local<'scope, v8::Promise>,
diff --git a/moli-renderer-v8/src/native_bridge/node/foreign/clone.rs b/moli-renderer-v8/src/native_bridge/node/foreign/clone.rs
index 9187cc08c..0043e4c39 100644
--- a/moli-renderer-v8/src/native_bridge/node/foreign/clone.rs
+++ b/moli-renderer-v8/src/native_bridge/node/foreign/clone.rs
@@ -252,13 +252,13 @@ mod tests {
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct TestForeignElementDeclaration {
local_name: String,
}
#[derive(WebApiObject)]
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct TestForeignDocumentDeclaration<'scope> {
node_name: &'static str,
document_element: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/native_bridge/node/metadata.rs b/moli-renderer-v8/src/native_bridge/node/metadata.rs
index de658d244..e724d2279 100644
--- a/moli-renderer-v8/src/native_bridge/node/metadata.rs
+++ b/moli-renderer-v8/src/native_bridge/node/metadata.rs
@@ -2,7 +2,7 @@ use crate::dom::native::LiveDomNodeMetadata;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NodeMetadataDeclaration<'scope> {
kind: v8::Local<'scope, v8::Value>,
node_type: u8,
diff --git a/moli-renderer-v8/src/native_bridge/node/tree/methods.rs b/moli-renderer-v8/src/native_bridge/node/tree/methods.rs
index 9fce671b2..51077c62a 100644
--- a/moli-renderer-v8/src/native_bridge/node/tree/methods.rs
+++ b/moli-renderer-v8/src/native_bridge/node/tree/methods.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::web_api_interfaces;
pub(in crate::native_bridge) fn node_contains_callback(
scope: &mut v8::PinScope<'_, '_>,
@@ -123,7 +124,7 @@ pub(in crate::native_bridge) fn node_compare_document_position_callback<'s>(
// disconnected even when this runtime cannot resolve its live tree handle.
let other_value = args.get(0);
if let Ok(other_object) = v8::Local::<v8::Object>::try_from(other_value)
- && moli_webapi_declare::implements_interface(scope, other_object, "Node")
+ && web_api_interfaces::Node::is_instance(scope, other_object)
{
let order_bit = disconnected_order_bit(args.this(), other_object);
rv.set(
diff --git a/moli-renderer-v8/src/network_host.rs b/moli-renderer-v8/src/network_host.rs
index 871fef123..efe220519 100644
--- a/moli-renderer-v8/src/network_host.rs
+++ b/moli-renderer-v8/src/network_host.rs
@@ -198,7 +198,7 @@ pub(crate) use crate::protocol_types::extract_subresource_auth_challenge;
pub(crate) use moli_fetch::NET_ERR_ABORTED_ERROR_TEXT as ABORTED_ERROR_TEXT;
#[derive(WebApiObject)]
-#[webapi(unbranded, interface = "Response")]
+#[webapi(fragment, prototype = "Response")]
struct ChildResponseConstructorDeclaration<'scope> {
data: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/network_host/beacon.rs b/moli-renderer-v8/src/network_host/beacon.rs
index bfd93cab3..7b6f49388 100644
--- a/moli-renderer-v8/src/network_host/beacon.rs
+++ b/moli-renderer-v8/src/network_host/beacon.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::web_api_interfaces;
use crate::webidl;
use moli_fetch::{
FetchCancelHandle, RequestCredentialsMode, RequestMode, RequestRedirectMode,
@@ -337,7 +338,7 @@ fn navigator_beacon_body<'s>(
}
let data = args.get(1);
if let Ok(object) = v8::Local::<v8::Object>::try_from(data)
- && moli_webapi_declare::implements_interface(scope, object, "ReadableStream")
+ && web_api_interfaces::ReadableStream::is_instance(scope, object)
{
crate::util::throw_type_error(scope, "sendBeacon cannot have a ReadableStream body.");
return None;
diff --git a/moli-renderer-v8/src/network_host/body.rs b/moli-renderer-v8/src/network_host/body.rs
index 0aa13f43f..6d7f25c00 100644
--- a/moli-renderer-v8/src/network_host/body.rs
+++ b/moli-renderer-v8/src/network_host/body.rs
@@ -1,4 +1,5 @@
use super::*;
+use crate::web_api_interfaces;
use crate::webidl;
pub(in crate::network_host) const URL_SEARCH_PARAMS_CONTENT_TYPE: &str =
@@ -46,7 +47,7 @@ pub(in crate::network_host) fn body_init<'s>(
let content_type = (!mime_type.is_empty()).then_some(mime_type);
return Ok(Some(PreparedBodyInit::new(bytes, content_type)));
}
- if moli_webapi_declare::implements_interface(scope, object, "ReadableStream") {
+ if web_api_interfaces::ReadableStream::is_instance(scope, object) {
return Ok(Some(PreparedBodyInit::new(Vec::new(), None)));
}
}
diff --git a/moli-renderer-v8/src/network_host/body_source.rs b/moli-renderer-v8/src/network_host/body_source.rs
index 64664e27b..fd670e7d8 100644
--- a/moli-renderer-v8/src/network_host/body_source.rs
+++ b/moli-renderer-v8/src/network_host/body_source.rs
@@ -5,6 +5,7 @@ use crate::context_bootstrap::{
use crate::protocol_types::SubresourceResponseBody;
use crate::types::NetworkBodySourceId;
use crate::util::{get_private_value, set_private_value};
+use crate::web_api_interfaces;
use crate::worker::get_worker_state;
use std::collections::{HashMap, HashSet};
use std::fs::{self, File, OpenOptions};
@@ -41,7 +42,7 @@ static NETWORK_BODY_SOURCES: OnceLock<Mutex<HashMap<NetworkBodySourceId, Network
OnceLock::new();
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct OwnedNetworkBodySourceDeclaration<'scope> {
#[webapi(slot = NETWORK_BODY_SOURCE_KIND_SLOT)]
kind: &'static str,
@@ -50,7 +51,7 @@ struct OwnedNetworkBodySourceDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct RegisteredNetworkBodySourceDeclaration<'scope> {
#[webapi(slot = NETWORK_BODY_SOURCE_KIND_SLOT)]
kind: &'static str,
@@ -65,7 +66,7 @@ struct RegisteredNetworkBodySourceDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct PendingNetworkBodySourceDeclaration<'scope> {
#[webapi(slot = NETWORK_BODY_SOURCE_KIND_SLOT)]
kind: &'static str,
@@ -1403,7 +1404,7 @@ fn readable_body_stream_from_value<'s>(
let Ok(stream) = v8::Local::<v8::Object>::try_from(value) else {
return None;
};
- if moli_webapi_declare::implements_interface(scope, stream, "ReadableStream") {
+ if web_api_interfaces::ReadableStream::is_instance(scope, stream) {
return Some(stream);
}
None
diff --git a/moli-renderer-v8/src/network_host/event_source/bindings.rs b/moli-renderer-v8/src/network_host/event_source/bindings.rs
index 29ff05f3f..447cfa77a 100644
--- a/moli-renderer-v8/src/network_host/event_source/bindings.rs
+++ b/moli-renderer-v8/src/network_host/event_source/bindings.rs
@@ -111,7 +111,7 @@ struct EventSourceAccessorsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct EventSourceMessageEventInitDeclaration<'scope> {
data: v8::Local<'scope, v8::String>,
origin: v8::Local<'scope, v8::String>,
@@ -608,7 +608,7 @@ fn event_source_is_branded<'s>(
scope: &mut v8::PinScope<'s, '_>,
event_source: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, event_source, "EventSource")
+ web_api_interfaces::EventSource::is_instance(scope, event_source)
}
fn event_source_string_slot<'s>(
diff --git a/moli-renderer-v8/src/network_host/fetch/bindings.rs b/moli-renderer-v8/src/network_host/fetch/bindings.rs
index e5bb7a735..1ac407f40 100644
--- a/moli-renderer-v8/src/network_host/fetch/bindings.rs
+++ b/moli-renderer-v8/src/network_host/fetch/bindings.rs
@@ -16,7 +16,7 @@ use crate::structured_clone::V8StructuredClonePayload;
use moli_webapi_declare::{ObjectLiteralDeclaration, WebApiObject};
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct FetchAbortListenerOptionsDeclaration {
#[webapi(init = true)]
once: (),
diff --git a/moli-renderer-v8/src/network_host/fetch_surface.rs b/moli-renderer-v8/src/network_host/fetch_surface.rs
index 158853f9a..68e07f63b 100644
--- a/moli-renderer-v8/src/network_host/fetch_surface.rs
+++ b/moli-renderer-v8/src/network_host/fetch_surface.rs
@@ -56,7 +56,7 @@ struct ResponseCloneShellDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ResponseInitObjectDeclaration<'scope> {
status: Option<f64>,
status_text: Option<String>,
@@ -178,7 +178,7 @@ pub(crate) fn is_branded_request_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "Request")
+ web_api_interfaces::Request::is_instance(scope, object)
}
pub(crate) fn request_headers_entries<'s>(
@@ -304,7 +304,7 @@ pub(crate) fn is_branded_response_object<'s>(
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
) -> bool {
- moli_webapi_declare::implements_interface(scope, object, "Response")
+ web_api_interfaces::Response::is_instance(scope, object)
}
fn require_response_receiver<'s>(
@@ -928,7 +928,7 @@ fn clone_response_readable_stream_body<'s>(
let Ok(stream) = v8::Local::<v8::Object>::try_from(value) else {
return Ok(None);
};
- if !moli_webapi_declare::implements_interface(scope, stream, "ReadableStream") {
+ if !web_api_interfaces::ReadableStream::is_instance(scope, stream) {
return Ok(None);
}
if readable_stream_locked(scope, stream) {
diff --git a/moli-renderer-v8/src/network_host/headers/methods.rs b/moli-renderer-v8/src/network_host/headers/methods.rs
index c8ccb1c73..2557eaf6f 100644
--- a/moli-renderer-v8/src/network_host/headers/methods.rs
+++ b/moli-renderer-v8/src/network_host/headers/methods.rs
@@ -21,7 +21,7 @@ pub(super) fn require_headers_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, "Headers") {
+ if web_api_interfaces::Headers::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/network_host/headers/methods/iteration.rs b/moli-renderer-v8/src/network_host/headers/methods/iteration.rs
index 76d197fa8..cb1cf2885 100644
--- a/moli-renderer-v8/src/network_host/headers/methods/iteration.rs
+++ b/moli-renderer-v8/src/network_host/headers/methods/iteration.rs
@@ -36,7 +36,7 @@ enum HeadersIteratorKind {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct HeadersIteratorResultDeclaration<'scope> {
done: bool,
value: v8::Local<'scope, v8::Value>,
diff --git a/moli-renderer-v8/src/network_host/request/bindings/init.rs b/moli-renderer-v8/src/network_host/request/bindings/init.rs
index b4ccaf57f..dce291547 100644
--- a/moli-renderer-v8/src/network_host/request/bindings/init.rs
+++ b/moli-renderer-v8/src/network_host/request/bindings/init.rs
@@ -6,6 +6,7 @@ use super::super::input::{
try_resolve_request_constructor_url_for_scope,
};
use super::super::*;
+use crate::web_api_interfaces;
use crate::webidl;
use moli_fetch::{RequestMode, RequestRedirectMode};
@@ -147,9 +148,7 @@ pub(super) fn apply_request_init_overrides<'s>(
)?;
let init_body_is_readable_stream = init_body_value
.and_then(|value| v8::Local::<v8::Object>::try_from(value).ok())
- .is_some_and(|object| {
- moli_webapi_declare::implements_interface(scope, object, "ReadableStream")
- });
+ .is_some_and(|object| web_api_interfaces::ReadableStream::is_instance(scope, object));
let body_from_init = init_body_value
.map(|value| body_init(scope, value, webidl::Context::member("RequestInit", "body")))
.transpose()?
diff --git a/moli-renderer-v8/src/network_host/request/input.rs b/moli-renderer-v8/src/network_host/request/input.rs
index 78ffdba68..950f2d7f5 100644
--- a/moli-renderer-v8/src/network_host/request/input.rs
+++ b/moli-renderer-v8/src/network_host/request/input.rs
@@ -1,5 +1,6 @@
use super::super::headers::HeadersGuard;
use super::*;
+use crate::web_api_interfaces;
use crate::webidl;
pub(in crate::network_host) fn normalize_request_method(
@@ -265,7 +266,7 @@ fn request_body_stream_locked<'s>(
let Ok(stream) = v8::Local::<v8::Object>::try_from(body) else {
return false;
};
- if !moli_webapi_declare::implements_interface(scope, stream, "ReadableStream") {
+ if !web_api_interfaces::ReadableStream::is_instance(scope, stream) {
return false;
}
stream
diff --git a/moli-renderer-v8/src/network_host/response/bindings.rs b/moli-renderer-v8/src/network_host/response/bindings.rs
index 7c324962b..02ce2507c 100644
--- a/moli-renderer-v8/src/network_host/response/bindings.rs
+++ b/moli-renderer-v8/src/network_host/response/bindings.rs
@@ -122,7 +122,7 @@ fn readable_stream_body_arg<'s>(
return None;
}
let object = v8::Local::<v8::Object>::try_from(value).ok()?;
- moli_webapi_declare::implements_interface(scope, object, "ReadableStream").then_some(object)
+ web_api_interfaces::ReadableStream::is_instance(scope, object).then_some(object)
}
fn readable_stream_body_locked(
diff --git a/moli-renderer-v8/src/network_host/response/materialize.rs b/moli-renderer-v8/src/network_host/response/materialize.rs
index a713340a5..80627ffc9 100644
--- a/moli-renderer-v8/src/network_host/response/materialize.rs
+++ b/moli-renderer-v8/src/network_host/response/materialize.rs
@@ -5,6 +5,7 @@ use super::super::fetch_surface::{
};
use super::*;
use crate::types::NetworkBodySourceId;
+use crate::web_api_interfaces;
use moli_fetch::RequestMode;
use moli_webapi_declare::WebApiObject;
@@ -31,7 +32,7 @@ impl From<crate::types::AsyncSubresourceFetchResponseFilter> for FetchResponseFi
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", prototype = "Response")]
+#[webapi(record, prototype = "Response")]
struct FetchResponseHeadDeclaration {
#[webapi(slot = RESPONSE_STATUS_SLOT)]
status: f64,
@@ -46,14 +47,14 @@ struct FetchResponseHeadDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct FetchResponseInternalUrlDeclaration {
#[webapi(slot = RESPONSE_INTERNAL_URL_SLOT)]
internal_url: String,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct FetchResponseBodyDeclaration<'scope> {
#[webapi(slot = RESPONSE_STATUS_TEXT_SLOT)]
status_text: String,
@@ -673,7 +674,7 @@ fn response_body_locked<'s>(
let Ok(stream) = v8::Local::<v8::Object>::try_from(body) else {
return false;
};
- if !moli_webapi_declare::implements_interface(scope, stream, "ReadableStream") {
+ if !web_api_interfaces::ReadableStream::is_instance(scope, stream) {
return false;
}
stream
diff --git a/moli-renderer-v8/src/network_host/xhr/delivery/progress.rs b/moli-renderer-v8/src/network_host/xhr/delivery/progress.rs
index 083e1723a..ed1c11c4d 100644
--- a/moli-renderer-v8/src/network_host/xhr/delivery/progress.rs
+++ b/moli-renderer-v8/src/network_host/xhr/delivery/progress.rs
@@ -14,7 +14,7 @@ const XHR_PROGRESS_DATA_INTERNAL_ID: &str = "internalId";
const XHR_PROGRESS_MINIMUM_INTERVAL_MS: u32 = 50;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct XhrProgressTimerDataDeclaration<'scope> {
xhr: v8::Local<'scope, v8::Object>,
internal_id: f64,
diff --git a/moli-renderer-v8/src/network_host/xhr/delivery/timeout.rs b/moli-renderer-v8/src/network_host/xhr/delivery/timeout.rs
index d1d36f44b..277b28cbc 100644
--- a/moli-renderer-v8/src/network_host/xhr/delivery/timeout.rs
+++ b/moli-renderer-v8/src/network_host/xhr/delivery/timeout.rs
@@ -9,7 +9,7 @@ const XHR_TIMEOUT_DATA_XHR: &str = "xhr";
const XHR_TIMEOUT_DATA_INTERNAL_ID: &str = "internalId";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct XhrTimeoutDataDeclaration<'scope> {
xhr: v8::Local<'scope, v8::Object>,
internal_id: f64,
diff --git a/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs b/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs
index 8337f93c6..bb6ee6cdc 100644
--- a/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs
+++ b/moli-renderer-v8/src/network_host/xhr/events/dispatch.rs
@@ -6,7 +6,7 @@ use crate::util::get_private_value;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct XhrReadyStateChangeEventDeclaration<'scope> {
r#type: &'static str,
target: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/network_host/xhr/events/progress.rs b/moli-renderer-v8/src/network_host/xhr/events/progress.rs
index 3dd57e66a..05c6e07db 100644
--- a/moli-renderer-v8/src/network_host/xhr/events/progress.rs
+++ b/moli-renderer-v8/src/network_host/xhr/events/progress.rs
@@ -2,14 +2,14 @@ use super::super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ProgressEventTargetDeclaration<'scope> {
target: v8::Local<'scope, v8::Object>,
current_target: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct ProgressEventInitDeclaration {
length_computable: bool,
loaded: f64,
diff --git a/moli-renderer-v8/src/network_host/xhr/instance_state.rs b/moli-renderer-v8/src/network_host/xhr/instance_state.rs
index a8e432412..15d561c41 100644
--- a/moli-renderer-v8/src/network_host/xhr/instance_state.rs
+++ b/moli-renderer-v8/src/network_host/xhr/instance_state.rs
@@ -33,7 +33,7 @@ const XHR_STATE_FIELD_INDEX: usize = 0;
const XHR_UPLOAD_FIELD_INDEX: usize = 1;
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct XmlHttpRequestStateDeclaration {
#[webapi(slot = XHR_EXECUTION_CONTEXT_BINDING_SLOT, init = "")]
execution_context_binding: (),
diff --git a/moli-renderer-v8/src/runtime_binding_data.rs b/moli-renderer-v8/src/runtime_binding_data.rs
index 9daa2573f..c683f52a6 100644
--- a/moli-renderer-v8/src/runtime_binding_data.rs
+++ b/moli-renderer-v8/src/runtime_binding_data.rs
@@ -13,7 +13,7 @@ use crate::{
};
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct RuntimeBindingDataDeclaration<'scope> {
host: v8::Local<'scope, v8::External>,
name: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/script_vm/native_module.rs b/moli-renderer-v8/src/script_vm/native_module.rs
index 51946eeff..b6c360358 100644
--- a/moli-renderer-v8/src/script_vm/native_module.rs
+++ b/moli-renderer-v8/src/script_vm/native_module.rs
@@ -583,13 +583,13 @@ const MODULE_REACTION_DOCUMENT_ID_SLOT: &str = "documentId";
const MODULE_REACTION_REALM_ID_SLOT: &str = "realmId";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NativeDynamicModuleReactionDataDeclaration<'scope> {
reaction_id: v8::Local<'scope, v8::BigInt>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NativeModuleScriptReactionDataDeclaration<'scope> {
module_script_reaction_id: v8::Local<'scope, v8::BigInt>,
scheduler_lane_id: v8::Local<'scope, v8::BigInt>,
@@ -598,7 +598,7 @@ struct NativeModuleScriptReactionDataDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct NativeChildModuleScriptReactionDataDeclaration<'scope> {
module_script_reaction_id: v8::Local<'scope, v8::BigInt>,
scheduler_lane_id: v8::Local<'scope, v8::BigInt>,
diff --git a/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs b/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs
index 217504838..883cf1a3b 100644
--- a/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs
+++ b/moli-renderer-v8/src/script_vm/tests/dom_xhr/xhr.rs
@@ -3,11 +3,11 @@ use crate::util::v8str;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", allow_empty)]
+#[webapi(record)]
struct PendingBodyOwnerProbeDeclaration {}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", allow_empty)]
+#[webapi(record)]
struct StreamingXhrProbeDeclaration {}
fn pending_body_owner_probe<'s>(scope: &mut v8::PinScope<'s, '_>) -> v8::Local<'s, v8::Object> {
diff --git a/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs b/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs
index 871722004..dcbe59505 100644
--- a/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs
+++ b/moli-renderer-v8/src/script_vm/tests/webidl_fetch.rs
@@ -3,13 +3,13 @@ use crate::util::v8str;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties)]
+#[webapi(record, data_properties)]
struct NullableRequiredDictionaryValueProbe<'scope> {
value: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", allow_empty)]
+#[webapi(record)]
struct NullableRequiredDictionaryAbsentProbe {}
#[test]
diff --git a/moli-renderer-v8/src/script_vm/tests/websocket.rs b/moli-renderer-v8/src/script_vm/tests/websocket.rs
index c06c82104..6af7e680b 100644
--- a/moli-renderer-v8/src/script_vm/tests/websocket.rs
+++ b/moli-renderer-v8/src/script_vm/tests/websocket.rs
@@ -2,7 +2,7 @@ use super::*;
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", allow_empty)]
+#[webapi(record)]
struct LoadingWorkerWrapperProbeDeclaration {}
fn loading_worker_wrapper_probe<'s>(scope: &mut v8::PinScope<'s, '_>) -> v8::Local<'s, v8::Object> {
diff --git a/moli-renderer-v8/src/script_vm/webcrypto_tasks.rs b/moli-renderer-v8/src/script_vm/webcrypto_tasks.rs
index 0b72ad6fa..2b27a4ac9 100644
--- a/moli-renderer-v8/src/script_vm/webcrypto_tasks.rs
+++ b/moli-renderer-v8/src/script_vm/webcrypto_tasks.rs
@@ -10,7 +10,7 @@ use crate::{
use moli_webapi_declare::WebApiObject;
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct CryptoKeyPairResultDeclaration<'scope> {
private_key: v8::Local<'scope, v8::Object>,
public_key: v8::Local<'scope, v8::Object>,
diff --git a/moli-renderer-v8/src/util.rs b/moli-renderer-v8/src/util.rs
index d33882f77..9a7c55822 100644
--- a/moli-renderer-v8/src/util.rs
+++ b/moli-renderer-v8/src/util.rs
@@ -644,19 +644,19 @@ mod tests {
use url::Url;
#[derive(WebApiObject)]
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct TestParentObjectDeclaration<'scope> {
parent_node: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct TestParentValueDeclaration<'scope> {
parent_node: v8::Local<'scope, v8::Value>,
}
#[derive(WebApiObject)]
- #[webapi(interface = "Object", allow_empty)]
+ #[webapi(record)]
struct TestIdentityObjectDeclaration {}
fn primitive_host_defined_options<'s>(
diff --git a/moli-renderer-v8/src/webidl_iterator.rs b/moli-renderer-v8/src/webidl_iterator.rs
index 9d635c977..429376e81 100644
--- a/moli-renderer-v8/src/webidl_iterator.rs
+++ b/moli-renderer-v8/src/webidl_iterator.rs
@@ -131,7 +131,7 @@ pub(crate) enum MaplikeWebIdlIteratorMethod {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SnapshotWebIdlIteratorDeclaration<'s> {
#[webapi(slot = SNAPSHOT_ITERATOR_VALUES_SLOT)]
values: v8::Local<'s, v8::Array>,
@@ -140,7 +140,7 @@ struct SnapshotWebIdlIteratorDeclaration<'s> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NativeCollectionWebIdlIteratorDeclaration<'s> {
#[webapi(slot = NATIVE_COLLECTION_ITERATOR_SLOT)]
iterator: v8::Local<'s, v8::Object>,
@@ -149,7 +149,7 @@ struct NativeCollectionWebIdlIteratorDeclaration<'s> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct SnapshotWebIdlIteratorResultDeclaration<'s> {
value: v8::Local<'s, v8::Value>,
done: bool,
diff --git a/moli-renderer-v8/src/window_host.rs b/moli-renderer-v8/src/window_host.rs
index 12b9b48d6..a60a7606b 100644
--- a/moli-renderer-v8/src/window_host.rs
+++ b/moli-renderer-v8/src/window_host.rs
@@ -64,7 +64,7 @@ const WINDOW_REQUEST_ANIMATION_FRAME_DELAY_MS: u32 = 16;
pub(crate) const TOP_WINDOW_MESSAGE_ENDPOINT_SLOT: &str = "__moliTopWindowMessageEndpoint";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WindowMessageEventInitDeclaration<'scope> {
data: v8::Local<'scope, v8::Value>,
origin: v8::Local<'scope, v8::String>,
@@ -73,7 +73,7 @@ struct WindowMessageEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WindowDocumentEventInitDeclaration {
bubbles: bool,
cancelable: bool,
@@ -1982,7 +1982,7 @@ fn idle_deadline_receiver<'s>(
scope: &mut v8::PinScope<'s, '_>,
receiver: v8::Local<'s, v8::Object>,
) -> Option<v8::Local<'s, v8::Object>> {
- if moli_webapi_declare::implements_interface(scope, receiver, "IdleDeadline") {
+ if web_api_interfaces::IdleDeadline::is_instance(scope, receiver) {
return Some(receiver);
}
throw_type_error(scope, "Illegal invocation");
diff --git a/moli-renderer-v8/src/worker/global_scope/mod.rs b/moli-renderer-v8/src/worker/global_scope/mod.rs
index 2b0af41cd..2ded26ad4 100644
--- a/moli-renderer-v8/src/worker/global_scope/mod.rs
+++ b/moli-renderer-v8/src/worker/global_scope/mod.rs
@@ -182,7 +182,7 @@ const SERVICE_WORKER_CLIENT_ID_SLOT: &str = "__lmServiceWorkerClientId";
const WORKER_ORIGINAL_CONSOLE_SLOT: &str = "__moliWorkerOriginalConsole";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record)]
struct WorkerGlobalBootstrapPropertiesDeclaration<'scope> {
#[webapi(slot = WORKER_STATE_SLOT)]
worker_state: v8::Local<'scope, v8::External>,
@@ -197,35 +197,35 @@ struct WorkerGlobalBootstrapPropertiesDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalNameDeclaration {
#[webapi(data_property, enumerable)]
name: String,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalOriginDeclaration {
#[webapi(data_property, readonly)]
origin: String,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalConsoleDeclaration<'scope> {
#[webapi(data_property)]
console: v8::Local<'scope, v8::Object>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalPerformanceDeclaration<'scope> {
#[webapi(data_property)]
performance: v8::Local<'scope, v8::Object>,
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerConsoleObjectDeclaration {
#[webapi(method, enumerable, callback = console_log_callback, data = v8str(scope, "log"))]
log: (),
@@ -281,7 +281,7 @@ struct WorkerPerformanceObjectDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct WorkerGlobalCommonEventHandlersDeclaration {
#[webapi(
accessor_property = "onerror",
@@ -316,7 +316,7 @@ struct WorkerGlobalCommonEventHandlersDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct DedicatedWorkerGlobalEventHandlersDeclaration {
#[webapi(
accessor_property = "onmessage",
@@ -333,7 +333,7 @@ struct DedicatedWorkerGlobalEventHandlersDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct SharedWorkerGlobalEventHandlersDeclaration {
#[webapi(
accessor_property = "onconnect",
@@ -344,7 +344,7 @@ struct SharedWorkerGlobalEventHandlersDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalCommonEventHandlerStateDeclaration {
#[webapi(slot = WORKER_GLOBAL_ONERROR_SLOT, init = "null")]
onerror: (),
@@ -359,7 +359,7 @@ struct WorkerGlobalCommonEventHandlerStateDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DedicatedWorkerGlobalEventHandlerStateDeclaration {
#[webapi(slot = WORKER_GLOBAL_ONMESSAGE_SLOT, init = "null")]
onmessage: (),
@@ -368,35 +368,35 @@ struct DedicatedWorkerGlobalEventHandlerStateDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SharedWorkerGlobalEventHandlerStateDeclaration {
#[webapi(slot = WORKER_GLOBAL_ONCONNECT_SLOT, init = "null")]
onconnect: (),
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "DedicatedWorkerGlobalScope", enumerable)]
+#[webapi(fragment, prototype = "DedicatedWorkerGlobalScope", enumerable)]
struct DedicatedWorkerGlobalMethodsDeclaration {
#[webapi(method, callback = worker_close_callback, length = 0)]
close: (),
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DedicatedWorkerGlobalPostMessageDeclaration {
#[webapi(method = "postMessage", callback = worker_post_message_callback, length = 1)]
post_message: (),
}
#[derive(Default, WebApiObject)]
-#[webapi(unbranded, interface = "SharedWorkerGlobalScope", enumerable)]
+#[webapi(fragment, prototype = "SharedWorkerGlobalScope", enumerable)]
struct SharedWorkerGlobalMethodsDeclaration {
#[webapi(method, callback = worker_close_callback, length = 0)]
close: (),
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalCommonOperationsDeclaration {
#[webapi(
method = "structuredClone",
@@ -411,7 +411,7 @@ struct WorkerGlobalCommonOperationsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalTimerOperationsDeclaration {
#[webapi(method = "setTimeout", callback = worker_set_timeout_callback, length = 1)]
set_timeout: (),
@@ -442,7 +442,7 @@ struct WorkerGlobalTimerOperationsDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalCreateImageBitmapDeclaration {
#[webapi(
method = "createImageBitmap",
@@ -453,7 +453,7 @@ struct WorkerGlobalCreateImageBitmapDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct ServiceWorkerGlobalEventHandlersDeclaration {
#[webapi(
accessor_property = "oninstall",
@@ -518,7 +518,7 @@ struct ServiceWorkerGlobalEventHandlersDeclaration {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerGlobalEventHandlerStateDeclaration {
#[webapi(slot = WORKER_GLOBAL_ONINSTALL_SLOT, init = "null")]
oninstall: (),
@@ -564,7 +564,7 @@ struct ServiceWorkerClientsDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerGlobalRuntimeDeclaration<'scope> {
#[webapi(data_property, readonly)]
registration: v8::Local<'scope, v8::Object>,
@@ -594,56 +594,56 @@ struct ExtendableEventTemplateDeclaration {
struct ExtendableMessageEventTemplateDeclaration {}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerGlobalScopeConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "WorkerGlobalScope")]
constructor: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DedicatedWorkerGlobalScopeConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "DedicatedWorkerGlobalScope")]
constructor: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct SharedWorkerGlobalScopeConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "SharedWorkerGlobalScope")]
constructor: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerGlobalScopeConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "ServiceWorkerGlobalScope")]
constructor: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ExtendableEventConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "ExtendableEvent")]
extendable_event: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ExtendableMessageEventConstructorGlobalDeclaration<'scope> {
#[webapi(data_property = "ExtendableMessageEvent")]
extendable_message_event: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerScopePrototypeConstructorDeclaration<'scope> {
#[webapi(data_property = "constructor")]
constructor: v8::Local<'scope, v8::Function>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerPrototypeTagDeclaration {
#[webapi(to_string_tag, readonly)]
tag: &'static str,
@@ -850,7 +850,7 @@ struct ServiceWorkerPushSubscriptionOptionsDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerNavigationPreloadStateDeclaration {
#[webapi(data_property, enumerable)]
enabled: bool,
diff --git a/moli-renderer-v8/src/worker/global_scope/xhr.rs b/moli-renderer-v8/src/worker/global_scope/xhr.rs
index 83cd21931..7c8f79f3f 100644
--- a/moli-renderer-v8/src/worker/global_scope/xhr.rs
+++ b/moli-renderer-v8/src/worker/global_scope/xhr.rs
@@ -22,7 +22,7 @@ pub(in crate::worker) const WORKER_XHR_TIMEOUT_DATA_XHR: &str = "xhr";
pub(in crate::worker) const WORKER_XHR_TIMEOUT_DATA_XHR_ID: &str = "xhrId";
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct WorkerXhrTimeoutDataDeclaration<'scope> {
xhr: v8::Local<'scope, v8::Object>,
xhr_id: f64,
diff --git a/moli-renderer-v8/src/worker/module_runtime.rs b/moli-renderer-v8/src/worker/module_runtime.rs
index 3c0a547da..f273dfd1f 100644
--- a/moli-renderer-v8/src/worker/module_runtime.rs
+++ b/moli-renderer-v8/src/worker/module_runtime.rs
@@ -35,14 +35,14 @@ pub(super) type WorkerModuleEvaluationId = u64;
const WORKER_MODULE_EVALUATION_REACTION_ID_SLOT: &str = "workerModuleEvaluationReactionId";
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerModuleEvaluationReactionDataDeclaration {
#[webapi(slot = WORKER_MODULE_EVALUATION_REACTION_ID_SLOT)]
evaluation_id: f64,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerImportMetaDeclaration<'scope> {
#[webapi(data_property, enumerable)]
url: v8::Local<'scope, v8::String>,
diff --git a/moli-renderer-v8/src/worker/thread/dispatch.rs b/moli-renderer-v8/src/worker/thread/dispatch.rs
index 64e9173eb..2564598bb 100644
--- a/moli-renderer-v8/src/worker/thread/dispatch.rs
+++ b/moli-renderer-v8/src/worker/thread/dispatch.rs
@@ -88,7 +88,7 @@ const SERVICE_WORKER_PERIODIC_SYNC_EVENT_ID_SLOT: &str = "__lmServiceWorkerPerio
const MAX_REPORTED_WORKER_PROMISE_REJECTIONS: usize = 1024;
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
@@ -99,7 +99,7 @@ struct WorkerMessageEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerErrorEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
message: v8::Local<'scope, v8::String>,
@@ -116,7 +116,7 @@ struct WorkerErrorEventInitDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct WorkerPromiseRejectionEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
cancelable: bool,
@@ -227,7 +227,7 @@ struct ServiceWorkerMessageEventDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerExtendableMessageEventInitDeclaration<'scope> {
#[webapi(data_property, enumerable)]
data: v8::Local<'scope, v8::Value>,
@@ -242,7 +242,7 @@ struct ServiceWorkerExtendableMessageEventInitDeclaration<'scope> {
}
#[derive(Default, WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerMessageDispatchMethodsDeclaration {
#[webapi(
method = "preventDefault",
@@ -344,7 +344,7 @@ struct ServiceWorkerPeriodicSyncEventDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerRespondWithCallbackDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
event_id: v8::Local<'scope, v8::BigInt>,
@@ -353,21 +353,21 @@ struct ServiceWorkerRespondWithCallbackDataDeclaration<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerRespondWithLifetimeCallbackDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
event_id: v8::Local<'scope, v8::BigInt>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerRespondWithBodyCallbackDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
event_id: v8::Local<'scope, v8::BigInt>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerRespondWithStreamChunkCallbackDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
event_id: v8::Local<'scope, v8::BigInt>,
@@ -2834,7 +2834,7 @@ fn build_service_worker_wait_until_callback<'s>(
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ServiceWorkerWaitUntilCallbackDataDeclaration<'scope> {
#[webapi(data_property, enumerable)]
event_id: v8::Local<'scope, v8::BigInt>,
diff --git a/moli-webapi-declare-derive/src/attrs.rs b/moli-webapi-declare-derive/src/attrs.rs
index b73df2108..1a34c4afa 100644
--- a/moli-webapi-declare-derive/src/attrs.rs
+++ b/moli-webapi-declare-derive/src/attrs.rs
@@ -1,78 +1,41 @@
use syn::spanned::Spanned;
use syn::{Error, Expr, ExprLit, Field, Lit, LitInt, LitStr, Path, Token};
-#[derive(Clone)]
-pub(crate) enum InterfaceAttr {
- Name(LitStr),
- Descriptor(Path),
-}
+pub(crate) type ReceiverAttr = Path;
-impl syn::parse::Parse for InterfaceAttr {
- fn parse(input: syn::parse::ParseStream<'_>) -> Result<Self, Error> {
- if input.peek(LitStr) {
- input.parse().map(Self::Name)
- } else {
- input.parse().map(Self::Descriptor)
- }
- }
+#[derive(Clone)]
+pub(crate) enum ObjectRole {
+ Instance(Path),
+ Record,
+ Fragment,
}
-impl InterfaceAttr {
- pub(crate) fn name(&self) -> proc_macro2::TokenStream {
+impl ObjectRole {
+ pub(crate) fn interface(&self) -> Option<&Path> {
match self {
- Self::Name(name) => quote::quote!(#name),
- Self::Descriptor(path) => quote::quote!(<#path>::DESCRIPTOR.name()),
+ Self::Instance(interface) => Some(interface),
+ Self::Record | Self::Fragment => None,
}
}
}
fn resolve_interface_receiver(
receiver: &mut Option<ReceiverAttr>,
- interface: Option<&InterfaceAttr>,
+ interface: Option<&Path>,
shorthand: Option<proc_macro2::Span>,
) -> Result<(), Error> {
if let Some(span) = shorthand {
if receiver.is_some() {
return Err(Error::new(span, "receiver can only be specified once"));
}
- *receiver = Some(match interface {
- Some(InterfaceAttr::Descriptor(path)) => {
- ReceiverAttr::Predicate(syn::parse_quote!(#path::is_instance))
- }
- _ => {
- return Err(Error::new(
- span,
- "receiver shorthand requires an interface descriptor",
- ));
- }
- });
+ let interface = interface.ok_or_else(|| {
+ Error::new(span, "receiver shorthand requires an interface descriptor")
+ })?;
+ *receiver = Some(syn::parse_quote!(#interface::is_instance));
}
Ok(())
}
-#[derive(Clone)]
-pub(crate) enum ReceiverAttr {
- Predicate(Path),
- Interface(LitStr),
-}
-
-impl syn::parse::Parse for ReceiverAttr {
- fn parse(input: syn::parse::ParseStream<'_>) -> Result<Self, Error> {
- if input.peek(LitStr) {
- let name: LitStr = input.parse()?;
- if name.value().is_empty() || name.value() == "Object" {
- return Err(Error::new(
- name.span(),
- "receiver requires a Web IDL interface name",
- ));
- }
- Ok(Self::Interface(name))
- } else {
- input.parse().map(Self::Predicate)
- }
- }
-}
-
#[derive(Clone)]
pub(crate) enum ConstructorAttr {
Illegal,
@@ -109,25 +72,22 @@ pub(crate) enum RenameRule {
#[derive(Default)]
pub(crate) struct ObjectAttrs {
pub(crate) receiver: Option<ReceiverAttr>,
- pub(crate) interface: Option<InterfaceAttr>,
- pub(crate) parent: Option<LitStr>,
- pub(crate) prototype: Option<LitStr>,
- pub(crate) own_to_string_tag: Option<LitStr>,
- pub(crate) fallback_to_string_tag: Option<LitStr>,
+ pub(crate) role: Option<ObjectRole>,
+ pub(crate) prototype: Option<Expr>,
+ pub(crate) own_to_string_tag: Option<Expr>,
+ pub(crate) fallback_to_string_tag: Option<Expr>,
pub(crate) readonly_to_string_tag: bool,
pub(crate) scope_lifetime: Option<syn::Lifetime>,
pub(crate) require_prototype: bool,
pub(crate) rename_all: RenameRule,
- pub(crate) allow_empty: bool,
pub(crate) default_data_properties: bool,
pub(crate) default_enumerable: bool,
pub(crate) no_dynamic_constructor: bool,
- pub(crate) unbranded: bool,
}
#[derive(Default)]
pub(crate) struct FunctionTemplateAttrs {
- pub(crate) interface: Option<InterfaceAttr>,
+ pub(crate) interface: Option<Path>,
pub(crate) receiver: Option<ReceiverAttr>,
pub(crate) name: Option<LitStr>,
pub(crate) constructor: Option<ConstructorAttr>,
@@ -266,14 +226,6 @@ pub(crate) fn parse_object_attrs(attrs: &[syn::Attribute]) -> Result<ObjectAttrs
let mut interface_receiver = None;
for attr in attrs.iter().filter(|attr| attr.path().is_ident("webapi")) {
attr.parse_nested_meta(|meta| {
- if meta.path.is_ident("parent") {
- parsed.parent = Some(meta.value()?.parse()?);
- return Ok(());
- }
- if meta.path.is_ident("unbranded") {
- parsed.unbranded = true;
- return Ok(());
- }
if meta.path.is_ident("receiver") {
if meta.input.peek(Token![=]) {
parsed.receiver = Some(meta.value()?.parse()?);
@@ -282,8 +234,22 @@ pub(crate) fn parse_object_attrs(attrs: &[syn::Attribute]) -> Result<ObjectAttrs
}
return Ok(());
}
- if meta.path.is_ident("interface") {
- parsed.interface = Some(meta.value()?.parse()?);
+ if meta.path.is_ident("interface")
+ || meta.path.is_ident("record")
+ || meta.path.is_ident("fragment")
+ {
+ if parsed.role.is_some() {
+ return Err(
+ meta.error("choose one object role: interface, record, or fragment")
+ );
+ }
+ parsed.role = Some(if meta.path.is_ident("interface") {
+ ObjectRole::Instance(meta.value()?.parse()?)
+ } else if meta.path.is_ident("record") {
+ ObjectRole::Record
+ } else {
+ ObjectRole::Fragment
+ });
return Ok(());
}
if meta.path.is_ident("prototype") {
@@ -315,10 +281,6 @@ pub(crate) fn parse_object_attrs(attrs: &[syn::Attribute]) -> Result<ObjectAttrs
parsed.rename_all = parse_rename_rule(&value)?;
return Ok(());
}
- if meta.path.is_ident("allow_empty") {
- parsed.allow_empty = true;
- return Ok(());
- }
if meta.path.is_ident("data_properties") {
parsed.default_data_properties = true;
return Ok(());
@@ -334,17 +296,9 @@ pub(crate) fn parse_object_attrs(attrs: &[syn::Attribute]) -> Result<ObjectAttrs
Err(meta.error("unsupported #[webapi(...)] object attribute"))
})?;
}
- if let Some(parent) = &parsed.parent
- && matches!(parsed.interface, Some(InterfaceAttr::Descriptor(_)))
- {
- return Err(Error::new(
- parent.span(),
- "parent belongs in the interface descriptor, not the object declaration",
- ));
- }
resolve_interface_receiver(
&mut parsed.receiver,
- parsed.interface.as_ref(),
+ parsed.role.as_ref().and_then(ObjectRole::interface),
interface_receiver,
)?;
Ok(parsed)
@@ -1039,6 +993,36 @@ mod tests {
};
use syn::Field;
+ #[test]
+ fn object_roles_are_exclusive() {
+ let cases: [Vec<syn::Attribute>; 3] = [
+ syn::parse_quote!(#[webapi(record, fragment)]),
+ syn::parse_quote!(#[webapi(interface = Event, record)]),
+ syn::parse_quote!(#[webapi(fragment, interface = Event)]),
+ ];
+ for attrs in cases {
+ let error = parse_object_attrs(&attrs).err().expect("conflicting roles");
+ assert_eq!(
+ error.to_string(),
+ "choose one object role: interface, record, or fragment"
+ );
+ }
+ }
+
+ #[test]
+ fn receiver_shorthand_requires_and_uses_the_declared_interface() {
+ let attrs: Vec<syn::Attribute> =
+ syn::parse_quote!(#[webapi(interface = interfaces::Event, receiver)]);
+ let parsed = parse_object_attrs(&attrs).expect("native instance receiver");
+ let receiver = parsed.receiver.expect("resolved receiver");
+ assert_eq!(
+ quote::quote!(#receiver).to_string(),
+ "interfaces :: Event :: is_instance"
+ );
+ let attrs: Vec<syn::Attribute> = syn::parse_quote!(#[webapi(record, receiver)]);
+ assert!(parse_object_attrs(&attrs).is_err());
+ }
+
#[test]
fn installation_kinds_conflict_even_across_separate_attributes() {
let fields: [Field; 3] = [
@@ -1057,7 +1041,7 @@ mod tests {
#[test]
fn inherited_defaults_respect_member_roles() {
- let receiver = syn::parse_quote!("Example");
+ let receiver = syn::parse_quote!(is_example);
let defaults = FieldDefaults {
receiver: Some(&receiver),
data_properties: true,
@@ -1103,7 +1087,7 @@ mod tests {
#[test]
fn object_enumerable_default_can_be_used_without_default_data_properties() {
let attrs: Vec<syn::Attribute> = syn::parse_quote! {
- #[webapi(interface = "Object", enumerable)]
+ #[webapi(record, enumerable)]
};
let attrs = parse_object_attrs(&attrs)
.expect("enumerable default should parse without data properties");
@@ -1114,7 +1098,7 @@ mod tests {
#[test]
fn object_data_properties_default_is_parsed() {
let attrs: Vec<syn::Attribute> = syn::parse_quote! {
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
};
let attrs = parse_object_attrs(&attrs).expect("data-properties default should parse");
assert!(attrs.default_data_properties);
@@ -1123,13 +1107,13 @@ mod tests {
#[test]
fn rename_all_none_is_the_only_explicit_rename_rule() {
let attrs: Vec<syn::Attribute> = syn::parse_quote! {
- #[webapi(interface = "Object", rename_all = "none")]
+ #[webapi(record, rename_all = "none")]
};
let attrs = parse_object_attrs(&attrs).expect("rename_all none should parse");
assert!(matches!(attrs.rename_all, RenameRule::None));
let attrs: Vec<syn::Attribute> = syn::parse_quote! {
- #[webapi(interface = "Object", rename_all = "camelCase")]
+ #[webapi(record, rename_all = "camelCase")]
};
let error = match parse_object_attrs(&attrs) {
Ok(_) => panic!("explicit camelCase rename_all should be rejected"),
@@ -1300,7 +1284,7 @@ mod tests {
#[test]
fn removed_object_properties_spelling_is_rejected() {
let attrs: Vec<syn::Attribute> = syn::parse_quote! {
- #[webapi(interface = "Object", properties)]
+ #[webapi(record, properties)]
};
let error = match parse_object_attrs(&attrs) {
Ok(_) => panic!("removed object properties spelling should be rejected"),
diff --git a/moli-webapi-declare-derive/src/expand.rs b/moli-webapi-declare-derive/src/expand.rs
index 2b6e2e5e6..8e82b954c 100644
--- a/moli-webapi-declare-derive/src/expand.rs
+++ b/moli-webapi-declare-derive/src/expand.rs
@@ -5,8 +5,8 @@ use syn::spanned::Spanned;
use syn::{Data, DeriveInput, Error, Field, Fields, GenericParam, Ident, Lit, LitStr, Type};
use crate::attrs::{
- ConstructorAttr, ConstructorDefaultAttr, FieldAttrs, FieldDefaults, FieldKind, InterfaceAttr,
- ObjectAttrs, RenameRule, ValueInitAttr, parse_field_attrs_with_defaults,
+ ConstructorAttr, ConstructorDefaultAttr, FieldAttrs, FieldDefaults, FieldKind, ObjectAttrs,
+ ObjectRole, RenameRule, ValueInitAttr, parse_field_attrs_with_defaults,
parse_function_template_attrs, parse_object_attrs,
};
@@ -62,7 +62,7 @@ pub(crate) fn expand_webapi_function_template(
let template_name = if let Some(name) = &attrs.name {
quote!(#name)
} else if let Some(interface) = &attrs.interface {
- interface.name()
+ quote!(<#interface>::DESCRIPTOR.name())
} else {
let name = LitStr::new(&struct_name.to_string(), struct_name.span());
quote!(#name)
@@ -76,7 +76,7 @@ pub(crate) fn expand_webapi_function_template(
quote!(::moli_webapi_declare::illegal_constructor_callback)
}
ConstructorAttr::Callback(callback) => {
- let Some(InterfaceAttr::Descriptor(interface)) = &attrs.interface else {
+ let Some(interface) = &attrs.interface else {
return Err(Error::new(
struct_name.span(),
"constructor_callback requires an interface descriptor",
@@ -212,17 +212,18 @@ pub(crate) fn expand_webapi_object(input: DeriveInput) -> Result<proc_macro2::To
let generics = input.generics;
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();
let attrs = parse_object_attrs(&input.attrs)?;
- let interface = attrs
- .interface
- .clone()
- .ok_or_else(|| Error::new(struct_name.span(), "missing #[webapi(interface = \"...\")]"))?;
- let has_explicit_prototype = attrs.prototype.is_some();
- let interface_name = interface.name();
+ let role = attrs.role.as_ref().ok_or_else(|| Error::new(
+ struct_name.span(), "choose an object role with #[webapi(interface = Type)], #[webapi(record)], or #[webapi(fragment)]",
+ ))?;
let prototype = attrs
.prototype
.as_ref()
- .map(|name| quote!(#name))
- .unwrap_or_else(|| interface_name.clone());
+ .map(|prototype| quote!(#prototype))
+ .or_else(|| match role {
+ ObjectRole::Instance(interface) => Some(quote!(<#interface>::DESCRIPTOR.name())),
+ ObjectRole::Record => Some(quote!("Object")),
+ ObjectRole::Fragment => None,
+ });
let own_to_string_tag = match attrs.own_to_string_tag.as_ref() {
Some(tag) => quote!(::std::option::Option::Some(#tag)),
None => quote!(::std::option::Option::None),
@@ -250,15 +251,21 @@ pub(crate) fn expand_webapi_object(input: DeriveInput) -> Result<proc_macro2::To
}
}
};
- let set_prototype = if attrs.require_prototype {
- quote! {
+ let set_prototype = match (prototype, attrs.require_prototype) {
+ (Some(prototype), true) => quote! {
::moli_webapi_declare::set_required_interface_prototype(scope, object, #prototype)?;
true
- }
- } else {
- quote! {
+ },
+ (Some(prototype), false) => quote!(
::moli_webapi_declare::set_interface_prototype(scope, object, #prototype)
+ ),
+ (None, true) => {
+ return Err(Error::new(
+ struct_name.span(),
+ "require_prototype on a fragment requires an explicit prototype",
+ ));
}
+ (None, false) => quote!(false),
};
let define_fallback_to_string_tag = quote! {
if !prototype_bound {
@@ -300,31 +307,12 @@ pub(crate) fn expand_webapi_object(input: DeriveInput) -> Result<proc_macro2::To
.iter()
.filter_map(expand_object_field)
.collect::<Result<Vec<_>, _>>()?;
- if fields.is_empty() && !attrs.allow_empty && !has_explicit_prototype {
- return Err(Error::new(
- struct_name.span(),
- "empty WebApiObject declaration requires #[webapi(allow_empty)]",
- ));
- }
-
- let initialize_brand = if attrs.unbranded {
- quote!()
- } else {
- match &interface {
- InterfaceAttr::Descriptor(path) => {
- quote!(<#path>::DESCRIPTOR.initialize(scope, object)?;)
- }
- InterfaceAttr::Name(name) if name.value() == "Object" => quote!(),
- InterfaceAttr::Name(name) => {
- quote!(::moli_webapi_declare::initialize_web_api_object(scope, object, #name)?;)
- }
+ let initialize_brand = role.interface().map(|interface| {
+ quote! {
+ <#interface>::DESCRIPTOR.initialize(scope, object)?;
}
- };
- let register_parent = attrs.parent.as_ref().map(|parent| quote! {
- ::moli_webapi_declare::register_web_api_interfaces(scope, [(#interface_name, Some(#parent))])?;
});
let initialize_body = quote! {
- #register_parent
#(#fields)*
#initialize_brand
::std::result::Result::Ok(())
@@ -338,9 +326,6 @@ pub(crate) fn expand_webapi_object(input: DeriveInput) -> Result<proc_macro2::To
let (trait_impl_generics, _, trait_where_clause) = trait_generics.split_for_impl();
let trait_impl = quote! {
impl #trait_impl_generics ::moli_webapi_declare::WebApiObjectDeclaration<#method_scope_lifetime> for #struct_name #ty_generics #trait_where_clause {
- const INTERFACE: &'static str = #interface_name;
- const OWN_TO_STRING_TAG: ::std::option::Option<&'static str> = #own_to_string_tag;
-
fn initialize(
&self,
scope: &mut ::moli_webapi_declare::v8::PinScope<#method_scope_lifetime, '_>,
@@ -1403,14 +1388,7 @@ fn expand_callback(
return quote!(#callback);
}
let receiver_check = attrs.receiver.as_ref().map(|receiver| {
- let check = match receiver {
- crate::attrs::ReceiverAttr::Predicate(predicate) => {
- quote!(#predicate(scope, args.this()))
- }
- crate::attrs::ReceiverAttr::Interface(interface) => quote!(
- ::moli_webapi_declare::implements_interface(scope, args.this(), #interface)
- ),
- };
+ let check = quote!(#receiver(scope, args.this()));
quote! {
if !#check {
::moli_webapi_declare::__private::throw_illegal_invocation(scope);
@@ -1833,7 +1811,7 @@ mod tests {
#[test]
fn inherited_receiver_cannot_silently_skip_an_already_built_getter() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object", receiver = check)]
+ #[webapi(record, receiver = check)]
struct Invalid {
#[webapi(accessor_property, getter_value = self.getter)]
getter: (),
@@ -1846,7 +1824,7 @@ mod tests {
#[test]
fn declaration_only_field_attributes_are_rejected() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object")]
+ #[webapi(record)]
struct BadObject {
#[webapi(init = "null")]
ignored: (),
@@ -1865,7 +1843,7 @@ mod tests {
#[test]
fn default_data_property_fields_can_use_data_property_initializers() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct DefaultObject {
#[webapi(init = "null")]
value: (),
@@ -1877,7 +1855,7 @@ mod tests {
#[test]
fn object_generated_constructor_defaults_to_new_for_dynamic_fields() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object")]
+ #[webapi(record)]
struct DynamicObject {
#[webapi(data_property, init = true)]
brand: (),
@@ -1896,7 +1874,7 @@ mod tests {
#[test]
fn object_generated_constructor_defaults_to_new_for_unit_fields() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object")]
+ #[webapi(record)]
struct StaticObject {
#[webapi(data_property, init = true)]
brand: (),
@@ -1915,7 +1893,7 @@ mod tests {
#[test]
fn object_generated_constructor_uses_constructor_defaults() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object")]
+ #[webapi(record)]
struct DefaultedObject {
#[webapi(data_property)]
value: u32,
@@ -1939,7 +1917,7 @@ mod tests {
#[test]
fn object_generated_constructor_defaults_can_reference_previous_fields() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object")]
+ #[webapi(record)]
struct DerivedDefaultObject {
#[webapi(data_property)]
client_x: i32,
@@ -1958,7 +1936,7 @@ mod tests {
#[test]
fn object_generated_constructor_can_be_suppressed() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object", no_dynamic_constructor)]
+ #[webapi(record, no_dynamic_constructor)]
struct ManualObject {
#[webapi(data_property)]
value: u32,
@@ -2043,7 +2021,7 @@ mod tests {
#[test]
fn object_intrinsic_data_properties_are_rejected() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object")]
+ #[webapi(record)]
struct BadObject {
#[webapi(
intrinsic_data_property = v8::Intrinsic::ArrayProtoValues
@@ -2137,7 +2115,7 @@ mod tests {
#[test]
fn object_readonly_accessor_property_fields_are_rejected() {
let input = syn::parse_quote! {
- #[webapi(interface = "Sample")]
+ #[webapi(interface = interfaces::Sample)]
struct BadObject {
#[webapi(accessor_property, getter = sample_getter, readonly)]
value: (),
@@ -2156,7 +2134,7 @@ mod tests {
#[test]
fn object_accessor_property_rejects_callback_and_getter_value_together() {
let input = syn::parse_quote! {
- #[webapi(interface = "Sample")]
+ #[webapi(interface = interfaces::Sample)]
struct BadObject<'scope> {
getter: ::moli_webapi_declare::v8::Local<'scope, ::moli_webapi_declare::v8::Function>,
#[webapi(accessor_property, getter = sample_getter, getter_value = self.getter)]
@@ -2176,7 +2154,7 @@ mod tests {
#[test]
fn object_native_data_property_fields_are_supported() {
let input = syn::parse_quote! {
- #[webapi(interface = "Sample", enumerable)]
+ #[webapi(interface = interfaces::Sample, enumerable)]
struct SampleObject {
#[webapi(native_data_property, getter = sample_getter)]
value: (),
@@ -2190,7 +2168,7 @@ mod tests {
#[test]
fn object_readonly_native_data_property_fields_are_rejected() {
let input = syn::parse_quote! {
- #[webapi(interface = "Sample")]
+ #[webapi(interface = interfaces::Sample)]
struct BadObject {
#[webapi(native_data_property, getter = sample_getter, readonly)]
value: (),
@@ -2209,7 +2187,7 @@ mod tests {
#[test]
fn object_static_method_fields_are_rejected() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct BadObject {
#[webapi(static_method, callback = sample_callback)]
create: (),
@@ -2228,7 +2206,7 @@ mod tests {
#[test]
fn object_constant_fields_are_supported() {
let input = syn::parse_quote! {
- #[webapi(interface = "Object", data_properties)]
+ #[webapi(record, data_properties)]
struct BadObject {
#[webapi(constant = "READY", value = 4u32)]
ready: (),
diff --git a/moli-webapi-declare-derive/src/lib.rs b/moli-webapi-declare-derive/src/lib.rs
index fccb31505..233410a66 100644
--- a/moli-webapi-declare-derive/src/lib.rs
+++ b/moli-webapi-declare-derive/src/lib.rs
@@ -29,6 +29,11 @@ pub fn derive_webapi_function_template(input: TokenStream) -> TokenStream {
/// Derives a Web API object declaration binder.
///
+/// Choose `interface = NativeType` for native identity, `record` for a plain
+/// object, or `fragment` for shared initialization without implicit identity or
+/// prototype changes. Empty declarations and a single scope lifetime require
+/// no additional flags.
+///
/// Each annotated field selects one installation path: JavaScript own data
/// property, WebIDL constant, method, JavaScript accessor property, V8 native
/// data property, non-enumerable hidden property, V8 private slot, runtime
diff --git a/moli-webapi-declare/src/declaration.rs b/moli-webapi-declare/src/declaration.rs
index 918ee96d5..a1b195df1 100644
--- a/moli-webapi-declare/src/declaration.rs
+++ b/moli-webapi-declare/src/declaration.rs
@@ -1,6 +1,4 @@
-use crate::{
- __private, BindError, WebApiObject, define_to_string_tag, set_interface_prototype, v8,
-};
+use crate::{__private, BindError, WebApiObject, v8};
/// Binds a constructor-backed Web API V8 function template.
///
@@ -27,17 +25,14 @@ pub trait WebApiFunctionTemplateDeclaration {
);
}
-/// Binds a Web API object instance or object-like shell.
+/// Binds a native instance, plain record, or shared initialization fragment.
///
/// Implementations are generated by `#[derive(WebApiObject)]`. `initialize`
/// installs only the fields that are explicitly declared as properties, methods,
/// hidden properties, private slots, prototype values, or toStringTag values.
-/// `bind_into` additionally applies the declared interface prototype and object
+/// `bind_into` additionally applies the role's prototype policy and declared object
/// tag. `bind` creates a fresh V8 object and then delegates to `bind_into`.
pub trait WebApiObjectDeclaration<'s> {
- const INTERFACE: &'static str;
- const OWN_TO_STRING_TAG: Option<&'static str>;
-
fn initialize(
&self,
scope: &mut v8::PinScope<'s, '_>,
@@ -48,33 +43,18 @@ pub trait WebApiObjectDeclaration<'s> {
&self,
scope: &mut v8::PinScope<'s, '_>,
object: v8::Local<'s, v8::Object>,
- ) -> Result<(), BindError> {
- let _ = set_interface_prototype(scope, object, Self::INTERFACE);
- if let Some(tag) = Self::OWN_TO_STRING_TAG {
- define_to_string_tag(scope, object, tag);
- }
- self.initialize(scope, object)
- }
+ ) -> Result<(), BindError>;
fn bind(
&self,
scope: &mut v8::PinScope<'s, '_>,
- ) -> Result<v8::Local<'s, v8::Object>, BindError> {
- let object = v8::Object::new(scope);
- self.bind_into(scope, object)?;
- Ok(object)
- }
+ ) -> Result<v8::Local<'s, v8::Object>, BindError>;
}
/// Declares the descriptor object returned by native named/indexed property
/// descriptor interceptors for data properties.
#[derive(WebApiObject)]
-#[webapi(
- interface = "Object",
- data_properties,
- enumerable,
- no_dynamic_constructor
-)]
+#[webapi(record, data_properties, enumerable, no_dynamic_constructor)]
pub struct DataPropertyDescriptorDeclaration<'scope> {
value: v8::Local<'scope, v8::Value>,
enumerable: bool,
diff --git a/moli-webapi-declare/src/lib.rs b/moli-webapi-declare/src/lib.rs
index d89c5a1e4..571b9301d 100644
--- a/moli-webapi-declare/src/lib.rs
+++ b/moli-webapi-declare/src/lib.rs
@@ -84,21 +84,33 @@
//! `data = self.some_field`, which lets a declaration carry callback data
//! without expanding the object reflection surface.
//!
-//! Named interface instances automatically receive a private Web API type after
-//! their fields initialize successfully. `bind`, `bind_into`, and `initialize`
-//! all use this path. `interface = "Object"` describes an unbranded record;
-//! `#[webapi(unbranded)]` explicitly opts named prototype/constructor installers,
-//! dictionaries, and shared initialization fragments out of instance branding.
-//! These fragments never erase an identity already present on their target.
-//! Use payload slots for data, handles, ownership, and lifecycle state instead
-//! of maintaining separate boolean brands. A named native declaration can use
-//! `prototype = "Object"` to preserve an existing plain public prototype while
-//! still assigning native identity.
+//! Object declarations choose one role:
+//!
+//! - `#[webapi(interface = interfaces::Event)]` creates a native instance. It
+//! receives private identity after its fields initialize successfully, whether
+//! called through `bind`, `bind_into`, or `initialize`. Its default prototype
+//! comes from the descriptor; an explicit `prototype` can preserve another
+//! public shape without changing native identity.
+//! - `#[webapi(record)]` describes an ordinary unbranded object, defaulting to
+//! `Object.prototype`. Field annotations and `data_properties` still control
+//! which Rust fields become JavaScript properties.
+//! - `#[webapi(fragment)]` installs shared state or members on an existing
+//! target. It assigns no identity and has no implicit prototype. Explicit
+//! prototype or tag declarations are applied by `bind_into`; `initialize`
+//! installs only the declared fields. Fragments never erase native identity.
+//!
+//! Empty declarations need no special opt-in: creating an empty record, branding
+//! a native instance and installing prototype metadata all have defined roles.
+//! A single lifetime parameter is inferred as the V8 scope lifetime; use
+//! `scope_lifetime` only when a declaration has multiple lifetimes. Payload slots
+//! hold data, ownership and lifecycle state, not additional boolean brands.
+//! Explicit prototype and tag expressions can use `Type::DESCRIPTOR.name()`
+//! to share names with generated interface metadata.
//!
//! Implementation sharing does not imply interface inheritance. For example,
//! encoding streams share TransformStream internals but have distinct native
//! interfaces. Their factory assigns the concrete type while the shared state
-//! fragment stays unbranded. Do not opt actual instances out of branding to
+//! declaration uses `fragment`. Do not turn actual native instances into records to
//! make them pass structured clone.
//!
//! Declare each interface once with `declare_web_api_interfaces!` and reference
diff --git a/moli-webapi-declare/tests/brand.rs b/moli-webapi-declare/tests/brand.rs
index 8daa6f4f5..d8a233821 100644
--- a/moli-webapi-declare/tests/brand.rs
+++ b/moli-webapi-declare/tests/brand.rs
@@ -7,21 +7,21 @@ use moli_webapi_declare::{
};
#[derive(WebApiObject)]
-#[webapi(interface = interfaces::TestBase, allow_empty)]
+#[webapi(interface = interfaces::TestBase)]
struct Base {}
#[derive(WebApiObject)]
-#[webapi(interface = interfaces::TestDerived, allow_empty)]
+#[webapi(interface = interfaces::TestDerived)]
struct Derived {}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct Record {
value: u32,
}
#[derive(WebApiObject)]
-#[webapi(interface = interfaces::TestBase, unbranded, allow_empty)]
+#[webapi(fragment, prototype = <interfaces::TestBase>::DESCRIPTOR.name())]
struct PrototypeMembers {}
fn eval<'s>(scope: &mut v8::PinScope<'s, '_>, source: &str) -> v8::Local<'s, v8::Value> {
@@ -220,7 +220,7 @@ fn only_explicitly_registered_native_proxies_share_target_identity() {
}
#[derive(moli_webapi_declare::WebApiFunctionTemplate)]
-#[webapi(name = "TestBase", receiver = "TestBase")]
+#[webapi(interface = interfaces::TestBase, receiver)]
struct CheckedBaseTemplate {
#[webapi(method, callback = convert_argument)]
convert: (),
@@ -342,3 +342,37 @@ fn cyclic_native_descriptors_fail_during_registration() {
.contains("cycle")
);
}
+
+#[derive(WebApiObject)]
+#[webapi(fragment)]
+struct SharedState {
+ #[webapi(slot = "__sharedState")]
+ value: u32,
+}
+
+#[test]
+fn shared_fragments_preserve_target_identity_and_prototype() {
+ ensure_v8();
+ let mut isolate = v8::Isolate::new(Default::default());
+ let scope = pin!(v8::HandleScope::new(&mut isolate));
+ let scope = &mut scope.init();
+ let context = v8::Context::new(scope, Default::default());
+ let scope = &mut v8::ContextScope::new(scope, context);
+ let real = Derived::new().bind(scope).unwrap();
+ let prototype = v8::Object::new(scope);
+ real.set_prototype(scope, prototype.into()).unwrap();
+ SharedState::new(7).bind_into(scope, real).unwrap();
+ assert!(
+ real.get_prototype(scope)
+ .unwrap()
+ .strict_equals(prototype.into())
+ );
+ assert!(interfaces::TestDerived::is_instance(scope, real));
+ assert!(interfaces::TestBase::is_instance(scope, real));
+ assert_eq!(
+ moli_v8_util::get_private_value(scope, real, "__sharedState")
+ .unwrap()
+ .uint32_value(scope),
+ Some(7)
+ );
+}
diff --git a/moli-webapi-declare/tests/declare.rs b/moli-webapi-declare/tests/declare.rs
index 547d53e9d..bb9691b56 100644
--- a/moli-webapi-declare/tests/declare.rs
+++ b/moli-webapi-declare/tests/declare.rs
@@ -267,7 +267,7 @@ struct SampleLocalObjectSlot<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct GeneratedConstructorObject<'scope> {
#[webapi(data_property, init = true)]
brand: (),
@@ -280,7 +280,7 @@ struct GeneratedConstructorObject<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NestedValueRecord {
#[webapi(data_property, enumerable)]
name: &'static str,
@@ -290,7 +290,7 @@ struct NestedValueRecord {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct DefaultNameObject<'scope> {
#[webapi(data_property, enumerable)]
_visible_label: &'static str,
@@ -351,7 +351,7 @@ struct DefaultNameObject<'scope> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct AliasObject {
#[webapi(method, enumerable, length = 0, callback = sample_now_callback)]
entries: (),
@@ -361,7 +361,7 @@ struct AliasObject {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ConstantObject {
#[webapi(constant = "READY", value = 4u32)]
ready: (),
@@ -462,7 +462,7 @@ struct IntrinsicIteratorTemplateDeclaration {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct ExplicitFunctionNameSymbolMethodObject {
#[webapi(
method,
@@ -474,14 +474,14 @@ struct ExplicitFunctionNameSymbolMethodObject {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct NativeDataPropertyObject {
#[webapi(native_data_property, getter = sample_native_holder_getter)]
native_holder: (),
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", enumerable)]
+#[webapi(record, enumerable)]
struct DefaultEnumerableMembersObject {
#[webapi(data_property)]
property_value: &'static str,
@@ -501,7 +501,7 @@ struct DefaultEnumerableMembersObject {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", data_properties, enumerable)]
+#[webapi(record, data_properties, enumerable)]
struct DefaultEnumerablePropertiesObject {
client_x: f64,
is_2d: bool,
@@ -516,7 +516,7 @@ struct PrototypeBackedEnumerablePropertiesObject {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", rename_all = "none", data_properties, enumerable)]
+#[webapi(record, rename_all = "none", data_properties, enumerable)]
struct ExplicitSnakeCasePropertiesObject {
snake_case_name: &'static str,
}
@@ -526,32 +526,23 @@ struct ExplicitSnakeCasePropertiesObject {
interface = interfaces::SamplePerformance,
own_to_string_tag = "ReadonlySample",
readonly_to_string_tag,
- allow_empty
)]
struct ReadonlyTagObject {}
#[derive(WebApiObject)]
-#[webapi(interface = interfaces::MissingSampleInterface, require_prototype, allow_empty)]
+#[webapi(interface = interfaces::MissingSampleInterface, require_prototype)]
struct RequiredPrototypeObject {}
#[derive(WebApiObject)]
-#[webapi(
- interface = "Object",
- prototype = "SamplePerformance",
- require_prototype
-)]
+#[webapi(record, prototype = "SamplePerformance", require_prototype)]
struct PrototypeOnlyObject {}
#[derive(WebApiObject)]
-#[webapi(
- interface = "Object",
- prototype = "MissingSampleInterface",
- require_prototype
-)]
+#[webapi(record, prototype = "MissingSampleInterface", require_prototype)]
struct MissingPrototypeOnlyObject {}
#[derive(WebApiObject)]
-#[webapi(interface = "Object", scope_lifetime = 'scope)]
+#[webapi(record, scope_lifetime = 'scope)]
struct RuntimePrototypeTaggedObject<'scope, 'tag> {
#[webapi(prototype)]
prototype: v8::Local<'scope, v8::Object>,
@@ -561,14 +552,14 @@ struct RuntimePrototypeTaggedObject<'scope, 'tag> {
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct RuntimeTagOnlyObject<'tag> {
#[webapi(to_string_tag)]
to_string_tag: Option<&'tag str>,
}
#[derive(WebApiObject)]
-#[webapi(interface = "Object")]
+#[webapi(record)]
struct RuntimeReadonlyLockedTagObject {
#[webapi(to_string_tag, readonly, dont_delete, init = string("LockedRuntimeTag"))]
to_string_tag: (),
@@ -578,7 +569,6 @@ struct RuntimeReadonlyLockedTagObject {
#[webapi(
interface = interfaces::SamplePerformance,
fallback_to_string_tag = "SampleFallback",
- allow_empty
)]
struct PrototypeBackedFallbackTagObject {}
@@ -586,7 +576,6 @@ struct PrototypeBackedFallbackTagObject {}
#[webapi(
interface = interfaces::MissingSampleInterface,
fallback_to_string_tag = "MissingSample",
- allow_empty
)]
struct MissingPrototypeFallbackTagObject {}