1 module spasm.bindings.notifications; 2 3 import spasm.types; 4 import spasm.bindings.common; 5 import spasm.bindings.dom; 6 import spasm.bindings.html; 7 import spasm.bindings.serviceworker; 8 import spasm.bindings.vibration; 9 10 @safe: 11 nothrow: 12 13 struct GetNotificationOptions { 14 nothrow: 15 JsHandle handle; 16 alias handle this; 17 this(Handle h) { 18 this.handle = JsHandle(h); 19 } 20 static auto create() { 21 return GetNotificationOptions(spasm_add__object()); 22 } 23 void tag()(string tag) { 24 GetNotificationOptions_tag_Set(this.handle, tag); 25 } 26 auto tag()() { 27 return GetNotificationOptions_tag_Get(this.handle); 28 } 29 } 30 struct Notification { 31 nothrow: 32 spasm.bindings.dom.EventTarget _parent; 33 alias _parent this; 34 this(Handle h) { 35 _parent = .EventTarget(h); 36 } 37 void permission()(NotificationPermission permission) { 38 Notification_permission_Set(this._parent, permission); 39 } 40 auto permission()() { 41 return Notification_permission_Get(this._parent); 42 } 43 auto requestPermission()(NotificationPermissionCallback deprecatedCallback) { 44 return Promise!(NotificationPermission)(Notification_requestPermission(this._parent, deprecatedCallback)); 45 } 46 auto requestPermission()() { 47 return Promise!(NotificationPermission)(Notification_requestPermission_0(this._parent)); 48 } 49 void maxActions()(uint maxActions) { 50 Notification_maxActions_Set(this._parent, maxActions); 51 } 52 auto maxActions()() { 53 return Notification_maxActions_Get(this._parent); 54 } 55 void onclick()(EventHandler onclick) { 56 Notification_onclick_Set(this._parent, onclick); 57 } 58 auto onclick()() { 59 return Notification_onclick_Get(this._parent); 60 } 61 void onshow()(EventHandler onshow) { 62 Notification_onshow_Set(this._parent, onshow); 63 } 64 auto onshow()() { 65 return Notification_onshow_Get(this._parent); 66 } 67 void onerror()(EventHandler onerror) { 68 Notification_onerror_Set(this._parent, onerror); 69 } 70 auto onerror()() { 71 return Notification_onerror_Get(this._parent); 72 } 73 void onclose()(EventHandler onclose) { 74 Notification_onclose_Set(this._parent, onclose); 75 } 76 auto onclose()() { 77 return Notification_onclose_Get(this._parent); 78 } 79 auto title()() { 80 return Notification_title_Get(this._parent); 81 } 82 auto dir()() { 83 return Notification_dir_Get(this._parent); 84 } 85 auto lang()() { 86 return Notification_lang_Get(this._parent); 87 } 88 auto body_()() { 89 return Notification_body_Get(this._parent); 90 } 91 auto tag()() { 92 return Notification_tag_Get(this._parent); 93 } 94 auto image()() { 95 return Notification_image_Get(this._parent); 96 } 97 auto icon()() { 98 return Notification_icon_Get(this._parent); 99 } 100 auto badge()() { 101 return Notification_badge_Get(this._parent); 102 } 103 auto vibrate()() { 104 return FrozenArray!(uint)(Notification_vibrate_Get(this._parent)); 105 } 106 auto timestamp()() { 107 return Notification_timestamp_Get(this._parent); 108 } 109 auto renotify()() { 110 return Notification_renotify_Get(this._parent); 111 } 112 auto silent()() { 113 return Notification_silent_Get(this._parent); 114 } 115 auto requireInteraction()() { 116 return Notification_requireInteraction_Get(this._parent); 117 } 118 auto data()() { 119 return Any(Notification_data_Get(this._parent)); 120 } 121 auto actions()() { 122 return FrozenArray!(NotificationAction)(Notification_actions_Get(this._parent)); 123 } 124 void close()() { 125 Notification_close(this._parent); 126 } 127 } 128 struct NotificationAction { 129 nothrow: 130 JsHandle handle; 131 alias handle this; 132 this(Handle h) { 133 this.handle = JsHandle(h); 134 } 135 static auto create() { 136 return NotificationAction(spasm_add__object()); 137 } 138 void action()(string action) { 139 NotificationAction_action_Set(this.handle, action); 140 } 141 auto action()() { 142 return NotificationAction_action_Get(this.handle); 143 } 144 void title()(string title) { 145 NotificationAction_title_Set(this.handle, title); 146 } 147 auto title()() { 148 return NotificationAction_title_Get(this.handle); 149 } 150 void icon()(string icon) { 151 NotificationAction_icon_Set(this.handle, icon); 152 } 153 auto icon()() { 154 return NotificationAction_icon_Get(this.handle); 155 } 156 } 157 enum NotificationDirection { 158 auto_, 159 ltr, 160 rtl 161 } 162 struct NotificationEvent { 163 nothrow: 164 spasm.bindings.serviceworker.ExtendableEvent _parent; 165 alias _parent this; 166 this(Handle h) { 167 _parent = .ExtendableEvent(h); 168 } 169 auto notification()() { 170 return Notification(NotificationEvent_notification_Get(this._parent)); 171 } 172 auto action()() { 173 return NotificationEvent_action_Get(this._parent); 174 } 175 } 176 struct NotificationEventInit { 177 nothrow: 178 spasm.bindings.serviceworker.ExtendableEventInit _parent; 179 alias _parent this; 180 this(Handle h) { 181 _parent = .ExtendableEventInit(h); 182 } 183 static auto create() { 184 return NotificationEventInit(spasm_add__object()); 185 } 186 void notification()(scope ref Notification notification) { 187 NotificationEventInit_notification_Set(this._parent, notification.handle); 188 } 189 auto notification()() { 190 return Notification(NotificationEventInit_notification_Get(this._parent)); 191 } 192 void action()(string action) { 193 NotificationEventInit_action_Set(this._parent, action); 194 } 195 auto action()() { 196 return NotificationEventInit_action_Get(this._parent); 197 } 198 } 199 struct NotificationOptions { 200 nothrow: 201 JsHandle handle; 202 alias handle this; 203 this(Handle h) { 204 this.handle = JsHandle(h); 205 } 206 static auto create() { 207 return NotificationOptions(spasm_add__object()); 208 } 209 void dir()(NotificationDirection dir) { 210 NotificationOptions_dir_Set(this.handle, dir); 211 } 212 auto dir()() { 213 return NotificationOptions_dir_Get(this.handle); 214 } 215 void lang()(string lang) { 216 NotificationOptions_lang_Set(this.handle, lang); 217 } 218 auto lang()() { 219 return NotificationOptions_lang_Get(this.handle); 220 } 221 void body_()(string body_) { 222 NotificationOptions_body_Set(this.handle, body_); 223 } 224 auto body_()() { 225 return NotificationOptions_body_Get(this.handle); 226 } 227 void tag()(string tag) { 228 NotificationOptions_tag_Set(this.handle, tag); 229 } 230 auto tag()() { 231 return NotificationOptions_tag_Get(this.handle); 232 } 233 void image()(string image) { 234 NotificationOptions_image_Set(this.handle, image); 235 } 236 auto image()() { 237 return NotificationOptions_image_Get(this.handle); 238 } 239 void icon()(string icon) { 240 NotificationOptions_icon_Set(this.handle, icon); 241 } 242 auto icon()() { 243 return NotificationOptions_icon_Get(this.handle); 244 } 245 void badge()(string badge) { 246 NotificationOptions_badge_Set(this.handle, badge); 247 } 248 auto badge()() { 249 return NotificationOptions_badge_Get(this.handle); 250 } 251 void vibrate()(scope ref VibratePattern vibrate) { 252 NotificationOptions_vibrate_Set(this.handle, vibrate); 253 } 254 auto vibrate()() { 255 return NotificationOptions_vibrate_Get(this.handle); 256 } 257 void timestamp()(uint timestamp) { 258 NotificationOptions_timestamp_Set(this.handle, timestamp); 259 } 260 auto timestamp()() { 261 return NotificationOptions_timestamp_Get(this.handle); 262 } 263 void renotify()(bool renotify) { 264 NotificationOptions_renotify_Set(this.handle, renotify); 265 } 266 auto renotify()() { 267 return NotificationOptions_renotify_Get(this.handle); 268 } 269 void silent()(bool silent) { 270 NotificationOptions_silent_Set(this.handle, silent); 271 } 272 auto silent()() { 273 return NotificationOptions_silent_Get(this.handle); 274 } 275 void requireInteraction()(bool requireInteraction) { 276 NotificationOptions_requireInteraction_Set(this.handle, requireInteraction); 277 } 278 auto requireInteraction()() { 279 return NotificationOptions_requireInteraction_Get(this.handle); 280 } 281 void data(T0)(scope auto ref T0 data) { 282 Handle _handle_data = getOrCreateHandle(data); 283 NotificationOptions_data_Set(this.handle, _handle_data); 284 dropHandle!(T0)(_handle_data); 285 } 286 auto data()() { 287 return Any(NotificationOptions_data_Get(this.handle)); 288 } 289 void actions()(scope ref Sequence!(NotificationAction) actions) { 290 NotificationOptions_actions_Set(this.handle, actions.handle); 291 } 292 auto actions()() { 293 return Sequence!(NotificationAction)(NotificationOptions_actions_Get(this.handle)); 294 } 295 } 296 enum NotificationPermission { 297 default_, 298 denied, 299 granted 300 } 301 alias NotificationPermissionCallback = void delegate(NotificationPermission); 302 303 304 extern (C) void GetNotificationOptions_tag_Set(Handle, string); 305 extern (C) string GetNotificationOptions_tag_Get(Handle); 306 extern (C) void Notification_permission_Set(Handle, NotificationPermission); 307 extern (C) NotificationPermission Notification_permission_Get(Handle); 308 extern (C) Handle Notification_requestPermission(Handle, NotificationPermissionCallback); 309 extern (C) Handle Notification_requestPermission_0(Handle); 310 extern (C) void Notification_maxActions_Set(Handle, uint); 311 extern (C) uint Notification_maxActions_Get(Handle); 312 extern (C) void Notification_onclick_Set(Handle, EventHandler); 313 extern (C) EventHandler Notification_onclick_Get(Handle); 314 extern (C) void Notification_onshow_Set(Handle, EventHandler); 315 extern (C) EventHandler Notification_onshow_Get(Handle); 316 extern (C) void Notification_onerror_Set(Handle, EventHandler); 317 extern (C) EventHandler Notification_onerror_Get(Handle); 318 extern (C) void Notification_onclose_Set(Handle, EventHandler); 319 extern (C) EventHandler Notification_onclose_Get(Handle); 320 extern (C) string Notification_title_Get(Handle); 321 extern (C) NotificationDirection Notification_dir_Get(Handle); 322 extern (C) string Notification_lang_Get(Handle); 323 extern (C) string Notification_body_Get(Handle); 324 extern (C) string Notification_tag_Get(Handle); 325 extern (C) string Notification_image_Get(Handle); 326 extern (C) string Notification_icon_Get(Handle); 327 extern (C) string Notification_badge_Get(Handle); 328 extern (C) Handle Notification_vibrate_Get(Handle); 329 extern (C) uint Notification_timestamp_Get(Handle); 330 extern (C) bool Notification_renotify_Get(Handle); 331 extern (C) bool Notification_silent_Get(Handle); 332 extern (C) bool Notification_requireInteraction_Get(Handle); 333 extern (C) Handle Notification_data_Get(Handle); 334 extern (C) Handle Notification_actions_Get(Handle); 335 extern (C) void Notification_close(Handle); 336 extern (C) void NotificationAction_action_Set(Handle, string); 337 extern (C) string NotificationAction_action_Get(Handle); 338 extern (C) void NotificationAction_title_Set(Handle, string); 339 extern (C) string NotificationAction_title_Get(Handle); 340 extern (C) void NotificationAction_icon_Set(Handle, string); 341 extern (C) string NotificationAction_icon_Get(Handle); 342 extern (C) Handle NotificationEvent_notification_Get(Handle); 343 extern (C) string NotificationEvent_action_Get(Handle); 344 extern (C) void NotificationEventInit_notification_Set(Handle, Handle); 345 extern (C) Handle NotificationEventInit_notification_Get(Handle); 346 extern (C) void NotificationEventInit_action_Set(Handle, string); 347 extern (C) string NotificationEventInit_action_Get(Handle); 348 extern (C) void NotificationOptions_dir_Set(Handle, NotificationDirection); 349 extern (C) NotificationDirection NotificationOptions_dir_Get(Handle); 350 extern (C) void NotificationOptions_lang_Set(Handle, string); 351 extern (C) string NotificationOptions_lang_Get(Handle); 352 extern (C) void NotificationOptions_body_Set(Handle, string); 353 extern (C) string NotificationOptions_body_Get(Handle); 354 extern (C) void NotificationOptions_tag_Set(Handle, string); 355 extern (C) string NotificationOptions_tag_Get(Handle); 356 extern (C) void NotificationOptions_image_Set(Handle, string); 357 extern (C) string NotificationOptions_image_Get(Handle); 358 extern (C) void NotificationOptions_icon_Set(Handle, string); 359 extern (C) string NotificationOptions_icon_Get(Handle); 360 extern (C) void NotificationOptions_badge_Set(Handle, string); 361 extern (C) string NotificationOptions_badge_Get(Handle); 362 extern (C) void NotificationOptions_vibrate_Set(Handle, scope ref VibratePattern); 363 extern (C) VibratePattern NotificationOptions_vibrate_Get(Handle); 364 extern (C) void NotificationOptions_timestamp_Set(Handle, uint); 365 extern (C) uint NotificationOptions_timestamp_Get(Handle); 366 extern (C) void NotificationOptions_renotify_Set(Handle, bool); 367 extern (C) bool NotificationOptions_renotify_Get(Handle); 368 extern (C) void NotificationOptions_silent_Set(Handle, bool); 369 extern (C) bool NotificationOptions_silent_Get(Handle); 370 extern (C) void NotificationOptions_requireInteraction_Set(Handle, bool); 371 extern (C) bool NotificationOptions_requireInteraction_Get(Handle); 372 extern (C) void NotificationOptions_data_Set(Handle, Handle); 373 extern (C) Handle NotificationOptions_data_Get(Handle); 374 extern (C) void NotificationOptions_actions_Set(Handle, Handle); 375 extern (C) Handle NotificationOptions_actions_Get(Handle);