github.com/primecitizens/pcz/std@v0.2.1/plat/js/webext/chromeosinfoprivate/apis_js_wasm.go (about) 1 // SPDX-License-Identifier: Apache-2.0 2 // Copyright 2023 The Prime Citizens 3 4 package chromeosinfoprivate 5 6 import ( 7 "github.com/primecitizens/pcz/std/ffi/js" 8 "github.com/primecitizens/pcz/std/plat/js/webext/chromeosinfoprivate/bindings" 9 ) 10 11 type AssistantStatus uint32 12 13 const ( 14 _ AssistantStatus = iota 15 16 AssistantStatus_UNSUPPORTED 17 AssistantStatus_SUPPORTED 18 ) 19 20 func (AssistantStatus) FromRef(str js.Ref) AssistantStatus { 21 return AssistantStatus(bindings.ConstOfAssistantStatus(str)) 22 } 23 24 func (x AssistantStatus) String() (string, bool) { 25 switch x { 26 case AssistantStatus_UNSUPPORTED: 27 return "unsupported", true 28 case AssistantStatus_SUPPORTED: 29 return "supported", true 30 default: 31 return "", false 32 } 33 } 34 35 type DeviceType uint32 36 37 const ( 38 _ DeviceType = iota 39 40 DeviceType_CHROMEBASE 41 DeviceType_CHROMEBIT 42 DeviceType_CHROMEBOOK 43 DeviceType_CHROMEBOX 44 DeviceType_CHROMEDEVICE 45 ) 46 47 func (DeviceType) FromRef(str js.Ref) DeviceType { 48 return DeviceType(bindings.ConstOfDeviceType(str)) 49 } 50 51 func (x DeviceType) String() (string, bool) { 52 switch x { 53 case DeviceType_CHROMEBASE: 54 return "chromebase", true 55 case DeviceType_CHROMEBIT: 56 return "chromebit", true 57 case DeviceType_CHROMEBOOK: 58 return "chromebook", true 59 case DeviceType_CHROMEBOX: 60 return "chromebox", true 61 case DeviceType_CHROMEDEVICE: 62 return "chromedevice", true 63 default: 64 return "", false 65 } 66 } 67 68 type ManagedDeviceStatus uint32 69 70 const ( 71 _ ManagedDeviceStatus = iota 72 73 ManagedDeviceStatus_MANAGED 74 ManagedDeviceStatus_NOT_MANAGED 75 ) 76 77 func (ManagedDeviceStatus) FromRef(str js.Ref) ManagedDeviceStatus { 78 return ManagedDeviceStatus(bindings.ConstOfManagedDeviceStatus(str)) 79 } 80 81 func (x ManagedDeviceStatus) String() (string, bool) { 82 switch x { 83 case ManagedDeviceStatus_MANAGED: 84 return "managed", true 85 case ManagedDeviceStatus_NOT_MANAGED: 86 return "not managed", true 87 default: 88 return "", false 89 } 90 } 91 92 type PlayStoreStatus uint32 93 94 const ( 95 _ PlayStoreStatus = iota 96 97 PlayStoreStatus_NOT_AVAILABLE 98 PlayStoreStatus_AVAILABLE 99 PlayStoreStatus_ENABLED 100 ) 101 102 func (PlayStoreStatus) FromRef(str js.Ref) PlayStoreStatus { 103 return PlayStoreStatus(bindings.ConstOfPlayStoreStatus(str)) 104 } 105 106 func (x PlayStoreStatus) String() (string, bool) { 107 switch x { 108 case PlayStoreStatus_NOT_AVAILABLE: 109 return "not available", true 110 case PlayStoreStatus_AVAILABLE: 111 return "available", true 112 case PlayStoreStatus_ENABLED: 113 return "enabled", true 114 default: 115 return "", false 116 } 117 } 118 119 type SessionType uint32 120 121 const ( 122 _ SessionType = iota 123 124 SessionType_NORMAL 125 SessionType_KIOSK 126 SessionType_PUBLIC_SESSION 127 ) 128 129 func (SessionType) FromRef(str js.Ref) SessionType { 130 return SessionType(bindings.ConstOfSessionType(str)) 131 } 132 133 func (x SessionType) String() (string, bool) { 134 switch x { 135 case SessionType_NORMAL: 136 return "normal", true 137 case SessionType_KIOSK: 138 return "kiosk", true 139 case SessionType_PUBLIC_SESSION: 140 return "public session", true 141 default: 142 return "", false 143 } 144 } 145 146 type StylusStatus uint32 147 148 const ( 149 _ StylusStatus = iota 150 151 StylusStatus_UNSUPPORTED 152 StylusStatus_SUPPORTED 153 StylusStatus_SEEN 154 ) 155 156 func (StylusStatus) FromRef(str js.Ref) StylusStatus { 157 return StylusStatus(bindings.ConstOfStylusStatus(str)) 158 } 159 160 func (x StylusStatus) String() (string, bool) { 161 switch x { 162 case StylusStatus_UNSUPPORTED: 163 return "unsupported", true 164 case StylusStatus_SUPPORTED: 165 return "supported", true 166 case StylusStatus_SEEN: 167 return "seen", true 168 default: 169 return "", false 170 } 171 } 172 173 type GetReturnType struct { 174 // A11yAutoClickEnabled is "GetReturnType.a11yAutoClickEnabled" 175 // 176 // Optional 177 // 178 // NOTE: FFI_USE_A11yAutoClickEnabled MUST be set to true to make this field effective. 179 A11yAutoClickEnabled bool 180 // A11yCaretHighlightEnabled is "GetReturnType.a11yCaretHighlightEnabled" 181 // 182 // Optional 183 // 184 // NOTE: FFI_USE_A11yCaretHighlightEnabled MUST be set to true to make this field effective. 185 A11yCaretHighlightEnabled bool 186 // A11yCursorColorEnabled is "GetReturnType.a11yCursorColorEnabled" 187 // 188 // Optional 189 // 190 // NOTE: FFI_USE_A11yCursorColorEnabled MUST be set to true to make this field effective. 191 A11yCursorColorEnabled bool 192 // A11yCursorHighlightEnabled is "GetReturnType.a11yCursorHighlightEnabled" 193 // 194 // Optional 195 // 196 // NOTE: FFI_USE_A11yCursorHighlightEnabled MUST be set to true to make this field effective. 197 A11yCursorHighlightEnabled bool 198 // A11yDockedMagnifierEnabled is "GetReturnType.a11yDockedMagnifierEnabled" 199 // 200 // Optional 201 // 202 // NOTE: FFI_USE_A11yDockedMagnifierEnabled MUST be set to true to make this field effective. 203 A11yDockedMagnifierEnabled bool 204 // A11yFocusHighlightEnabled is "GetReturnType.a11yFocusHighlightEnabled" 205 // 206 // Optional 207 // 208 // NOTE: FFI_USE_A11yFocusHighlightEnabled MUST be set to true to make this field effective. 209 A11yFocusHighlightEnabled bool 210 // A11yHighContrastEnabled is "GetReturnType.a11yHighContrastEnabled" 211 // 212 // Optional 213 // 214 // NOTE: FFI_USE_A11yHighContrastEnabled MUST be set to true to make this field effective. 215 A11yHighContrastEnabled bool 216 // A11yLargeCursorEnabled is "GetReturnType.a11yLargeCursorEnabled" 217 // 218 // Optional 219 // 220 // NOTE: FFI_USE_A11yLargeCursorEnabled MUST be set to true to make this field effective. 221 A11yLargeCursorEnabled bool 222 // A11yScreenMagnifierEnabled is "GetReturnType.a11yScreenMagnifierEnabled" 223 // 224 // Optional 225 // 226 // NOTE: FFI_USE_A11yScreenMagnifierEnabled MUST be set to true to make this field effective. 227 A11yScreenMagnifierEnabled bool 228 // A11ySelectToSpeakEnabled is "GetReturnType.a11ySelectToSpeakEnabled" 229 // 230 // Optional 231 // 232 // NOTE: FFI_USE_A11ySelectToSpeakEnabled MUST be set to true to make this field effective. 233 A11ySelectToSpeakEnabled bool 234 // A11ySpokenFeedbackEnabled is "GetReturnType.a11ySpokenFeedbackEnabled" 235 // 236 // Optional 237 // 238 // NOTE: FFI_USE_A11ySpokenFeedbackEnabled MUST be set to true to make this field effective. 239 A11ySpokenFeedbackEnabled bool 240 // A11yStickyKeysEnabled is "GetReturnType.a11yStickyKeysEnabled" 241 // 242 // Optional 243 // 244 // NOTE: FFI_USE_A11yStickyKeysEnabled MUST be set to true to make this field effective. 245 A11yStickyKeysEnabled bool 246 // A11ySwitchAccessEnabled is "GetReturnType.a11ySwitchAccessEnabled" 247 // 248 // Optional 249 // 250 // NOTE: FFI_USE_A11ySwitchAccessEnabled MUST be set to true to make this field effective. 251 A11ySwitchAccessEnabled bool 252 // A11yVirtualKeyboardEnabled is "GetReturnType.a11yVirtualKeyboardEnabled" 253 // 254 // Optional 255 // 256 // NOTE: FFI_USE_A11yVirtualKeyboardEnabled MUST be set to true to make this field effective. 257 A11yVirtualKeyboardEnabled bool 258 // AssistantStatus is "GetReturnType.assistantStatus" 259 // 260 // Optional 261 AssistantStatus AssistantStatus 262 // Board is "GetReturnType.board" 263 // 264 // Optional 265 Board js.String 266 // ClientId is "GetReturnType.clientId" 267 // 268 // Optional 269 ClientId js.String 270 // CustomizationId is "GetReturnType.customizationId" 271 // 272 // Optional 273 CustomizationId js.String 274 // DeviceType is "GetReturnType.deviceType" 275 // 276 // Optional 277 DeviceType DeviceType 278 // HomeProvider is "GetReturnType.homeProvider" 279 // 280 // Optional 281 HomeProvider js.String 282 // Hwid is "GetReturnType.hwid" 283 // 284 // Optional 285 Hwid js.String 286 // InitialLocale is "GetReturnType.initialLocale" 287 // 288 // Optional 289 InitialLocale js.String 290 // IsMeetDevice is "GetReturnType.isMeetDevice" 291 // 292 // Optional 293 // 294 // NOTE: FFI_USE_IsMeetDevice MUST be set to true to make this field effective. 295 IsMeetDevice bool 296 // IsOwner is "GetReturnType.isOwner" 297 // 298 // Optional 299 // 300 // NOTE: FFI_USE_IsOwner MUST be set to true to make this field effective. 301 IsOwner bool 302 // ManagedDeviceStatus is "GetReturnType.managedDeviceStatus" 303 // 304 // Optional 305 ManagedDeviceStatus ManagedDeviceStatus 306 // PlayStoreStatus is "GetReturnType.playStoreStatus" 307 // 308 // Optional 309 PlayStoreStatus PlayStoreStatus 310 // SendFunctionKeys is "GetReturnType.sendFunctionKeys" 311 // 312 // Optional 313 // 314 // NOTE: FFI_USE_SendFunctionKeys MUST be set to true to make this field effective. 315 SendFunctionKeys bool 316 // SessionType is "GetReturnType.sessionType" 317 // 318 // Optional 319 SessionType SessionType 320 // StylusStatus is "GetReturnType.stylusStatus" 321 // 322 // Optional 323 StylusStatus StylusStatus 324 // SupportedTimezones is "GetReturnType.supportedTimezones" 325 // 326 // Optional 327 SupportedTimezones js.Array[js.Array[js.String]] 328 // Timezone is "GetReturnType.timezone" 329 // 330 // Optional 331 Timezone js.String 332 333 FFI_USE_A11yAutoClickEnabled bool // for A11yAutoClickEnabled. 334 FFI_USE_A11yCaretHighlightEnabled bool // for A11yCaretHighlightEnabled. 335 FFI_USE_A11yCursorColorEnabled bool // for A11yCursorColorEnabled. 336 FFI_USE_A11yCursorHighlightEnabled bool // for A11yCursorHighlightEnabled. 337 FFI_USE_A11yDockedMagnifierEnabled bool // for A11yDockedMagnifierEnabled. 338 FFI_USE_A11yFocusHighlightEnabled bool // for A11yFocusHighlightEnabled. 339 FFI_USE_A11yHighContrastEnabled bool // for A11yHighContrastEnabled. 340 FFI_USE_A11yLargeCursorEnabled bool // for A11yLargeCursorEnabled. 341 FFI_USE_A11yScreenMagnifierEnabled bool // for A11yScreenMagnifierEnabled. 342 FFI_USE_A11ySelectToSpeakEnabled bool // for A11ySelectToSpeakEnabled. 343 FFI_USE_A11ySpokenFeedbackEnabled bool // for A11ySpokenFeedbackEnabled. 344 FFI_USE_A11yStickyKeysEnabled bool // for A11yStickyKeysEnabled. 345 FFI_USE_A11ySwitchAccessEnabled bool // for A11ySwitchAccessEnabled. 346 FFI_USE_A11yVirtualKeyboardEnabled bool // for A11yVirtualKeyboardEnabled. 347 FFI_USE_IsMeetDevice bool // for IsMeetDevice. 348 FFI_USE_IsOwner bool // for IsOwner. 349 FFI_USE_SendFunctionKeys bool // for SendFunctionKeys. 350 351 FFI_USE bool 352 } 353 354 // FromRef calls UpdateFrom and returns a GetReturnType with all fields set. 355 func (p GetReturnType) FromRef(ref js.Ref) GetReturnType { 356 p.UpdateFrom(ref) 357 return p 358 } 359 360 // New creates a new GetReturnType in the application heap. 361 func (p GetReturnType) New() js.Ref { 362 return bindings.GetReturnTypeJSLoad( 363 js.Pointer(&p), js.True, 0, 364 ) 365 } 366 367 // UpdateFrom copies value of all fields of the heap object to p. 368 func (p *GetReturnType) UpdateFrom(ref js.Ref) { 369 bindings.GetReturnTypeJSStore( 370 js.Pointer(p), ref, 371 ) 372 } 373 374 // Update writes all fields of the p to the heap object referenced by ref. 375 func (p *GetReturnType) Update(ref js.Ref) { 376 bindings.GetReturnTypeJSLoad( 377 js.Pointer(p), js.False, ref, 378 ) 379 } 380 381 // FreeMembers frees fields with heap reference, if recursive is true 382 // free all heap references reachable from p. 383 func (p *GetReturnType) FreeMembers(recursive bool) { 384 js.Free( 385 p.Board.Ref(), 386 p.ClientId.Ref(), 387 p.CustomizationId.Ref(), 388 p.HomeProvider.Ref(), 389 p.Hwid.Ref(), 390 p.InitialLocale.Ref(), 391 p.SupportedTimezones.Ref(), 392 p.Timezone.Ref(), 393 ) 394 p.Board = p.Board.FromRef(js.Undefined) 395 p.ClientId = p.ClientId.FromRef(js.Undefined) 396 p.CustomizationId = p.CustomizationId.FromRef(js.Undefined) 397 p.HomeProvider = p.HomeProvider.FromRef(js.Undefined) 398 p.Hwid = p.Hwid.FromRef(js.Undefined) 399 p.InitialLocale = p.InitialLocale.FromRef(js.Undefined) 400 p.SupportedTimezones = p.SupportedTimezones.FromRef(js.Undefined) 401 p.Timezone = p.Timezone.FromRef(js.Undefined) 402 } 403 404 type PropertyName uint32 405 406 const ( 407 _ PropertyName = iota 408 409 PropertyName_TIMEZONE 410 PropertyName_A_11Y_LARGE_CURSOR_ENABLED 411 PropertyName_A_11Y_STICKY_KEYS_ENABLED 412 PropertyName_A_11Y_SPOKEN_FEEDBACK_ENABLED 413 PropertyName_A_11Y_HIGH_CONTRAST_ENABLED 414 PropertyName_A_11Y_SCREEN_MAGNIFIER_ENABLED 415 PropertyName_A_11Y_AUTO_CLICK_ENABLED 416 PropertyName_A_11Y_VIRTUAL_KEYBOARD_ENABLED 417 PropertyName_A_11Y_CARET_HIGHLIGHT_ENABLED 418 PropertyName_A_11Y_CURSOR_HIGHLIGHT_ENABLED 419 PropertyName_A_11Y_FOCUS_HIGHLIGHT_ENABLED 420 PropertyName_A_11Y_SELECT_TO_SPEAK_ENABLED 421 PropertyName_A_11Y_SWITCH_ACCESS_ENABLED 422 PropertyName_A_11Y_CURSOR_COLOR_ENABLED 423 PropertyName_A_11Y_DOCKED_MAGNIFIER_ENABLED 424 PropertyName_SEND_FUNCTION_KEYS 425 ) 426 427 func (PropertyName) FromRef(str js.Ref) PropertyName { 428 return PropertyName(bindings.ConstOfPropertyName(str)) 429 } 430 431 func (x PropertyName) String() (string, bool) { 432 switch x { 433 case PropertyName_TIMEZONE: 434 return "timezone", true 435 case PropertyName_A_11Y_LARGE_CURSOR_ENABLED: 436 return "a11yLargeCursorEnabled", true 437 case PropertyName_A_11Y_STICKY_KEYS_ENABLED: 438 return "a11yStickyKeysEnabled", true 439 case PropertyName_A_11Y_SPOKEN_FEEDBACK_ENABLED: 440 return "a11ySpokenFeedbackEnabled", true 441 case PropertyName_A_11Y_HIGH_CONTRAST_ENABLED: 442 return "a11yHighContrastEnabled", true 443 case PropertyName_A_11Y_SCREEN_MAGNIFIER_ENABLED: 444 return "a11yScreenMagnifierEnabled", true 445 case PropertyName_A_11Y_AUTO_CLICK_ENABLED: 446 return "a11yAutoClickEnabled", true 447 case PropertyName_A_11Y_VIRTUAL_KEYBOARD_ENABLED: 448 return "a11yVirtualKeyboardEnabled", true 449 case PropertyName_A_11Y_CARET_HIGHLIGHT_ENABLED: 450 return "a11yCaretHighlightEnabled", true 451 case PropertyName_A_11Y_CURSOR_HIGHLIGHT_ENABLED: 452 return "a11yCursorHighlightEnabled", true 453 case PropertyName_A_11Y_FOCUS_HIGHLIGHT_ENABLED: 454 return "a11yFocusHighlightEnabled", true 455 case PropertyName_A_11Y_SELECT_TO_SPEAK_ENABLED: 456 return "a11ySelectToSpeakEnabled", true 457 case PropertyName_A_11Y_SWITCH_ACCESS_ENABLED: 458 return "a11ySwitchAccessEnabled", true 459 case PropertyName_A_11Y_CURSOR_COLOR_ENABLED: 460 return "a11yCursorColorEnabled", true 461 case PropertyName_A_11Y_DOCKED_MAGNIFIER_ENABLED: 462 return "a11yDockedMagnifierEnabled", true 463 case PropertyName_SEND_FUNCTION_KEYS: 464 return "sendFunctionKeys", true 465 default: 466 return "", false 467 } 468 } 469 470 // HasFuncGet returns true if the function "WEBEXT.chromeosInfoPrivate.get" exists. 471 func HasFuncGet() bool { 472 return js.True == bindings.HasFuncGet() 473 } 474 475 // FuncGet returns the function "WEBEXT.chromeosInfoPrivate.get". 476 func FuncGet() (fn js.Func[func(propertyNames js.Array[js.String]) js.Promise[GetReturnType]]) { 477 bindings.FuncGet( 478 js.Pointer(&fn), 479 ) 480 return 481 } 482 483 // Get calls the function "WEBEXT.chromeosInfoPrivate.get" directly. 484 func Get(propertyNames js.Array[js.String]) (ret js.Promise[GetReturnType]) { 485 bindings.CallGet( 486 js.Pointer(&ret), 487 propertyNames.Ref(), 488 ) 489 490 return 491 } 492 493 // TryGet calls the function "WEBEXT.chromeosInfoPrivate.get" 494 // in a try/catch block and returns (_, err, ok = false) when it went through 495 // the catch clause. 496 func TryGet(propertyNames js.Array[js.String]) (ret js.Promise[GetReturnType], exception js.Any, ok bool) { 497 ok = js.True == bindings.TryGet( 498 js.Pointer(&ret), js.Pointer(&exception), 499 propertyNames.Ref(), 500 ) 501 502 return 503 } 504 505 // HasFuncIsTabletModeEnabled returns true if the function "WEBEXT.chromeosInfoPrivate.isTabletModeEnabled" exists. 506 func HasFuncIsTabletModeEnabled() bool { 507 return js.True == bindings.HasFuncIsTabletModeEnabled() 508 } 509 510 // FuncIsTabletModeEnabled returns the function "WEBEXT.chromeosInfoPrivate.isTabletModeEnabled". 511 func FuncIsTabletModeEnabled() (fn js.Func[func() js.Promise[js.Boolean]]) { 512 bindings.FuncIsTabletModeEnabled( 513 js.Pointer(&fn), 514 ) 515 return 516 } 517 518 // IsTabletModeEnabled calls the function "WEBEXT.chromeosInfoPrivate.isTabletModeEnabled" directly. 519 func IsTabletModeEnabled() (ret js.Promise[js.Boolean]) { 520 bindings.CallIsTabletModeEnabled( 521 js.Pointer(&ret), 522 ) 523 524 return 525 } 526 527 // TryIsTabletModeEnabled calls the function "WEBEXT.chromeosInfoPrivate.isTabletModeEnabled" 528 // in a try/catch block and returns (_, err, ok = false) when it went through 529 // the catch clause. 530 func TryIsTabletModeEnabled() (ret js.Promise[js.Boolean], exception js.Any, ok bool) { 531 ok = js.True == bindings.TryIsTabletModeEnabled( 532 js.Pointer(&ret), js.Pointer(&exception), 533 ) 534 535 return 536 } 537 538 // HasFuncSet returns true if the function "WEBEXT.chromeosInfoPrivate.set" exists. 539 func HasFuncSet() bool { 540 return js.True == bindings.HasFuncSet() 541 } 542 543 // FuncSet returns the function "WEBEXT.chromeosInfoPrivate.set". 544 func FuncSet() (fn js.Func[func(propertyName PropertyName, propertyValue js.Any)]) { 545 bindings.FuncSet( 546 js.Pointer(&fn), 547 ) 548 return 549 } 550 551 // Set calls the function "WEBEXT.chromeosInfoPrivate.set" directly. 552 func Set(propertyName PropertyName, propertyValue js.Any) (ret js.Void) { 553 bindings.CallSet( 554 js.Pointer(&ret), 555 uint32(propertyName), 556 propertyValue.Ref(), 557 ) 558 559 return 560 } 561 562 // TrySet calls the function "WEBEXT.chromeosInfoPrivate.set" 563 // in a try/catch block and returns (_, err, ok = false) when it went through 564 // the catch clause. 565 func TrySet(propertyName PropertyName, propertyValue js.Any) (ret js.Void, exception js.Any, ok bool) { 566 ok = js.True == bindings.TrySet( 567 js.Pointer(&ret), js.Pointer(&exception), 568 uint32(propertyName), 569 propertyValue.Ref(), 570 ) 571 572 return 573 }