1 module libwasm.bindings.MutationObserver; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.Animation; 7 import libwasm.bindings.Node; 8 import libwasm.bindings.NodeList; 9 10 @safe: 11 nothrow: 12 13 alias MutationCallback = void delegate(Sequence!(MutationRecord), MutationObserver); 14 struct MutationObserver { 15 nothrow: 16 JsHandle handle; 17 alias handle this; 18 this(Handle h) { 19 this.handle = JsHandle(h); 20 } 21 void observe()(scope ref Node target, scope ref MutationObserverInit options) { 22 Serialize_Object_VarArgCall!void(this.handle, "observe", "Handle;Handle", tuple(cast(Handle)target._parent, cast(Handle)options.handle)); 23 } 24 void observe()(scope ref Node target) { 25 Object_Call_Handle__void(this.handle, "observe", target._parent); 26 } 27 void disconnect()() { 28 Object_Call__void(this.handle, "disconnect"); 29 } 30 auto takeRecords()() { 31 return Sequence!(MutationRecord)(Object_Getter__Handle(this.handle, "takeRecords")); 32 } 33 auto getObservingInfo()() { 34 return Sequence!(Optional!(MutationObservingInfo))(Object_Getter__Handle(this.handle, "getObservingInfo")); 35 } 36 MutationCallback mutationCallback()() { 37 return MutationObserver_mutationCallback_Get(this.handle); 38 } 39 void mergeAttributeRecords()(bool mergeAttributeRecords) { 40 Object_Call_bool__void(this.handle, "mergeAttributeRecords", mergeAttributeRecords); 41 } 42 bool mergeAttributeRecords()() { 43 return Object_Getter__bool(this.handle, "mergeAttributeRecords"); 44 } 45 } 46 struct MutationObserverInit { 47 nothrow: 48 JsHandle handle; 49 alias handle this; 50 this(Handle h) { 51 this.handle = JsHandle(h); 52 } 53 static auto create() { 54 return MutationObserverInit(libwasm_add__object()); 55 } 56 void childList()(bool childList) { 57 Object_Call_bool__void(this.handle, "childList", childList); 58 } 59 bool childList()() { 60 return Object_Getter__bool(this.handle, "childList"); 61 } 62 void attributes()(bool attributes) { 63 Object_Call_bool__void(this.handle, "attributes", attributes); 64 } 65 bool attributes()() { 66 return Object_Getter__bool(this.handle, "attributes"); 67 } 68 void characterData()(bool characterData) { 69 Object_Call_bool__void(this.handle, "characterData", characterData); 70 } 71 bool characterData()() { 72 return Object_Getter__bool(this.handle, "characterData"); 73 } 74 void subtree()(bool subtree) { 75 Object_Call_bool__void(this.handle, "subtree", subtree); 76 } 77 bool subtree()() { 78 return Object_Getter__bool(this.handle, "subtree"); 79 } 80 void attributeOldValue()(bool attributeOldValue) { 81 Object_Call_bool__void(this.handle, "attributeOldValue", attributeOldValue); 82 } 83 bool attributeOldValue()() { 84 return Object_Getter__bool(this.handle, "attributeOldValue"); 85 } 86 void characterDataOldValue()(bool characterDataOldValue) { 87 Object_Call_bool__void(this.handle, "characterDataOldValue", characterDataOldValue); 88 } 89 bool characterDataOldValue()() { 90 return Object_Getter__bool(this.handle, "characterDataOldValue"); 91 } 92 void nativeAnonymousChildList()(bool nativeAnonymousChildList) { 93 Object_Call_bool__void(this.handle, "nativeAnonymousChildList", nativeAnonymousChildList); 94 } 95 bool nativeAnonymousChildList()() { 96 return Object_Getter__bool(this.handle, "nativeAnonymousChildList"); 97 } 98 void animations()(bool animations) { 99 Object_Call_bool__void(this.handle, "animations", animations); 100 } 101 bool animations()() { 102 return Object_Getter__bool(this.handle, "animations"); 103 } 104 void attributeFilter()(scope ref Sequence!(string) attributeFilter) { 105 Object_Call_Handle__void(this.handle, "attributeFilter", attributeFilter.handle); 106 } 107 auto attributeFilter()() { 108 return Sequence!(string)(Object_Getter__Handle(this.handle, "attributeFilter")); 109 } 110 } 111 struct MutationObservingInfo { 112 nothrow: 113 libwasm.bindings.MutationObserver.MutationObserverInit _parent; 114 alias _parent this; 115 this(Handle h) { 116 _parent = .MutationObserverInit(h); 117 } 118 static auto create() { 119 return MutationObservingInfo(libwasm_add__object()); 120 } 121 void observedNode(T0)(scope auto ref Optional!(T0) observedNode) if (isTOrPointer!(T0, Node)) { 122 Serialize_Object_VarArgCall!void(this._parent, "observedNode", "Optional!Handle", tuple(!observedNode.empty, cast(Handle)observedNode.front._parent)); 123 } 124 auto observedNode()() { 125 return recastOpt!(Node)(Object_Getter__OptionalHandle(this._parent, "observedNode")); 126 } 127 } 128 struct MutationRecord { 129 nothrow: 130 JsHandle handle; 131 alias handle this; 132 this(Handle h) { 133 this.handle = JsHandle(h); 134 } 135 string type()() { 136 return Object_Getter__string(this.handle, "type"); 137 } 138 auto target()() { 139 return recastOpt!(Node)(Object_Getter__OptionalHandle(this.handle, "target")); 140 } 141 auto addedNodes()() { 142 return NodeList(Object_Getter__Handle(this.handle, "addedNodes")); 143 } 144 auto removedNodes()() { 145 return NodeList(Object_Getter__Handle(this.handle, "removedNodes")); 146 } 147 auto previousSibling()() { 148 return recastOpt!(Node)(Object_Getter__OptionalHandle(this.handle, "previousSibling")); 149 } 150 auto nextSibling()() { 151 return recastOpt!(Node)(Object_Getter__OptionalHandle(this.handle, "nextSibling")); 152 } 153 Optional!(string) attributeName()() { 154 return Object_Getter__OptionalString(this.handle, "attributeName"); 155 } 156 Optional!(string) attributeNamespace()() { 157 return Object_Getter__OptionalString(this.handle, "attributeNamespace"); 158 } 159 Optional!(string) oldValue()() { 160 return Object_Getter__OptionalString(this.handle, "oldValue"); 161 } 162 auto addedAnimations()() { 163 return Sequence!(Animation)(Object_Getter__Handle(this.handle, "addedAnimations")); 164 } 165 auto changedAnimations()() { 166 return Sequence!(Animation)(Object_Getter__Handle(this.handle, "changedAnimations")); 167 } 168 auto removedAnimations()() { 169 return Sequence!(Animation)(Object_Getter__Handle(this.handle, "removedAnimations")); 170 } 171 } 172 173 174 extern (C) MutationCallback MutationObserver_mutationCallback_Get(Handle);