Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

separating workers #69

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions Browser/Fable.Helpers.WebWorker.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
module Fable.Helpers.WebWorker
alfonsogarciacaro marked this conversation as resolved.
Show resolved Hide resolved

open Fable.Import.WebWorker

module Notification =
let emptyNotification() = Fable.Core.JsInterop.createEmpty<NotificationOptions>

let withActions actions (notification : NotificationOptions) =
notification.actions <- (Some actions)
notification

let withBadge badge (notification : NotificationOptions) =
notification.badge <- Some badge
notification

let withBody body (notification:NotificationOptions) =
notification.body <- Some body
notification

let withData data (notification:NotificationOptions) =
notification.data <- Some data
notification

let withDir dir (notification:NotificationOptions) =
notification.dir <- Some dir
notification

let withIcon icon (notification:NotificationOptions) =
notification.icon <- Some icon
notification

let withImage image (notification:NotificationOptions) =
notification.image <- Some image
notification

let withLang lang (notification:NotificationOptions) =
notification.lang <- Some lang
notification

let withRenotify renotify (notification:NotificationOptions) =
notification.renotify <- Some renotify
notification

let withRequireInteraction requireInteraction (notification:NotificationOptions) =
notification.requireInteraction <- Some requireInteraction

let withSilent silent (notification:NotificationOptions) =
notification.silent <- Some silent
notification

let withTag tag (notification:NotificationOptions) =
notification.tag <- Some tag
notification

let withTimestamp timestamp (notification:NotificationOptions) =
notification.timestamp <- Some timestamp
notification

let withVibrate vibratePattern (notification:NotificationOptions) =
notification.vibrate <- Some vibratePattern
notification
22 changes: 5 additions & 17 deletions Browser/Fable.Import.Browser.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5807,7 +5807,7 @@ module Browser =

and [<AllowNullLiteral>] InstallEvent =
inherit ExtendableEvent
abstract activeWorker: ServiceWorker with get, set
abstract activeWorker: Fable.Import.WebWorker.ServiceWorker with get, set

and [<AllowNullLiteral>] KeyboardEvent =
inherit UIEvent
Expand Down Expand Up @@ -7254,20 +7254,8 @@ module Browser =
| Error
| Opaque

and [<AllowNullLiteral>] ServiceWorker =
inherit Worker
abstract scriptURL: string with get, set
abstract state: ServiceWorkerState with get, set
[<Emit("$0.addEventListener('install',$1...)")>] abstract addEventListener_install: listener: (InstallEvent -> 'Out) * ?useCapture : bool -> unit
[<Emit("$0.addEventListener('activate',$1...)")>] abstract addEventListener_activate: listener: (ActivateEvent -> 'Out) * ?useCapture : bool -> unit
[<Emit("$0.addEventListener('fetch',$1...)")>] abstract addEventListener_fetch: listener: (FetchEvent -> 'Out) * ?useCapture : bool -> unit
[<Emit("$0.addEventListener('push',$1...)")>] abstract addEventListener_push: listener: (PushEvent -> 'Out) * ?useCapture : bool -> unit
[<Emit("$0.addEventListener('notificationclick',$1...)")>] abstract addEventListener_notificationclick: listener: (NotificationEvent -> 'Out) * ?useCapture : bool -> unit
[<Emit("$0.addEventListener('notificationclose',$1...)")>] abstract addEventListener_notificationclose: listener: (NotificationEvent -> 'Out) * ?useCapture : bool -> unit
[<Emit("$0.addEventListener('sync',$1...)")>] abstract addEventListener_sync: listener: (SyncEvent -> 'Out) * ?useCapture : bool -> unit

and [<AllowNullLiteral>] ServiceWorkerContainer =
abstract controller: ServiceWorker option with get, set
abstract controller: Fable.Import.WebWorker.ServiceWorker option with get, set
abstract oncontrollerchange: (Event -> obj option) option with get, set
abstract onerror: (Event -> obj option) option with get, set
abstract onmessage: (Event -> obj option) option with get, set
Expand All @@ -7280,12 +7268,12 @@ module Browser =
abstract tag: string option with get, set

and [<AllowNullLiteral>] ServiceWorkerRegistration =
abstract active: ServiceWorker option with get, set
abstract installing: ServiceWorker option with get, set
abstract active: Fable.Import.WebWorker.ServiceWorker option with get, set
abstract installing: Fable.Import.WebWorker.ServiceWorker option with get, set
abstract onupdatefound: (Event -> obj option) option with get, set
abstract pushManager: PushManager with get, set
abstract scope: string with get, set
abstract waiting: ServiceWorker option with get, set
abstract waiting: Fable.Import.WebWorker.ServiceWorker option with get, set
abstract getNotifications: ?options: ServiceWorkerNotificationOptions -> Promise<Array<Notification>>
abstract update: unit -> unit
abstract unregister: unit -> Promise<bool>
Expand Down
5 changes: 5 additions & 0 deletions Browser/Fable.Import.Browser.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
</PropertyGroup>
<ItemGroup>
<Compile Include="Fable.Import.WebWorker.fs" />
<Compile Include="Fable.Import.Browser.fs" />
<Compile Include="Fable.Helpers.WebWorker.fs" />
</ItemGroup>
<ItemGroup>
<None Include="test.fsx" />
</ItemGroup>
<Import Project="..\.paket\Paket.Restore.targets" />
</Project>
Loading