@nsshunt/stsrunnerframework 1.0.129 → 1.0.131

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/README.md CHANGED
@@ -71,16 +71,6 @@ parentPort?.on('message', (data: any) => {
71
71
  } else {
72
72
  throw new Error(`Invalid command: [${command}]`)
73
73
  }
74
- } else {
75
- const { command, payload } = data.data;
76
- if (command === eIWMessageCommands.MessagePort) {
77
- payload.port.on('message', (data: any) => {
78
- worker.ProcessMessage(data.data); // browser version
79
- });
80
- worker.ProcessMessage(data.data);
81
- } else {
82
- throw new Error(`Invalid command: [${command}]`)
83
- }
84
74
  }
85
75
  });
86
76
  ```
@@ -91,8 +81,6 @@ parentPort?.on('message', (data: any) => {
91
81
  import { IRunnerInstance, ITestRunnerTelemetryPayload, WorkerInstance, eIWMessageCommands } from './../index'
92
82
  import { TestCase01 } from './testCase01'
93
83
 
94
- import isNode from 'detect-node'
95
-
96
84
  export class WorkerTestCases extends WorkerInstance {
97
85
  constructor() {
98
86
  super()
@@ -111,26 +99,23 @@ export class WorkerTestCases extends WorkerInstance {
111
99
  const worker = new WorkerTestCases();
112
100
 
113
101
  onmessage = async function(data: any) {
114
- if (isNode) {
115
- const { command, payload } = data;
116
- if (command === eIWMessageCommands.MessagePort) {
117
- payload.port.on('message', (data: any) => {
118
- worker.ProcessMessage(data);
119
- });
120
- worker.ProcessMessage(data);
121
- } else {
122
- throw new Error(`Invalid command: [${command}]`)
123
- }
102
+ const { command, payload } = data.data;
103
+ if (command === eIWMessageCommands.MessagePort) {
104
+ payload.port.start();
105
+ payload.port.addEventListener('message', (data: any) => {
106
+ worker.ProcessMessage(data.data); // browser version
107
+ });
108
+
109
+ /*
110
+ payload.port.addEventListener('messageerror', (error: any) => {
111
+ console.error(`onmessageerror(): [${error}]`)
112
+ worker.ProcessMessage(data.data); // browser version
113
+ });
114
+ */
115
+
116
+ worker.ProcessMessage(data.data);
124
117
  } else {
125
- const { command, payload } = data.data;
126
- if (command === eIWMessageCommands.MessagePort) {
127
- payload.port.on('message', (data: any) => {
128
- worker.ProcessMessage(data.data); // browser version
129
- });
130
- worker.ProcessMessage(data.data);
131
- } else {
132
- throw new Error(`Invalid command: [${command}]`)
133
- }
118
+ throw new Error(`Invalid command: [${command}]`)
134
119
  }
135
120
  }
136
121
  ```
@@ -1549,7 +1549,11 @@ class WorkerInstance {
1549
1549
  for (let i = 0; i < removeList.length; i++) {
1550
1550
  __privateGet(this, _runners)[removeList[i]].archived = true;
1551
1551
  if (__privateGet(this, _archiveDeleteTimeout) !== 0) {
1552
- setTimeout(() => delete __privateGet(this, _runners)[removeList[i]], __privateGet(this, _archiveDeleteTimeout) * 1e3).unref();
1552
+ if (isNode) {
1553
+ setTimeout(() => delete __privateGet(this, _runners)[removeList[i]], __privateGet(this, _archiveDeleteTimeout) * 1e3).unref();
1554
+ } else {
1555
+ setTimeout(() => delete __privateGet(this, _runners)[removeList[i]], __privateGet(this, _archiveDeleteTimeout) * 1e3);
1556
+ }
1553
1557
  }
1554
1558
  }
1555
1559
  __privateGet(this, _debug).call(this, chalk.grey(`WorkerInstance:#processLoopExecutor(): Remaining Runner Count: [${Object.keys(__privateGet(this, _runners)).length}]`));
@@ -1576,12 +1580,12 @@ class WorkerInstance {
1576
1580
  __privateSet(this, _collectorCollectorPort, workerMessagePort.port);
1577
1581
  if (isNode) {
1578
1582
  __privateGet(this, _collectorCollectorPort).on("message", (data) => {
1579
- __privateGet(this, _debug).call(this, `collectorCollectorPort onmessage: ${JSON.stringify(data)}`);
1583
+ __privateGet(this, _debug).call(this, `collectorCollectorPort on('message'): ${JSON.stringify(data)}`);
1580
1584
  });
1581
1585
  } else {
1582
- __privateGet(this, _collectorCollectorPort).onmessage = function(data) {
1583
- __privateGet(this, _debug).call(this, `collectorCollectorPort onmessage: ${JSON.stringify(data.data)}`);
1584
- };
1586
+ __privateGet(this, _collectorCollectorPort).addEventListener("message", (data) => {
1587
+ __privateGet(this, _debug).call(this, `collectorCollectorPort addEventListener('message'): ${JSON.stringify(data.data)}`);
1588
+ });
1585
1589
  }
1586
1590
  const response = {
1587
1591
  command: eIWMessageCommands.MessagePortResponse,
@@ -2326,7 +2330,11 @@ class STSWorkerManager {
2326
2330
  }
2327
2331
  runnerEx.archived = true;
2328
2332
  if (__privateGet(this, _archiveDeleteTimeout2) !== 0) {
2329
- setTimeout(() => delete workerEx.runnersEx[removeList[i].runnerId], __privateGet(this, _archiveDeleteTimeout2) * 1e3).unref();
2333
+ if (isNode) {
2334
+ setTimeout(() => delete workerEx.runnersEx[removeList[i].runnerId], __privateGet(this, _archiveDeleteTimeout2) * 1e3).unref();
2335
+ } else {
2336
+ setTimeout(() => delete workerEx.runnersEx[removeList[i].runnerId], __privateGet(this, _archiveDeleteTimeout2) * 1e3);
2337
+ }
2330
2338
  }
2331
2339
  }
2332
2340
  }
@@ -2375,7 +2383,16 @@ class STSWorkerManager {
2375
2383
  // Filter by plan and/or tag. Leave blank to not use in filter.
2376
2384
  __publicField(this, "GetArchiveList", (runnerSearchFilters) => {
2377
2385
  try {
2378
- return __privateGet(this, _archiveList).filter((runner) => !runnerSearchFilters.plan ? true : !runner.options.plan ? false : runner.options.plan.localeCompare(runnerSearchFilters.plan) === 0).filter((runner) => !runnerSearchFilters.planId ? true : !runner.options.planId ? false : runner.options.planId.localeCompare(runnerSearchFilters.planId) === 0).filter((runner) => !runnerSearchFilters.tag ? true : !runner.options.tag ? false : runner.options.tag.includes(runnerSearchFilters.tag)).filter((runner) => !runnerSearchFilters.userDataKey ? true : !runner.options.userData ? false : runner.options.userData[runnerSearchFilters.userDataKey] ? true : false);
2386
+ return __privateGet(this, _archiveList).filter((runner) => {
2387
+ var _a, _b;
2388
+ return !runnerSearchFilters.plan ? true : ((_b = (_a = runner.options.runnerPlan) == null ? void 0 : _a.plan) == null ? void 0 : _b.localeCompare(runnerSearchFilters.plan)) === 0;
2389
+ }).filter((runner) => {
2390
+ var _a, _b;
2391
+ return !runnerSearchFilters.planId ? true : ((_b = (_a = runner.options.runnerPlan) == null ? void 0 : _a.planId) == null ? void 0 : _b.localeCompare(runnerSearchFilters.planId)) === 0;
2392
+ }).filter((runner) => {
2393
+ var _a;
2394
+ return !runnerSearchFilters.tag ? true : (_a = runner.options.tag) == null ? void 0 : _a.includes(runnerSearchFilters.tag);
2395
+ }).filter((runner) => !runnerSearchFilters.userDataKey ? true : !runner.options.userData ? false : !!runner.options.userData[runnerSearchFilters.userDataKey]);
2379
2396
  } catch (error) {
2380
2397
  __privateGet(this, _error2).call(this, `GetArchiveList(): Error: [${error}]`);
2381
2398
  return [];
@@ -2413,6 +2430,9 @@ class STSWorkerManager {
2413
2430
  port2
2414
2431
  // collector message port
2415
2432
  } = new MessageChannel();
2433
+ if (!isNode) {
2434
+ port1.start();
2435
+ }
2416
2436
  const workerId = v4();
2417
2437
  const stsWorkerEx = {
2418
2438
  id: workerId,
@@ -2554,10 +2574,10 @@ class STSWorkerManager {
2554
2574
  processMessage(publishMessagePayload);
2555
2575
  });
2556
2576
  } else {
2557
- stsWorkerEx.messagePort.onmessage = (data) => {
2577
+ stsWorkerEx.messagePort.addEventListener("message", (data) => {
2558
2578
  publishMessagePayload = data.data;
2559
2579
  processMessage(publishMessagePayload);
2560
- };
2580
+ });
2561
2581
  }
2562
2582
  __privateGet(this, _workersEx)[stsWorkerEx.id] = stsWorkerEx;
2563
2583
  __privateGet(this, _debug2).call(this, `Added worker: [${stsWorkerEx.id}]`);
@@ -3200,11 +3220,15 @@ class STSWorkerManager {
3200
3220
  const retVal = {
3201
3221
  id: runnerEx.id,
3202
3222
  iteration: runnerEx.iteration,
3203
- state: runnerEx.state,
3204
- options: {
3205
- plan: runnerEx.options.plan
3206
- }
3223
+ state: runnerEx.state
3207
3224
  };
3225
+ if (runnerEx.options && runnerEx.options.runnerPlan) {
3226
+ retVal.options = {
3227
+ runnerPlan: {
3228
+ plan: runnerEx.options.runnerPlan.plan
3229
+ }
3230
+ };
3231
+ }
3208
3232
  return retVal;
3209
3233
  } catch (error) {
3210
3234
  __privateGet(this, _error2).call(this, `CreateRunnerCopy(): Error: [${error}]`);