@nsshunt/stsvueutils 1.0.16 → 1.0.18
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/dist/stsvueutils.mjs +681 -0
- package/dist/stsvueutils.mjs.map +1 -0
- package/dist/stsvueutils.umd.js +2 -0
- package/dist/stsvueutils.umd.js.map +1 -0
- package/package.json +22 -12
- package/types/plugins/workerManager.d.ts.map +1 -1
- package/dist/index.js +0 -26
- package/dist/index.js.map +0 -1
- package/dist/index.test.js +0 -8
- package/dist/index.test.js.map +0 -1
- package/dist/plugins/emitter.js +0 -49
- package/dist/plugins/emitter.js.map +0 -1
- package/dist/plugins/requestResponseHelper.js +0 -82
- package/dist/plugins/requestResponseHelper.js.map +0 -1
- package/dist/plugins/storage.js +0 -40
- package/dist/plugins/storage.js.map +0 -1
- package/dist/plugins/stsPluginKeys.js +0 -8
- package/dist/plugins/stsPluginKeys.js.map +0 -1
- package/dist/plugins/stsStorage.js +0 -133
- package/dist/plugins/stsStorage.js.map +0 -1
- package/dist/plugins/stsTestWorkerDefinitions.js +0 -18
- package/dist/plugins/stsTestWorkerDefinitions.js.map +0 -1
- package/dist/plugins/workerInstance.js +0 -115
- package/dist/plugins/workerInstance.js.map +0 -1
- package/dist/plugins/workerManager.js +0 -380
- package/dist/plugins/workerManager.js.map +0 -1
- package/dist/stores/TelemetryStore.js +0 -62
- package/dist/stores/TelemetryStore.js.map +0 -1
|
@@ -0,0 +1,681 @@
|
|
|
1
|
+
var me = Object.defineProperty;
|
|
2
|
+
var he = (s, e, t) => e in s ? me(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
+
var c = (s, e, t) => (he(s, typeof e != "symbol" ? e + "" : e, t), t), x = (s, e, t) => {
|
|
4
|
+
if (!e.has(s))
|
|
5
|
+
throw TypeError("Cannot " + t);
|
|
6
|
+
};
|
|
7
|
+
var n = (s, e, t) => (x(s, e, "read from private field"), t ? t.call(s) : e.get(s)), l = (s, e, t) => {
|
|
8
|
+
if (e.has(s))
|
|
9
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
10
|
+
e instanceof WeakSet ? e.add(s) : e.set(s, t);
|
|
11
|
+
}, g = (s, e, t, r) => (x(s, e, "write to private field"), r ? r.call(s, t) : e.set(s, t), t), Z = (s, e, t, r) => ({
|
|
12
|
+
set _(o) {
|
|
13
|
+
g(s, e, o, t);
|
|
14
|
+
},
|
|
15
|
+
get _() {
|
|
16
|
+
return n(s, e, r);
|
|
17
|
+
}
|
|
18
|
+
}), ee = (s, e, t) => (x(s, e, "access private method"), t);
|
|
19
|
+
import { inject as ue } from "vue";
|
|
20
|
+
import Y from "debug";
|
|
21
|
+
import { STSInstrumentControllerPluginKey as A, GetSTSInstrumentController as fe, PublishMessageCommands as h, GetSTSInstrumentControllerPluginKey as Se } from "@nsshunt/stspublisherserver";
|
|
22
|
+
import { Gauge as de } from "@nsshunt/stsinstrumentation";
|
|
23
|
+
import { ModelDelimeter as te } from "@nsshunt/stsmodels";
|
|
24
|
+
import { defineStore as ye } from "pinia";
|
|
25
|
+
import { Sleep as ke } from "@nsshunt/stsutils";
|
|
26
|
+
const oe = Symbol("storage"), ne = Symbol("emitter"), ie = Symbol("workerManager");
|
|
27
|
+
var ae = {}, Te = {
|
|
28
|
+
get exports() {
|
|
29
|
+
return ae;
|
|
30
|
+
},
|
|
31
|
+
set exports(s) {
|
|
32
|
+
ae = s;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
function ge() {
|
|
36
|
+
}
|
|
37
|
+
ge.prototype = {
|
|
38
|
+
on: function(s, e, t) {
|
|
39
|
+
var r = this.e || (this.e = {});
|
|
40
|
+
return (r[s] || (r[s] = [])).push({
|
|
41
|
+
fn: e,
|
|
42
|
+
ctx: t
|
|
43
|
+
}), this;
|
|
44
|
+
},
|
|
45
|
+
once: function(s, e, t) {
|
|
46
|
+
var r = this;
|
|
47
|
+
function o() {
|
|
48
|
+
r.off(s, o), e.apply(t, arguments);
|
|
49
|
+
}
|
|
50
|
+
return o._ = e, this.on(s, o, t);
|
|
51
|
+
},
|
|
52
|
+
emit: function(s) {
|
|
53
|
+
var e = [].slice.call(arguments, 1), t = ((this.e || (this.e = {}))[s] || []).slice(), r = 0, o = t.length;
|
|
54
|
+
for (r; r < o; r++)
|
|
55
|
+
t[r].fn.apply(t[r].ctx, e);
|
|
56
|
+
return this;
|
|
57
|
+
},
|
|
58
|
+
off: function(s, e) {
|
|
59
|
+
var t = this.e || (this.e = {}), r = t[s], o = [];
|
|
60
|
+
if (r && e)
|
|
61
|
+
for (var i = 0, a = r.length; i < a; i++)
|
|
62
|
+
r[i].fn !== e && r[i].fn._ !== e && o.push(r[i]);
|
|
63
|
+
return o.length ? t[s] = o : delete t[s], this;
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
Te.exports = ge;
|
|
67
|
+
var Re = ae.TinyEmitter = ge;
|
|
68
|
+
const Je = () => ue(ne), He = {
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
70
|
+
install: (s) => {
|
|
71
|
+
const e = new Re();
|
|
72
|
+
s.config.globalProperties.$sts || (s.config.globalProperties.$sts = {}), s.config.globalProperties.$sts[ne] = e, s.provide(ne, e);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
76
|
+
function _(s) {
|
|
77
|
+
for (var e = 1; e < arguments.length; e++) {
|
|
78
|
+
var t = arguments[e];
|
|
79
|
+
for (var r in t)
|
|
80
|
+
s[r] = t[r];
|
|
81
|
+
}
|
|
82
|
+
return s;
|
|
83
|
+
}
|
|
84
|
+
var We = {
|
|
85
|
+
read: function(s) {
|
|
86
|
+
return s[0] === '"' && (s = s.slice(1, -1)), s.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
87
|
+
},
|
|
88
|
+
write: function(s) {
|
|
89
|
+
return encodeURIComponent(s).replace(
|
|
90
|
+
/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
|
|
91
|
+
decodeURIComponent
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
function le(s, e) {
|
|
96
|
+
function t(o, i, a) {
|
|
97
|
+
if (!(typeof document > "u")) {
|
|
98
|
+
a = _({}, e, a), typeof a.expires == "number" && (a.expires = new Date(Date.now() + a.expires * 864e5)), a.expires && (a.expires = a.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
|
|
99
|
+
var u = "";
|
|
100
|
+
for (var m in a)
|
|
101
|
+
a[m] && (u += "; " + m, a[m] !== !0 && (u += "=" + a[m].split(";")[0]));
|
|
102
|
+
return document.cookie = o + "=" + s.write(i, o) + u;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function r(o) {
|
|
106
|
+
if (!(typeof document > "u" || arguments.length && !o)) {
|
|
107
|
+
for (var i = document.cookie ? document.cookie.split("; ") : [], a = {}, u = 0; u < i.length; u++) {
|
|
108
|
+
var m = i[u].split("="), pe = m.slice(1).join("=");
|
|
109
|
+
try {
|
|
110
|
+
var X = decodeURIComponent(m[0]);
|
|
111
|
+
if (a[X] = s.read(pe, X), o === X)
|
|
112
|
+
break;
|
|
113
|
+
} catch {
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return o ? a[o] : a;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return Object.create(
|
|
120
|
+
{
|
|
121
|
+
set: t,
|
|
122
|
+
get: r,
|
|
123
|
+
remove: function(o, i) {
|
|
124
|
+
t(
|
|
125
|
+
o,
|
|
126
|
+
"",
|
|
127
|
+
_({}, i, {
|
|
128
|
+
expires: -1
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
},
|
|
132
|
+
withAttributes: function(o) {
|
|
133
|
+
return le(this.converter, _({}, this.attributes, o));
|
|
134
|
+
},
|
|
135
|
+
withConverter: function(o) {
|
|
136
|
+
return le(_({}, this.converter, o), this.attributes);
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
attributes: { value: Object.freeze(e) },
|
|
141
|
+
converter: { value: Object.freeze(s) }
|
|
142
|
+
}
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
var se = le(We, { path: "/" });
|
|
146
|
+
const Q = Y(`proc:${process.pid}:storage.ts`);
|
|
147
|
+
let p = "_ststra_";
|
|
148
|
+
var Pe = /* @__PURE__ */ ((s) => (s.LOCAL_STORAGE = "LocalStorage", s.SESSION_STORAGE = "SessionStorage", s.COOKIE_STORAGE = "CookieStorage", s.MEMORY_STORAGE = "MemoryStorage", s))(Pe || {});
|
|
149
|
+
class ve {
|
|
150
|
+
constructor() {
|
|
151
|
+
c(this, "get", (e) => {
|
|
152
|
+
const t = se.get(p + e);
|
|
153
|
+
return t ? JSON.parse(t) : null;
|
|
154
|
+
});
|
|
155
|
+
c(this, "set", (e, t, r = {}) => {
|
|
156
|
+
let o = {};
|
|
157
|
+
window.location.protocol === "https:" && (o = {
|
|
158
|
+
secure: !0,
|
|
159
|
+
sameSite: "none"
|
|
160
|
+
}), r && r.daysUntilExpire ? o.expires = r.daysUntilExpire : o.expires = 1, Q(`CookieStorage.set: key: ${e}, value: [${t}]`), se.set(p + e, JSON.stringify(t), o);
|
|
161
|
+
});
|
|
162
|
+
c(this, "remove", (e) => {
|
|
163
|
+
se.remove(p + e);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
class Oe {
|
|
168
|
+
constructor() {
|
|
169
|
+
c(this, "get", (e) => {
|
|
170
|
+
const t = sessionStorage.getItem(p + e);
|
|
171
|
+
return t ? JSON.parse(t) : null;
|
|
172
|
+
});
|
|
173
|
+
c(this, "set", (e, t) => {
|
|
174
|
+
Q(`SessionStorage.set: key: ${e}, value: [${t}]`), sessionStorage.setItem(p + e, JSON.stringify(t));
|
|
175
|
+
});
|
|
176
|
+
c(this, "remove", (e) => {
|
|
177
|
+
sessionStorage.removeItem(p + e);
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
class $e {
|
|
182
|
+
constructor() {
|
|
183
|
+
c(this, "get", (e) => {
|
|
184
|
+
const t = localStorage.getItem(p + e);
|
|
185
|
+
return t ? JSON.parse(t) : null;
|
|
186
|
+
});
|
|
187
|
+
c(this, "set", (e, t) => {
|
|
188
|
+
Q(`LocalStorage.set: key: ${e}, value: [${t}]`), localStorage.setItem(p + e, JSON.stringify(t));
|
|
189
|
+
});
|
|
190
|
+
c(this, "remove", (e) => {
|
|
191
|
+
localStorage.removeItem(p + e);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
var v;
|
|
196
|
+
class Ie {
|
|
197
|
+
constructor() {
|
|
198
|
+
l(this, v, {});
|
|
199
|
+
c(this, "get", (e) => {
|
|
200
|
+
const t = n(this, v)[p + e];
|
|
201
|
+
return t || null;
|
|
202
|
+
});
|
|
203
|
+
c(this, "set", (e, t) => {
|
|
204
|
+
Q(`MemoryStorage.set: key: ${e}, value: [${t}]`), n(this, v)[p + e] = t;
|
|
205
|
+
});
|
|
206
|
+
c(this, "remove", (e) => {
|
|
207
|
+
delete n(this, v)[p + e];
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
v = new WeakMap();
|
|
212
|
+
var y;
|
|
213
|
+
class Me {
|
|
214
|
+
constructor(e) {
|
|
215
|
+
l(this, y, void 0);
|
|
216
|
+
switch (e.usePrefix === !1 && (p = ""), e.clientStorageType) {
|
|
217
|
+
case "SessionStorage":
|
|
218
|
+
g(this, y, new Oe());
|
|
219
|
+
break;
|
|
220
|
+
case "LocalStorage":
|
|
221
|
+
g(this, y, new $e());
|
|
222
|
+
break;
|
|
223
|
+
case "CookieStorage":
|
|
224
|
+
g(this, y, new ve());
|
|
225
|
+
break;
|
|
226
|
+
case "MemoryStorage":
|
|
227
|
+
g(this, y, new Ie());
|
|
228
|
+
break;
|
|
229
|
+
default:
|
|
230
|
+
throw new Error(`Unknown [${e.clientStorageType}] storage type.`);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
GetStorage() {
|
|
234
|
+
return n(this, y);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
y = new WeakMap();
|
|
238
|
+
const Le = () => ue(oe), Fe = {
|
|
239
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
+
install: (s, e) => {
|
|
241
|
+
const r = new Me({ clientStorageType: e.clientStorageType, usePrefix: !0 }).GetStorage();
|
|
242
|
+
s.config.globalProperties.$sts || (s.config.globalProperties.$sts = {}), s.config.globalProperties.$sts[oe] = r, s.provide(oe, r);
|
|
243
|
+
}
|
|
244
|
+
}, re = ye("__sts__TelemetryStore", {
|
|
245
|
+
// State
|
|
246
|
+
// https://pinia.vuejs.org/core-concepts/state.html
|
|
247
|
+
state: () => ({
|
|
248
|
+
workers: {}
|
|
249
|
+
}),
|
|
250
|
+
// Getters
|
|
251
|
+
// https://pinia.vuejs.org/core-concepts/getters.html
|
|
252
|
+
// Actions
|
|
253
|
+
// https://pinia.vuejs.org/core-concepts/actions.html
|
|
254
|
+
actions: {
|
|
255
|
+
RemoveWorker(s) {
|
|
256
|
+
delete this.workers[s.id];
|
|
257
|
+
},
|
|
258
|
+
RemoveRunner(s, e) {
|
|
259
|
+
const t = this.workers[s.id];
|
|
260
|
+
t && t.runners && delete t.runners[e.id];
|
|
261
|
+
},
|
|
262
|
+
Update(s, e) {
|
|
263
|
+
this.workers[s.id] || (this.workers[s.id] = {
|
|
264
|
+
id: s.id,
|
|
265
|
+
state: s.state,
|
|
266
|
+
primaryThreadWorkerOptions: { ...s.primaryThreadWorkerOptions },
|
|
267
|
+
workerThreadWorkerOptions: { ...s.workerThreadWorkerOptions },
|
|
268
|
+
runners: {}
|
|
269
|
+
});
|
|
270
|
+
const t = this.workers[s.id];
|
|
271
|
+
if (t.runners)
|
|
272
|
+
if (t.runners[e.id]) {
|
|
273
|
+
const r = t.runners[e.id];
|
|
274
|
+
r.instrumentData = { ...e.instrumentData };
|
|
275
|
+
} else {
|
|
276
|
+
const r = {
|
|
277
|
+
id: e.id,
|
|
278
|
+
asyncRunnerContext: { ...e.asyncRunnerContext },
|
|
279
|
+
options: { ...e.options },
|
|
280
|
+
state: e.state,
|
|
281
|
+
instrumentData: { ...e.instrumentData }
|
|
282
|
+
};
|
|
283
|
+
t.runners[r.id] = r;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
var C = /* @__PURE__ */ ((s) => (s.created = "created", s.running = "running", s.stopped = "stopped", s.paused = "paused", s.error = "error", s))(C || {}), q = /* @__PURE__ */ ((s) => (s.starting = "starting", s.started = "started", s.stopped = "stopped", s))(q || {});
|
|
289
|
+
const P = Y(`proc:${process.pid}:workerManager`);
|
|
290
|
+
var O, k, j, T, R, D, N, ce, E, J, H, W, L, $, F;
|
|
291
|
+
class be {
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
293
|
+
constructor(e, t) {
|
|
294
|
+
l(this, N);
|
|
295
|
+
//#agentSession: string = null;
|
|
296
|
+
l(this, O, {});
|
|
297
|
+
l(this, k, 0);
|
|
298
|
+
l(this, j, 0);
|
|
299
|
+
l(this, T, void 0);
|
|
300
|
+
l(this, R, void 0);
|
|
301
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
302
|
+
l(this, D, void 0);
|
|
303
|
+
c(this, "AddWorker", async (e) => {
|
|
304
|
+
let t;
|
|
305
|
+
e ? t = e : t = n(this, T).workerFactory;
|
|
306
|
+
const r = {
|
|
307
|
+
id: Z(this, j)._++,
|
|
308
|
+
// uuidv4()
|
|
309
|
+
worker: t.createWorkerThreadWorker(),
|
|
310
|
+
primaryWorker: t.createPrimaryThreadWorker(n(this, D), t.primaryThreadWorkerOptions),
|
|
311
|
+
state: q.starting,
|
|
312
|
+
workerThreadWorkerOptions: t.workerThreadWorkerOptions,
|
|
313
|
+
primaryThreadWorkerOptions: t.primaryThreadWorkerOptions,
|
|
314
|
+
runnersEx: {},
|
|
315
|
+
AddRunner: (u) => this.AddRunnerToWorker(r, u),
|
|
316
|
+
StopRunner: (u) => n(this, $).call(this, r, u),
|
|
317
|
+
Stop: async () => n(this, F).call(this, r)
|
|
318
|
+
};
|
|
319
|
+
console.log(`Adding worker: [${r.id}]`), r.worker.onmessage = function(u) {
|
|
320
|
+
console.log(u.data);
|
|
321
|
+
}, r.worker.onerror = function(u) {
|
|
322
|
+
console.log(u);
|
|
323
|
+
};
|
|
324
|
+
const {
|
|
325
|
+
port1: o,
|
|
326
|
+
// process message port
|
|
327
|
+
port2: i
|
|
328
|
+
// collector message port
|
|
329
|
+
} = new MessageChannel(), a = o;
|
|
330
|
+
return console.log(`STSWorkerManager::AddWorker::workerThreadWorkerOptions: [${JSON.stringify(r.workerThreadWorkerOptions)}]`), n(this, W).call(this, r, h.MessagePort, {
|
|
331
|
+
port: i,
|
|
332
|
+
//applicationStoreState: stateCopy,
|
|
333
|
+
options: { ...r.workerThreadWorkerOptions }
|
|
334
|
+
}, i), a.onmessage = async (u) => {
|
|
335
|
+
const m = u.data;
|
|
336
|
+
switch (m.command) {
|
|
337
|
+
case h.MessagePortResponse:
|
|
338
|
+
r.state = q.started;
|
|
339
|
+
break;
|
|
340
|
+
case h.InstrumentTelemetry:
|
|
341
|
+
n(this, J).call(this, r, m.payload);
|
|
342
|
+
break;
|
|
343
|
+
default:
|
|
344
|
+
r.primaryWorker.ProcessMessageFromWorker(a, m);
|
|
345
|
+
}
|
|
346
|
+
}, n(this, O)[r.id] = r, console.log(`Added worker: [${r.id}]`), r;
|
|
347
|
+
});
|
|
348
|
+
c(this, "AddRunnerToWorker", (e, t) => {
|
|
349
|
+
const r = n(this, H).call(this, e, t);
|
|
350
|
+
return e.runnersEx[r.id] = r, n(this, E).call(this, e, r), r;
|
|
351
|
+
});
|
|
352
|
+
l(this, E, (e, t) => {
|
|
353
|
+
const r = {
|
|
354
|
+
runner: ee(this, N, ce).call(this, t)
|
|
355
|
+
};
|
|
356
|
+
n(this, W).call(this, e, h.Add, r);
|
|
357
|
+
});
|
|
358
|
+
l(this, J, (e, t) => {
|
|
359
|
+
const r = re(), { runner: o } = t;
|
|
360
|
+
if (e.runnersEx[o.id]) {
|
|
361
|
+
const i = e.runnersEx[o.id];
|
|
362
|
+
let a = !1;
|
|
363
|
+
i.instrumentData.count = o.instrumentData.count, i.instrumentData.velocity = o.instrumentData.velocity, o.instrumentData.message ? i.instrumentData.message = [...o.instrumentData.message] : i.instrumentData.message = [], o.instrumentData.message && (o.instrumentData.message.forEach((u) => {
|
|
364
|
+
i.publishInstrumentController.LogEx(u);
|
|
365
|
+
}), a = !0), o.instrumentData.count && (i.publishInstrumentController.UpdateInstrument(de.REQUEST_COUNT_GAUGE, {
|
|
366
|
+
val: i.instrumentData.count
|
|
367
|
+
}), i.publishInstrumentController.UpdateInstrument(de.VELOCITY_GAUGE, {
|
|
368
|
+
Inc: i.instrumentData.velocity
|
|
369
|
+
}), a = !0), a && r.Update(e, i);
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
l(this, H, (e, t) => {
|
|
373
|
+
Z(this, k)._++;
|
|
374
|
+
const r = {
|
|
375
|
+
nid: `${e.workerThreadWorkerOptions.hostName}${te.COMPONENT_SEPERATOR}${e.workerThreadWorkerOptions.agentId}-${e.workerThreadWorkerOptions.userAgent}${te.NID_SEPERATOR}worker${e.id}${te.SEPERATOR}${n(this, k)}`,
|
|
376
|
+
id: n(this, k).toString(),
|
|
377
|
+
hostName: e.workerThreadWorkerOptions.hostName ? e.workerThreadWorkerOptions.hostName : "host",
|
|
378
|
+
agentName: `${e.workerThreadWorkerOptions.agentId}-${e.workerThreadWorkerOptions.userAgent}`,
|
|
379
|
+
threadId: `worker${e.id}`,
|
|
380
|
+
asyncRunnerId: n(this, k)
|
|
381
|
+
}, o = {
|
|
382
|
+
id: n(this, k),
|
|
383
|
+
publishInstrumentController: n(this, R).AddPublishInstrumentController(r),
|
|
384
|
+
asyncRunnerContext: r,
|
|
385
|
+
state: C.created,
|
|
386
|
+
options: t,
|
|
387
|
+
instrumentData: {
|
|
388
|
+
count: 0,
|
|
389
|
+
velocity: 0,
|
|
390
|
+
message: []
|
|
391
|
+
},
|
|
392
|
+
Stop: async () => n(this, $).call(this, e, o)
|
|
393
|
+
};
|
|
394
|
+
return o;
|
|
395
|
+
});
|
|
396
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
397
|
+
l(this, W, (e, t, r, o) => {
|
|
398
|
+
o ? (console.log("#PostMessageToWorker with transfer object"), e.worker.postMessage({ command: t, payload: r }, [o]), console.log("#PostMessageToWorker with transfer object - done...")) : (console.log("#PostMessageToWorker"), e.worker.postMessage({ command: t, payload: r }));
|
|
399
|
+
});
|
|
400
|
+
l(this, L, (e) => {
|
|
401
|
+
if (e.worker) {
|
|
402
|
+
const t = re();
|
|
403
|
+
e.worker.terminate(), console.log(`Terminated worker: [${e.id}]`), t.RemoveWorker(e), delete n(this, O)[e.id];
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
l(this, $, async (e, t = null) => {
|
|
407
|
+
if (t === null) {
|
|
408
|
+
const r = Object.keys(e.runnersEx);
|
|
409
|
+
if (r.length > 0) {
|
|
410
|
+
const o = r[0];
|
|
411
|
+
t = e.runnersEx[o];
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
if (t !== null) {
|
|
415
|
+
n(this, W).call(this, e, h.Stop, {
|
|
416
|
+
runner: ee(this, N, ce).call(this, t)
|
|
417
|
+
}), t.publishInstrumentController.LogEx(`Terminating runner: [${t.id}]`);
|
|
418
|
+
const r = [];
|
|
419
|
+
r.push((async () => (await ke(100), t.publishInstrumentController.InstrumentTerminate()))()), re().RemoveRunner(e, t), delete e.runnersEx[t.id];
|
|
420
|
+
const i = await Promise.all(r);
|
|
421
|
+
console.log(`Removed instrument workers: [${i}]`);
|
|
422
|
+
}
|
|
423
|
+
return !0;
|
|
424
|
+
});
|
|
425
|
+
l(this, F, async (e) => {
|
|
426
|
+
try {
|
|
427
|
+
if (e.state !== q.stopped) {
|
|
428
|
+
n(this, W).call(this, e, h.Stop, null), console.log(`Terminating worker: [${e.id}]`);
|
|
429
|
+
const t = [];
|
|
430
|
+
Object.keys(e.runnersEx).forEach((o) => {
|
|
431
|
+
const i = e.runnersEx[o];
|
|
432
|
+
t.push(n(this, $).call(this, e, i));
|
|
433
|
+
}), await Promise.all(t), n(this, L).call(this, e);
|
|
434
|
+
}
|
|
435
|
+
return !0;
|
|
436
|
+
} catch (t) {
|
|
437
|
+
return console.log(`Error in STSTestWorker:StopWorker: [${t}]`), !1;
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
c(this, "GetNextAvailableWorker", () => {
|
|
441
|
+
let e = null;
|
|
442
|
+
for (const [, t] of Object.entries(this.WorkersEx))
|
|
443
|
+
e ? Object.keys(t.runnersEx).length < Object.keys(e.runnersEx).length && (e = t) : e = t;
|
|
444
|
+
return e;
|
|
445
|
+
});
|
|
446
|
+
c(this, "GetBusyWorker", () => {
|
|
447
|
+
let e = null;
|
|
448
|
+
for (const [, t] of Object.entries(this.WorkersEx))
|
|
449
|
+
e ? Object.keys(t.runnersEx).length > Object.keys(e.runnersEx).length && (e = t) : e = t;
|
|
450
|
+
return e;
|
|
451
|
+
});
|
|
452
|
+
/*
|
|
453
|
+
StopRunner = async () => {
|
|
454
|
+
// Calculate the worker with the most runners
|
|
455
|
+
let largestRunnerWorker: IWorkerEx | null = null;
|
|
456
|
+
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
457
|
+
if (largestRunnerWorker) {
|
|
458
|
+
if (Object.keys(stsWorker.runnersEx).length > Object.keys(largestRunnerWorker.runnersEx).length) {
|
|
459
|
+
largestRunnerWorker = stsWorker;
|
|
460
|
+
}
|
|
461
|
+
} else {
|
|
462
|
+
largestRunnerWorker = stsWorker;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (largestRunnerWorker) largestRunnerWorker.StopRunner();
|
|
466
|
+
}
|
|
467
|
+
*/
|
|
468
|
+
/*
|
|
469
|
+
StopWorker = async () => {
|
|
470
|
+
// Calculate the worker with the least runners
|
|
471
|
+
let largestRunnerWorker: IWorkerEx | null = null;
|
|
472
|
+
for (const [, stsWorker] of Object.entries(this.WorkersEx)) {
|
|
473
|
+
if (largestRunnerWorker) {
|
|
474
|
+
if (Object.keys(stsWorker.runnersEx).length < Object.keys(largestRunnerWorker.runnersEx).length) {
|
|
475
|
+
largestRunnerWorker = stsWorker;
|
|
476
|
+
}
|
|
477
|
+
} else {
|
|
478
|
+
largestRunnerWorker = stsWorker;
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
if (largestRunnerWorker) largestRunnerWorker.Stop();
|
|
482
|
+
}
|
|
483
|
+
*/
|
|
484
|
+
c(this, "StopAllWorkers", async () => {
|
|
485
|
+
const e = [];
|
|
486
|
+
for (const [, t] of Object.entries(this.WorkersEx))
|
|
487
|
+
e.push(t.Stop());
|
|
488
|
+
await Promise.all(e);
|
|
489
|
+
});
|
|
490
|
+
g(this, D, e), t ? g(this, T, t) : g(this, T, {}), P(`CompareSTSInstrumentControllerPluginKeyWMEx(): [${we()}]`), P(`Attempting to get STSInstrumentControllerPlugin using symbol: [${String(A)}]`), g(this, R, fe(e)), P(n(this, R)), P("keys within app.config.globalProperties.$sts");
|
|
491
|
+
for (const [r, o] of Object.entries(e.config.globalProperties.$sts))
|
|
492
|
+
P(`${r}`);
|
|
493
|
+
n(this, R) || P(`Failed to get STSInstrumentControllerPlugin using symbol: [${String(A)}]`);
|
|
494
|
+
}
|
|
495
|
+
get WorkersEx() {
|
|
496
|
+
return n(this, O);
|
|
497
|
+
}
|
|
498
|
+
get Options() {
|
|
499
|
+
return n(this, T);
|
|
500
|
+
}
|
|
501
|
+
set Options(e) {
|
|
502
|
+
g(this, T, e);
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
O = new WeakMap(), k = new WeakMap(), j = new WeakMap(), T = new WeakMap(), R = new WeakMap(), D = new WeakMap(), N = new WeakSet(), ce = function(e) {
|
|
506
|
+
return {
|
|
507
|
+
id: e.id,
|
|
508
|
+
asyncRunnerContext: { ...e.asyncRunnerContext },
|
|
509
|
+
options: { ...e.options },
|
|
510
|
+
state: e.state,
|
|
511
|
+
instrumentData: { ...e.instrumentData }
|
|
512
|
+
};
|
|
513
|
+
}, E = new WeakMap(), J = new WeakMap(), H = new WeakMap(), W = new WeakMap(), L = new WeakMap(), $ = new WeakMap(), F = new WeakMap();
|
|
514
|
+
const Ke = () => A, Be = (s) => s === A, we = () => A === Se(), ze = () => ue(ie), Ve = {
|
|
515
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
516
|
+
install: (s, e) => {
|
|
517
|
+
const t = new be(s, e);
|
|
518
|
+
s.config.globalProperties.$sts || (s.config.globalProperties.$sts = {}), s.config.globalProperties.$sts[ie] = t, s.provide(ie, t);
|
|
519
|
+
}
|
|
520
|
+
}, w = Y(`proc:${process.pid}`);
|
|
521
|
+
var d, G, I, K;
|
|
522
|
+
class Ce {
|
|
523
|
+
constructor(e) {
|
|
524
|
+
l(this, d, {});
|
|
525
|
+
l(this, G, 1e4);
|
|
526
|
+
//@@ config
|
|
527
|
+
l(this, I, void 0);
|
|
528
|
+
c(this, "PostMessage", (e) => new Promise((t, r) => {
|
|
529
|
+
const { messageId: o } = e.payload;
|
|
530
|
+
if (o)
|
|
531
|
+
n(this, d)[o] ? r(`RequestResponseHelper: Message with id: [${o}] already exists within the Request/Response record structure`) : (n(this, d)[o] = {
|
|
532
|
+
publishMessagePayload: { ...e },
|
|
533
|
+
cb: () => {
|
|
534
|
+
const i = n(this, d)[o].publishMessagePayloadResponse;
|
|
535
|
+
if (clearTimeout(n(this, d)[o].timeout), setTimeout(() => {
|
|
536
|
+
delete n(this, d)[o];
|
|
537
|
+
}, 0), i)
|
|
538
|
+
w(`RequestResponseHelper: Resolving response message with id: [${o}] from target worker port. Details: [${JSON.stringify(i)}]`), t(i);
|
|
539
|
+
else {
|
|
540
|
+
const a = "Could not get detail from this.#requestResponseMessages[messageId].publishMessagePayloadResponse";
|
|
541
|
+
w(a), r(a);
|
|
542
|
+
}
|
|
543
|
+
},
|
|
544
|
+
timeout: setTimeout(() => {
|
|
545
|
+
setTimeout(() => {
|
|
546
|
+
delete n(this, d)[o];
|
|
547
|
+
}, 0), w(`RequestResponseHelper: Timeout has occurred after: [${n(this, G)}]ms with message id: [${o}]. Details: [${JSON.stringify(n(this, d)[o].publishMessagePayload)}]`), r("RequestResponseHelper: Did not receive response form parent process.");
|
|
548
|
+
}, n(this, G))
|
|
549
|
+
// max message timeout allowed
|
|
550
|
+
}, w(`RequestResponseHelper: Sending message with id: [${o}] to target worker port. Details: [${JSON.stringify(n(this, d)[o].publishMessagePayload)}]`), n(this, I).postMessage(e));
|
|
551
|
+
else {
|
|
552
|
+
const i = "RequestResponseHelper: Response did not include a message id";
|
|
553
|
+
w(i), r(i);
|
|
554
|
+
}
|
|
555
|
+
}));
|
|
556
|
+
l(this, K, () => {
|
|
557
|
+
n(this, I).onmessage = async (e) => {
|
|
558
|
+
const t = e.data;
|
|
559
|
+
if (t.payload.messageId) {
|
|
560
|
+
const r = t.payload.messageId;
|
|
561
|
+
if (r && r !== "")
|
|
562
|
+
if (n(this, d)[r]) {
|
|
563
|
+
const o = n(this, d)[r];
|
|
564
|
+
o.publishMessagePayloadResponse = { ...t }, o.cb();
|
|
565
|
+
} else
|
|
566
|
+
throw new Error(`RequestResponseHelper: Could not find Request/Response message with id: [${r}]`);
|
|
567
|
+
}
|
|
568
|
+
};
|
|
569
|
+
});
|
|
570
|
+
g(this, I, e), n(this, K).call(this);
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
d = new WeakMap(), G = new WeakMap(), I = new WeakMap(), K = new WeakMap();
|
|
574
|
+
const f = Y(`proc:${process.pid}:workerInstance`);
|
|
575
|
+
var S, U, M, b, B, z, V;
|
|
576
|
+
class Ye {
|
|
577
|
+
constructor() {
|
|
578
|
+
l(this, S, null);
|
|
579
|
+
l(this, U, null);
|
|
580
|
+
l(this, M, {});
|
|
581
|
+
l(this, b, null);
|
|
582
|
+
c(this, "GetRandomInt", (e) => (f("WorkerInstance::GetRandomInt"), Math.floor(Math.random() * Math.floor(e))));
|
|
583
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
584
|
+
c(this, "StartWork", async (e) => {
|
|
585
|
+
f("WorkerInstance::StartWork");
|
|
586
|
+
});
|
|
587
|
+
c(this, "PostTelemetry", (e) => {
|
|
588
|
+
if (n(this, S)) {
|
|
589
|
+
const t = {
|
|
590
|
+
command: h.InstrumentTelemetry,
|
|
591
|
+
payload: {
|
|
592
|
+
runner: e
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
n(this, S).postMessage(t);
|
|
596
|
+
}
|
|
597
|
+
});
|
|
598
|
+
l(this, B, (e) => {
|
|
599
|
+
f("WorkerInstance::SetMessagePort"), g(this, S, e.port), n(this, S).onmessage = function(r) {
|
|
600
|
+
console.log(`collectorCollectorPort onmessage: ${r.data}`);
|
|
601
|
+
}, g(this, U, new Ce(n(this, S)));
|
|
602
|
+
const t = {
|
|
603
|
+
command: h.MessagePortResponse,
|
|
604
|
+
payload: {}
|
|
605
|
+
};
|
|
606
|
+
n(this, S).postMessage(t);
|
|
607
|
+
});
|
|
608
|
+
c(this, "StartRunner", async (e) => {
|
|
609
|
+
f("WorkerInstance::StartRunner"), console.log(`StartTests: [${JSON.stringify(e)}]`), e.state = C.running, this.StartWork(e);
|
|
610
|
+
});
|
|
611
|
+
l(this, z, (e) => {
|
|
612
|
+
f("WorkerInstance::AddAsyncRunner");
|
|
613
|
+
const { runner: t } = e;
|
|
614
|
+
n(this, M)[t.id] = t, this.StartRunner(t);
|
|
615
|
+
});
|
|
616
|
+
l(this, V, (e) => {
|
|
617
|
+
if (f("WorkerInstance::StopRunners"), e === null)
|
|
618
|
+
for (const [, t] of Object.entries(n(this, M)))
|
|
619
|
+
t.state = C.stopped;
|
|
620
|
+
else {
|
|
621
|
+
const t = n(this, M)[e.runner.id];
|
|
622
|
+
t && (t.state = C.stopped);
|
|
623
|
+
}
|
|
624
|
+
});
|
|
625
|
+
c(this, "ProcessMessage", async (e) => {
|
|
626
|
+
f("WorkerInstance::ProcessMessage");
|
|
627
|
+
try {
|
|
628
|
+
const t = e.data;
|
|
629
|
+
switch (t.command) {
|
|
630
|
+
case h.MessagePort:
|
|
631
|
+
n(this, B).call(this, t.payload), g(this, b, t.payload.options), f(`WorkerInstance::ProcessMessage::#options: [${JSON.stringify(n(this, b))}]`);
|
|
632
|
+
break;
|
|
633
|
+
case h.Add:
|
|
634
|
+
n(this, z).call(this, t.payload);
|
|
635
|
+
break;
|
|
636
|
+
case h.Stop:
|
|
637
|
+
n(this, V).call(this, t.payload);
|
|
638
|
+
break;
|
|
639
|
+
default:
|
|
640
|
+
f(`Invalid payloadMessage.command: [${t.command}] - Ignoring`);
|
|
641
|
+
}
|
|
642
|
+
} catch (t) {
|
|
643
|
+
console.log(t);
|
|
644
|
+
}
|
|
645
|
+
});
|
|
646
|
+
f("WorkerInstance::constructor");
|
|
647
|
+
}
|
|
648
|
+
get RequestResponseHelper() {
|
|
649
|
+
return n(this, U);
|
|
650
|
+
}
|
|
651
|
+
get CollectorCollectorPort() {
|
|
652
|
+
return n(this, S);
|
|
653
|
+
}
|
|
654
|
+
get Options() {
|
|
655
|
+
return n(this, b);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
S = new WeakMap(), U = new WeakMap(), M = new WeakMap(), b = new WeakMap(), B = new WeakMap(), z = new WeakMap(), V = new WeakMap();
|
|
659
|
+
export {
|
|
660
|
+
Me as ClientStorageFactory,
|
|
661
|
+
Pe as ClientStorageType,
|
|
662
|
+
Be as CompareSTSInstrumentControllerPluginKeyWM,
|
|
663
|
+
we as CompareSTSInstrumentControllerPluginKeyWMEx,
|
|
664
|
+
Ke as GetSTSInstrumentControllerPluginKeyWM,
|
|
665
|
+
C as IRunnerState,
|
|
666
|
+
q as IWorkerState,
|
|
667
|
+
Ce as RequestResponseHelper,
|
|
668
|
+
He as STSEmitterPlugin,
|
|
669
|
+
ne as STSEmitterPluginKey,
|
|
670
|
+
Fe as STSStoragePlugin,
|
|
671
|
+
oe as STSStoragePluginKey,
|
|
672
|
+
be as STSWorkerManager,
|
|
673
|
+
Ve as STSWorkerManagerPlugin,
|
|
674
|
+
ie as STSWorkerManagerPluginKey,
|
|
675
|
+
re as TelemetryStore,
|
|
676
|
+
Ye as WorkerInstance,
|
|
677
|
+
Je as useSTSEmitterPlugin,
|
|
678
|
+
Le as useSTSStoragePlugin,
|
|
679
|
+
ze as useSTSWorkerManager
|
|
680
|
+
};
|
|
681
|
+
//# sourceMappingURL=stsvueutils.mjs.map
|