On the introduction of typedefs

Version 0.8.0 introduces typedefs to XIBLE. This brings two important features for developers and end-users.

Colors

Firstly, colors for your custom types in the editor can finally be set. Until this version, there were only a handful of hard-coded css rules that determined the colors of some basic types. Any other types simply showed up black.

Colored types make it easy for end-users to see whether an input and output can be connected, without actually having to drag a connector that may not match.

Extending other types

A bigger impact on the type system is the implementation of the ‘extends’ keyword in the type definitions. Previously, an input of type ‘string’ could only connect to outputs of the exact same type, or outputs that did not specify a type at all (or ‘any’).

With the implementation of the ‘object’ nodes, a clear problem arose. A string is also an object, just like its representation in the underlying platform NodeJS and language javascript. So the object.* nodes should also be able to interact with string types.

The ‘extends’ keyword in the typedef.json solves this by allowing to extend any type with another. This builds an extends chain which makes type connections much more flexible. Outputs of type string for example can now be connected to an input of type object, because string extends object.

Example typedef.json

Type definitions are stored in a typedef.json file, which should be stored somewhere in your nodepack, preferably alongside corresponding structure.json files.


{
  "mytype": {
    "color": "pink",
    "extends": "object"
  }
}

Typedefs in the docs, and the commit.