mirror of
https://github.com/syumai/workers.git
synced 2025-03-10 17:29:11 +00:00
remove jsutil.Global()
This commit is contained in:
parent
7025700201
commit
1f1d7bc2f1
2
cloudflare/cache/client.go
vendored
2
cloudflare/cache/client.go
vendored
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/syumai/workers/internal/jsutil"
|
"github.com/syumai/workers/internal/jsutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var cache = jsutil.Global.Get("caches")
|
var cache = js.Global().Get("caches")
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
type Cache struct {
|
type Cache struct {
|
||||||
|
@ -37,7 +37,7 @@ var scheduledTask Task
|
|||||||
// ScheduleTask sets the Task to be executed
|
// ScheduleTask sets the Task to be executed
|
||||||
func ScheduleTask(task Task) {
|
func ScheduleTask(task Task) {
|
||||||
scheduledTask = task
|
scheduledTask = task
|
||||||
jsutil.Global.Call("ready")
|
js.Global().Call("ready")
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,5 +78,5 @@ func init() {
|
|||||||
|
|
||||||
return jsutil.NewPromise(cb)
|
return jsutil.NewPromise(cb)
|
||||||
})
|
})
|
||||||
jsutil.Global.Set("runScheduler", runSchedulerCallback)
|
js.Global().Set("runScheduler", runSchedulerCallback)
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,6 @@ package fetch
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
"github.com/syumai/workers/internal/jsutil"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Client is an HTTP client.
|
// Client is an HTTP client.
|
||||||
@ -44,7 +42,7 @@ func WithBinding(bind js.Value) ClientOption {
|
|||||||
// NewClient returns new Client
|
// NewClient returns new Client
|
||||||
func NewClient(opts ...ClientOption) *Client {
|
func NewClient(opts ...ClientOption) *Client {
|
||||||
c := &Client{
|
c := &Client{
|
||||||
namespace: jsutil.Global,
|
namespace: js.Global(),
|
||||||
}
|
}
|
||||||
c.applyOptions(opts)
|
c.applyOptions(opts)
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"syscall/js"
|
"syscall/js"
|
||||||
|
|
||||||
"github.com/syumai/workers/cloudflare/internal/cfruntimecontext"
|
"github.com/syumai/workers/cloudflare/internal/cfruntimecontext"
|
||||||
|
|
||||||
"github.com/syumai/workers/internal/jsutil"
|
"github.com/syumai/workers/internal/jsutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ func (kv *KVNamespace) GetReader(key string, opts *KVNamespaceGetOptions) (io.Re
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
jsutil.Global.Get("console").Call("log", v)
|
js.Global().Get("console").Call("log", v)
|
||||||
return jsutil.ConvertStreamReaderToReader(v.Call("getReader")), nil
|
return jsutil.ConvertStreamReaderToReader(v.Call("getReader")), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ func init() {
|
|||||||
})
|
})
|
||||||
return jsutil.NewPromise(cb)
|
return jsutil.NewPromise(cb)
|
||||||
})
|
})
|
||||||
jsutil.Global.Set("handleRequest", handleRequestCallback)
|
js.Global().Set("handleRequest", handleRequestCallback)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleRequest accepts a Request object and returns Response object.
|
// handleRequest accepts a Request object and returns Response object.
|
||||||
@ -78,6 +78,6 @@ func Serve(handler http.Handler) {
|
|||||||
handler = http.DefaultServeMux
|
handler = http.DefaultServeMux
|
||||||
}
|
}
|
||||||
httpHandler = handler
|
httpHandler = handler
|
||||||
jsutil.Global.Call("ready")
|
js.Global().Call("ready")
|
||||||
select {}
|
select {}
|
||||||
}
|
}
|
||||||
|
@ -7,17 +7,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Global = js.Global()
|
ObjectClass = js.Global().Get("Object")
|
||||||
ObjectClass = Global.Get("Object")
|
PromiseClass = js.Global().Get("Promise")
|
||||||
PromiseClass = Global.Get("Promise")
|
RequestClass = js.Global().Get("Request")
|
||||||
RequestClass = Global.Get("Request")
|
ResponseClass = js.Global().Get("Response")
|
||||||
ResponseClass = Global.Get("Response")
|
HeadersClass = js.Global().Get("Headers")
|
||||||
HeadersClass = Global.Get("Headers")
|
ArrayClass = js.Global().Get("Array")
|
||||||
ArrayClass = Global.Get("Array")
|
Uint8ArrayClass = js.Global().Get("Uint8Array")
|
||||||
Uint8ArrayClass = Global.Get("Uint8Array")
|
ErrorClass = js.Global().Get("Error")
|
||||||
ErrorClass = Global.Get("Error")
|
ReadableStreamClass = js.Global().Get("ReadableStream")
|
||||||
ReadableStreamClass = Global.Get("ReadableStream")
|
DateClass = js.Global().Get("Date")
|
||||||
DateClass = Global.Get("Date")
|
|
||||||
Null = js.ValueOf(nil)
|
Null = js.ValueOf(nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user