tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

types.js (3463B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 "use strict";
      6 
      7 const PropTypes = require("resource://devtools/client/shared/vendor/react-prop-types.mjs");
      8 const { createEnum } = require("resource://devtools/client/shared/enum.js");
      9 
     10 // React PropTypes are used to describe the expected "shape" of various common
     11 // objects that get passed down as props to components.
     12 
     13 /* ENUMS */
     14 
     15 /**
     16 * An enum containing the possible states for loadable things.
     17 */
     18 exports.loadableState = createEnum([
     19  "INITIALIZED",
     20  "LOADING",
     21  "LOADED",
     22  "ERROR",
     23 ]);
     24 
     25 /* DEVICE */
     26 
     27 /**
     28 * A single device that can be displayed in the viewport.
     29 */
     30 const device = {
     31  // The name of the device
     32  name: PropTypes.string,
     33 
     34  // The width of the device
     35  width: PropTypes.number,
     36 
     37  // The height of the device
     38  height: PropTypes.number,
     39 
     40  // The pixel ratio of the device
     41  pixelRatio: PropTypes.number,
     42 
     43  // The user agent string of the device
     44  userAgent: PropTypes.string,
     45 
     46  // Whether or not it is a touch device
     47  touch: PropTypes.bool,
     48 
     49  // The operating system of the device
     50  os: PropTypes.string,
     51 
     52  // Whether or not the device is displayed in the device selector
     53  displayed: PropTypes.bool,
     54 };
     55 
     56 /**
     57 * A list of devices and their types that can be displayed in the viewport.
     58 */
     59 exports.devices = {
     60  // An array of device types
     61  types: PropTypes.arrayOf(PropTypes.string),
     62 
     63  // An array of phone devices
     64  phones: PropTypes.arrayOf(PropTypes.shape(device)),
     65 
     66  // An array of tablet devices
     67  tablets: PropTypes.arrayOf(PropTypes.shape(device)),
     68 
     69  // An array of laptop devices
     70  laptops: PropTypes.arrayOf(PropTypes.shape(device)),
     71 
     72  // An array of television devices
     73  televisions: PropTypes.arrayOf(PropTypes.shape(device)),
     74 
     75  // An array of console devices
     76  consoles: PropTypes.arrayOf(PropTypes.shape(device)),
     77 
     78  // An array of watch devices
     79  watches: PropTypes.arrayOf(PropTypes.shape(device)),
     80 
     81  // Whether or not the device modal is open
     82  isModalOpen: PropTypes.bool,
     83 
     84  // Viewport id that triggered the modal to open
     85  modalOpenedFromViewport: PropTypes.number,
     86 
     87  // Device list state, possible values are exported above in an enum
     88  listState: PropTypes.oneOf(Object.keys(exports.loadableState)),
     89 };
     90 
     91 /* VIEWPORT */
     92 
     93 /**
     94 * Network throttling state for a given viewport.
     95 */
     96 exports.networkThrottling = {
     97  // Whether or not network throttling is enabled
     98  enabled: PropTypes.bool,
     99 
    100  // Name of the selected throttling profile
    101  profile: PropTypes.string,
    102 };
    103 
    104 /**
    105 * A single viewport displaying a document.
    106 */
    107 exports.viewport = {
    108  // The id of the viewport
    109  id: PropTypes.number,
    110 
    111  // The currently selected device applied to the viewport
    112  device: PropTypes.string,
    113 
    114  // The currently selected device type applied to the viewport
    115  deviceType: PropTypes.string,
    116 
    117  // The width of the viewport
    118  width: PropTypes.number,
    119 
    120  // The height of the viewport
    121  height: PropTypes.number,
    122 
    123  // The device pixel ratio of the viewport
    124  pixelRatio: PropTypes.number,
    125 
    126  // The user context (container) ID for the viewport
    127  // Defaults to 0 meaning the default context
    128  userContextId: PropTypes.number,
    129 };
    130 
    131 /* ACTIONS IN PROGRESS */
    132 
    133 /**
    134 * The progression of the screenshot.
    135 */
    136 exports.screenshot = {
    137  // Whether screenshot capturing is in progress
    138  isCapturing: PropTypes.bool,
    139 };