Hopefully you will be as excited as I am about some of the new features in this release!
Most notably, a brand new client library in both ESM and IIFE (UMD) versions so that you can start experimenting with browser-based ES Modules if you wish to or you can carry on using the simple script tag to load the more traditional IIFE version if you prefer.
The new client library introduces the concept of configuration-driven UI's. Create a UI partially or fully from JSON data either from files, web API's or simply from messages sent from Node-RED. Completely up to you. It works with standard HTML elements but also with ANY framework! Including Web Components, VueJS (v2 and v3), Svelte, etc. Check out the client documentation in the Tech Docs: Using the modern front-end client (totallyinformation.github.io).
Along with the new UI feature comes the first experimental UI node. uib-list
allows you to dynamically create a list on any web page connected to uibuilder simply by sending an array or object of data. The data is also cached and so is automatically sent when a client connects. A little simplistic in this version but please check out the roadmap for some of the goodies to come: Roadmap (totallyinformation.github.io).
There are also the usual updates and bug fixes. A potentially useful update for some is the addition of a pageName
property on the client connect/disconnect control messages. This allows you to make decisions about whether to respond based on the source page - useful in multi-page apps.
Also new is the connections
counter on control messages that let you know whether a client is a fresh page load or a reconnection. This is already added as an option to the uib-cache
node so that you can optimise cache replay events. It will be added to other caching nodes such as uib-list
in a future release.
As always, please let me know what you think and about any bugs.
Many thanks to the various people who have helped me with this release both with ideas and with testing.
Regards, Julian.
Note that this is likely to be the last of the v5 series (barring small fixes). The next main release should be v6 with a move to Node.js v14 LTS as a minimum version. That will be released after Node-RED v3 is released.
Changelog
Fixed
- Improved module path search to allow an array of locations. Removes spurious warning about socket.io client not being found.
-
/uibuilder/ping
now correctly returns 204 (no content) status not 201. -
web.js
::buildHtmlTable
- over-optimised regex broke the table cells, now fixed. - Connected control message now correctly contains the client id and client IP address. The client id does not change as much as the _socketId, it is saved in browser local storage so will be the same across sessions and multiple windows/tabs.
-
uib-sender
was not using topic defined in settings. If present, that overrides msg.topic. -
uibuilder
node - Editor: Add library had been over-optimised and wasn't working in the right order. Now fixed. This also fixed a problem with url rename.
Changed
-
clientId
is now session stable. That means that it does not change unless the client browser is restarted. It is now also included in more messages. For control messages, it will be found as a msg property. For_ui
related messages, it will be a property undermsg._ui
. Any other uses will appear undermsg._uib
. -
All code now Linted to "Standard JavaScript" with node.js v12 and front-end to ECMA2019. Null/undefined guards put in place.
-
Package.json: Changed homepage to point to Tech Docs on github.io.
-
Client libraries and css available on
../uibuilder/
path as well as on./
path for consistency with other server paths. -
Client connect, disconnect and error control messages (uibulder node output port #2) now contain more information. Includes: client version, clientId, Client IP address, page name, number of (re)connections.
-
express-session
andjsonwebtoken
dependencies removed as no longer in use. -
Editor:
- Added stylesheet containing a class of
emoji
which provides nicer, cross-platform, colour emojis. - Libraries tab:
- Change "URL to use:" to "Estimated link:" on the Libraries tab to make it clear that it might not be correct (down to the library author).
- Added info emoji to package name (links to package homepage).
- Added url link to estimated library to make it easier to find out if it actually exists and exactly where.
- Added stylesheet containing a class of
-
uib-cache
node- Added option to not replay the cache if the client connection isn't actually new (e.g. if the client is a reconnection after restarting Node-RED).If the control msg recieved contains
msg.connected
and it is >0, that means that the client is reconnecting and this isn't a client page load. Note that currently, only the new ES module client library populates themsg.connected
value. This option is selected by default. - The context store type (node, flow, global) can now be selected (only node was previously used).
- The variable name can now be changed. May be needed if using flow/global stores with multiple cache nodes.
- Added option to not replay the cache if the client connection isn't actually new (e.g. if the client is a reconnection after restarting Node-RED).If the control msg recieved contains
-
package-mgt.js
:- Rewrite root package.json and package details processing for more efficiency + prettify package.json output
- Add outdated (current/wanted/latest) to uibRoot/package.json>uibuilder.packages in prep for update display in Editor
-
Old client library
uibuilderfe.js
- Connection count, and page name added to initial "client connect" message in line with the new client.
- The old
uibuilderfe.js
client library is now "functionally stable". It will no longer be updated. Please consider moving to the new library (see below). When v6 is released, the old client library will be deprecated.
New
-
uib-brand.css
- will eventually be the new default uibuilder CSS. It is light/dark switchable both manually and by browser preference. Still under development, this WILL CHANGE, probably quite a bit. There are still some variables that are needed in order to be able to sensible control things like spacing and sizing. -
New ES Module front-end client library (
uibuilder.esm.min.js
)The new library will only work with web browsers from early 2019 or later (only really impacts if you are stuck on IE11 or on an Apple device that doesn't support iOS 12 or later). It uses the new brand CSS by default.
Key differences from the old library:
- Supports the new configuration/message-driven features that let you both build and modify web pages dynamically.
- Can load an entire UI from a JSON file (or JSON response from a web server). Can also do incremental loads and dynamic changes.
- Incorporates the socket.io client library so you don't need to worry about it ever again!
- Requires a modern(ish) browser.
- Has to be loaded as an ES Module.
- No built-in VueJS features, use the new msg._ui features instead.
- No need for
uibuilder.start()
in your code any more (nearly always). Often no code needed at all in fact! (Other than loading the library of course). -
uibuilder.eventSend()
now has a lot more information attached. It also now uses themsg._ui
property to hold all of the information (except for the payload which is as-before). This brings it into line with the other _ui handling. Attributes, classes, clientId and custom properties are all now included. - New function
uibuilder.ui({...})
allows passing the same data asmsg._ui
from front-end code. - The "client connect" uibuilder control msg that is output on port #2 when a client (re)connects, now has additional details from the client: client
version
,clientId
, clientip
, number ofconnections
since the client last (re)loaded the page. Use to work out whether the client is new or a reconnection. Used by the updateduib-cache
node.
See the
uibuilder.module.md
page in the tech docs for all of the features and details for the new library.- Clients now report how many times they have connected since last page load. This lets uibuilder know whether the client is reconnecting or connecting for the first time.
Please use the
uibuilder.esm.min.js
in preference to theuibuilder.esm.js
version which is only for people needing to do their own bundling. Themin
version includes amap
so that debugging is as good as (actually better than) using the non-min version. -
New IIFE Module front-end client library (
uibuilder.iife.min.js
)This is the same as the ES Module client version above but is wrapped as as a standard JavaScript IIFE function which means that it can simply be loaded as a script link (as per the orgiginal
uibuilderfe.js
client library). You should not attempt to load this version of the new library as an ES Module.As with the module version above, when using this version, you should no longer manually load the Socket.IO client library and should hardly ever need to call
uibuilder.start
.All of the features of the ESM version should work as expected but please note that testing on this client has been limited so far. Please report any errors so that they can be corrected.
-
New Node -
uib-list
Consider this to be the first experimental node in what will hopefully be a series. It can be sent a message who's payload is an array of strings or an array of an array of strings.
The node creates a new
<ul>
,<ol>
, or<dl>
HTML list according to the settings. In the case of it being sent an array of arrays, the outer array creates a new list entry and the inner array is joined as a comma-separated list. A<dl>
list however must be given an array of arrays and the first entry in the inner array becomes the<dt>
entry with the 2nd becoming the<dd>
entry.The node also requires you specify the uibuilder URL that the node links to along with a required HTML element id that is used to identify the element. Optionally, you can also set a parent element by specifying a CSS selector, the list will be attached ot the end of that parent as a new child. Note that if the selector is not unique, only the first found element will be used.
Instead of outputting to the uibuilder node, you can instead output a message that contains the appropriate
msg._ui
configuration used by the new front-end ES Module library. You can use this to help you build larger and more complex UI's and to help learn about how the configuration-driven UI features work. Such a message could be further processed and then sent to an appropriate uibuilder node.One additional feature is that the configuration is retained in the node (until Node-RED is restarted or you re-deploy the node/flow) and whenever a new client connects to the matching uibuilder instance, it will send the complete configuration to the new client. This ensures that client browsers connecting after you have created the configuration will all receive it and so will have matching UI's.
-
Runtime
-
Each uibuilder node instance issues a tiEvent when:
- Instance setup is completed (
node-red-contrib-uibuilder/${url}/instanceSetupComplete
). The node object is passed as data. - A client (re)connects (
node-red-contrib-uibuilder/${url}/clientConnect
). The control msg is passed as data. - When a client disconnects (
node-red-contrib-uibuilder/${url}/clientDisconnect
). The control msg is passed as data.
These can be used by any other node that uses the
@totallyinformation/ti-common-events
module. Such as the experimentaluib-list
node. - Instance setup is completed (
-