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

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright 2023 The Prime Citizens
     3  
     4  package systemprivate
     5  
     6  import (
     7  	"github.com/primecitizens/pcz/std/ffi/js"
     8  	"github.com/primecitizens/pcz/std/plat/js/webext/systemprivate/bindings"
     9  )
    10  
    11  type GetIncognitoModeAvailabilityValue uint32
    12  
    13  const (
    14  	_ GetIncognitoModeAvailabilityValue = iota
    15  
    16  	GetIncognitoModeAvailabilityValue_ENABLED
    17  	GetIncognitoModeAvailabilityValue_DISABLED
    18  	GetIncognitoModeAvailabilityValue_FORCED
    19  )
    20  
    21  func (GetIncognitoModeAvailabilityValue) FromRef(str js.Ref) GetIncognitoModeAvailabilityValue {
    22  	return GetIncognitoModeAvailabilityValue(bindings.ConstOfGetIncognitoModeAvailabilityValue(str))
    23  }
    24  
    25  func (x GetIncognitoModeAvailabilityValue) String() (string, bool) {
    26  	switch x {
    27  	case GetIncognitoModeAvailabilityValue_ENABLED:
    28  		return "enabled", true
    29  	case GetIncognitoModeAvailabilityValue_DISABLED:
    30  		return "disabled", true
    31  	case GetIncognitoModeAvailabilityValue_FORCED:
    32  		return "forced", true
    33  	default:
    34  		return "", false
    35  	}
    36  }
    37  
    38  type UpdateStatusState uint32
    39  
    40  const (
    41  	_ UpdateStatusState = iota
    42  
    43  	UpdateStatusState_NOT_AVAILABLE
    44  	UpdateStatusState_UPDATING
    45  	UpdateStatusState_NEED_RESTART
    46  )
    47  
    48  func (UpdateStatusState) FromRef(str js.Ref) UpdateStatusState {
    49  	return UpdateStatusState(bindings.ConstOfUpdateStatusState(str))
    50  }
    51  
    52  func (x UpdateStatusState) String() (string, bool) {
    53  	switch x {
    54  	case UpdateStatusState_NOT_AVAILABLE:
    55  		return "NotAvailable", true
    56  	case UpdateStatusState_UPDATING:
    57  		return "Updating", true
    58  	case UpdateStatusState_NEED_RESTART:
    59  		return "NeedRestart", true
    60  	default:
    61  		return "", false
    62  	}
    63  }
    64  
    65  type UpdateStatus struct {
    66  	// DownloadProgress is "UpdateStatus.downloadProgress"
    67  	//
    68  	// Required
    69  	DownloadProgress float64
    70  	// State is "UpdateStatus.state"
    71  	//
    72  	// Required
    73  	State UpdateStatusState
    74  
    75  	FFI_USE bool
    76  }
    77  
    78  // FromRef calls UpdateFrom and returns a UpdateStatus with all fields set.
    79  func (p UpdateStatus) FromRef(ref js.Ref) UpdateStatus {
    80  	p.UpdateFrom(ref)
    81  	return p
    82  }
    83  
    84  // New creates a new UpdateStatus in the application heap.
    85  func (p UpdateStatus) New() js.Ref {
    86  	return bindings.UpdateStatusJSLoad(
    87  		js.Pointer(&p), js.True, 0,
    88  	)
    89  }
    90  
    91  // UpdateFrom copies value of all fields of the heap object to p.
    92  func (p *UpdateStatus) UpdateFrom(ref js.Ref) {
    93  	bindings.UpdateStatusJSStore(
    94  		js.Pointer(p), ref,
    95  	)
    96  }
    97  
    98  // Update writes all fields of the p to the heap object referenced by ref.
    99  func (p *UpdateStatus) Update(ref js.Ref) {
   100  	bindings.UpdateStatusJSLoad(
   101  		js.Pointer(p), js.False, ref,
   102  	)
   103  }
   104  
   105  // FreeMembers frees fields with heap reference, if recursive is true
   106  // free all heap references reachable from p.
   107  func (p *UpdateStatus) FreeMembers(recursive bool) {
   108  }
   109  
   110  // HasFuncGetApiKey returns true if the function "WEBEXT.systemPrivate.getApiKey" exists.
   111  func HasFuncGetApiKey() bool {
   112  	return js.True == bindings.HasFuncGetApiKey()
   113  }
   114  
   115  // FuncGetApiKey returns the function "WEBEXT.systemPrivate.getApiKey".
   116  func FuncGetApiKey() (fn js.Func[func() js.Promise[js.String]]) {
   117  	bindings.FuncGetApiKey(
   118  		js.Pointer(&fn),
   119  	)
   120  	return
   121  }
   122  
   123  // GetApiKey calls the function "WEBEXT.systemPrivate.getApiKey" directly.
   124  func GetApiKey() (ret js.Promise[js.String]) {
   125  	bindings.CallGetApiKey(
   126  		js.Pointer(&ret),
   127  	)
   128  
   129  	return
   130  }
   131  
   132  // TryGetApiKey calls the function "WEBEXT.systemPrivate.getApiKey"
   133  // in a try/catch block and returns (_, err, ok = false) when it went through
   134  // the catch clause.
   135  func TryGetApiKey() (ret js.Promise[js.String], exception js.Any, ok bool) {
   136  	ok = js.True == bindings.TryGetApiKey(
   137  		js.Pointer(&ret), js.Pointer(&exception),
   138  	)
   139  
   140  	return
   141  }
   142  
   143  // HasFuncGetIncognitoModeAvailability returns true if the function "WEBEXT.systemPrivate.getIncognitoModeAvailability" exists.
   144  func HasFuncGetIncognitoModeAvailability() bool {
   145  	return js.True == bindings.HasFuncGetIncognitoModeAvailability()
   146  }
   147  
   148  // FuncGetIncognitoModeAvailability returns the function "WEBEXT.systemPrivate.getIncognitoModeAvailability".
   149  func FuncGetIncognitoModeAvailability() (fn js.Func[func() js.Promise[GetIncognitoModeAvailabilityValue]]) {
   150  	bindings.FuncGetIncognitoModeAvailability(
   151  		js.Pointer(&fn),
   152  	)
   153  	return
   154  }
   155  
   156  // GetIncognitoModeAvailability calls the function "WEBEXT.systemPrivate.getIncognitoModeAvailability" directly.
   157  func GetIncognitoModeAvailability() (ret js.Promise[GetIncognitoModeAvailabilityValue]) {
   158  	bindings.CallGetIncognitoModeAvailability(
   159  		js.Pointer(&ret),
   160  	)
   161  
   162  	return
   163  }
   164  
   165  // TryGetIncognitoModeAvailability calls the function "WEBEXT.systemPrivate.getIncognitoModeAvailability"
   166  // in a try/catch block and returns (_, err, ok = false) when it went through
   167  // the catch clause.
   168  func TryGetIncognitoModeAvailability() (ret js.Promise[GetIncognitoModeAvailabilityValue], exception js.Any, ok bool) {
   169  	ok = js.True == bindings.TryGetIncognitoModeAvailability(
   170  		js.Pointer(&ret), js.Pointer(&exception),
   171  	)
   172  
   173  	return
   174  }
   175  
   176  // HasFuncGetUpdateStatus returns true if the function "WEBEXT.systemPrivate.getUpdateStatus" exists.
   177  func HasFuncGetUpdateStatus() bool {
   178  	return js.True == bindings.HasFuncGetUpdateStatus()
   179  }
   180  
   181  // FuncGetUpdateStatus returns the function "WEBEXT.systemPrivate.getUpdateStatus".
   182  func FuncGetUpdateStatus() (fn js.Func[func() js.Promise[UpdateStatus]]) {
   183  	bindings.FuncGetUpdateStatus(
   184  		js.Pointer(&fn),
   185  	)
   186  	return
   187  }
   188  
   189  // GetUpdateStatus calls the function "WEBEXT.systemPrivate.getUpdateStatus" directly.
   190  func GetUpdateStatus() (ret js.Promise[UpdateStatus]) {
   191  	bindings.CallGetUpdateStatus(
   192  		js.Pointer(&ret),
   193  	)
   194  
   195  	return
   196  }
   197  
   198  // TryGetUpdateStatus calls the function "WEBEXT.systemPrivate.getUpdateStatus"
   199  // in a try/catch block and returns (_, err, ok = false) when it went through
   200  // the catch clause.
   201  func TryGetUpdateStatus() (ret js.Promise[UpdateStatus], exception js.Any, ok bool) {
   202  	ok = js.True == bindings.TryGetUpdateStatus(
   203  		js.Pointer(&ret), js.Pointer(&exception),
   204  	)
   205  
   206  	return
   207  }