diff --git a/root/src/config.json b/root/src/config.json
index 2d07ea3..1ca2c78 100644
--- a/root/src/config.json
+++ b/root/src/config.json
@@ -37,7 +37,6 @@
"js_files": [
"js/{%= jsname %}.js"
],
- "entrypoint": "js/{%= entrypoint %}.js",
"title": "{%= project_name %}",
"translations": {},
"type": "widget",
diff --git a/root/src/config.xml b/root/src/config.xml
index a41f081..c053483 100644
--- a/root/src/config.xml
+++ b/root/src/config.xml
@@ -32,7 +32,6 @@
-
diff --git a/root/src/js/name.js b/root/src/js/name.js
index a8d69ff..6fec60b 100644
--- a/root/src/js/name.js
+++ b/root/src/js/name.js
@@ -6,9 +6,7 @@
* Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
*/
-/* exported {%= entrypoint %} */
-
-(function () {
+(function (script) {
"use strict";
@@ -16,7 +14,7 @@
// CLASS DEFINITION
// =========================================================================
- class {%= entrypoint %} {
+ class Widget {
constructor(MashupPlatform, shadowDOM, extra) {
this.MashupPlatform = MashupPlatform;
this.shadowDOM = shadowDOM;
@@ -27,11 +25,15 @@
}
}
- // We define the class as part of the window object so that it can be instantiated by Wirecloud
- window.{%= entrypoint %} = {%= entrypoint %};
+ if (!('Wirecloud' in window)) {
+ // For testing purposes
+ window.Widget = Widget;
+ } else {
+ Wirecloud.registerWidgetClass(script, Widget);
+ }
/* test-code */
/* end-test-code */
-})();
+})(document.currentScript);
diff --git a/root/src/ts/name.ts b/root/src/ts/name.ts
index 3997a68..5c07f98 100644
--- a/root/src/ts/name.ts
+++ b/root/src/ts/name.ts
@@ -9,7 +9,7 @@ import MashupPlatform = require("MashupPlatform");
{% if (ngsi) { %}import NGSI = require("NGSI");{% }%}
/* end-import-block */
-export class {%= entrypoint %} {
+export class Widget {
private MashupPlatform: MashupPlatform;
private shadowDOM: any;
{% if (ngsi) { %}private NGSI: NGSI;{% }%}
@@ -27,5 +27,8 @@ export class {%= entrypoint %} {
}
}
-// We define the class as part of the window object so that it can be instantiated by Wirecloud
-(window)["{%= entrypoint %}"] = {%= entrypoint %};
+if (!(window).Wirecloud) {
+ (window).Widget = Widget;
+} else {
+ (window).Wirecloud.registerWidgetClass((document).currentScript, Widget);
+}
diff --git a/root/tests/js/nameSpec.js b/root/tests/js/nameSpec.js
index 066adc1..58f2872 100644
--- a/root/tests/js/nameSpec.js
+++ b/root/tests/js/nameSpec.js
@@ -6,7 +6,7 @@
* Licensed under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.
*/
-/* globals $, MashupPlatform, MockMP, {%= entrypoint %} */
+/* globals $, MashupPlatform, MockMP */
(function () {
@@ -16,16 +16,19 @@
var widget;
var MashupPlatform;
+ var Widget;
beforeAll(function () {
MashupPlatform = new MockMP({
type: 'widget'
});
+
+ Widget = window.Widget;
});
beforeEach(function () {
MashupPlatform.reset();
- widget = new {%= entrypoint %}(MashupPlatform, undefined, {});
+ widget = new Widget(MashupPlatform, undefined, {});
});
it("Dummy test", function () {
diff --git a/template.js b/template.js
index 2dcc2f8..2bea84b 100644
--- a/template.js
+++ b/template.js
@@ -51,13 +51,6 @@ var capitalizeAndRemoveUnderscore = function capitalizeAndRemoveUnderscore(old)
return t.charAt(0).toUpperCase() + t.slice(1);
};
-var getEntrypointName = function getEntrypointName(vendor, name) {
- // Remove all non-alphanumeric characters. Replace spaces with underscores.
- vendor = vendor.replace(/[^a-zA-Z0-9]/g, '').replace(/\s/g, '_');
- name = name.replace(/[^a-zA-Z0-9]/g, '').replace(/\s/g, '_');
- return vendor + '_' + name;
-}
-
// The actual init template.
exports.template = function(grunt, init, done) {
init.process([
@@ -130,7 +123,6 @@ exports.template = function(grunt, init, done) {
], function(err, props){
var exportsOverride = {};
props.jsname = capitalizeAndRemoveUnderscore(props.name);
- props.entrypoint = getEntrypointName(props.vendor, props.name);
props.bower = true; // Change way to determine bower?
props.ngsi = false; // ??
var bowerdeps = {};