File tree Expand file tree Collapse file tree 9 files changed +169
-7
lines changed Expand file tree Collapse file tree 9 files changed +169
-7
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ /* @globals self */
2
+
3
+ export function location ( ) {
4
+ return self . location ;
5
+ }
6
+
7
+ export function navigator ( ) {
8
+ return self . navigator ;
9
+ }
10
+
11
+ export function postMessage ( data ) {
12
+ return function ( transfer ) {
13
+ return function ( ) {
14
+ self . postMessage ( data , transfer . length > 0 ? transfer : undefined ) ;
15
+ } ;
16
+ } ;
17
+ }
18
+
19
+ export function close ( ) {
20
+ self . close ( ) ;
21
+ }
Original file line number Diff line number Diff line change
1
+ -- https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator
2
+
3
+ module Web.Worker.GlobalScope where
4
+
5
+ import Prelude
6
+ import Effect (Effect )
7
+ import Web.Worker.Navigator (Navigator )
8
+ import Web.Worker.Location (Location )
9
+
10
+ foreign import location :: Effect Location
11
+
12
+ foreign import navigator :: Effect Navigator
13
+
14
+ foreign import postMessage :: forall msg tr . msg -> Array tr -> Effect Unit
15
+
16
+ foreign import close :: Effect Unit
Original file line number Diff line number Diff line change
1
+ export function hash ( location ) {
2
+ return function ( ) {
3
+ return location . hash ;
4
+ } ;
5
+ }
6
+
7
+ export function host ( location ) {
8
+ return function ( ) {
9
+ return location . host ;
10
+ } ;
11
+ }
12
+
13
+ export function hostname ( location ) {
14
+ return function ( ) {
15
+ return location . hostname ;
16
+ } ;
17
+ }
18
+
19
+ export function href ( location ) {
20
+ return function ( ) {
21
+ return location . href ;
22
+ } ;
23
+ }
24
+
25
+ export function origin ( location ) {
26
+ return function ( ) {
27
+ return location . origin ;
28
+ } ;
29
+ }
30
+
31
+ export function pathname ( location ) {
32
+ return function ( ) {
33
+ return location . pathname ;
34
+ } ;
35
+ }
36
+
37
+ export function port ( location ) {
38
+ return function ( ) {
39
+ return location . port ;
40
+ } ;
41
+ }
42
+
43
+ export function protocol ( location ) {
44
+ return function ( ) {
45
+ return location . protocol ;
46
+ } ;
47
+ }
48
+
49
+ export function search ( location ) {
50
+ return function ( ) {
51
+ return location . search ;
52
+ } ;
53
+ }
Original file line number Diff line number Diff line change
1
+ -- https://developer.mozilla.org/en-US/docs/Web/API/WorkerLocation
2
+
3
+ module Web.Worker.Location
4
+ ( Location
5
+ , hash
6
+ , host
7
+ , hostname
8
+ , href
9
+ , origin
10
+ , pathname
11
+ , port
12
+ , protocol
13
+ , search
14
+ )
15
+ where
16
+
17
+ import Effect (Effect )
18
+
19
+ foreign import data Location :: Type
20
+
21
+ foreign import hash :: Location -> Effect String
22
+
23
+ foreign import host :: Location -> Effect String
24
+
25
+ foreign import hostname :: Location -> Effect String
26
+
27
+ foreign import href :: Location -> Effect String
28
+
29
+ foreign import origin :: Location -> Effect String
30
+
31
+ foreign import pathname :: Location -> Effect String
32
+
33
+ foreign import port :: Location -> Effect String
34
+
35
+ foreign import protocol :: Location -> Effect String
36
+
37
+ foreign import search :: Location -> Effect String
Original file line number Diff line number Diff line change
1
+ export function language ( navigator ) {
2
+ return function ( ) {
3
+ return navigator . language ;
4
+ } ;
5
+ }
6
+
7
+ export function hardwareConcurrency ( navigator ) {
8
+ return function ( ) {
9
+ return navigator . hardwareConcurrency ;
10
+ } ;
11
+ }
12
+
13
+ export function onLine ( navigator ) {
14
+ return function ( ) {
15
+ return navigator . onLine ;
16
+ } ;
17
+ }
Original file line number Diff line number Diff line change
1
+ -- https://developer.mozilla.org/en-US/docs/Web/API/WorkerNavigator
2
+
3
+ module Web.Worker.Navigator where
4
+
5
+ import Effect (Effect )
6
+
7
+ foreign import data Navigator :: Type
8
+
9
+ foreign import language :: Navigator -> Effect String
10
+
11
+ foreign import hardwareConcurrency :: Navigator -> Effect Int
12
+
13
+ foreign import onLine :: Navigator -> Effect Boolean
14
+
15
+ -- connection
Original file line number Diff line number Diff line change @@ -30,6 +30,14 @@ export function onMessage(f) {
30
30
} ;
31
31
}
32
32
33
+ export function onMessageError ( f ) {
34
+ return function ( worker ) {
35
+ return function ( ) {
36
+ worker . onmessageerror = f ;
37
+ } ;
38
+ } ;
39
+ }
40
+
33
41
export function onError ( f ) {
34
42
return function ( worker ) {
35
43
return function ( ) {
Original file line number Diff line number Diff line change @@ -67,6 +67,8 @@ foreign import terminate :: Worker -> Effect Unit
67
67
68
68
foreign import onMessage :: (MessageEvent -> Effect Unit ) -> Worker -> Effect Unit
69
69
70
+ foreign import onMessageError :: (MessageEvent -> Effect Unit ) -> Worker -> Effect Unit
71
+
70
72
foreign import onError :: (Event -> Effect Unit ) -> Worker -> Effect Unit
71
73
72
74
instance Show WorkerType where
You can’t perform that action at this time.
0 commit comments