node-red-contrib-typescript 1.0.17 → 1.0.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/instance/instance.html +2 -4
- package/src/instance/instance.js +10 -24
package/package.json
CHANGED
|
@@ -284,13 +284,11 @@
|
|
|
284
284
|
</div>
|
|
285
285
|
|
|
286
286
|
<div class="form-row">
|
|
287
|
+
<label for="node-input-filename"><i class="fa fa-tag"></i> Filename</label>
|
|
288
|
+
<input id="node-input-filename" type="text" value="">
|
|
287
289
|
<label for="node-input-outputs"><i class="fa fa-random"></i> <span data-i18n="function.label.outputs"></span></label>
|
|
288
290
|
<input id="node-input-outputs" style="width: 60px;" value="1">
|
|
289
291
|
</div>
|
|
290
|
-
<div class="form-row">
|
|
291
|
-
<label for="node-input-filename"><i class="fa fa-tag"></i> Filename <br><sub>(prefix, if ends with '/')</sub></label>
|
|
292
|
-
<input id="node-input-filename" type="text" value="">
|
|
293
|
-
</div>
|
|
294
292
|
|
|
295
293
|
<div style="height: calc(100% - 68px); min-height:250px;" class="node-text-editor" id="node-input-example-editor"></div>
|
|
296
294
|
</script>
|
package/src/instance/instance.js
CHANGED
|
@@ -2,6 +2,7 @@ let registry = {};
|
|
|
2
2
|
module.exports = function(RED) {
|
|
3
3
|
var helper = require("../../helper.js");
|
|
4
4
|
var vm = require("vm");
|
|
5
|
+
var nodePath = require("path");
|
|
5
6
|
|
|
6
7
|
function TypescriptInstance(config) {
|
|
7
8
|
RED.nodes.createNode(this,config);
|
|
@@ -65,27 +66,19 @@ module.exports = function(RED) {
|
|
|
65
66
|
if (target.startsWith("/subflow")) {
|
|
66
67
|
target = path + target.substring(9);
|
|
67
68
|
}
|
|
68
|
-
if (target.startsWith("
|
|
69
|
-
target = "/lib/" + target.substring(1);
|
|
70
|
-
}
|
|
71
|
-
if (target.startsWith("$/")) {
|
|
72
|
-
target = target.substring(1);
|
|
73
|
-
}
|
|
74
|
-
if (target.startsWith("./")) {
|
|
69
|
+
if (target.startsWith("./") || target.startsWith("../")) {
|
|
75
70
|
if (node.config.name.indexOf("/") !== -1) {
|
|
76
71
|
let count = node.config.name.lastIndexOf("/") + 1;
|
|
77
72
|
let pathSuffix = node.config.name.substring(0, count);
|
|
78
|
-
target = path + pathSuffix + target
|
|
73
|
+
target = path + pathSuffix + target;
|
|
79
74
|
}
|
|
80
75
|
else {
|
|
81
|
-
target = path + target
|
|
76
|
+
target = path + target;
|
|
82
77
|
}
|
|
83
78
|
}
|
|
84
|
-
if (target.endsWith(".pkg")) {
|
|
85
|
-
target = target.substring(0, target.length - 4) + "/index";
|
|
86
|
-
}
|
|
87
79
|
|
|
88
80
|
if (target.startsWith("/")) {
|
|
81
|
+
target = nodePath.normalize(target);
|
|
89
82
|
libraryPromises.push(
|
|
90
83
|
new Promise(async (resolve, reject) => {
|
|
91
84
|
let dependency = registry[target];
|
|
@@ -124,26 +117,19 @@ module.exports = function(RED) {
|
|
|
124
117
|
if (target.startsWith("/subflow")) {
|
|
125
118
|
target = path + target.substring(9);
|
|
126
119
|
}
|
|
127
|
-
if (target.startsWith("
|
|
128
|
-
target = "/lib/" + target.substring(1);
|
|
129
|
-
}
|
|
130
|
-
if (target.startsWith("$/")) {
|
|
131
|
-
target = target.substring(1);
|
|
132
|
-
}
|
|
133
|
-
if (target.startsWith("./")) {
|
|
120
|
+
if (target.startsWith("./") || target.startsWith("../")) {
|
|
134
121
|
if (node.config.name.indexOf("/") !== -1) {
|
|
135
122
|
let count = node.config.name.lastIndexOf("/") + 1;
|
|
136
123
|
let pathSuffix = node.config.name.substring(0, count);
|
|
137
|
-
target = path + pathSuffix + target
|
|
124
|
+
target = path + pathSuffix + target;
|
|
138
125
|
}
|
|
139
126
|
else {
|
|
140
|
-
target = path + target
|
|
141
|
-
}
|
|
142
|
-
if (target.endsWith(".pkg")) {
|
|
143
|
-
target = target.substring(0, target.length - 4) + "/index";
|
|
127
|
+
target = path + target;
|
|
128
|
+
}
|
|
144
129
|
}
|
|
145
130
|
|
|
146
131
|
if (target.startsWith("/")) {
|
|
132
|
+
target = nodePath.normalize(target);
|
|
147
133
|
return registry[target].exports;
|
|
148
134
|
}
|
|
149
135
|
return modules[target];
|