Looks like everyone, including me starts out trying to build C3 addons in the same sequence in which the manual reads. This is definitely NOT the way to start C3 addon development. The C3 SDK manual is upside-down. You MUST first setup a local plugin server, go through the process of getting that working. Then you MUST develop your plugins in "developer mode" per the manual. After you get your plugin loading and working in developer mode, you can say "it's working" and then do the normal .zip/.c3addon import into C3. DO NOT keep trying to import any custom plugin with even one single bug! In addition to no debugging info in the console, you will also lock up C3 editor addon mamanger and object import dialogs. Sometimes you will lock the main addon loading screen.
Get your local plugin dev server working FIRST and dev that way.
Here is my working C3 plugin server. If you don't know Node/Express, Google and you'll find a million articles and tutorials. Very easy to install. Below is a link to the zip of the c3-plugin-server app folder. Make sure you run your command window as admin. Unzip the app. Then run npm install to update/install all the packages you need. There are helpful comments in server.js. nodemon server.js will start the plugin server. Node provides good error messages on install. If you see any you should be able to fix.
https://drive.google.com/file/d/0B2LbtzyJ6MqNWHZnVDhfR2o1SFk/view?usp=sharing
const https = require('https');
const fs = require('fs');
const path = require('path');
const express = require('express');
const cors = require('cors');
const corsOptions = {
origin: 'https://editor.construct.net'
};
// You will need to use openssl or some Windows app
// to generate your own self-signed cert files. C3
// developer mode plugin loading will NOT work in Http
// mode. Plugin server must be Https
const serverOptions = {
key: fs.readFileSync('./key-20171101-071835.pem'),
cert: fs.readFileSync('./cert-20171101-071835.crt'),
requestCert: false,
rejectUnauthorized: true
};
const app = express();
app.use(cors(corsOptions));
// Put testing and non-plugin static content in this folder
app.use('/static', express.static(path.join(__dirname, 'static')));
// Put all plugin related code and static content in this folder
// Put each plugin in its own folder like: /plugin/mytestplugin1/
// In C3 addon manager, in developer mode, load plugin like...
// https://localhost:49200/plugin/mytestplugin1/addon.json
app.use('/plugin', express.static(path.join(__dirname, 'plugin')));
const port = process.env.PORT || 49200;
https.createServer(serverOptions, app).listen(port, function () {
console.log('Construct 3 plugin server running. Listening on port: ' + port);
});
[/code:298jj1yn]
locohost
Thanks for this, I'm trying it out with nodemon server.js, but I am getting errors when trying to load the addon. It looks like the server is running (I can get the addon.json file via a general chrome browser request via: https://localhost:49200/plugin/example/addon.json ). I installed self-signed cert/key and updated server.js (otherwise the previous would not work.)
C3 reports the generic, 'unable to load, go check server, etc.'. Checking the chrome console, this is the error:
r69-2/main.js:154 Error loading addon JSON: TypeError: Assignment to constant variable.
at d.ǃvcY (r69-2/main.js:73)
at <anonymous>
ǃG.ǃEA.then.then.catch @ r69-2/main.js:154
[/code:298jj1yn]
If I put in another bad filename, I see a different error message on console, so I think the file is being server to C3. but then something seems to fail on parsing (I also tried the C3 EffectSDK example and get the same error.)
Any hints?