@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.
- package/contracts/deviceData.d.ts +11 -11
- package/contracts/deviceData.d.ts.map +1 -1
- package/contracts/general.d.ts +10 -1
- package/contracts/general.d.ts.map +1 -1
- package/dummy/catalogs/plans.d.ts +19 -0
- package/dummy/catalogs/plans.d.ts.map +1 -1
- package/dummy/catalogs/plans.js +45 -7
- package/dummy/catalogs/scenarios.d.ts +195 -0
- package/dummy/catalogs/scenarios.d.ts.map +1 -1
- package/dummy/catalogs/scenarios.js +151 -7
- package/dummy/index.d.ts +1 -1
- package/dummy/index.d.ts.map +1 -1
- package/dummy/runtime/dummy.d.ts.map +1 -1
- package/dummy/runtime/dummy.js +110 -82
- package/dummy/runtime/simulation.d.ts.map +1 -1
- package/dummy/runtime/simulation.js +501 -382
- package/dummy/shared/types.d.ts +45 -0
- package/dummy/shared/types.d.ts.map +1 -1
- package/fixtures/constants.d.ts +36 -0
- package/fixtures/constants.d.ts.map +1 -1
- package/fixtures/constants.js +44 -4
- package/fixtures/scenarios.d.ts +24 -0
- package/fixtures/scenarios.d.ts.map +1 -1
- package/fixtures/scenarios.js +24 -0
- package/fixtures/types.d.ts +5 -1
- package/fixtures/types.d.ts.map +1 -1
- package/fixtures/types.js +1 -1
- package/package.json +1 -1
package/dummy/runtime/dummy.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import { SourceDataBase as
|
|
2
|
-
import { buildRealTimeDummyRuntimeModel as
|
|
3
|
-
import
|
|
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
|
|
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
|
|
20
|
-
p = e,
|
|
25
|
+
function v(e) {
|
|
26
|
+
p = e, k();
|
|
21
27
|
}
|
|
22
|
-
function
|
|
28
|
+
function u(e, t) {
|
|
23
29
|
return {
|
|
24
30
|
updatedAtMs: t,
|
|
25
31
|
value: e
|
|
26
32
|
};
|
|
27
33
|
}
|
|
28
|
-
function
|
|
34
|
+
function g(e) {
|
|
29
35
|
return new Date(e).toISOString();
|
|
30
36
|
}
|
|
31
|
-
function
|
|
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
|
-
|
|
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
|
-
|
|
51
|
+
u(i.diXValue?.value, t)
|
|
43
52
|
])
|
|
44
53
|
),
|
|
45
|
-
|
|
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:
|
|
67
|
+
motionStatus: u(
|
|
50
68
|
e.current.vpts?.vptGnss?.gnssMotionStatus?.value,
|
|
51
69
|
t
|
|
52
70
|
),
|
|
53
|
-
signal:
|
|
71
|
+
signal: u(
|
|
54
72
|
e.current.vpts?.vptGnss?.gnssSignal?.value,
|
|
55
73
|
t
|
|
56
74
|
)
|
|
57
75
|
};
|
|
58
76
|
}
|
|
59
|
-
function
|
|
60
|
-
return e.value !== t && (e.value = t, e.updatedAtMs = s),
|
|
77
|
+
function l(e, t, s) {
|
|
78
|
+
return e.value !== t && (e.value = t, e.updatedAtMs = s), g(e.updatedAtMs);
|
|
61
79
|
}
|
|
62
|
-
function
|
|
63
|
-
const i =
|
|
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,
|
|
68
|
-
const
|
|
69
|
-
t.diXByKey[r] =
|
|
70
|
-
|
|
71
|
-
|
|
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
|
-
)),
|
|
74
|
-
|
|
75
|
-
|
|
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,
|
|
79
|
-
const
|
|
80
|
-
t.doXByKey[r] =
|
|
81
|
-
|
|
82
|
-
|
|
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 =
|
|
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 =
|
|
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 =
|
|
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
|
-
)),
|
|
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
|
|
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
|
|
132
|
+
return f(i.current, t, s), e;
|
|
105
133
|
}
|
|
106
|
-
return
|
|
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
|
|
143
|
+
function M(e, t) {
|
|
116
144
|
return e.emissionOffsetMs <= 0 ? t : e.emissionOffsetMs;
|
|
117
145
|
}
|
|
118
|
-
function
|
|
119
|
-
const
|
|
120
|
-
let
|
|
121
|
-
for (let
|
|
122
|
-
if (
|
|
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
|
-
|
|
153
|
+
n = 0;
|
|
126
154
|
}
|
|
127
|
-
const
|
|
128
|
-
if (!
|
|
155
|
+
const c = t.messages[n];
|
|
156
|
+
if (!c)
|
|
129
157
|
break;
|
|
130
|
-
|
|
158
|
+
a.push(S(c)), n += 1;
|
|
131
159
|
}
|
|
132
|
-
return s.set(t.resourceSerialId,
|
|
160
|
+
return s.set(t.resourceSerialId, n), a;
|
|
133
161
|
}
|
|
134
|
-
function
|
|
162
|
+
function E(e, t) {
|
|
135
163
|
return e.every((s) => (t.get(s.resourceSerialId) ?? 0) >= s.messages.length);
|
|
136
164
|
}
|
|
137
|
-
function
|
|
138
|
-
const
|
|
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
|
-
|
|
171
|
+
a
|
|
144
172
|
);
|
|
145
|
-
if (
|
|
173
|
+
if (c.length) {
|
|
146
174
|
const m = i.get(t.resourceSerialId);
|
|
147
|
-
|
|
175
|
+
n(
|
|
148
176
|
e.resourceTypeId,
|
|
149
|
-
m ?
|
|
150
|
-
|
|
177
|
+
m ? c.map((b) => I(
|
|
178
|
+
b,
|
|
151
179
|
m,
|
|
152
|
-
|
|
153
|
-
)) :
|
|
180
|
+
o
|
|
181
|
+
)) : c
|
|
154
182
|
);
|
|
155
183
|
}
|
|
156
184
|
}
|
|
157
|
-
class
|
|
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
|
|
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,
|
|
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 (
|
|
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 &&
|
|
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 =
|
|
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((
|
|
250
|
-
),
|
|
251
|
-
i.devices.map((
|
|
252
|
-
const
|
|
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
|
-
|
|
255
|
-
|
|
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:
|
|
264
|
-
},
|
|
291
|
+
timestampStates: a
|
|
292
|
+
}, v({
|
|
265
293
|
getState: () => this.getPlaybackDriverState(),
|
|
266
294
|
pause: () => {
|
|
267
295
|
this.pausePlayback();
|
|
268
296
|
},
|
|
269
|
-
resume: (
|
|
270
|
-
this.resumePlayback(
|
|
297
|
+
resume: (n) => {
|
|
298
|
+
this.resumePlayback(n);
|
|
271
299
|
}
|
|
272
|
-
}), i.devices.forEach((
|
|
273
|
-
const
|
|
274
|
-
this.scheduleRuntimeDeviceTick(
|
|
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" &&
|
|
309
|
+
this.clearDeviceSchedulers(), this.isPlaybackPaused = !1, this.playbackRuntime = null, p?.getState() !== "stopped" && v(null);
|
|
282
310
|
}
|
|
283
311
|
}
|
|
284
312
|
export {
|
|
285
|
-
|
|
286
|
-
|
|
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;
|
|
1
|
+
{"version":3,"file":"simulation.d.ts","source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