From aba65e99a16af2831283fa82409e2aa9db5ab437 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 9 Aug 2022 22:53:44 -0700 Subject: [PATCH 1/2] fix: js.Wrapper was removed in go1.19 Fixes build against go1.19 js.Wrapper was removed: add it back as JSWrapper. https://github.com/golang/go/issues/50310 https://github.com/golang/go/commit/6c0daa733192031eab23d09ed6515c4cd959aa92#diff-38b359833111770b96ea3bb8bc5e2b807e18bdbb80684a397ce63ff05e6d02ecL31 Signed-off-by: Christian Stewart --- indexeddb/idbblob/blob.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/indexeddb/idbblob/blob.go b/indexeddb/idbblob/blob.go index dd5ae8b..d9c3a24 100644 --- a/indexeddb/idbblob/blob.go +++ b/indexeddb/idbblob/blob.go @@ -59,9 +59,15 @@ func newBlob(buf js.Value) *Blob { return b } +// JSWrapper is implemented by types that are backed by a JavaScript value. +type JSWrapper interface { + // JSValue returns a JavaScript value associated with an object. + JSValue() js.Value +} + // FromBlob creates a Blob from the given blob.Blob, either wrapping the JS value or copying the bytes if incompatible. func FromBlob(b blob.Blob) *Blob { - if b, ok := b.(js.Wrapper); ok { + if b, ok := b.(JSWrapper); ok { return newBlob(b.JSValue()) } buf := b.Bytes() @@ -90,7 +96,7 @@ func (b *Blob) Bytes() []byte { return buf } -// JSValue implements js.Wrapper +// JSValue implements JSWrapper func (b *Blob) JSValue() js.Value { return b.jsValue.Load().(js.Value) } From 427dd91fbcc86a80df6c130b4f89ed91f7f6a667 Mon Sep 17 00:00:00 2001 From: John Starich Date: Sun, 13 Nov 2022 21:46:30 -0600 Subject: [PATCH 2/2] Avoid defining as public interface, unexports as 'jsWrapper' --- indexeddb/idbblob/blob.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/indexeddb/idbblob/blob.go b/indexeddb/idbblob/blob.go index d9c3a24..a592cc9 100644 --- a/indexeddb/idbblob/blob.go +++ b/indexeddb/idbblob/blob.go @@ -59,15 +59,15 @@ func newBlob(buf js.Value) *Blob { return b } -// JSWrapper is implemented by types that are backed by a JavaScript value. -type JSWrapper interface { +// jsWrapper is implemented by types that are backed by a JavaScript value. +type jsWrapper interface { // JSValue returns a JavaScript value associated with an object. JSValue() js.Value } // FromBlob creates a Blob from the given blob.Blob, either wrapping the JS value or copying the bytes if incompatible. func FromBlob(b blob.Blob) *Blob { - if b, ok := b.(JSWrapper); ok { + if b, ok := b.(jsWrapper); ok { return newBlob(b.JSValue()) } buf := b.Bytes()