github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/mediaplayerprivate/apis_js_wasm.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package mediaplayerprivate
     5  
     6  import (
     7  	"github.com/primecitizens/pcz/std/core/abi"
     8  	"github.com/primecitizens/pcz/std/ffi/js"
     9  	"github.com/primecitizens/pcz/std/plat/js/webext/mediaplayerprivate/bindings"
    10  )
    11  
    12  type OnNextTrackEventCallbackFunc func(this js.Ref) js.Ref
    13  
    14  func (fn OnNextTrackEventCallbackFunc) Register() js.Func[func()] {
    15  	return js.RegisterCallback[func()](
    16  		fn, abi.FuncPCABIInternal(fn),
    17  	)
    18  }
    19  
    20  func (fn OnNextTrackEventCallbackFunc) DispatchCallback(
    21  	targetPC uintptr, ctx *js.CallbackContext,
    22  ) {
    23  	args := ctx.Args()
    24  	if len(args) != 0+1 /* js this */ ||
    25  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
    26  		js.ThrowInvalidCallbackInvocation()
    27  	}
    28  
    29  	if ctx.Return(fn(
    30  		args[0],
    31  	)) {
    32  		return
    33  	}
    34  
    35  	js.ThrowCallbackValueNotReturned()
    36  }
    37  
    38  type OnNextTrackEventCallback[T any] struct {
    39  	Fn  func(arg T, this js.Ref) js.Ref
    40  	Arg T
    41  }
    42  
    43  func (cb *OnNextTrackEventCallback[T]) Register() js.Func[func()] {
    44  	return js.RegisterCallback[func()](
    45  		cb, abi.FuncPCABIInternal(cb.Fn),
    46  	)
    47  }
    48  
    49  func (cb *OnNextTrackEventCallback[T]) DispatchCallback(
    50  	targetPC uintptr, ctx *js.CallbackContext,
    51  ) {
    52  	args := ctx.Args()
    53  	if len(args) != 0+1 /* js this */ ||
    54  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
    55  		js.ThrowInvalidCallbackInvocation()
    56  	}
    57  
    58  	if ctx.Return(cb.Fn(
    59  		cb.Arg,
    60  		args[0],
    61  	)) {
    62  		return
    63  	}
    64  
    65  	js.ThrowCallbackValueNotReturned()
    66  }
    67  
    68  // HasFuncOnNextTrack returns true if the function "WEBEXT.mediaPlayerPrivate.onNextTrack.addListener" exists.
    69  func HasFuncOnNextTrack() bool {
    70  	return js.True == bindings.HasFuncOnNextTrack()
    71  }
    72  
    73  // FuncOnNextTrack returns the function "WEBEXT.mediaPlayerPrivate.onNextTrack.addListener".
    74  func FuncOnNextTrack() (fn js.Func[func(callback js.Func[func()])]) {
    75  	bindings.FuncOnNextTrack(
    76  		js.Pointer(&fn),
    77  	)
    78  	return
    79  }
    80  
    81  // OnNextTrack calls the function "WEBEXT.mediaPlayerPrivate.onNextTrack.addListener" directly.
    82  func OnNextTrack(callback js.Func[func()]) (ret js.Void) {
    83  	bindings.CallOnNextTrack(
    84  		js.Pointer(&ret),
    85  		callback.Ref(),
    86  	)
    87  
    88  	return
    89  }
    90  
    91  // TryOnNextTrack calls the function "WEBEXT.mediaPlayerPrivate.onNextTrack.addListener"
    92  // in a try/catch block and returns (_, err, ok = false) when it went through
    93  // the catch clause.
    94  func TryOnNextTrack(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
    95  	ok = js.True == bindings.TryOnNextTrack(
    96  		js.Pointer(&ret), js.Pointer(&exception),
    97  		callback.Ref(),
    98  	)
    99  
   100  	return
   101  }
   102  
   103  // HasFuncOffNextTrack returns true if the function "WEBEXT.mediaPlayerPrivate.onNextTrack.removeListener" exists.
   104  func HasFuncOffNextTrack() bool {
   105  	return js.True == bindings.HasFuncOffNextTrack()
   106  }
   107  
   108  // FuncOffNextTrack returns the function "WEBEXT.mediaPlayerPrivate.onNextTrack.removeListener".
   109  func FuncOffNextTrack() (fn js.Func[func(callback js.Func[func()])]) {
   110  	bindings.FuncOffNextTrack(
   111  		js.Pointer(&fn),
   112  	)
   113  	return
   114  }
   115  
   116  // OffNextTrack calls the function "WEBEXT.mediaPlayerPrivate.onNextTrack.removeListener" directly.
   117  func OffNextTrack(callback js.Func[func()]) (ret js.Void) {
   118  	bindings.CallOffNextTrack(
   119  		js.Pointer(&ret),
   120  		callback.Ref(),
   121  	)
   122  
   123  	return
   124  }
   125  
   126  // TryOffNextTrack calls the function "WEBEXT.mediaPlayerPrivate.onNextTrack.removeListener"
   127  // in a try/catch block and returns (_, err, ok = false) when it went through
   128  // the catch clause.
   129  func TryOffNextTrack(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   130  	ok = js.True == bindings.TryOffNextTrack(
   131  		js.Pointer(&ret), js.Pointer(&exception),
   132  		callback.Ref(),
   133  	)
   134  
   135  	return
   136  }
   137  
   138  // HasFuncHasOnNextTrack returns true if the function "WEBEXT.mediaPlayerPrivate.onNextTrack.hasListener" exists.
   139  func HasFuncHasOnNextTrack() bool {
   140  	return js.True == bindings.HasFuncHasOnNextTrack()
   141  }
   142  
   143  // FuncHasOnNextTrack returns the function "WEBEXT.mediaPlayerPrivate.onNextTrack.hasListener".
   144  func FuncHasOnNextTrack() (fn js.Func[func(callback js.Func[func()]) bool]) {
   145  	bindings.FuncHasOnNextTrack(
   146  		js.Pointer(&fn),
   147  	)
   148  	return
   149  }
   150  
   151  // HasOnNextTrack calls the function "WEBEXT.mediaPlayerPrivate.onNextTrack.hasListener" directly.
   152  func HasOnNextTrack(callback js.Func[func()]) (ret bool) {
   153  	bindings.CallHasOnNextTrack(
   154  		js.Pointer(&ret),
   155  		callback.Ref(),
   156  	)
   157  
   158  	return
   159  }
   160  
   161  // TryHasOnNextTrack calls the function "WEBEXT.mediaPlayerPrivate.onNextTrack.hasListener"
   162  // in a try/catch block and returns (_, err, ok = false) when it went through
   163  // the catch clause.
   164  func TryHasOnNextTrack(callback js.Func[func()]) (ret bool, exception js.Any, ok bool) {
   165  	ok = js.True == bindings.TryHasOnNextTrack(
   166  		js.Pointer(&ret), js.Pointer(&exception),
   167  		callback.Ref(),
   168  	)
   169  
   170  	return
   171  }
   172  
   173  type OnPrevTrackEventCallbackFunc func(this js.Ref) js.Ref
   174  
   175  func (fn OnPrevTrackEventCallbackFunc) Register() js.Func[func()] {
   176  	return js.RegisterCallback[func()](
   177  		fn, abi.FuncPCABIInternal(fn),
   178  	)
   179  }
   180  
   181  func (fn OnPrevTrackEventCallbackFunc) DispatchCallback(
   182  	targetPC uintptr, ctx *js.CallbackContext,
   183  ) {
   184  	args := ctx.Args()
   185  	if len(args) != 0+1 /* js this */ ||
   186  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   187  		js.ThrowInvalidCallbackInvocation()
   188  	}
   189  
   190  	if ctx.Return(fn(
   191  		args[0],
   192  	)) {
   193  		return
   194  	}
   195  
   196  	js.ThrowCallbackValueNotReturned()
   197  }
   198  
   199  type OnPrevTrackEventCallback[T any] struct {
   200  	Fn  func(arg T, this js.Ref) js.Ref
   201  	Arg T
   202  }
   203  
   204  func (cb *OnPrevTrackEventCallback[T]) Register() js.Func[func()] {
   205  	return js.RegisterCallback[func()](
   206  		cb, abi.FuncPCABIInternal(cb.Fn),
   207  	)
   208  }
   209  
   210  func (cb *OnPrevTrackEventCallback[T]) DispatchCallback(
   211  	targetPC uintptr, ctx *js.CallbackContext,
   212  ) {
   213  	args := ctx.Args()
   214  	if len(args) != 0+1 /* js this */ ||
   215  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   216  		js.ThrowInvalidCallbackInvocation()
   217  	}
   218  
   219  	if ctx.Return(cb.Fn(
   220  		cb.Arg,
   221  		args[0],
   222  	)) {
   223  		return
   224  	}
   225  
   226  	js.ThrowCallbackValueNotReturned()
   227  }
   228  
   229  // HasFuncOnPrevTrack returns true if the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.addListener" exists.
   230  func HasFuncOnPrevTrack() bool {
   231  	return js.True == bindings.HasFuncOnPrevTrack()
   232  }
   233  
   234  // FuncOnPrevTrack returns the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.addListener".
   235  func FuncOnPrevTrack() (fn js.Func[func(callback js.Func[func()])]) {
   236  	bindings.FuncOnPrevTrack(
   237  		js.Pointer(&fn),
   238  	)
   239  	return
   240  }
   241  
   242  // OnPrevTrack calls the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.addListener" directly.
   243  func OnPrevTrack(callback js.Func[func()]) (ret js.Void) {
   244  	bindings.CallOnPrevTrack(
   245  		js.Pointer(&ret),
   246  		callback.Ref(),
   247  	)
   248  
   249  	return
   250  }
   251  
   252  // TryOnPrevTrack calls the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.addListener"
   253  // in a try/catch block and returns (_, err, ok = false) when it went through
   254  // the catch clause.
   255  func TryOnPrevTrack(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   256  	ok = js.True == bindings.TryOnPrevTrack(
   257  		js.Pointer(&ret), js.Pointer(&exception),
   258  		callback.Ref(),
   259  	)
   260  
   261  	return
   262  }
   263  
   264  // HasFuncOffPrevTrack returns true if the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.removeListener" exists.
   265  func HasFuncOffPrevTrack() bool {
   266  	return js.True == bindings.HasFuncOffPrevTrack()
   267  }
   268  
   269  // FuncOffPrevTrack returns the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.removeListener".
   270  func FuncOffPrevTrack() (fn js.Func[func(callback js.Func[func()])]) {
   271  	bindings.FuncOffPrevTrack(
   272  		js.Pointer(&fn),
   273  	)
   274  	return
   275  }
   276  
   277  // OffPrevTrack calls the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.removeListener" directly.
   278  func OffPrevTrack(callback js.Func[func()]) (ret js.Void) {
   279  	bindings.CallOffPrevTrack(
   280  		js.Pointer(&ret),
   281  		callback.Ref(),
   282  	)
   283  
   284  	return
   285  }
   286  
   287  // TryOffPrevTrack calls the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.removeListener"
   288  // in a try/catch block and returns (_, err, ok = false) when it went through
   289  // the catch clause.
   290  func TryOffPrevTrack(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   291  	ok = js.True == bindings.TryOffPrevTrack(
   292  		js.Pointer(&ret), js.Pointer(&exception),
   293  		callback.Ref(),
   294  	)
   295  
   296  	return
   297  }
   298  
   299  // HasFuncHasOnPrevTrack returns true if the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.hasListener" exists.
   300  func HasFuncHasOnPrevTrack() bool {
   301  	return js.True == bindings.HasFuncHasOnPrevTrack()
   302  }
   303  
   304  // FuncHasOnPrevTrack returns the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.hasListener".
   305  func FuncHasOnPrevTrack() (fn js.Func[func(callback js.Func[func()]) bool]) {
   306  	bindings.FuncHasOnPrevTrack(
   307  		js.Pointer(&fn),
   308  	)
   309  	return
   310  }
   311  
   312  // HasOnPrevTrack calls the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.hasListener" directly.
   313  func HasOnPrevTrack(callback js.Func[func()]) (ret bool) {
   314  	bindings.CallHasOnPrevTrack(
   315  		js.Pointer(&ret),
   316  		callback.Ref(),
   317  	)
   318  
   319  	return
   320  }
   321  
   322  // TryHasOnPrevTrack calls the function "WEBEXT.mediaPlayerPrivate.onPrevTrack.hasListener"
   323  // in a try/catch block and returns (_, err, ok = false) when it went through
   324  // the catch clause.
   325  func TryHasOnPrevTrack(callback js.Func[func()]) (ret bool, exception js.Any, ok bool) {
   326  	ok = js.True == bindings.TryHasOnPrevTrack(
   327  		js.Pointer(&ret), js.Pointer(&exception),
   328  		callback.Ref(),
   329  	)
   330  
   331  	return
   332  }
   333  
   334  type OnTogglePlayStateEventCallbackFunc func(this js.Ref) js.Ref
   335  
   336  func (fn OnTogglePlayStateEventCallbackFunc) Register() js.Func[func()] {
   337  	return js.RegisterCallback[func()](
   338  		fn, abi.FuncPCABIInternal(fn),
   339  	)
   340  }
   341  
   342  func (fn OnTogglePlayStateEventCallbackFunc) DispatchCallback(
   343  	targetPC uintptr, ctx *js.CallbackContext,
   344  ) {
   345  	args := ctx.Args()
   346  	if len(args) != 0+1 /* js this */ ||
   347  		targetPC != uintptr(abi.FuncPCABIInternal(fn)) {
   348  		js.ThrowInvalidCallbackInvocation()
   349  	}
   350  
   351  	if ctx.Return(fn(
   352  		args[0],
   353  	)) {
   354  		return
   355  	}
   356  
   357  	js.ThrowCallbackValueNotReturned()
   358  }
   359  
   360  type OnTogglePlayStateEventCallback[T any] struct {
   361  	Fn  func(arg T, this js.Ref) js.Ref
   362  	Arg T
   363  }
   364  
   365  func (cb *OnTogglePlayStateEventCallback[T]) Register() js.Func[func()] {
   366  	return js.RegisterCallback[func()](
   367  		cb, abi.FuncPCABIInternal(cb.Fn),
   368  	)
   369  }
   370  
   371  func (cb *OnTogglePlayStateEventCallback[T]) DispatchCallback(
   372  	targetPC uintptr, ctx *js.CallbackContext,
   373  ) {
   374  	args := ctx.Args()
   375  	if len(args) != 0+1 /* js this */ ||
   376  		targetPC != uintptr(abi.FuncPCABIInternal(cb.Fn)) {
   377  		js.ThrowInvalidCallbackInvocation()
   378  	}
   379  
   380  	if ctx.Return(cb.Fn(
   381  		cb.Arg,
   382  		args[0],
   383  	)) {
   384  		return
   385  	}
   386  
   387  	js.ThrowCallbackValueNotReturned()
   388  }
   389  
   390  // HasFuncOnTogglePlayState returns true if the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.addListener" exists.
   391  func HasFuncOnTogglePlayState() bool {
   392  	return js.True == bindings.HasFuncOnTogglePlayState()
   393  }
   394  
   395  // FuncOnTogglePlayState returns the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.addListener".
   396  func FuncOnTogglePlayState() (fn js.Func[func(callback js.Func[func()])]) {
   397  	bindings.FuncOnTogglePlayState(
   398  		js.Pointer(&fn),
   399  	)
   400  	return
   401  }
   402  
   403  // OnTogglePlayState calls the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.addListener" directly.
   404  func OnTogglePlayState(callback js.Func[func()]) (ret js.Void) {
   405  	bindings.CallOnTogglePlayState(
   406  		js.Pointer(&ret),
   407  		callback.Ref(),
   408  	)
   409  
   410  	return
   411  }
   412  
   413  // TryOnTogglePlayState calls the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.addListener"
   414  // in a try/catch block and returns (_, err, ok = false) when it went through
   415  // the catch clause.
   416  func TryOnTogglePlayState(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   417  	ok = js.True == bindings.TryOnTogglePlayState(
   418  		js.Pointer(&ret), js.Pointer(&exception),
   419  		callback.Ref(),
   420  	)
   421  
   422  	return
   423  }
   424  
   425  // HasFuncOffTogglePlayState returns true if the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.removeListener" exists.
   426  func HasFuncOffTogglePlayState() bool {
   427  	return js.True == bindings.HasFuncOffTogglePlayState()
   428  }
   429  
   430  // FuncOffTogglePlayState returns the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.removeListener".
   431  func FuncOffTogglePlayState() (fn js.Func[func(callback js.Func[func()])]) {
   432  	bindings.FuncOffTogglePlayState(
   433  		js.Pointer(&fn),
   434  	)
   435  	return
   436  }
   437  
   438  // OffTogglePlayState calls the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.removeListener" directly.
   439  func OffTogglePlayState(callback js.Func[func()]) (ret js.Void) {
   440  	bindings.CallOffTogglePlayState(
   441  		js.Pointer(&ret),
   442  		callback.Ref(),
   443  	)
   444  
   445  	return
   446  }
   447  
   448  // TryOffTogglePlayState calls the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.removeListener"
   449  // in a try/catch block and returns (_, err, ok = false) when it went through
   450  // the catch clause.
   451  func TryOffTogglePlayState(callback js.Func[func()]) (ret js.Void, exception js.Any, ok bool) {
   452  	ok = js.True == bindings.TryOffTogglePlayState(
   453  		js.Pointer(&ret), js.Pointer(&exception),
   454  		callback.Ref(),
   455  	)
   456  
   457  	return
   458  }
   459  
   460  // HasFuncHasOnTogglePlayState returns true if the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.hasListener" exists.
   461  func HasFuncHasOnTogglePlayState() bool {
   462  	return js.True == bindings.HasFuncHasOnTogglePlayState()
   463  }
   464  
   465  // FuncHasOnTogglePlayState returns the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.hasListener".
   466  func FuncHasOnTogglePlayState() (fn js.Func[func(callback js.Func[func()]) bool]) {
   467  	bindings.FuncHasOnTogglePlayState(
   468  		js.Pointer(&fn),
   469  	)
   470  	return
   471  }
   472  
   473  // HasOnTogglePlayState calls the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.hasListener" directly.
   474  func HasOnTogglePlayState(callback js.Func[func()]) (ret bool) {
   475  	bindings.CallHasOnTogglePlayState(
   476  		js.Pointer(&ret),
   477  		callback.Ref(),
   478  	)
   479  
   480  	return
   481  }
   482  
   483  // TryHasOnTogglePlayState calls the function "WEBEXT.mediaPlayerPrivate.onTogglePlayState.hasListener"
   484  // in a try/catch block and returns (_, err, ok = false) when it went through
   485  // the catch clause.
   486  func TryHasOnTogglePlayState(callback js.Func[func()]) (ret bool, exception js.Any, ok bool) {
   487  	ok = js.True == bindings.TryHasOnTogglePlayState(
   488  		js.Pointer(&ret), js.Pointer(&exception),
   489  		callback.Ref(),
   490  	)
   491  
   492  	return
   493  }