Anyone know what the error message "Plugin TypeError: r is not a function" is about

Plugin TypeError: r is not a function
    at Object.execScenegraphEdit (plugins/ScenegraphGuard.js:1:3285)
    at BaseCommand._invokePluginCommand [as _commandFn] (plugins/PluginLoader.js:1:3296)
    at BaseCommand.execute (lib/BaseCommand.js:1:929)
    at Commands._execute (lib/Commands.js:1:1915)
    at Commands.executeAsGesture (lib/Commands.js:1:2064)

Just if anything rings a bell. I’ll describe how to reproduce it if not.

This might be a sign of an incorrect parameter to a scenegraph API. Can you share repro steps?

I’ll do that, just need to clean up the code a bit =)

1 Like

So, to reproduce:

git clone git@github.com:eklem/designing-with-search-data.git
cd designing-with-search-data
npm install

Add var indexedDB to ./node_modules/level-js/index.js like this:

/* global indexedDB */

'use strict'

var indexedDB
module.exports = Level

Back to console

npx webpack-cli --devtool false --mode development XD-webpackable.js -o XD-webpacked.js
cp -r ../designing-with-search-data <XD plugin develop folder>

Basically two commands repeated. Outside any function (runs when plugin is loaded), and inside PopulateWithSearch. The first one gets to index the documents and do a search, but not populate a repeater grid, and the second one (menu choice) errors like above.

1 Like

I’m guessing something in the code I’ve webpacked is not compatible with the SceneGraph?

@stevekwak Could you help me a little with this bug / issue? I’m trying to get going on the search engine plugin again =)

I guess I need to set up a webpack.config.js with “externals”: “scenegraph” ?

But is it so that I need need to import / require stuff from the sceneGraph in my webpack’able script and then say in my webpack.config.js that it is not to be imported in the webpaced script?

I can’t git clone your repo due to permission issues. Yes - you are right that you have to put XD specific modules in the externals property in your config file.

1 Like

Ah, my fault. You need to fork it, but I understand some more since last time and I’ll try some more before getting back with new questions =)

Thanks for you input, @stevekwak

So, just so I got it right. I want to do this:

let repeatGrid = selection.items[0].parent.parent;
let selectedTextNode = selection.items[0]
repeatGrid.attachTextDataSeries(selectedTextNode, searchReults)

Then I need to have this in my webpack’able file:

let {selection} = require('scenegraph')

And this in my webpack.config.js

externals: {
  scenegraph: 'scenegraph'
}

I guess that understanding what externals I’m using from XD is the part I’m most unsure aboiut.

But, just setting up the plugin to run when it’s loaded/reloaded seems promising, since I get this error message:

Plugin Error: Plugin cdxxxxxxxx is not permitted to make changes from the background. Use editDocument() for panel UI handlers, or return a Promise to extend an edit operation asynchronously.

1 Like

Repeat grids is one of the special nodes that need to be selected directly by user.

see - edit context rule . The plugin is not allowed to make changes beyond the edit context.

Yes, I have it selected, forgot to say that. But that error message is just when I reload the plugin, and have a text within a repeat grid selected. When choosing the function from the menu (still text within repeat grid selected) I get the “Plugin TypeError: r is not a function”-error.

I was more wondering if the require-code and externals-code looked correct, so that I can look at what other stuff might be wrong.

@stevekwak I’ve gotten the edit-part to work earlier, just using some dummy data, so I just wanted to know if the require-part and the externals-part looked okay?

Yes - glad to hear you got it working!

Ah, no, I’m just creating some confusion here, @stevekwak =) Still haven’t gotten it working, just the part without the webpacking and no search-engine, and just with some dummy-data. So I was wondering if the require-part and the externals-part seemed okay?

I think my issue is just to make something build with webpack and then interact with scenegraph through attachTextDataSeries

Best way would be looking at a working example: https://github.com/AdobeXD/plugin-samples/tree/master/quick-start-react