remotegcli-839862: Update connect command

Previously we were constrained to have only one connection at a time
and we didn't have any route to adding differing types of connection.
By extracting a Connection object, we can easily connect more than once
and by having a Request object we begin to separate the connection
protocol from the rest of GCLI.

Also add a canon.removeProxyCommands function to match the
canon.addProxyCommands that we added earlier.
We also created a new 'connection' type that completes the named
connections.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
types-767589: s/getType/createType/g

Some initial preparation.
types.getType is a misleading name because in many cases (and probably
it should be all cases) we are creating a new object. So we name it
types.createType instead.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
types-767589: Allow object literal type definitions

Previously Types all inherited (eventually) from 'Type' or more directly
from SelectionType or DelegateType. They had to do this because various
parts of the system used 'instanceof' to check what they were.

This makes exposing types hard because all new types must first import
types from GCLI, and must then jump through JS inheritance hoops before
registering a new type.

So this change arms 'addType' with the ability to register a new type
using an object literal that contains a 'parent' property which points
to another type whose properties should be used as a 'manual prototype',
that is to say we'll create a new object copy in the parent properties
then copy in the provided properties.

In future commits we'll avoid using instanceof in GCLI code and upgrade
a couple of types to the new system.

We're continuing to allow old-style types in the short term for 2
reasons:
* It's work to remove them, and external things may still need them
* We have some concerns that it might slow the system down as a result
  of confusing the type inference system in JS engines.

Any existing slowdown is in the order of 0.5ms per keypress [1], however
which sounds low, put it has to be put against the overall average time
to process a keypress of around 5ms.

[1] This isn't very scientific though.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
types-767589: Allow subtype discovery

Most types can be discovered using their name property (for example:
type.name === 'string') however delegate and selection types are
designed to be inherited from, so we add isDelegate and isSelection to
the type definition.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
types-767589: Use new type identification system

Convert use of instanceof to either 'type.name === xxx' or type.isXxx
as detailed in previous 2 commits.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
types-767589: Use object-literal type style

Upgrade the following types to use the new object-literal type style:
connection, setting, settingValue and the test types in mockCommands.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
types-767589: Refactor 'tokenize' to be static

Previously the tokenize function was available on the Requisition object
but it never required access to any of the properties of a requisition
so we've making it a separate function.

In the future we are likely to have command line functions that make
use of this tokenise functionality.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Hack modules not the help command

GCLI in node-js uses the standard help command, however because we're
outputting to text there is a different template. Previously in order
to get this to be used we'd alter the help module, however with this
change we just define the template that we want help to require.

Changes to code that goes into Firefox:
- The help module no-longer exports hooks to alter the templates
- A new viewToString converter

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Better errors from converters.js

The fallback converter now outputs to console.error. Plus some minor
tidy-ups.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Tighten up conversion types

Add a number of converters from number, boolean, undefined and null to
dom, which could help with commands like 'pref set' that have no return
value.

Complain if the value that we get in the output object is just 'object'
which means that it wasn't specified anywhere.

Have intro.js output a typed object rather than leaving it to be
guessed by something.

Also remove a redundant check:{} from testCanon.js

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Collect websocket support together

Previously the websocket support was meshed into the 'server start'
command exec function. This is now extracted into a separate collection
of functions and the argument is renamed from --commands to
--websocket.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Output.onChange -> output.promise

Output already had a promise, but it tried to use an onChange function
too in-case of an evolving output. Current thinking is that we should
have long-running commands emit a separate stream object rather than
having Output be both a promise and a stream.

This change removes the onChange event and replaces it with a promise.

Signed-off-by: Joe Walker <jwalker@mozilla.com>