1 module libwasm.bindings.ServiceWorkerRegistration; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.EventHandler; 7 import libwasm.bindings.EventTarget; 8 import libwasm.bindings.Notification; 9 import libwasm.bindings.PushManager; 10 import libwasm.bindings.ServiceWorker; 11 12 @safe: 13 nothrow: 14 15 struct ServiceWorkerRegistration { 16 nothrow: 17 libwasm.bindings.EventTarget.EventTarget _parent; 18 alias _parent this; 19 this(Handle h) { 20 _parent = .EventTarget(h); 21 } 22 auto installing()() { 23 return recastOpt!(ServiceWorker)(Object_Getter__OptionalHandle(this._parent, "installing")); 24 } 25 auto waiting()() { 26 return recastOpt!(ServiceWorker)(Object_Getter__OptionalHandle(this._parent, "waiting")); 27 } 28 auto active()() { 29 return recastOpt!(ServiceWorker)(Object_Getter__OptionalHandle(this._parent, "active")); 30 } 31 string scope_()() { 32 return Object_Getter__string(this._parent, "scope"); 33 } 34 ServiceWorkerUpdateViaCache updateViaCache()() { 35 return Object_Getter__int(this._parent, "updateViaCache"); 36 } 37 auto update()() { 38 return JsPromise!(void)(Object_Getter__Handle(this._parent, "update")); 39 } 40 auto unregister()() { 41 return JsPromise!(bool)(Object_Getter__Handle(this._parent, "unregister")); 42 } 43 void onupdatefound(T0)(scope auto ref Optional!(T0) onupdatefound) if (isTOrPointer!(T0, EventHandlerNonNull)) { 44 Object_Call_EventHandler__void(this._parent, "onupdatefound", !onupdatefound.empty, onupdatefound.front); 45 } 46 EventHandler onupdatefound()() { 47 return Object_Getter__EventHandler(this._parent, "onupdatefound"); 48 } 49 auto pushManager()() { 50 return PushManager(Object_Getter__Handle(this._parent, "pushManager")); 51 } 52 auto showNotification()(string title, scope ref NotificationOptions options) { 53 return JsPromise!(void)(Serialize_Object_VarArgCall!Handle(this._parent, "showNotification", "string;Handle", tuple(title, cast(Handle)options.handle))); 54 } 55 auto showNotification()(string title) { 56 return JsPromise!(void)(Object_Call_string__Handle(this._parent, "showNotification", title)); 57 } 58 auto getNotifications()(scope ref GetNotificationOptions filter) { 59 return JsPromise!(Sequence!(Notification))(Object_Call_Handle__Handle(this._parent, "getNotifications", filter.handle)); 60 } 61 auto getNotifications()() { 62 return JsPromise!(Sequence!(Notification))(Object_Getter__Handle(this._parent, "getNotifications")); 63 } 64 } 65 enum ServiceWorkerUpdateViaCache { 66 imports, 67 all, 68 none 69 } 70 71