jsterm-911456: Review fixes

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsonhelp-964283: Convert json property to toJson() function

Crops up in Command and Parameter, we’re going to need to make this
async, so it’s clearer if it’s a function not a property.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Simplify how we create param name in help

A small simplification to create the name at the top rather than in 2
parts which we concatenate later.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Pre-calculate parameter properties

We were using Object.defineProperty, but that seems like an overkill

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsonhelp-964283: Update toJson to not serialize defaultValue

We really need to support defaultText as a replacement, but that’s
going to take more work so for now we just use a dummy value.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Improve debugging on stringify failure

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsonhelp-964283: Use metadata rather than server objects

This allows us to work remotely.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
refactor-864370: Remove dysfunctional defaultValue check

This check wasn’t being used due to a bug, and while nice can’t be
safely re-enabled due to lack of a ‘context’ object. We should
re-instate this check when we support defaultText

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccanon-964287: Move remoted functions to remoted.exposed

The remoted module contains functions that we want to expose remotely.
Previously they were stored at the top level of the module, but that
made it hard to add non-remoted functions (which we want to do for
server events) So we move the remoted functions to an ‘exposed’
property.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccanon-964287: Add server event support

Add simple [add|remove]Listener functions on the 'remoted' module.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccanon-964287: Create a Connection base type

The base connection type contains methods for passing events from the
server back to the client. This system is not supported for XHR
connections for obvious reasons.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccanon-964287: Simplify converter registration

Previously we were adding all items to the client requisition, and then
filtering out the non-converters with hacks. Now we do the filtering
before we call addItems.

This change also wires up the server event system.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccanon-964287: Simplify how items are transferred

We did have a structure that separated commands from types (like
{ commands:…, types:… } which wasn’t great because elsewhere we have a
pattern of using a single ‘items’ array (commands and types are easy to
distinguish) and because we never used types anyway. So this removes
the structure and uses a simple items array.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
synccanon-964287: ‘context’ is a client only command

The context command is client only because it's essentially sugar to
help typing commands. When there is a command prefix in action, it is
the job of the remoter to add the prefix to the typed strings that are
sent for remote execution.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
delegatedremote-964290: Fix delegated remote types

Well almost. There is one remaining problem because the state of the
command line is not correctly setup before the remote delegated arg
parse happens. Hence the skipIf:options.isRemote that we added to
testPref1.testPrefSetStatus()

Signed-off-by: Joe Walker <jwalker@mozilla.com>
delegatedremote-964290: Don’t use callHandle for remote delegate types

Add 3 functions to remoted to remove the need for callHandle which is
jacky and probably going to cause memory leaks.
This also fixes the problem with the failing test in testPref1.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
delegatedremote-964290: Don’t use callHandle at all

The whole callHandle was a memory leak waiting to happen. So now we’ve
got methods declared in remoted for everything we remote.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
delegatedremote-964290: Setup mock settings with mock commands

Not all test cases were working properly because sometimes the mock
settings were being setup on the client cli and used on the server cli
so we move mock setting setup/shutdown to use the same system as mock
commands.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Simplify startup

Now all parts of the startup process take an options object from which
they get what they need and pass on what they create. Also the setup of
mocks was moved into the test setup (where it obviously should be)
rather than the connect code.

Signed-off-by: Joe Walker <jwalker@mozilla.com>
jsterm-911456: Minor tweaks

Update various bits of documentation.
Add better debug to the server.
Make DirectConnection switchable between sync and async calling for
testing and debug.

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