github.com/vugu/vugu@v0.3.6-0.20240430171613-3f6f402e014b/js/impl-nonjs.go (about) 1 //go:build !js 2 // +build !js 3 4 package js 5 6 import "errors" 7 8 var errNotImpl = errors.New("js not implemented") 9 10 // Error placeholder for syscall/js 11 type Error struct { 12 Value 13 } 14 15 // Error placeholder for syscall/js 16 func (e Error) Error() string { 17 return errNotImpl.Error() 18 } 19 20 // Func placeholder for syscall/js 21 type Func struct { 22 Value 23 } 24 25 // FuncOf placeholder for syscall/js 26 func FuncOf(fn func(Value, []Value) interface{}) Func { 27 // making this panic for now, although I can see some utility in allowing this 28 // and then they just never get called, will see... 29 panic(errNotImpl) 30 // return Func{} 31 } 32 33 // Release placeholder for syscall/js 34 func (c Func) Release() { 35 // nop 36 } 37 38 // Type placeholder for syscall/js 39 type Type int 40 41 // Placeholder for syscall/js 42 const ( 43 TypeUndefined Type = iota 44 TypeNull 45 TypeBoolean 46 TypeNumber 47 TypeString 48 TypeSymbol 49 TypeObject 50 TypeFunction 51 ) 52 53 // String placeholder for syscall/js 54 func (t Type) String() string { 55 return "undefined" 56 } 57 58 // Undefined placeholder for syscall/js 59 func Undefined() Value { 60 return Value{} 61 } 62 63 // Null placeholder for syscall/js 64 func Null() Value { 65 return Value{} 66 } 67 68 // Global placeholder for syscall/js 69 func Global() Value { 70 return Value{} 71 } 72 73 // ValueOf placeholder for syscall/js 74 func ValueOf(x interface{}) Value { 75 return Value{} 76 } 77 78 // CopyBytesToGo placeholder for syscall/js 79 func CopyBytesToGo(dst []byte, src Value) int { 80 return 0 81 } 82 83 // CopyBytesToJS placeholder for syscall/js 84 func CopyBytesToJS(dst Value, src []byte) int { 85 return 0 86 } 87 88 // // TypedArray placeholder for syscall/js 89 // type TypedArray struct { 90 // Value 91 // } 92 93 // // TypedArrayOf placeholder for syscall/js 94 // func TypedArrayOf(slice interface{}) TypedArray { 95 // return TypedArray{} 96 // } 97 98 // // Release placeholder for syscall/js 99 // func (a TypedArray) Release() { 100 // // nop 101 // } 102 103 // ValueError placeholder for syscall/js 104 type ValueError struct { 105 Method string 106 Type Type 107 } 108 109 // Error placeholder for syscall/js 110 func (e *ValueError) Error() string { 111 return errNotImpl.Error() 112 } 113 114 // Wrapper placeholder for syscall/js 115 type Wrapper interface { 116 JSValue() Value 117 } 118 119 // Value placeholder for syscall/js 120 type Value struct { 121 stub uint64 //nolint:golint,unused 122 } 123 124 // JSValue placeholder for syscall/js 125 func (v Value) JSValue() Value { 126 return v 127 } 128 129 // Type placeholder for syscall/js 130 func (v Value) Type() Type { 131 return TypeUndefined 132 } 133 134 func (v Value) Get(p string) Value { 135 return Undefined() 136 } 137 138 func (v Value) Set(p string, x interface{}) { 139 panic(errNotImpl) 140 } 141 142 func (v Value) Index(i int) Value { 143 return Undefined() 144 } 145 146 func (v Value) SetIndex(i int, x interface{}) { 147 panic(errNotImpl) 148 } 149 150 func (v Value) Length() int { 151 return 0 152 } 153 154 func (v Value) Call(m string, args ...interface{}) Value { 155 panic(errNotImpl) 156 } 157 158 func (v Value) Invoke(args ...interface{}) Value { 159 panic(errNotImpl) 160 } 161 162 func (v Value) New(args ...interface{}) Value { 163 return Undefined() 164 } 165 166 func (v Value) Float() float64 { 167 return 0 168 } 169 170 func (v Value) Int() int { 171 return 0 172 } 173 174 func (v Value) Bool() bool { 175 return false 176 } 177 178 func (v Value) Truthy() bool { 179 return false 180 } 181 182 func (v Value) String() string { 183 return "" 184 } 185 186 func (v Value) InstanceOf(t Value) bool { 187 return false 188 } 189 190 func (v Value) IsUndefined() bool { 191 return true 192 } 193 194 func (v Value) IsNull() bool { 195 return false 196 }