1 module libwasm.bindings.CustomElementRegistry;
2 
3 import libwasm.types;
4 
5 import memutils.ct: tuple;
6 import libwasm.bindings.Function;
7 import libwasm.bindings.Node;
8 
9 @safe:
10 nothrow:
11 
12 alias CustomElementCreationCallback = void delegate(string);
13 struct CustomElementRegistry {
14   nothrow:
15   JsHandle handle;
16   alias handle this;
17   this(Handle h) {
18     this.handle = JsHandle(h);
19   }
20   void define()(string name, Function functionConstructor, scope ref ElementDefinitionOptions options) {
21     CustomElementRegistry_define(this.handle, name, functionConstructor, options.handle);
22   }
23   void define()(string name, Function functionConstructor) {
24     CustomElementRegistry_define_0(this.handle, name, functionConstructor);
25   }
26   void setElementCreationCallback()(string name, CustomElementCreationCallback callback) {
27     CustomElementRegistry_setElementCreationCallback(this.handle, name, callback);
28   }
29   auto get()(string name) {
30     return Any(Object_Call_string__Handle(this.handle, "get", name));
31   }
32   auto whenDefined()(string name) {
33     return JsPromise!(void)(Object_Call_string__Handle(this.handle, "whenDefined", name));
34   }
35   void upgrade()(scope ref Node root) {
36     Object_Call_Handle__void(this.handle, "upgrade", root._parent);
37   }
38 }
39 struct ElementDefinitionOptions {
40   nothrow:
41   JsHandle handle;
42   alias handle this;
43   this(Handle h) {
44     this.handle = JsHandle(h);
45   }
46   static auto create() {
47     return ElementDefinitionOptions(libwasm_add__object());
48   }
49   void extends()(string extends) {
50     Object_Call_string__void(this.handle, "extends", extends);
51   }
52   string extends()() {
53     return Object_Getter__string(this.handle, "extends");
54   }
55 }
56 
57 
58 extern (C) void CustomElementRegistry_define(Handle, string, Function, Handle);
59 extern (C) void CustomElementRegistry_define_0(Handle, string, Function);
60 extern (C) void CustomElementRegistry_setElementCreationCallback(Handle, string, CustomElementCreationCallback);