noflo 1.4.3 → 1.5.1

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.
Files changed (90) hide show
  1. package/.ecrc +3 -0
  2. package/.eslintignore +2 -0
  3. package/{CHANGES.md → CHANGELOG.md} +527 -527
  4. package/README.md +1 -1
  5. package/bin/noflo-cache-preheat +4 -4
  6. package/components/Graph.d.ts +50 -15
  7. package/components/Graph.js +94 -68
  8. package/examples/http/HelloController.js +9 -6
  9. package/examples/spreadsheet/parse.fbp +3 -3
  10. package/lib/AsCallback.d.ts +22 -9
  11. package/lib/AsCallback.js +69 -18
  12. package/lib/AsComponent.d.ts +1 -1
  13. package/lib/AsComponent.js +5 -3
  14. package/lib/BaseNetwork.d.ts +16 -6
  15. package/lib/BaseNetwork.js +65 -31
  16. package/lib/BasePort.d.ts +39 -12
  17. package/lib/BasePort.js +34 -6
  18. package/lib/Component.d.ts +8 -8
  19. package/lib/Component.js +23 -20
  20. package/lib/ComponentLoader.d.ts +3 -4
  21. package/lib/ComponentLoader.js +9 -10
  22. package/lib/IP.d.ts +12 -8
  23. package/lib/IP.js +6 -4
  24. package/lib/InPort.d.ts +64 -9
  25. package/lib/InPort.js +72 -13
  26. package/lib/InternalSocket.d.ts +53 -7
  27. package/lib/InternalSocket.js +51 -14
  28. package/lib/LegacyNetwork.d.ts +12 -2
  29. package/lib/LegacyNetwork.js +5 -5
  30. package/lib/Network.d.ts +13 -2
  31. package/lib/Network.js +10 -10
  32. package/lib/NoFlo.d.ts +48 -13
  33. package/lib/NoFlo.js +55 -27
  34. package/lib/OutPort.d.ts +64 -13
  35. package/lib/OutPort.js +73 -15
  36. package/lib/Platform.d.ts +1 -1
  37. package/lib/Platform.js +9 -4
  38. package/lib/Ports.d.ts +11 -12
  39. package/lib/Ports.js +8 -4
  40. package/lib/ProcessInput.d.ts +5 -9
  41. package/lib/ProcessInput.js +8 -9
  42. package/lib/ProcessOutput.d.ts +2 -2
  43. package/lib/ProcessOutput.js +5 -5
  44. package/lib/loader/NodeJs.d.ts +0 -1
  45. package/lib/loader/NodeJs.js +152 -161
  46. package/lib/loader/register.d.ts +1 -1
  47. package/lib/loader/register.js +8 -4
  48. package/package.json +25 -16
  49. package/spec/.eslintrc +5 -2
  50. package/spec/AsCallback.js +9 -13
  51. package/spec/AsComponent.js +10 -4
  52. package/spec/AsPromise.js +38 -0
  53. package/spec/CommonJS.cjs +10 -0
  54. package/spec/ComponentLoader.js +19 -7
  55. package/spec/ESModule.mjs +11 -0
  56. package/spec/Network.js +32 -11
  57. package/spec/NetworkSync.js +892 -0
  58. package/spec/Scoping.js +27 -42
  59. package/spec/Subgraph.js +6 -11
  60. package/spec/fixtures/componentloader/components/Output.js +1 -1
  61. package/spec/fixtures/componentloader/components/Repeat.ts +1 -1
  62. package/spec/fixtures/componentloader/components/RepeatAsync.coffee +1 -1
  63. package/spec/fixtures/componentloader/node_modules/example/components/Forward.js +1 -1
  64. package/spec/fixtures/componentloader/node_modules/example/package.json +1 -1
  65. package/spec/fixtures/componentloader/package.json +2 -1
  66. package/spec/fixtures/componentloader/spec/Repeat.yaml +1 -1
  67. package/spec/utils/inject.js +1 -1
  68. package/src/.eslintrc +9 -2
  69. package/src/components/Graph.js +105 -71
  70. package/src/lib/AsCallback.js +71 -16
  71. package/src/lib/AsComponent.js +5 -4
  72. package/src/lib/BaseNetwork.js +48 -15
  73. package/src/lib/BasePort.js +43 -9
  74. package/src/lib/Component.js +8 -8
  75. package/src/lib/ComponentLoader.js +3 -4
  76. package/src/lib/IP.js +7 -4
  77. package/src/lib/InPort.js +74 -13
  78. package/src/lib/InternalSocket.js +49 -9
  79. package/src/lib/LegacyNetwork.js +2 -2
  80. package/src/lib/Network.js +2 -2
  81. package/src/lib/NoFlo.js +43 -13
  82. package/src/lib/OutPort.js +77 -14
  83. package/src/lib/Platform.js +9 -4
  84. package/src/lib/Ports.js +6 -2
  85. package/src/lib/ProcessInput.js +7 -9
  86. package/src/lib/ProcessOutput.js +1 -1
  87. package/src/lib/loader/NodeJs.js +185 -178
  88. package/src/lib/loader/register.js +2 -2
  89. /package/{karma.config.js → karma.config.cjs} +0 -0
  90. /package/{webpack.config.js → webpack.config.cjs} +0 -0
@@ -7,10 +7,10 @@
7
7
  import/prefer-default-export,
8
8
  */
9
9
  import { Graph } from 'fbp-graph';
10
- import { ComponentLoader } from './ComponentLoader';
11
- import { Network } from './Network';
12
- import IP from './IP';
13
- import * as internalSocket from './InternalSocket';
10
+ import { ComponentLoader } from './ComponentLoader.js';
11
+ import { Network } from './Network.js';
12
+ import IP from './IP.js';
13
+ import * as internalSocket from './InternalSocket.js';
14
14
 
15
15
  // ## asCallback embedding API
16
16
  //
@@ -46,6 +46,14 @@ import * as internalSocket from './InternalSocket';
46
46
  * @property {Object} [flowtrace] - Flowtrace instance to use for tracing this network run
47
47
  * @property {NetworkCallback} [networkCallback] - Access to Network instance
48
48
  * @property {boolean} [raw] - Whether the callback should operate on raw noflo.IP objects
49
+ * @property {boolean} [asyncDelivery] - Make Information Packet delivery asynchronous
50
+ */
51
+
52
+ /**
53
+ * @typedef {Array<Object<string, IP>>} OutputMap
54
+ */
55
+ /**
56
+ * @typedef {Object<string, Array<IP|any>>|Array<Object<string, IP|any>>} InputMap
49
57
  */
50
58
 
51
59
  /**
@@ -70,6 +78,9 @@ function normalizeOptions(options, component) {
70
78
  if (!options.raw) {
71
79
  options.raw = false;
72
80
  }
81
+ if (!options.asyncDelivery) {
82
+ options.asyncDelivery = false;
83
+ }
73
84
  return options;
74
85
  }
75
86
 
@@ -138,7 +149,7 @@ function prepareNetwork(component, options) {
138
149
  /**
139
150
  * @param {Network} network
140
151
  * @param {any} inputs
141
- * @returns {Promise<any>}
152
+ * @returns {Promise<OutputMap>}
142
153
  */
143
154
  function runNetwork(network, inputs) {
144
155
  return new Promise((resolve, reject) => {
@@ -157,9 +168,11 @@ function runNetwork(network, inputs) {
157
168
  if (!process || !process.component) {
158
169
  return;
159
170
  }
160
- outSockets[outport] = internalSocket.createSocket();
171
+ outSockets[outport] = internalSocket.createSocket({}, {
172
+ debug: false,
173
+ });
161
174
  network.subscribeSocket(outSockets[outport]);
162
- process.component.outPorts[portDef.port].attach(outSockets[outport]);
175
+ process.component.outPorts.ports[portDef.port].attach(outSockets[outport]);
163
176
  outSockets[outport].from = {
164
177
  process,
165
178
  port: portDef.port,
@@ -172,9 +185,19 @@ function runNetwork(network, inputs) {
172
185
  });
173
186
  });
174
187
  // Subscribe to process errors
175
- let onEnd = null;
176
- let onError = null;
177
- onError = (err) => {
188
+ /**
189
+ * @callback EndListener
190
+ * @returns {void}
191
+ */
192
+ /**
193
+ * @callback ErrorListener
194
+ * @param {import("./InternalSocket").SocketError} err
195
+ * @returns {void}
196
+ */
197
+ /** @type {EndListener} */
198
+ let onEnd;
199
+ /** @type {ErrorListener} */
200
+ const onError = (err) => {
178
201
  reject(err.error);
179
202
  network.removeListener('end', onEnd);
180
203
  };
@@ -213,13 +236,15 @@ function runNetwork(network, inputs) {
213
236
  reject(new Error(`Process ${portDef.process} for port ${port} not available in the graph`));
214
237
  return;
215
238
  }
216
- inSockets[port] = internalSocket.createSocket();
239
+ inSockets[port] = internalSocket.createSocket({}, {
240
+ debug: false,
241
+ });
217
242
  network.subscribeSocket(inSockets[port]);
218
243
  inSockets[port].to = {
219
244
  process,
220
245
  port,
221
246
  };
222
- process.component.inPorts[portDef.port].attach(inSockets[port]);
247
+ process.component.inPorts.ports[portDef.port].attach(inSockets[port]);
223
248
  }
224
249
  try {
225
250
  if (IP.isIP(value)) {
@@ -239,6 +264,11 @@ function runNetwork(network, inputs) {
239
264
  });
240
265
  }
241
266
 
267
+ /**
268
+ * @param {any} inputs
269
+ * @param {Network} network
270
+ * @returns {string}
271
+ */
242
272
  function getType(inputs, network) {
243
273
  // Scalar values are always simple inputs
244
274
  if (typeof inputs !== 'object' || !inputs) { return 'simple'; }
@@ -261,6 +291,12 @@ function getType(inputs, network) {
261
291
  return 'map';
262
292
  }
263
293
 
294
+ /**
295
+ * @param {any} inputs
296
+ * @param {string} inputType
297
+ * @param {Network} network
298
+ * @returns {InputMap}
299
+ */
264
300
  function prepareInputMap(inputs, inputType, network) {
265
301
  // Sequence we can use as-is
266
302
  if (inputType === 'sequence') { return inputs; }
@@ -272,15 +308,25 @@ function prepareInputMap(inputs, inputType, network) {
272
308
  return {};
273
309
  }
274
310
  // If we have a port named "IN", send to that
275
- if (network.graph.inports.in) { inPort = 'in'; }
311
+ if (network.graph.inports.in) {
312
+ inPort = 'in';
313
+ }
314
+ /** @type {InputMap} */
276
315
  const map = {};
277
316
  map[inPort] = inputs;
278
317
  return [map];
279
318
  }
280
319
 
320
+ /**
321
+ * @param {Array<IP>} values
322
+ * @param {AsCallbackOptions} options
323
+ * @returns {Array<any>}
324
+ */
281
325
  function normalizeOutput(values, options) {
282
326
  if (options.raw) { return values; }
327
+ /** @type {Array<any>} */
283
328
  const result = [];
329
+ /** @type {Array<any>|null} */
284
330
  let previous = null;
285
331
  let current = result;
286
332
  values.forEach((packet) => {
@@ -293,7 +339,7 @@ function normalizeOutput(values, options) {
293
339
  current.push(packet.data);
294
340
  }
295
341
  if (packet.type === 'closeBracket') {
296
- current = previous;
342
+ current = /** @type {Array<any>} */ (previous);
297
343
  }
298
344
  });
299
345
  if (result.length === 1) {
@@ -301,7 +347,11 @@ function normalizeOutput(values, options) {
301
347
  }
302
348
  return result;
303
349
  }
304
-
350
+ /**
351
+ * @param {OutputMap} outputs
352
+ * @param {string} resultType
353
+ * @param {AsCallbackOptions} options
354
+ */
305
355
  function sendOutputMap(outputs, resultType, options) {
306
356
  // First check if the output sequence contains errors
307
357
  const errors = outputs.filter((map) => map.error != null).map((map) => map.error);
@@ -311,6 +361,7 @@ function sendOutputMap(outputs, resultType, options) {
311
361
 
312
362
  if (resultType === 'sequence') {
313
363
  return Promise.resolve(outputs.map((map) => {
364
+ /** @type {Object<string, any|IP>} */
314
365
  const res = {};
315
366
  Object.keys(map).forEach((key) => {
316
367
  const val = map[key];
@@ -325,11 +376,14 @@ function sendOutputMap(outputs, resultType, options) {
325
376
  }
326
377
 
327
378
  // Flatten the sequence
379
+ /** @type {Object<string, Array<any|IP>>} */
328
380
  const mappedOutputs = {};
329
381
  outputs.forEach((map) => {
330
382
  Object.keys(map).forEach((key) => {
331
383
  const val = map[key];
332
- if (!mappedOutputs[key]) { mappedOutputs[key] = []; }
384
+ if (!mappedOutputs[key]) {
385
+ mappedOutputs[key] = [];
386
+ }
333
387
  mappedOutputs[key].push(val);
334
388
  });
335
389
  });
@@ -344,6 +398,7 @@ function sendOutputMap(outputs, resultType, options) {
344
398
  // Single outport
345
399
  return Promise.resolve(normalizeOutput(mappedOutputs[withValue[0]], options));
346
400
  }
401
+ /** @type {Object<string, any|IP>} */
347
402
  const result = {};
348
403
  Object.keys(mappedOutputs).forEach((port) => {
349
404
  const packets = mappedOutputs[port];
@@ -4,8 +4,8 @@
4
4
  /* eslint-disable
5
5
  import/prefer-default-export,
6
6
  */
7
- import * as getParams from 'get-function-params';
8
- import { Component } from './Component';
7
+ import getParams from 'get-function-params';
8
+ import { Component } from './Component.js';
9
9
 
10
10
  /**
11
11
  * @typedef FuncParam
@@ -101,8 +101,9 @@ export function asComponent(func, options) {
101
101
  c.forwardBrackets[p.param] = ['out', 'error'];
102
102
  });
103
103
  if (!params.length) {
104
- c.inPorts.add('in',
105
- { datatype: 'bang' });
104
+ c.inPorts.add('in', {
105
+ datatype: 'bang',
106
+ });
106
107
  }
107
108
 
108
109
  c.outPorts.add('out');
@@ -10,11 +10,11 @@
10
10
  */
11
11
 
12
12
  import { EventEmitter } from 'events';
13
- import * as internalSocket from './InternalSocket';
14
- import { ComponentLoader } from './ComponentLoader';
15
- import { debounce } from './Utils';
16
- import IP from './IP';
17
- import { deprecated, isBrowser, makeAsync } from './Platform';
13
+ import * as internalSocket from './InternalSocket.js';
14
+ import { ComponentLoader } from './ComponentLoader.js';
15
+ import { debounce } from './Utils.js';
16
+ import IP from './IP.js';
17
+ import { deprecated, isBrowser, makeAsync } from './Platform.js';
18
18
 
19
19
  /**
20
20
  * @typedef NetworkProcess
@@ -39,7 +39,7 @@ import { deprecated, isBrowser, makeAsync } from './Platform';
39
39
  * @param {internalSocket.InternalSocket} socket
40
40
  * @param {NetworkProcess} process
41
41
  * @param {string} port
42
- * @param {number|void} index
42
+ * @param {number|null} index
43
43
  * @param {boolean} inbound
44
44
  * @returns {Promise<internalSocket.InternalSocket>}
45
45
  */
@@ -89,6 +89,7 @@ function connectPort(socket, process, port, index, inbound) {
89
89
  * @property {string} [baseDir] - Project base directory for component loading
90
90
  * @property {ComponentLoader} [componentLoader] - Component loader instance to use, if any
91
91
  * @property {Object} [flowtrace] - Flowtrace instance to use for tracing this network run
92
+ * @property {boolean} [asyncDelivery] - Make Information Packet delivery asynchronous
92
93
  */
93
94
 
94
95
  /**
@@ -135,6 +136,7 @@ export class BaseNetwork extends EventEmitter {
135
136
  this.started = false;
136
137
  this.stopped = true;
137
138
  this.debug = true;
139
+ this.asyncDelivery = options.asyncDelivery || false;
138
140
  /** @type {Array<NetworkEvent>} */
139
141
  this.eventBuffer = [];
140
142
 
@@ -569,6 +571,7 @@ export class BaseNetwork extends EventEmitter {
569
571
  }
570
572
 
571
573
  instance.network.setDebug(this.debug);
574
+ instance.network.setAsyncDelivery(this.asyncDelivery);
572
575
  if (this.flowtrace) {
573
576
  instance.network.setFlowtrace(this.flowtrace, node.componentName, false);
574
577
  }
@@ -720,8 +723,10 @@ export class BaseNetwork extends EventEmitter {
720
723
  }
721
724
  const promise = this.ensureNode(edge.from.node, 'outbound')
722
725
  .then((from) => {
723
- const socket = internalSocket.createSocket(edge.metadata);
724
- socket.setDebug(this.debug);
726
+ const socket = internalSocket.createSocket(edge.metadata, {
727
+ debug: this.debug,
728
+ async: this.asyncDelivery,
729
+ });
725
730
  return this.ensureNode(edge.to.node, 'inbound')
726
731
  .then((to) => {
727
732
  // Subscribe to events from the socket
@@ -785,8 +790,10 @@ export class BaseNetwork extends EventEmitter {
785
790
  if (!port.hasDefault() || port.isAttached()) {
786
791
  return Promise.resolve();
787
792
  }
788
- const socket = internalSocket.createSocket();
789
- socket.setDebug(this.debug);
793
+ const socket = internalSocket.createSocket({}, {
794
+ debug: this.debug,
795
+ async: this.asyncDelivery,
796
+ });
790
797
 
791
798
  // Subscribe to events from the socket
792
799
  this.subscribeSocket(socket);
@@ -814,8 +821,10 @@ export class BaseNetwork extends EventEmitter {
814
821
 
815
822
  const promise = this.ensureNode(initializer.to.node, 'inbound')
816
823
  .then((to) => {
817
- const socket = internalSocket.createSocket(initializer.metadata);
818
- socket.setDebug(this.debug);
824
+ const socket = internalSocket.createSocket(initializer.metadata, {
825
+ debug: this.debug,
826
+ async: this.asyncDelivery,
827
+ });
819
828
 
820
829
  // Subscribe to events from the socket
821
830
  this.subscribeSocket(socket);
@@ -891,7 +900,7 @@ export class BaseNetwork extends EventEmitter {
891
900
  */
892
901
  sendInitials() {
893
902
  return new Promise((resolve) => {
894
- makeAsync(resolve);
903
+ makeAsync(resolve, true);
895
904
  })
896
905
  .then(() => this.initials.reduce((chain, initial) => chain
897
906
  .then(() => {
@@ -1067,8 +1076,9 @@ export class BaseNetwork extends EventEmitter {
1067
1076
  }
1068
1077
  this.started = true;
1069
1078
  this.stopped = false;
1070
- this.bufferedEmit('start',
1071
- { start: this.startupDate });
1079
+ this.bufferedEmit('start', {
1080
+ start: this.startupDate,
1081
+ });
1072
1082
  }
1073
1083
 
1074
1084
  checkIfFinished() {
@@ -1111,6 +1121,29 @@ export class BaseNetwork extends EventEmitter {
1111
1121
  });
1112
1122
  }
1113
1123
 
1124
+ /**
1125
+ * @param {boolean} active
1126
+ */
1127
+ setAsyncDelivery(active) {
1128
+ if (active === this.asyncDelivery) { return; }
1129
+ this.asyncDelivery = active;
1130
+
1131
+ this.connections.forEach((socket) => {
1132
+ socket.async = this.asyncDelivery;
1133
+ });
1134
+ Object.keys(this.processes).forEach((processId) => {
1135
+ const process = this.processes[processId];
1136
+ if (!process.component) {
1137
+ return;
1138
+ }
1139
+ const instance = process.component;
1140
+ if (instance.isSubgraph()) {
1141
+ const inst = /** @type {import("../components/Graph").Graph} */ (instance);
1142
+ inst.network.setAsyncDelivery(active);
1143
+ }
1144
+ });
1145
+ }
1146
+
1114
1147
  /**
1115
1148
  * @param {Object|null} flowtrace
1116
1149
  * @param {string|null} [name]
@@ -27,6 +27,8 @@ const validTypes = [
27
27
  /**
28
28
  * @typedef {Object} BaseOptions - Options for configuring all types of ports
29
29
  * @property {string} [description='']
30
+ * @property {boolean} [addressable=false]
31
+ * @property {boolean} [buffered=false]
30
32
  * @property {string} [datatype='all']
31
33
  * @property {string} [schema=null]
32
34
  * @property {string} [type=null]
@@ -78,13 +80,16 @@ function handleOptions(options) {
78
80
  }
79
81
 
80
82
  export default class BasePort extends EventEmitter {
83
+ /**
84
+ * @param {BaseOptions} options
85
+ */
81
86
  constructor(options) {
82
87
  super();
83
88
  // Options holds all options of the current port
84
89
  this.options = handleOptions(options);
85
90
  // Sockets list contains all currently attached
86
91
  // connections to the port
87
- /** @type {Array<import("./InternalSocket").InternalSocket>} */
92
+ /** @type {Array<import("./InternalSocket").InternalSocket|void>} */
88
93
  this.sockets = [];
89
94
  // Name of the graph node this port is in
90
95
  /** @type {string|null} */
@@ -103,14 +108,21 @@ export default class BasePort extends EventEmitter {
103
108
  return `${this.node} ${this.name.toUpperCase()}`;
104
109
  }
105
110
 
106
- getDataType() { return this.options.datatype; }
111
+ /**
112
+ * @returns {string}
113
+ */
114
+ getDataType() { return this.options.datatype || 'all'; }
107
115
 
108
116
  getSchema() { return this.options.schema || null; }
109
117
 
110
118
  getDescription() { return this.options.description; }
111
119
 
120
+ /**
121
+ * @param {import("./InternalSocket").InternalSocket} socket
122
+ * @param {number|null} [index]
123
+ */
112
124
  attach(socket, index = null) {
113
- let idx = index;
125
+ let idx = /** @type {number} */ (index);
114
126
  if (!this.isAddressable() || (index === null)) {
115
127
  idx = this.sockets.length;
116
128
  }
@@ -123,9 +135,15 @@ export default class BasePort extends EventEmitter {
123
135
  this.emit('attach', socket);
124
136
  }
125
137
 
126
- // eslint-disable-next-line class-methods-use-this,no-unused-vars
127
- attachSocket(socket, index = null) { }
138
+ /**
139
+ * @param {import("./InternalSocket").InternalSocket} socket
140
+ * @param {number|null} [index]
141
+ */
142
+ attachSocket(socket, index = null) { } // eslint-disable-line class-methods-use-this,no-unused-vars,max-len
128
143
 
144
+ /**
145
+ * @param {import("./InternalSocket").InternalSocket} socket
146
+ */
129
147
  detach(socket) {
130
148
  const index = this.sockets.indexOf(socket);
131
149
  if (index === -1) {
@@ -154,12 +172,18 @@ export default class BasePort extends EventEmitter {
154
172
  return false;
155
173
  }
156
174
 
175
+ /**
176
+ * @param {number|null} socketId
177
+ * @returns {boolean}
178
+ */
157
179
  isAttached(socketId = null) {
158
180
  if (this.isAddressable() && (socketId !== null)) {
159
181
  if (this.sockets[socketId]) { return true; }
160
182
  return false;
161
183
  }
162
- if (this.sockets.length) { return true; }
184
+ if (this.sockets.length) {
185
+ return true;
186
+ }
163
187
  return false;
164
188
  }
165
189
 
@@ -172,11 +196,21 @@ export default class BasePort extends EventEmitter {
172
196
  return attached;
173
197
  }
174
198
 
199
+ /**
200
+ * @param {number|null} socketId
201
+ * @returns {boolean}
202
+ */
175
203
  isConnected(socketId = null) {
176
204
  if (this.isAddressable()) {
177
- if (socketId === null) { throw new Error(`${this.getId()}: Socket ID required`); }
178
- if (!this.sockets[socketId]) { throw new Error(`${this.getId()}: Socket ${socketId} not available`); }
179
- return this.sockets[socketId].isConnected();
205
+ if (socketId === null) {
206
+ throw new Error(`${this.getId()}: Socket ID required`);
207
+ }
208
+ if (!this.sockets[socketId]) {
209
+ throw new Error(`${this.getId()}: Socket ${socketId} not available`);
210
+ }
211
+ // eslint-disable-next-line max-len
212
+ const socket = /** @type {import("./InternalSocket").InternalSocket} */ (this.sockets[socketId]);
213
+ return socket.isConnected();
180
214
  }
181
215
 
182
216
  let connected = false;
@@ -10,14 +10,14 @@
10
10
  */
11
11
  import { EventEmitter } from 'events';
12
12
  import debug from 'debug';
13
- import { InPorts, OutPorts, normalizePortName } from './Ports';
14
- import { deprecated } from './Platform';
15
- import InPort from './InPort'; // eslint-disable-line no-unused-vars
16
- import OutPort from './OutPort'; // eslint-disable-line no-unused-vars
17
- import ProcessContext from './ProcessContext';
18
- import ProcessInput from './ProcessInput';
19
- import ProcessOutput from './ProcessOutput';
20
- import IP from './IP'; // eslint-disable-line no-unused-vars
13
+ import { InPorts, OutPorts, normalizePortName } from './Ports.js';
14
+ import { deprecated } from './Platform.js';
15
+ import InPort from './InPort.js'; // eslint-disable-line no-unused-vars
16
+ import OutPort from './OutPort.js'; // eslint-disable-line no-unused-vars
17
+ import ProcessContext from './ProcessContext.js';
18
+ import ProcessInput from './ProcessInput.js';
19
+ import ProcessOutput from './ProcessOutput.js';
20
+ import IP from './IP.js'; // eslint-disable-line no-unused-vars
21
21
 
22
22
  const debugComponent = debug('noflo:component');
23
23
  const debugBrackets = debug('noflo:component:brackets');
@@ -10,8 +10,8 @@
10
10
  */
11
11
 
12
12
  import { Graph } from 'fbp-graph';
13
- import * as registerLoader from './loader/register';
14
- import { deprecated, makeAsync } from './Platform';
13
+ import * as registerLoader from './loader/register.js';
14
+ import { deprecated, makeAsync } from './Platform.js';
15
15
 
16
16
  /**
17
17
  * @callback ComponentFactory
@@ -226,9 +226,8 @@ export class ComponentLoader {
226
226
  return promise;
227
227
  }
228
228
 
229
- // Creates an instance of a component.
230
229
  /**
231
- * @protected
230
+ * Creates an instance of a component.
232
231
  * @param {string} name
233
232
  * @param {ComponentDefinitionWithoutGraph} component
234
233
  * @param {import("fbp-graph/lib/Types").GraphNodeMetadata} metadata
package/src/lib/IP.js CHANGED
@@ -27,6 +27,10 @@
27
27
  // - 'openBracket'
28
28
  // - 'closeBracket'
29
29
 
30
+ /**
31
+ * @typedef {Object<string, boolean|string>} IPOptions
32
+ */
33
+
30
34
  export default class IP {
31
35
  // Detects if an arbitrary value is an IP
32
36
  /**
@@ -42,7 +46,7 @@ export default class IP {
42
46
  /**
43
47
  * @param {string} type
44
48
  * @param {any} data
45
- * @param {Object<string, boolean|string>} [options]
49
+ * @param {IPOptions} [options]
46
50
  */
47
51
  constructor(type, data = null, options = {}) {
48
52
  this.type = type || 'data';
@@ -50,7 +54,7 @@ export default class IP {
50
54
  this.isIP = true;
51
55
  /** @type {string|null} */
52
56
  this.scope = null; // sync scope id
53
- /** @type {string|null} */
57
+ /** @type {import("./Component").Component|null} */
54
58
  this.owner = null; // packet owner process
55
59
  this.clonable = false; // cloning safety flag
56
60
  /** @type {number|null} */
@@ -61,7 +65,6 @@ export default class IP {
61
65
  if (typeof options === 'object') {
62
66
  Object.keys(options).forEach((key) => { this[key] = options[key]; });
63
67
  }
64
- return this;
65
68
  }
66
69
 
67
70
  // Creates a new IP copying its contents by value not reference
@@ -85,7 +88,7 @@ export default class IP {
85
88
 
86
89
  // Moves an IP to a different owner
87
90
  /**
88
- * @param {string|null} owner
91
+ * @param {import("./Component").Component|null} owner
89
92
  */
90
93
  move(owner) {
91
94
  // no-op