tor-browser

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

index.js (1737B)


      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 const client = require("resource://devtools/client/shared/components/object-inspector/utils/client.js");
      6 const loadProperties = require("resource://devtools/client/shared/components/object-inspector/utils/load-properties.js");
      7 const node = require("resource://devtools/client/shared/components/object-inspector/utils/node.js");
      8 const { nodeIsError, nodeIsPrimitive } = node;
      9 const selection = require("resource://devtools/client/shared/components/object-inspector/utils/selection.js");
     10 
     11 const {
     12  MODE,
     13 } = ChromeUtils.importESModule("resource://devtools/client/shared/components/reps/reps/constants.mjs", {global: "current"});
     14 const {
     15  REPS: { Rep, Grip },
     16 } = ChromeUtils.importESModule("resource://devtools/client/shared/components/reps/reps/rep.mjs", {global: "current"});
     17 
     18 function shouldRenderRootsInReps(roots, props = {}) {
     19  if (roots.length !== 1) {
     20    return false;
     21  }
     22 
     23  const root = roots[0];
     24  const name = root && root.name;
     25 
     26  return (
     27    (name === null || typeof name === "undefined") &&
     28    (nodeIsPrimitive(root) ||
     29      (root?.contents?.value?.useCustomFormatter === true &&
     30        Array.isArray(root?.contents?.value?.header)) ||
     31      (nodeIsError(root) && props?.customFormat === true))
     32  );
     33 }
     34 
     35 function renderRep(item, props) {
     36  return Rep({
     37    ...props,
     38    front: item.contents.front,
     39    object: node.getValue(item),
     40    mode: props.mode || MODE.TINY,
     41    defaultRep: Grip,
     42  });
     43 }
     44 
     45 module.exports = {
     46  client,
     47  loadProperties,
     48  node,
     49  renderRep,
     50  selection,
     51  shouldRenderRootsInReps,
     52 };