Problem with RED.library in v3.0.x

I'm using RED.library in node-red-contrib-hal2, and I'm having some problems in Node-RED v3.0.x. 'Open library...' no longer works with error

red.min.js?v=3.0.2:18 Uncaught TypeError: Cannot read properties of undefined (reading 'split')
    at Object.create (red.min.js?v=3.0.2:18:493228)
    at Object.create (red.min.js?v=3.0.2:18:445676)
    at Object.createEditor (red.min.js?v=3.0.2:18:421231)
    at Object.onselect (red.min.js?v=3.0.2:18:565468)
    at f (red.min.js?v=3.0.2:18:47362)
    at HTMLAnchorElement.<anonymous> (red.min.js?v=3.0.2:18:46005)
    at HTMLAnchorElement.dispatch (vendor.js?v=3.0.2:2:43090)
    at v.handle (vendor.js?v=3.0.2:2:41074)

'Save to library' still works as it should.

I'm guessing there's been a change? I've tried this in v.3.0.0 and v3.0.2.

My library.create:

            RED.library.create({
                url:"hal2ThingType", 
                type:"hal2ThingType",
                editor:editors['statusFn'],
                fields:[
                    {
                        name: 'name',
                        get: function() { return $("#node-config-input-name").val(); },
                        set: function(v) { $("#node-config-input-name").val(v+' (template copy)'); }
                    },                    
                    {
                        name: 'context_store',
                        get: function() { return contextStore = $("#node-config-input-contextStore").val(); },
                        set: function(v) { $("#node-config-input-contextStore").val((contextStores.includes(v)) ? v : contextStores[0]) }
                    },
                    {
                        name: 'show_state',
                        get: function() { return $("#node-config-input-nodestatus").typedInput('value'); },
                        set: function(v) { $("#node-config-input-nodestatus").typedInput('value',v) }
                    },
                    {
                        name: 'show_statetype',
                        get: function() { return $("#node-config-input-nodestatus").typedInput('type'); },
                        set: function(v) { if (typeof v != 'undefined') { $("#node-config-input-nodestatus").typedInput('type',v); }}
                    },
                    {
                        name: 'ingress',
                        get: function() { return JSON.stringify(getFunctions('ingress')); },
                        set: function(v) {
                            addFunctions('ingress',JSON.parse(v));
                            updateMainTab('ingress');
                            updateHbFunctions();
                            updateFilterFunctions();                            
                        }
                    },
                    {
                        name: 'egress',
                        get: function() { return JSON.stringify(getFunctions('egress')); },
                        set: function(v) {
                            addFunctions('egress',JSON.parse(v));
                            updateMainTab('egress');
                        }
                    },
                    {
                        name: 'filter_function',
                        get: function() { return $("#node-config-input-filterFunction").val(); },
                        set: function(v) { $("#node-config-input-filterFunction").val(v) }
                    },
                    {
                        name: 'attributes',
                        get: function() { return JSON.stringify(getAttributes()); },
                        set: function(v) { addAttributes(JSON.parse(v)); }
                    },
                    {
                        name: 'items',
                        get: function() { return JSON.stringify(getItems()); },
                        set: function(v) { addItems(JSON.parse(v)); }
                    },                    
                    {
                        name: 'check_alive',
                        get: function() { return $("#node-config-input-hbCheck").is(":checked") ? 'true' : 'false'; },
                        set: function(v) { $("#node-config-input-hbCheck").prop("checked",(v == 'true')).trigger('change'); }
                    },
                    {
                        name: 'heartbeat_type',
                        get: function() { return $("#node-config-input-hbType").val(); },
                        set: function(v) { $("#node-config-input-hbType").val(v).trigger('change'); }
                    },
                    {
                        name: 'heartbeat_ttl',
                        get: function() { return $("#node-config-input-hbTTL").val(); },
                        set: function(v) { $("#node-config-input-hbTTL").val(v) }
                    },
                    {
                        name: 'heartbeat_topicfilter',
                        get: function() { return $("#node-config-input-hbFilterVal").typedInput('value'); },
                        set: function(v) { $("#node-config-input-hbFilterVal").typedInput('value',v) }
                    },
                    {
                        name: 'heartbeat_topicfilterType',
                        get: function() { return $("#node-config-input-hbFilterVal").typedInput('type'); },
                        set: function(v) { $("#node-config-input-hbFilterVal").typedInput('type',v); }
                    },
                    {
                        name: 'heartbeat_ingress',
                        get: function() { return ($("#node-config-input-hbLWT").val() === null) ? '' : $("#node-config-input-hbLWT").val(); },
                        set: function(v) { $("#node-config-input-hbLWT").val(v) }
                    },
                    {
                        name: 'heartbeat_timestampProp',
                        get: function() { return ($("#node-config-input-hbPropVal").val() === null) ? '' : $("#node-config-input-hbPropVal").typedInput('value'); },
                        set: function(v) { if (typeof v != 'undefined') { $("#node-config-input-hbPropVal").typedInput('value',v) }}
                    },
                    {
                        name: 'heartbeat_timestampType',
                        get: function() { return ($("#node-config-input-hbPropVal").val() === null) ? '' : $("#node-config-input-hbPropVal").typedInput('type'); },
                        set: function(v) { if (typeof v != 'undefined') { $("#node-config-input-hbPropVal").typedInput('type',v); }}
                    }

                ],
                ext: "template"
            });

There are 2 ways to fix this...

  1. add mode and/or title to the options for RED.library.create({ title: 'My Library', mode: 'ace/mode/json', url: 'xxx', type: 'xxx', ... }
    OR
  2. upgrade to v3.0.2 (a bug was fixed 3 weeks ago)

Proof in v3.0.2...

Code used to build that...

RED.library.create({
    url:"hal2ThingType", 
    type:"hal2ThingType",
    editor: theFuncCodeEditor,
    fields:[
        {
            name: 'name',
            get: function() { return $("#node-input-name").val(); },
            set: function(v) { $("#node-input-name").val(v+' (template copy)'); }
        },
    ],
    ext: "template"
});

NOTE: theFuncCodeEditor was a temp hack to grab the function nodes editor & provide an editor instance to the library create options

Title & mode works perfectly, thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.