@m4l/gclick-realtime 1.0.3 → 1.0.4

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.
@@ -1,8 +1,14 @@
1
- import { SourceDataBase as g } from "@m4l/realtime-runtime";
2
- import { buildRealTimeDummyRuntimeModel as b } from "./simulation.js";
3
- import k from "../../node_modules/lodash-es/cloneDeep.js";
1
+ import { SourceDataBase as D } from "@m4l/realtime-runtime";
2
+ import { buildRealTimeDummyRuntimeModel as _ } from "./simulation.js";
3
+ import S from "../../node_modules/lodash-es/cloneDeep.js";
4
+ const y = [
5
+ "gnssCourse",
6
+ "gnssLatitude",
7
+ "gnssLongitude",
8
+ "gnssSpeed"
9
+ ];
4
10
  let p = null;
5
- function D() {
11
+ function k() {
6
12
  const e = globalThis;
7
13
  return e.__M4L_TEST_DUMMY_PLAYBACK_DRIVER__ || (e.__M4L_TEST_DUMMY_PLAYBACK_DRIVER__ = {
8
14
  getState() {
@@ -16,94 +22,116 @@ function D() {
16
22
  }
17
23
  }), e.__M4L_TEST_DUMMY_PLAYBACK_DRIVER__;
18
24
  }
19
- function f(e) {
20
- p = e, D();
25
+ function v(e) {
26
+ p = e, k();
21
27
  }
22
- function l(e, t) {
28
+ function u(e, t) {
23
29
  return {
24
30
  updatedAtMs: t,
25
31
  value: e
26
32
  };
27
33
  }
28
- function y(e) {
34
+ function g(e) {
29
35
  return new Date(e).toISOString();
30
36
  }
31
- function S(e, t) {
37
+ function h(e) {
38
+ return typeof e == "object" && e !== null && "value" in e;
39
+ }
40
+ function R(e, t) {
32
41
  return {
33
42
  diXByKey: Object.fromEntries(
34
43
  Object.entries(e.current.vpts?.vptDiX ?? {}).map(([s, i]) => [
35
44
  s,
36
- l(i.diXValue?.value, t)
45
+ u(i.diXValue?.value, t)
37
46
  ])
38
47
  ),
39
48
  doXByKey: Object.fromEntries(
40
49
  Object.entries(e.current.vpts?.vptDoX ?? {}).map(([s, i]) => [
41
50
  s,
42
- l(i.diXValue?.value, t)
51
+ u(i.diXValue?.value, t)
43
52
  ])
44
53
  ),
45
- ignition: l(
54
+ gnssByKey: Object.fromEntries(
55
+ y.flatMap((s) => {
56
+ const i = e.current.vpts?.vptGnss?.[s];
57
+ return h(i) ? [[
58
+ s,
59
+ u(i.value, t)
60
+ ]] : [];
61
+ })
62
+ ),
63
+ ignition: u(
46
64
  e.current.vpts?.vptIgnition?.ignitionValue?.value,
47
65
  t
48
66
  ),
49
- motionStatus: l(
67
+ motionStatus: u(
50
68
  e.current.vpts?.vptGnss?.gnssMotionStatus?.value,
51
69
  t
52
70
  ),
53
- signal: l(
71
+ signal: u(
54
72
  e.current.vpts?.vptGnss?.gnssSignal?.value,
55
73
  t
56
74
  )
57
75
  };
58
76
  }
59
- function c(e, t, s) {
60
- return e.value !== t && (e.value = t, e.updatedAtMs = s), y(e.updatedAtMs);
77
+ function l(e, t, s) {
78
+ return e.value !== t && (e.value = t, e.updatedAtMs = s), g(e.updatedAtMs);
61
79
  }
62
- function v(e, t, s) {
63
- const i = y(s);
64
- return e.reportProfiles?.trackerEvents && (e.reportProfiles.trackerEvents.modemLastEvent = {
80
+ function f(e, t, s) {
81
+ const i = g(s);
82
+ return e.reportProfiles?.trackerEvents?.modemLastEvent && (e.reportProfiles.trackerEvents.modemLastEvent = {
65
83
  ...e.reportProfiles.trackerEvents.modemLastEvent,
66
84
  date: i
67
- }), Object.entries(e.vpts?.vptDiX ?? {}).forEach(([r, n]) => {
68
- const a = t.diXByKey[r] ?? l(n.diXValue?.value, s);
69
- t.diXByKey[r] = a, n.diXStatus && (n.diXStatus.updatedAt = c(
70
- a,
71
- n.diXValue?.value,
85
+ }), Object.entries(e.vpts?.vptDiX ?? {}).forEach(([r, a]) => {
86
+ const n = t.diXByKey[r] ?? u(a.diXValue?.value, s);
87
+ t.diXByKey[r] = n, a.diXStatus && (a.diXStatus.updatedAt = l(
88
+ n,
89
+ a.diXValue?.value,
72
90
  s
73
- )), n.diXValue && (n.diXValue.updatedAt = c(
74
- a,
75
- n.diXValue.value,
91
+ )), a.diXValue && (a.diXValue.updatedAt = l(
92
+ n,
93
+ a.diXValue.value,
76
94
  s
77
95
  ));
78
- }), Object.entries(e.vpts?.vptDoX ?? {}).forEach(([r, n]) => {
79
- const a = t.doXByKey[r] ?? l(n.diXValue?.value, s);
80
- t.doXByKey[r] = a, n.diXValue && (n.diXValue.updatedAt = c(
81
- a,
82
- n.diXValue.value,
96
+ }), Object.entries(e.vpts?.vptDoX ?? {}).forEach(([r, a]) => {
97
+ const n = t.doXByKey[r] ?? u(a.diXValue?.value, s);
98
+ t.doXByKey[r] = n, a.diXValue && (a.diXValue.updatedAt = l(
99
+ n,
100
+ a.diXValue.value,
83
101
  s
84
102
  ));
85
- }), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = c(
103
+ }), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = l(
86
104
  t.motionStatus,
87
105
  e.vpts.vptGnss.gnssMotionStatus.value,
88
106
  s
89
- )), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = c(
107
+ )), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = l(
90
108
  t.signal,
91
109
  e.vpts.vptGnss.gnssSignal.value,
92
110
  s
93
- )), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = c(
111
+ )), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = l(
94
112
  t.ignition,
95
113
  e.vpts.vptIgnition.ignitionValue.value,
96
114
  s
97
- )), e.vpts?.vptModem && (e.vpts.vptModem.modemLastConnection = i, e.vpts.vptModem.modemLastEvent = i), e;
115
+ )), y.forEach((r) => {
116
+ const a = e.vpts?.vptGnss?.[r];
117
+ if (!h(a))
118
+ return;
119
+ const n = t.gnssByKey[r] ?? u(a.value, s);
120
+ t.gnssByKey[r] = n, a.updatedAt = l(
121
+ n,
122
+ a.value,
123
+ s
124
+ );
125
+ }), e.vpts?.vptModem && (e.vpts.vptModem.modemLastConnection && (e.vpts.vptModem.modemLastConnection = i), e.vpts.vptModem.modemLastEvent && (e.vpts.vptModem.modemLastEvent = i)), e;
98
126
  }
99
- function _(e, t, s) {
127
+ function I(e, t, s) {
100
128
  if (e.type === "delete")
101
129
  return e;
102
130
  if (e.type === "new") {
103
131
  const i = e.payload;
104
- return v(i.current, t, s), e;
132
+ return f(i.current, t, s), e;
105
133
  }
106
- return v(
134
+ return f(
107
135
  e.payload.current,
108
136
  t,
109
137
  s
@@ -112,49 +140,49 @@ function _(e, t, s) {
112
140
  function d(e, t) {
113
141
  return e.initialHashResources?.[t.resourceSerialId] ? t.initialMessageIndex : 0;
114
142
  }
115
- function I(e, t) {
143
+ function M(e, t) {
116
144
  return e.emissionOffsetMs <= 0 ? t : e.emissionOffsetMs;
117
145
  }
118
- function R(e, t, s, i, r) {
119
- const n = [];
120
- let a = s.get(t.resourceSerialId) ?? d(e, t);
121
- for (let u = 0; u < i; u += 1) {
122
- if (a >= t.messages.length) {
146
+ function P(e, t, s, i, r) {
147
+ const a = [];
148
+ let n = s.get(t.resourceSerialId) ?? d(e, t);
149
+ for (let o = 0; o < i; o += 1) {
150
+ if (n >= t.messages.length) {
123
151
  if (!r)
124
152
  break;
125
- a = 0;
153
+ n = 0;
126
154
  }
127
- const o = t.messages[a];
128
- if (!o)
155
+ const c = t.messages[n];
156
+ if (!c)
129
157
  break;
130
- n.push(k(o)), a += 1;
158
+ a.push(S(c)), n += 1;
131
159
  }
132
- return s.set(t.resourceSerialId, a), n;
160
+ return s.set(t.resourceSerialId, n), a;
133
161
  }
134
- function M(e, t) {
162
+ function E(e, t) {
135
163
  return e.every((s) => (t.get(s.resourceSerialId) ?? 0) >= s.messages.length);
136
164
  }
137
- function P(e, t, s, i, r, n, a) {
138
- const u = Date.now(), o = R(
165
+ function T(e, t, s, i, r, a, n) {
166
+ const o = Date.now(), c = P(
139
167
  e,
140
168
  t,
141
169
  s,
142
170
  r,
143
- n
171
+ a
144
172
  );
145
- if (o.length) {
173
+ if (c.length) {
146
174
  const m = i.get(t.resourceSerialId);
147
- a(
175
+ n(
148
176
  e.resourceTypeId,
149
- m ? o.map((h) => _(
150
- h,
177
+ m ? c.map((b) => I(
178
+ b,
151
179
  m,
152
- u
153
- )) : o
180
+ o
181
+ )) : c
154
182
  );
155
183
  }
156
184
  }
157
- class V extends g {
185
+ class x extends D {
158
186
  deviceSchedulerIds = /* @__PURE__ */ new Map();
159
187
  isPlaybackPaused = !1;
160
188
  playbackRuntime = null;
@@ -182,10 +210,10 @@ class V extends g {
182
210
  const r = i.nextMessageIndexes.get(t.resourceSerialId) ?? d(i.config, t);
183
211
  if (!i.runtime.playback.loop && r >= t.messages.length)
184
212
  return;
185
- const n = setTimeout(() => {
213
+ const a = setTimeout(() => {
186
214
  this.deviceSchedulerIds.delete(t.resourceSerialId), !(this.isPlaybackPaused || !this.playbackRuntime) && this.emitRuntimeDeviceTick(t);
187
215
  }, s);
188
- this.deviceSchedulerIds.set(t.resourceSerialId, n);
216
+ this.deviceSchedulerIds.set(t.resourceSerialId, a);
189
217
  }
190
218
  /**
191
219
  * Emit one runtime-device batch immediately and schedule the next cadence tick when needed.
@@ -193,7 +221,7 @@ class V extends g {
193
221
  emitRuntimeDeviceTick(t) {
194
222
  const s = this.playbackRuntime;
195
223
  if (s) {
196
- if (P(
224
+ if (T(
197
225
  s.config,
198
226
  t,
199
227
  s.nextMessageIndexes,
@@ -201,7 +229,7 @@ class V extends g {
201
229
  s.runtime.playback.framesPerTick,
202
230
  s.runtime.playback.loop,
203
231
  this.onMessages
204
- ), !s.runtime.playback.loop && M(
232
+ ), !s.runtime.playback.loop && E(
205
233
  s.runtime.devices,
206
234
  s.nextMessageIndexes
207
235
  )) {
@@ -243,16 +271,16 @@ class V extends g {
243
271
  */
244
272
  start() {
245
273
  this.stop();
246
- const t = this.config, s = t.wallClockStartAtMs ?? Date.now(), i = b(t.simulation, {
274
+ const t = this.config, s = t.wallClockStartAtMs ?? Date.now(), i = _(t.simulation, {
247
275
  wallClockStartAtMs: s
248
276
  }), r = new Map(
249
- i.devices.map((a) => [a.resourceSerialId, d(t, a)])
250
- ), n = new Map(
251
- i.devices.map((a) => {
252
- const u = t.initialHashResources?.[a.resourceSerialId] ?? a.initialResource;
277
+ i.devices.map((n) => [n.resourceSerialId, d(t, n)])
278
+ ), a = new Map(
279
+ i.devices.map((n) => {
280
+ const o = t.initialHashResources?.[n.resourceSerialId] ?? n.initialResource;
253
281
  return [
254
- a.resourceSerialId,
255
- S(u, s)
282
+ n.resourceSerialId,
283
+ R(o, s)
256
284
  ];
257
285
  })
258
286
  );
@@ -260,28 +288,28 @@ class V extends g {
260
288
  config: t,
261
289
  nextMessageIndexes: r,
262
290
  runtime: i,
263
- timestampStates: n
264
- }, f({
291
+ timestampStates: a
292
+ }, v({
265
293
  getState: () => this.getPlaybackDriverState(),
266
294
  pause: () => {
267
295
  this.pausePlayback();
268
296
  },
269
- resume: (a) => {
270
- this.resumePlayback(a);
297
+ resume: (n) => {
298
+ this.resumePlayback(n);
271
299
  }
272
- }), i.devices.forEach((a) => {
273
- const u = I(a, i.playback.intervalMs);
274
- this.scheduleRuntimeDeviceTick(a, u);
300
+ }), i.devices.forEach((n) => {
301
+ const o = M(n, i.playback.intervalMs);
302
+ this.scheduleRuntimeDeviceTick(n, o);
275
303
  });
276
304
  }
277
305
  /**
278
306
  * Stop the deterministic dummy playback loop.
279
307
  */
280
308
  stop() {
281
- this.clearDeviceSchedulers(), this.isPlaybackPaused = !1, this.playbackRuntime = null, p?.getState() !== "stopped" && f(null);
309
+ this.clearDeviceSchedulers(), this.isPlaybackPaused = !1, this.playbackRuntime = null, p?.getState() !== "stopped" && v(null);
282
310
  }
283
311
  }
284
312
  export {
285
- V as SourceDataDummy,
286
- V as default
313
+ x as SourceDataDummy,
314
+ x as default
287
315
  };
@@ -1 +1 @@
1
- {"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/dummy/runtime/simulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM3E,OAAO,KAAK,EAUV,6BAA6B,EAC7B,+BAA+B,EAC/B,0CAA0C,EAC3C,MAAM,iBAAiB,CAAC;AAyBzB,UAAU,gCAAgC;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA0FD,UAAU,4CAA4C;IACpD,cAAc,EAAE,sBAAsB,CAAC;IACvC,UAAU,CAAC,EAAE,6BAA6B,CAAC;CAC5C;AAED,UAAU,sDAAsD;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,sBAAsB,CAAC;IACvC,mBAAmB,CAAC,EAAE,6BAA6B,CAAC;CACrD;AAED,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,cAAc,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,gBAAgB,EAAE,wBAAwB,CAAC;CAC5C;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,QAAQ,EAAE,QAAQ,CAAC,+BAA+B,CAAC,CAAC;CACrD;AAs1CD;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,CAAC,EAAE,6BAA6B,EAC1C,OAAO,CAAC,EAAE,gCAAgC,GACzC,yBAAyB,CA+B3B;AAED;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,UAAU,CAAC,EAAE,6BAA6B,EAC1C,OAAO,CAAC,EAAE,gCAAgC,oDAgB3C;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CAAC,EACpD,cAAc,EACd,UAAU,GACX,EAAE,4CAA4C,GAAG,0CAA0C,CAY3F;AAED;;GAEG;AACH,wBAAgB,+CAA+C,CAAC,EAC9D,QAAQ,EACR,cAAc,EACd,mBAAmB,GACpB,EAAE,sDAAsD,GAAG,0CAA0C,CAQrG"}
1
+ {"version":3,"file":"simulation.d.ts","sourceRoot":"","sources":["../../../../../../packages/gclick-realtime/src/dummy/runtime/simulation.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAiB,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAM3E,OAAO,KAAK,EAUV,6BAA6B,EAC7B,+BAA+B,EAC/B,0CAA0C,EAC3C,MAAM,iBAAiB,CAAC;AAkCzB,UAAU,gCAAgC;IACxC,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AA0FD,UAAU,4CAA4C;IACpD,cAAc,EAAE,sBAAsB,CAAC;IACvC,UAAU,CAAC,EAAE,6BAA6B,CAAC;CAC5C;AAED,UAAU,sDAAsD;IAC9D,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,sBAAsB,CAAC;IACvC,mBAAmB,CAAC,EAAE,6BAA6B,CAAC;CACrD;AAED,MAAM,WAAW,0BAA0B;IACzC,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,cAAc,CAAC;IAChC,mBAAmB,EAAE,MAAM,CAAC;IAC5B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,gBAAgB,EAAE,wBAAwB,CAAC;CAC5C;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,0BAA0B,EAAE,CAAC;IACtC,QAAQ,EAAE,QAAQ,CAAC,+BAA+B,CAAC,CAAC;CACrD;AA6kDD;;GAEG;AACH,wBAAgB,8BAA8B,CAC5C,UAAU,CAAC,EAAE,6BAA6B,EAC1C,OAAO,CAAC,EAAE,gCAAgC,GACzC,yBAAyB,CA+B3B;AAED;;GAEG;AACH,wBAAgB,mCAAmC,CACjD,UAAU,CAAC,EAAE,6BAA6B,EAC1C,OAAO,CAAC,EAAE,gCAAgC,oDAgB3C;AAED;;GAEG;AACH,wBAAgB,qCAAqC,CAAC,EACpD,cAAc,EACd,UAAU,GACX,EAAE,4CAA4C,GAAG,0CAA0C,CAY3F;AAED;;GAEG;AACH,wBAAgB,+CAA+C,CAAC,EAC9D,QAAQ,EACR,cAAc,EACd,mBAAmB,GACpB,EAAE,sDAAsD,GAAG,0CAA0C,CAQrG"}