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
package/lib/InPort.js CHANGED
@@ -3,20 +3,27 @@ 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
11
  /**
12
12
  * @typedef InPortOptions
13
+ * @property {any} [default]
14
+ * @property {Array<any>} [values]
13
15
  * @property {boolean} [control]
14
16
  * @property {boolean} [triggering]
15
17
  */
18
+ /**
19
+ * @callback HasValidationCallback
20
+ * @param {import("./IP").default} ip
21
+ * @returns {boolean}
22
+ */
16
23
  /**
17
24
  * @typedef {import("./BasePort").BaseOptions & InPortOptions} PortOptions
18
25
  */
19
- class InPort extends BasePort_1.default {
26
+ class InPort extends BasePort_js_1.default {
20
27
  /**
21
28
  * @param {PortOptions} [options]
22
29
  */
@@ -32,10 +39,18 @@ class InPort extends BasePort_1.default {
32
39
  opts.triggering = true;
33
40
  }
34
41
  super(opts);
42
+ const baseOptions = this.options;
43
+ this.options = /** @type {PortOptions} */ (baseOptions);
44
+ /** @type {import("./Component").Component|null} */
35
45
  this.nodeInstance = null;
36
46
  this.prepareBuffer();
37
47
  }
38
- // 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
+ */
39
54
  attachSocket(socket, localId = null) {
40
55
  // have a default value.
41
56
  if (this.hasDefault()) {
@@ -51,7 +66,11 @@ class InPort extends BasePort_1.default {
51
66
  socket.on('disconnect', () => this.handleSocketEvent('disconnect', socket, localId));
52
67
  socket.on('ip', (ip) => this.handleIP(ip, localId));
53
68
  }
54
- handleIP(packet, index) {
69
+ /**
70
+ * @param {import("./IP").default} packet
71
+ * @param {number|null} [index]
72
+ */
73
+ handleIP(packet, index = null) {
55
74
  if (this.options.control && (packet.type !== 'data')) {
56
75
  return;
57
76
  }
@@ -75,6 +94,11 @@ class InPort extends BasePort_1.default {
75
94
  }
76
95
  this.emit('ip', ip, index);
77
96
  }
97
+ /**
98
+ * @param {string} event
99
+ * @param {any} payload
100
+ * @param {number} [id]
101
+ */
78
102
  handleSocketEvent(event, payload, id) {
79
103
  // Emit port event
80
104
  if (this.isAddressable()) {
@@ -143,6 +167,9 @@ class InPort extends BasePort_1.default {
143
167
  }
144
168
  return this.buffer;
145
169
  }
170
+ /**
171
+ * @param {any} data
172
+ */
146
173
  validateData(data) {
147
174
  if (!this.options.values) {
148
175
  return;
@@ -206,8 +233,12 @@ class InPort extends BasePort_1.default {
206
233
  }
207
234
  return buf.shift();
208
235
  }
209
- // Fetches a packet from the port
210
- 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) {
211
242
  const res = this.getFromBuffer(scope, index);
212
243
  if (res !== undefined) {
213
244
  return res;
@@ -215,6 +246,13 @@ class InPort extends BasePort_1.default {
215
246
  // Try to find an IIP instead
216
247
  return this.getFromBuffer(null, index, true);
217
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
+ */
218
256
  hasIPinBuffer(scope, index, validate, initial = false) {
219
257
  const buf = this.getBuffer(scope, index, initial);
220
258
  if (!(buf != null ? buf.length : undefined)) {
@@ -227,17 +265,30 @@ class InPort extends BasePort_1.default {
227
265
  }
228
266
  return false;
229
267
  }
268
+ /**
269
+ * @param {number|null} index
270
+ * @param {HasValidationCallback} validate
271
+ */
230
272
  hasIIP(index, validate) {
231
273
  return this.hasIPinBuffer(null, index, validate, true);
232
274
  }
233
- // 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
+ */
234
281
  has(scope, index, validate) {
235
282
  let valid = validate;
236
- let idx = index;
237
- if (!this.isAddressable()) {
238
- valid = idx;
283
+ /** @type {number|null} */
284
+ let idx;
285
+ if (typeof index === 'function') {
286
+ valid = /** @type {HasValidationCallback} */ (index);
239
287
  idx = null;
240
288
  }
289
+ else {
290
+ idx = index;
291
+ }
241
292
  if (this.hasIPinBuffer(scope, idx, valid)) {
242
293
  return true;
243
294
  }
@@ -246,15 +297,23 @@ class InPort extends BasePort_1.default {
246
297
  }
247
298
  return false;
248
299
  }
249
- // Returns the number of data packets in an inport
250
- 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) {
251
307
  const buf = this.getBuffer(scope, index);
252
308
  if (!buf) {
253
309
  return 0;
254
310
  }
255
311
  return buf.length;
256
312
  }
257
- // Tells if buffer has packets or not
313
+ /**
314
+ * Tells if buffer has packets or not
315
+ * @param {string|null} scope
316
+ */
258
317
  ready(scope) {
259
318
  return this.length(scope) > 0;
260
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,38 @@ 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
+ declare const _default: {
44
+ isBrowser: typeof isBrowser;
45
+ ComponentLoader: typeof ComponentLoader;
46
+ Component: typeof Component;
47
+ InPorts: typeof InPorts;
48
+ OutPorts: typeof OutPorts;
49
+ InPort: typeof InPort;
50
+ OutPort: typeof OutPort;
51
+ internalSocket: typeof internalSocket;
52
+ IP: typeof IP;
53
+ createNetwork: typeof createNetwork;
54
+ loadFile: typeof loadFile;
55
+ saveFile: typeof saveFile;
56
+ asCallback: typeof asCallback;
57
+ asPromise: typeof asPromise;
58
+ asComponent: typeof asComponent;
59
+ Graph: typeof graph.Graph;
60
+ createGraph: typeof graph.createGraph;
61
+ loadJSON: typeof graph.loadJSON;
62
+ loadFBP: typeof graph.loadFBP;
63
+ equivalent: typeof graph.equivalent;
64
+ mergeResolveTheirs: typeof graph.mergeResolveTheirs;
65
+ };
66
+ export default _default;
43
67
  export type NetworkCallback = (err: Error | null, network?: Network | LegacyNetwork) => any;
44
68
  export type CreateNetworkOptions = {
45
69
  /**
@@ -51,11 +75,22 @@ export type CreateNetworkOptions = {
51
75
  */
52
76
  delay?: boolean;
53
77
  };
54
- export type NetworkOptions = CreateNetworkOptions & import("./BaseNetwork").NetworkOwnOptions & import("./ComponentLoader").ComponentLoaderOptions;
55
- import { Network } from "./Network";
56
- import { LegacyNetwork } from "./LegacyNetwork";
78
+ export type NetworkOptions = CreateNetworkOptions & import("./BaseNetwork").NetworkOptions;
79
+ import { Network } from "./Network.js";
80
+ import { LegacyNetwork } from "./LegacyNetwork.js";
57
81
  import { graph } from "fbp-graph";
58
- import * as internalSocket from "./InternalSocket";
82
+ import * as internalSocket from "./InternalSocket.js";
83
+ import { isBrowser } from "./Platform.js";
84
+ import { ComponentLoader } from "./ComponentLoader.js";
85
+ import { Component } from "./Component.js";
86
+ import { InPorts } from "./Ports.js";
87
+ import { OutPorts } from "./Ports.js";
88
+ import InPort from "./InPort.js";
89
+ import OutPort from "./OutPort.js";
90
+ import IP from "./IP.js";
91
+ import { asCallback } from "./AsCallback.js";
92
+ import { asPromise } from "./AsCallback.js";
93
+ import { asComponent } from "./AsComponent.js";
59
94
  export { graph, Graph, journal, Journal } from "fbp-graph";
60
- export { InPorts, OutPorts } from "./Ports";
61
- export { asCallback, asPromise } from "./AsCallback";
95
+ export { InPorts, OutPorts } from "./Ports.js";
96
+ export { asCallback, asPromise } from "./AsCallback.js";