noflo 1.4.2 → 1.5.0

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 (89) hide show
  1. package/.ecrc +3 -0
  2. package/.eslintignore +2 -0
  3. package/{CHANGES.md → CHANGELOG.md} +520 -523
  4. package/README.md +1 -1
  5. package/bin/noflo-cache-preheat +17 -15
  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 +81 -10
  25. package/lib/InPort.js +83 -19
  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 +13 -13
  33. package/lib/NoFlo.js +29 -27
  34. package/lib/OutPort.d.ts +74 -32
  35. package/lib/OutPort.js +79 -23
  36. package/lib/Platform.d.ts +1 -1
  37. package/lib/Platform.js +9 -4
  38. package/lib/Ports.d.ts +14 -21
  39. package/lib/Ports.js +11 -13
  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 +104 -105
  46. package/lib/loader/register.d.ts +1 -1
  47. package/lib/loader/register.js +8 -4
  48. package/package.json +16 -11
  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 +2 -38
  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 +1 -1
  66. package/spec/fixtures/componentloader/spec/Repeat.yaml +1 -1
  67. package/src/.eslintrc +9 -2
  68. package/src/components/Graph.js +105 -71
  69. package/src/lib/AsCallback.js +71 -16
  70. package/src/lib/AsComponent.js +4 -3
  71. package/src/lib/BaseNetwork.js +48 -15
  72. package/src/lib/BasePort.js +43 -9
  73. package/src/lib/Component.js +8 -8
  74. package/src/lib/ComponentLoader.js +3 -4
  75. package/src/lib/IP.js +7 -4
  76. package/src/lib/InPort.js +86 -21
  77. package/src/lib/InternalSocket.js +49 -9
  78. package/src/lib/LegacyNetwork.js +2 -2
  79. package/src/lib/Network.js +2 -2
  80. package/src/lib/NoFlo.js +15 -13
  81. package/src/lib/OutPort.js +83 -22
  82. package/src/lib/Platform.js +9 -4
  83. package/src/lib/Ports.js +9 -11
  84. package/src/lib/ProcessInput.js +7 -9
  85. package/src/lib/ProcessOutput.js +1 -1
  86. package/src/lib/loader/NodeJs.js +122 -116
  87. package/src/lib/loader/register.js +2 -2
  88. /package/{karma.config.js → karma.config.cjs} +0 -0
  89. /package/{webpack.config.js → webpack.config.cjs} +0 -0
package/lib/InPort.js CHANGED
@@ -3,12 +3,30 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // NoFlo - Flow-Based Programming for JavaScript
4
4
  // (c) 2014-2017 Flowhub UG
5
5
  // NoFlo may be freely distributed under the MIT license
6
- const BasePort_1 = require("./BasePort");
6
+ const BasePort_js_1 = require("./BasePort.js");
7
7
  // ## NoFlo inport
8
8
  //
9
9
  // Input Port (inport) implementation for NoFlo components. These
10
10
  // ports are the way a component receives Information Packets.
11
- class InPort extends BasePort_1.default {
11
+ /**
12
+ * @typedef InPortOptions
13
+ * @property {any} [default]
14
+ * @property {Array<any>} [values]
15
+ * @property {boolean} [control]
16
+ * @property {boolean} [triggering]
17
+ */
18
+ /**
19
+ * @callback HasValidationCallback
20
+ * @param {import("./IP").default} ip
21
+ * @returns {boolean}
22
+ */
23
+ /**
24
+ * @typedef {import("./BasePort").BaseOptions & InPortOptions} PortOptions
25
+ */
26
+ class InPort extends BasePort_js_1.default {
27
+ /**
28
+ * @param {PortOptions} [options]
29
+ */
12
30
  constructor(options = {}) {
13
31
  const opts = options;
14
32
  if (opts.control == null) {
@@ -20,17 +38,19 @@ class InPort extends BasePort_1.default {
20
38
  if (opts.triggering == null) {
21
39
  opts.triggering = true;
22
40
  }
23
- if (opts.process) {
24
- throw new Error('InPort process callback is deprecated. Please use Process API');
25
- }
26
- if (opts.handle) {
27
- throw new Error('InPort handle callback is deprecated. Please use Process API');
28
- }
29
41
  super(opts);
42
+ const baseOptions = this.options;
43
+ this.options = /** @type {PortOptions} */ (baseOptions);
44
+ /** @type {import("./Component").Component|null} */
30
45
  this.nodeInstance = null;
31
46
  this.prepareBuffer();
32
47
  }
33
- // Assign a delegate for retrieving data should this inPort
48
+ /**
49
+ * Assign a delegate for retrieving data should this inPort
50
+ *
51
+ * @param {import("./InternalSocket").InternalSocket} socket
52
+ * @param {number|null} [localId]
53
+ */
34
54
  attachSocket(socket, localId = null) {
35
55
  // have a default value.
36
56
  if (this.hasDefault()) {
@@ -46,7 +66,11 @@ class InPort extends BasePort_1.default {
46
66
  socket.on('disconnect', () => this.handleSocketEvent('disconnect', socket, localId));
47
67
  socket.on('ip', (ip) => this.handleIP(ip, localId));
48
68
  }
49
- handleIP(packet, index) {
69
+ /**
70
+ * @param {import("./IP").default} packet
71
+ * @param {number|null} [index]
72
+ */
73
+ handleIP(packet, index = null) {
50
74
  if (this.options.control && (packet.type !== 'data')) {
51
75
  return;
52
76
  }
@@ -70,6 +94,11 @@ class InPort extends BasePort_1.default {
70
94
  }
71
95
  this.emit('ip', ip, index);
72
96
  }
97
+ /**
98
+ * @param {string} event
99
+ * @param {any} payload
100
+ * @param {number} [id]
101
+ */
73
102
  handleSocketEvent(event, payload, id) {
74
103
  // Emit port event
75
104
  if (this.isAddressable()) {
@@ -138,6 +167,9 @@ class InPort extends BasePort_1.default {
138
167
  }
139
168
  return this.buffer;
140
169
  }
170
+ /**
171
+ * @param {any} data
172
+ */
141
173
  validateData(data) {
142
174
  if (!this.options.values) {
143
175
  return;
@@ -201,8 +233,12 @@ class InPort extends BasePort_1.default {
201
233
  }
202
234
  return buf.shift();
203
235
  }
204
- // Fetches a packet from the port
205
- get(scope, index) {
236
+ /**
237
+ * Fetches a packet from the port
238
+ * @param {string|null} scope
239
+ * @param {number|null} [index]
240
+ */
241
+ get(scope, index = null) {
206
242
  const res = this.getFromBuffer(scope, index);
207
243
  if (res !== undefined) {
208
244
  return res;
@@ -210,6 +246,13 @@ class InPort extends BasePort_1.default {
210
246
  // Try to find an IIP instead
211
247
  return this.getFromBuffer(null, index, true);
212
248
  }
249
+ /**
250
+ * Fetches a packet from the port
251
+ * @param {string|null} scope
252
+ * @param {number|null} index
253
+ * @param {HasValidationCallback} validate
254
+ * @param {boolean} [initial]
255
+ */
213
256
  hasIPinBuffer(scope, index, validate, initial = false) {
214
257
  const buf = this.getBuffer(scope, index, initial);
215
258
  if (!(buf != null ? buf.length : undefined)) {
@@ -222,17 +265,30 @@ class InPort extends BasePort_1.default {
222
265
  }
223
266
  return false;
224
267
  }
268
+ /**
269
+ * @param {number|null} index
270
+ * @param {HasValidationCallback} validate
271
+ */
225
272
  hasIIP(index, validate) {
226
273
  return this.hasIPinBuffer(null, index, validate, true);
227
274
  }
228
- // Returns true if port contains packet(s) matching the validator
275
+ /**
276
+ * Returns true if port contains packet(s) matching the validator
277
+ * @param {string|null} scope
278
+ * @param {number|null|HasValidationCallback} index
279
+ * @param {HasValidationCallback} [validate]
280
+ */
229
281
  has(scope, index, validate) {
230
282
  let valid = validate;
231
- let idx = index;
232
- if (!this.isAddressable()) {
233
- valid = idx;
283
+ /** @type {number|null} */
284
+ let idx;
285
+ if (typeof index === 'function') {
286
+ valid = /** @type {HasValidationCallback} */ (index);
234
287
  idx = null;
235
288
  }
289
+ else {
290
+ idx = index;
291
+ }
236
292
  if (this.hasIPinBuffer(scope, idx, valid)) {
237
293
  return true;
238
294
  }
@@ -241,15 +297,23 @@ class InPort extends BasePort_1.default {
241
297
  }
242
298
  return false;
243
299
  }
244
- // Returns the number of data packets in an inport
245
- length(scope, index) {
300
+ /**
301
+ * Returns the number of data packets in an inport
302
+ * @param {string|null} scope
303
+ * @param {number|null} [index]
304
+ * @returns {number}
305
+ */
306
+ length(scope, index = null) {
246
307
  const buf = this.getBuffer(scope, index);
247
308
  if (!buf) {
248
309
  return 0;
249
310
  }
250
311
  return buf.length;
251
312
  }
252
- // Tells if buffer has packets or not
313
+ /**
314
+ * Tells if buffer has packets or not
315
+ * @param {string|null} scope
316
+ */
253
317
  ready(scope) {
254
318
  return this.length(scope) > 0;
255
319
  }
@@ -1,20 +1,61 @@
1
1
  /**
2
- * @param {Object} [metadata]
2
+ * @param {import("fbp-graph/lib/Types").GraphEdgeMetadata} [metadata]
3
+ * @param {InternalSocketOptions} [options]
3
4
  * @returns {InternalSocket}
4
5
  */
5
- export function createSocket(metadata?: any): InternalSocket;
6
+ export function createSocket(metadata?: import("fbp-graph/lib/Types").GraphEdgeMetadata, options?: {
7
+ /**
8
+ * - Whether to catch exceptions caused by IP transmission
9
+ */
10
+ debug?: boolean;
11
+ /**
12
+ * - Whether IP transmission should be asynchronous
13
+ */
14
+ async?: boolean;
15
+ }): InternalSocket;
16
+ /**
17
+ * @typedef SocketError
18
+ * @property {Error} error
19
+ * @property {string} [id]
20
+ * @property {import("fbp-graph/lib/Types").GraphNodeMetadata} [metadata]
21
+ */
6
22
  export class InternalSocket extends EventEmitter {
7
- constructor(metadata?: {});
8
- regularEmitEvent(event: any, data: any): void;
9
- debugEmitEvent(event: any, data: any): void;
10
- metadata: {};
23
+ /**
24
+ * @typedef InternalSocketOptions
25
+ * @property {boolean} [debug] - Whether to catch exceptions caused by IP transmission
26
+ * @property {boolean} [async] - Whether IP transmission should be asynchronous
27
+ */
28
+ /**
29
+ * @param {import("fbp-graph/lib/Types").GraphEdgeMetadata} [metadata]
30
+ * @param {InternalSocketOptions} [options]
31
+ */
32
+ constructor(metadata?: import("fbp-graph/lib/Types").GraphEdgeMetadata, options?: {
33
+ /**
34
+ * - Whether to catch exceptions caused by IP transmission
35
+ */
36
+ debug?: boolean;
37
+ /**
38
+ * - Whether IP transmission should be asynchronous
39
+ */
40
+ async?: boolean;
41
+ });
42
+ /**
43
+ * @private
44
+ */
45
+ private regularEmitEvent;
46
+ /**
47
+ * @private
48
+ */
49
+ private debugEmitEvent;
50
+ metadata: import("fbp-graph/lib/Types").PropertyMap;
11
51
  brackets: any[];
12
52
  connected: boolean;
13
53
  dataDelegate: any;
14
54
  debug: boolean;
15
- emitEvent: (event: any, data: any) => void;
55
+ async: boolean;
16
56
  from: any;
17
57
  to: any;
58
+ emitEvent(event: any, data: any): void;
18
59
  connect(): void;
19
60
  disconnect(): void;
20
61
  isConnected(): boolean;
@@ -27,4 +68,9 @@ export class InternalSocket extends EventEmitter {
27
68
  getId(): string;
28
69
  handleSocketEvent(event: any, payload: any, autoConnect?: boolean): void;
29
70
  }
71
+ export type SocketError = {
72
+ error: Error;
73
+ id?: string;
74
+ metadata?: import("fbp-graph/lib/Types").GraphNodeMetadata;
75
+ };
30
76
  import { EventEmitter } from "events";
@@ -6,20 +6,21 @@ exports.createSocket = exports.InternalSocket = void 0;
6
6
  // (c) 2011-2012 Henri Bergius, Nemein
7
7
  // NoFlo may be freely distributed under the MIT license
8
8
  const events_1 = require("events");
9
- const IP_1 = require("./IP");
9
+ const IP_js_1 = require("./IP.js");
10
+ const Platform_js_1 = require("./Platform.js");
10
11
  function legacyToIp(event, payload) {
11
12
  // No need to wrap modern IP Objects
12
- if (IP_1.default.isIP(payload)) {
13
+ if (IP_js_1.default.isIP(payload)) {
13
14
  return payload;
14
15
  }
15
16
  // Wrap legacy events into appropriate IP objects
16
17
  switch (event) {
17
18
  case 'begingroup':
18
- return new IP_1.default('openBracket', payload);
19
+ return new IP_js_1.default('openBracket', payload);
19
20
  case 'endgroup':
20
- return new IP_1.default('closeBracket');
21
+ return new IP_js_1.default('closeBracket');
21
22
  case 'data':
22
- return new IP_1.default('data', payload);
23
+ return new IP_js_1.default('data', payload);
23
24
  default:
24
25
  return null;
25
26
  }
@@ -45,6 +46,12 @@ function ipToLegacy(ip) {
45
46
  return null;
46
47
  }
47
48
  }
49
+ /**
50
+ * @typedef SocketError
51
+ * @property {Error} error
52
+ * @property {string} [id]
53
+ * @property {import("fbp-graph/lib/Types").GraphNodeMetadata} [metadata]
54
+ */
48
55
  // ## Internal Sockets
49
56
  //
50
57
  // The default communications mechanism between NoFlo processes is
@@ -53,9 +60,15 @@ function ipToLegacy(ip) {
53
60
  // events so that the packets can be caught to the inport of the
54
61
  // connected process.
55
62
  class InternalSocket extends events_1.EventEmitter {
63
+ /**
64
+ * @private
65
+ */
56
66
  regularEmitEvent(event, data) {
57
67
  this.emit(event, data);
58
68
  }
69
+ /**
70
+ * @private
71
+ */
59
72
  debugEmitEvent(event, data) {
60
73
  try {
61
74
  this.emit(event, data);
@@ -73,23 +86,47 @@ class InternalSocket extends events_1.EventEmitter {
73
86
  throw error;
74
87
  }
75
88
  this.emit('error', {
76
- id: this.to.process.id,
89
+ id: this.to ? this.to.process.id : null,
77
90
  error,
78
91
  metadata: this.metadata,
79
92
  });
80
93
  }
81
94
  }
82
- constructor(metadata = {}) {
95
+ /**
96
+ * @typedef InternalSocketOptions
97
+ * @property {boolean} [debug] - Whether to catch exceptions caused by IP transmission
98
+ * @property {boolean} [async] - Whether IP transmission should be asynchronous
99
+ */
100
+ /**
101
+ * @param {import("fbp-graph/lib/Types").GraphEdgeMetadata} [metadata]
102
+ * @param {InternalSocketOptions} [options]
103
+ */
104
+ constructor(metadata = {}, options = {}) {
83
105
  super();
84
106
  this.metadata = metadata;
85
107
  this.brackets = [];
86
108
  this.connected = false;
87
109
  this.dataDelegate = null;
88
- this.debug = false;
89
- this.emitEvent = this.regularEmitEvent;
110
+ this.debug = options.debug || false;
111
+ this.async = options.async || false;
90
112
  this.from = null;
91
113
  this.to = null;
92
114
  }
115
+ emitEvent(event, data) {
116
+ if (this.debug) {
117
+ if (this.async) {
118
+ (0, Platform_js_1.makeAsync)(() => this.debugEmitEvent(event, data));
119
+ return;
120
+ }
121
+ this.debugEmitEvent(event, data);
122
+ return;
123
+ }
124
+ if (this.async) {
125
+ (0, Platform_js_1.makeAsync)(() => this.regularEmitEvent(event, data));
126
+ return;
127
+ }
128
+ this.regularEmitEvent(event, data);
129
+ }
93
130
  // ## Socket connections
94
131
  //
95
132
  // Sockets that are attached to the ports of processes may be
@@ -220,7 +257,6 @@ class InternalSocket extends events_1.EventEmitter {
220
257
  // notification to the developer.
221
258
  setDebug(active) {
222
259
  this.debug = active;
223
- this.emitEvent = this.debug ? this.debugEmitEvent : this.regularEmitEvent;
224
260
  }
225
261
  // ## Socket identifiers
226
262
  //
@@ -244,7 +280,7 @@ class InternalSocket extends events_1.EventEmitter {
244
280
  }
245
281
  /* eslint-disable no-param-reassign */
246
282
  handleSocketEvent(event, payload, autoConnect = true) {
247
- const isIP = (event === 'ip') && IP_1.default.isIP(payload);
283
+ const isIP = (event === 'ip') && IP_js_1.default.isIP(payload);
248
284
  const ip = isIP ? payload : legacyToIp(event, payload);
249
285
  if (!ip) {
250
286
  return;
@@ -296,10 +332,11 @@ class InternalSocket extends events_1.EventEmitter {
296
332
  }
297
333
  exports.InternalSocket = InternalSocket;
298
334
  /**
299
- * @param {Object} [metadata]
335
+ * @param {import("fbp-graph/lib/Types").GraphEdgeMetadata} [metadata]
336
+ * @param {InternalSocketOptions} [options]
300
337
  * @returns {InternalSocket}
301
338
  */
302
- function createSocket(metadata = {}) {
303
- return new InternalSocket(metadata);
339
+ function createSocket(metadata = {}, options = {}) {
340
+ return new InternalSocket(metadata, options);
304
341
  }
305
342
  exports.createSocket = createSocket;
@@ -1,5 +1,15 @@
1
1
  export class LegacyNetwork extends BaseNetwork {
2
2
  constructor(graph: any, options?: {});
3
- subscribeGraph(): import("fbp-graph/lib/Graph").Graph;
3
+ /**
4
+ * @callback ErrorableCallback
5
+ * @param {Error|null} [err]
6
+ * @returns {void}
7
+ */
8
+ /**
9
+ * @param {ErrorableCallback} [callback]
10
+ * @returns {Promise<this>}
11
+ */
12
+ connect(callback?: (err?: Error | null) => void): Promise<LegacyNetwork>;
13
+ subscribeGraph(): import("fbp-graph/lib/Graph.js").Graph;
4
14
  }
5
- import { BaseNetwork } from "./BaseNetwork";
15
+ import { BaseNetwork } from "./BaseNetwork.js";
@@ -5,8 +5,8 @@ exports.LegacyNetwork = void 0;
5
5
  // (c) 2013-2018 Flowhub UG
6
6
  // (c) 2011-2012 Henri Bergius, Nemein
7
7
  // NoFlo may be freely distributed under the MIT license
8
- const BaseNetwork_1 = require("./BaseNetwork");
9
- const Platform_1 = require("./Platform");
8
+ const BaseNetwork_js_1 = require("./BaseNetwork.js");
9
+ const Platform_js_1 = require("./Platform.js");
10
10
  /* eslint-disable
11
11
  import/prefer-default-export,
12
12
  */
@@ -19,7 +19,7 @@ const Platform_1 = require("./Platform");
19
19
  // instantiate all the necessary processes from the designated
20
20
  // components, attach sockets between them, and handle the sending
21
21
  // of Initial Information Packets.
22
- class LegacyNetwork extends BaseNetwork_1.BaseNetwork {
22
+ class LegacyNetwork extends BaseNetwork_js_1.BaseNetwork {
23
23
  // All NoFlo networks are instantiated with a graph. Upon instantiation
24
24
  // they will load all the needed components, instantiate them, and
25
25
  // set up the defined connections and IIPs.
@@ -28,7 +28,7 @@ class LegacyNetwork extends BaseNetwork_1.BaseNetwork {
28
28
  // accordingly, including removing connections, adding new nodes,
29
29
  // and sending new IIPs.
30
30
  constructor(graph, options = {}) {
31
- Platform_1.deprecated('subscribeGraph: true is deprecated. Live-edit network graphs via the network methods instead');
31
+ (0, Platform_js_1.deprecated)('subscribeGraph: true is deprecated. Live-edit network graphs via the network methods instead');
32
32
  super(graph, options);
33
33
  }
34
34
  /**
@@ -47,7 +47,7 @@ class LegacyNetwork extends BaseNetwork_1.BaseNetwork {
47
47
  return this;
48
48
  });
49
49
  if (callback) {
50
- Platform_1.deprecated('Providing a callback to Network.connect is deprecated, use Promises');
50
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.connect is deprecated, use Promises');
51
51
  promise.then(() => {
52
52
  callback(null);
53
53
  }, callback);
package/lib/Network.d.ts CHANGED
@@ -5,11 +5,22 @@
5
5
  * @property {import("./Component").Component} [component]
6
6
  */
7
7
  export class Network extends BaseNetwork {
8
- constructor(graph: import("fbp-graph/lib/Graph").Graph, options?: import("./BaseNetwork").NetworkOptions);
8
+ /**
9
+ * @param {import("fbp-graph/lib/Types").GraphNode} node
10
+ * @param {Object} options
11
+ * @returns {Promise<NetworkProcess>}
12
+ */
13
+ addNode(node: import("fbp-graph/lib/Types").GraphNode, options: any, callback: any): Promise<NetworkProcess>;
14
+ removeNode(node: any, callback: any): Promise<any>;
15
+ renameNode(oldId: any, newId: any, callback: any): Promise<void>;
16
+ addEdge(edge: any, options: any, callback: any): Promise<import("./InternalSocket.js").InternalSocket>;
17
+ removeEdge(edge: any, callback: any): Promise<any>;
18
+ addInitial(iip: any, options: any, callback: any): Promise<import("./InternalSocket.js").InternalSocket>;
19
+ removeInitial(iip: any, callback: any): Promise<void>;
9
20
  }
10
21
  export type NetworkProcess = {
11
22
  id: string;
12
23
  componentName?: string;
13
24
  component?: import("./Component").Component;
14
25
  };
15
- import { BaseNetwork } from "./BaseNetwork";
26
+ import { BaseNetwork } from "./BaseNetwork.js";
package/lib/Network.js CHANGED
@@ -5,8 +5,8 @@ exports.Network = void 0;
5
5
  // (c) 2013-2018 Flowhub UG
6
6
  // (c) 2011-2012 Henri Bergius, Nemein
7
7
  // NoFlo may be freely distributed under the MIT license
8
- const BaseNetwork_1 = require("./BaseNetwork");
9
- const Platform_1 = require("./Platform");
8
+ const BaseNetwork_js_1 = require("./BaseNetwork.js");
9
+ const Platform_js_1 = require("./Platform.js");
10
10
  /* eslint-disable
11
11
  no-param-reassign,
12
12
  import/prefer-default-export,
@@ -26,7 +26,7 @@ const Platform_1 = require("./Platform");
26
26
  // instantiate all the necessary processes from the designated
27
27
  // components, attach sockets between them, and handle the sending
28
28
  // of Initial Information Packets.
29
- class Network extends BaseNetwork_1.BaseNetwork {
29
+ class Network extends BaseNetwork_js_1.BaseNetwork {
30
30
  // Add a process to the network. The node will also be registered
31
31
  // with the current graph.
32
32
  /**
@@ -48,7 +48,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
48
48
  return process;
49
49
  });
50
50
  if (callback) {
51
- Platform_1.deprecated('Providing a callback to Network.addNode is deprecated, use Promises');
51
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.addNode is deprecated, use Promises');
52
52
  promise.then((process) => {
53
53
  callback(null, process);
54
54
  }, callback);
@@ -64,7 +64,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
64
64
  return null;
65
65
  });
66
66
  if (callback) {
67
- Platform_1.deprecated('Providing a callback to Network.removeNode is deprecated, use Promises');
67
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.removeNode is deprecated, use Promises');
68
68
  promise.then(() => {
69
69
  callback(null);
70
70
  }, callback);
@@ -79,7 +79,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
79
79
  this.graph.renameNode(oldId, newId);
80
80
  });
81
81
  if (callback) {
82
- Platform_1.deprecated('Providing a callback to Network.renameNode is deprecated, use Promises');
82
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.renameNode is deprecated, use Promises');
83
83
  promise.then(() => {
84
84
  callback(null);
85
85
  }, callback);
@@ -102,7 +102,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
102
102
  return socket;
103
103
  });
104
104
  if (callback) {
105
- Platform_1.deprecated('Providing a callback to Network.addEdge is deprecated, use Promises');
105
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.addEdge is deprecated, use Promises');
106
106
  promise.then((socket) => {
107
107
  callback(null, socket);
108
108
  }, callback);
@@ -118,7 +118,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
118
118
  return null;
119
119
  });
120
120
  if (callback) {
121
- Platform_1.deprecated('Providing a callback to Network.removeEdge is deprecated, use Promises');
121
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.removeEdge is deprecated, use Promises');
122
122
  promise.then(() => {
123
123
  callback(null);
124
124
  }, callback);
@@ -141,7 +141,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
141
141
  return socket;
142
142
  });
143
143
  if (callback) {
144
- Platform_1.deprecated('Providing a callback to Network.addInitial is deprecated, use Promises');
144
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.addInitial is deprecated, use Promises');
145
145
  promise.then(() => {
146
146
  callback(null);
147
147
  }, callback);
@@ -156,7 +156,7 @@ class Network extends BaseNetwork_1.BaseNetwork {
156
156
  this.graph.removeInitial(iip.to.node, iip.to.port);
157
157
  });
158
158
  if (callback) {
159
- Platform_1.deprecated('Providing a callback to Network.removeInitial is deprecated, use Promises');
159
+ (0, Platform_js_1.deprecated)('Providing a callback to Network.removeInitial is deprecated, use Promises');
160
160
  promise.then(() => {
161
161
  callback(null);
162
162
  }, callback);
package/lib/NoFlo.d.ts CHANGED
@@ -32,14 +32,14 @@ export function loadFile(file: string, options: NetworkOptions, callback?: any):
32
32
  * @returning {Promise<string>}
33
33
  */
34
34
  export function saveFile(graphInstance: graph.Graph, file: string, callback?: any): void;
35
- export { isBrowser } from "./Platform";
36
- export { ComponentLoader } from "./ComponentLoader";
37
- export { Component } from "./Component";
38
- export { default as InPort } from "./InPort";
39
- export { default as OutPort } from "./OutPort";
35
+ export { isBrowser } from "./Platform.js";
36
+ export { ComponentLoader } from "./ComponentLoader.js";
37
+ export { Component } from "./Component.js";
38
+ export { default as InPort } from "./InPort.js";
39
+ export { default as OutPort } from "./OutPort.js";
40
40
  export { internalSocket };
41
- export { default as IP } from "./IP";
42
- export { asComponent } from "./AsComponent";
41
+ export { default as IP } from "./IP.js";
42
+ export { asComponent } from "./AsComponent.js";
43
43
  export type NetworkCallback = (err: Error | null, network?: Network | LegacyNetwork) => any;
44
44
  export type CreateNetworkOptions = {
45
45
  /**
@@ -51,11 +51,11 @@ export type CreateNetworkOptions = {
51
51
  */
52
52
  delay?: boolean;
53
53
  };
54
- export type NetworkOptions = CreateNetworkOptions & import("./BaseNetwork").NetworkOwnOptions & import("./ComponentLoader").ComponentLoaderOptions;
55
- import { Network } from "./Network";
56
- import { LegacyNetwork } from "./LegacyNetwork";
54
+ export type NetworkOptions = CreateNetworkOptions & import("./BaseNetwork").NetworkOptions;
55
+ import { Network } from "./Network.js";
56
+ import { LegacyNetwork } from "./LegacyNetwork.js";
57
57
  import { graph } from "fbp-graph";
58
- import * as internalSocket from "./InternalSocket";
58
+ import * as internalSocket from "./InternalSocket.js";
59
59
  export { graph, Graph, journal, Journal } from "fbp-graph";
60
- export { InPorts, OutPorts } from "./Ports";
61
- export { asCallback, asPromise } from "./AsCallback";
60
+ export { InPorts, OutPorts } from "./Ports.js";
61
+ export { asCallback, asPromise } from "./AsCallback.js";