@ziztechnology/dial-library 0.0.15 → 0.0.17
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 +382 -250
- package/dist/index.d.mts +132 -3
- package/dist/index.mjs +815 -432
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -40,7 +40,7 @@ const dialSdkDebugWarn = (moduleName, scope, phase, data) => {
|
|
|
40
40
|
const message = `[DIAL_SDK_DEBUG - ${moduleName}] ${scope}: ${phase}`;
|
|
41
41
|
try {
|
|
42
42
|
if (!hasLoggedSdkVersion) {
|
|
43
|
-
console.log(`[DIAL_SDK_DEBUG] SDK version: 0.0.
|
|
43
|
+
console.log(`[DIAL_SDK_DEBUG] SDK version: 0.0.17`);
|
|
44
44
|
hasLoggedSdkVersion = true;
|
|
45
45
|
}
|
|
46
46
|
if (data === void 0) console.log(message);
|
|
@@ -49,19 +49,19 @@ const dialSdkDebugWarn = (moduleName, scope, phase, data) => {
|
|
|
49
49
|
};
|
|
50
50
|
//#endregion
|
|
51
51
|
//#region src/sensor/unified_info.ts
|
|
52
|
-
const DEBUG_MODULE$
|
|
52
|
+
const DEBUG_MODULE$6 = "unified_info.ts";
|
|
53
53
|
const unifiedSensorInfo = () => {
|
|
54
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
54
|
+
dialSdkDebugWarn(DEBUG_MODULE$6, "unifiedSensorInfo", "called");
|
|
55
55
|
try {
|
|
56
56
|
return window.unifiedSensorInfo().then((payload) => {
|
|
57
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
57
|
+
dialSdkDebugWarn(DEBUG_MODULE$6, "unifiedSensorInfo", "resolved", { payload });
|
|
58
58
|
return payload;
|
|
59
59
|
}, (error) => {
|
|
60
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
60
|
+
dialSdkDebugWarn(DEBUG_MODULE$6, "unifiedSensorInfo", "rejected", error);
|
|
61
61
|
throw error;
|
|
62
62
|
});
|
|
63
63
|
} catch (error) {
|
|
64
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
64
|
+
dialSdkDebugWarn(DEBUG_MODULE$6, "unifiedSensorInfo", "threw", error);
|
|
65
65
|
throw error;
|
|
66
66
|
}
|
|
67
67
|
};
|
|
@@ -148,8 +148,27 @@ const isRecord = (value, debug) => {
|
|
|
148
148
|
return result;
|
|
149
149
|
};
|
|
150
150
|
//#endregion
|
|
151
|
+
//#region src/driving_expression/directional_longitudinal_tuning.ts
|
|
152
|
+
const BRAKING_ENTRY_OFFSET = .3;
|
|
153
|
+
const BRAKING_EXIT_OFFSET = .15;
|
|
154
|
+
const SUDDEN_BRAKING_PEAK_OFFSET = .4;
|
|
155
|
+
const SUDDEN_BRAKING_MEAN_OFFSET = .3;
|
|
156
|
+
const resolveDirectionalLongitudinalTuning = (tuning) => ({
|
|
157
|
+
accelerationThreshold: tuning.longitudinalThreshold,
|
|
158
|
+
accelerationExitThreshold: tuning.longitudinalExitThreshold,
|
|
159
|
+
brakingThreshold: tuning.longitudinalThreshold + BRAKING_ENTRY_OFFSET,
|
|
160
|
+
brakingExitThreshold: tuning.longitudinalExitThreshold + BRAKING_EXIT_OFFSET,
|
|
161
|
+
rapidAccelerationPeakThreshold: tuning.rapidLongitudinalPeakThreshold,
|
|
162
|
+
rapidAccelerationMeanThreshold: tuning.rapidLongitudinalMeanThreshold,
|
|
163
|
+
suddenBrakingPeakThreshold: tuning.rapidLongitudinalPeakThreshold + SUDDEN_BRAKING_PEAK_OFFSET,
|
|
164
|
+
suddenBrakingMeanThreshold: tuning.rapidLongitudinalMeanThreshold + SUDDEN_BRAKING_MEAN_OFFSET,
|
|
165
|
+
normalBrakingMinimumDominance: .8,
|
|
166
|
+
suddenBrakingMinimumDominance: 1.25,
|
|
167
|
+
maximumBrakingGravityDirectionChangeRad: Math.PI / 60
|
|
168
|
+
});
|
|
169
|
+
//#endregion
|
|
151
170
|
//#region src/driving_expression/check_status.ts
|
|
152
|
-
const DEBUG_MODULE$
|
|
171
|
+
const DEBUG_MODULE$5 = "check_status.ts";
|
|
153
172
|
const DEVICE_RIGHT = {
|
|
154
173
|
x: 1,
|
|
155
174
|
y: 0,
|
|
@@ -161,7 +180,7 @@ const ZERO_VECTOR$1 = {
|
|
|
161
180
|
z: 0
|
|
162
181
|
};
|
|
163
182
|
const DEFAULT_DRIVING_STATUS_TUNING = Object.freeze({
|
|
164
|
-
version: "driving-status-calibrated-2026-07-17-
|
|
183
|
+
version: "driving-status-calibrated-2026-07-17-r3",
|
|
165
184
|
maxSampleAgeMs: 1e3,
|
|
166
185
|
gravityFilterTimeConstantMs: 1e3,
|
|
167
186
|
biasFilterTimeConstantMs: 1e4,
|
|
@@ -205,14 +224,14 @@ const DEFAULT_DRIVING_STATUS_TUNING = Object.freeze({
|
|
|
205
224
|
turnClosureWindowMs: 1500
|
|
206
225
|
});
|
|
207
226
|
const classifyDrivingSnapshot = (info, tuningOverrides) => {
|
|
208
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
227
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingSnapshot", "called", {
|
|
209
228
|
info,
|
|
210
229
|
tuningOverrides
|
|
211
230
|
});
|
|
212
231
|
const tuning = resolveDrivingStatusTuning(tuningOverrides);
|
|
213
232
|
const metrics = extractDrivingSnapshotMetrics(info, tuning);
|
|
214
233
|
if (metrics === null) {
|
|
215
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
234
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingSnapshot", "returned", { result: null });
|
|
216
235
|
return null;
|
|
217
236
|
}
|
|
218
237
|
const { candidateStatus, rejectionReason } = classifyInstantaneousEvidence(metrics, tuning);
|
|
@@ -226,11 +245,11 @@ const classifyDrivingSnapshot = (info, tuningOverrides) => {
|
|
|
226
245
|
maximumSampleAgeMs: Math.max(info.capturedAtMs - metrics.linearAccelerationSampledAtMs, info.capturedAtMs - metrics.gyroscopeSampledAtMs, info.capturedAtMs - metrics.gravitySampledAtMs)
|
|
227
246
|
}
|
|
228
247
|
};
|
|
229
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
248
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "classifyDrivingSnapshot", "returned", { result });
|
|
230
249
|
return result;
|
|
231
250
|
};
|
|
232
251
|
const resolveDrivingStatusTuning = (overrides = {}) => {
|
|
233
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
252
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "resolveDrivingStatusTuning", "called", { overrides });
|
|
234
253
|
const tuning = {
|
|
235
254
|
...DEFAULT_DRIVING_STATUS_TUNING,
|
|
236
255
|
...overrides
|
|
@@ -270,7 +289,7 @@ const resolveDrivingStatusTuning = (overrides = {}) => {
|
|
|
270
289
|
"turnExitConfirmationMs",
|
|
271
290
|
"turnClosureWindowMs"
|
|
272
291
|
]) requirePositiveFinite(field, tuning[field], {
|
|
273
|
-
moduleName: DEBUG_MODULE$
|
|
292
|
+
moduleName: DEBUG_MODULE$5,
|
|
274
293
|
scope: "assertPositiveFinite"
|
|
275
294
|
});
|
|
276
295
|
for (const field of [
|
|
@@ -295,17 +314,17 @@ const resolveDrivingStatusTuning = (overrides = {}) => {
|
|
|
295
314
|
if (tuning.rapidLongitudinalMeanThreshold <= tuning.longitudinalThreshold) throwLoggedRangeError("resolveDrivingStatusTuning", "rapidLongitudinalMeanThreshold must be greater than longitudinalThreshold");
|
|
296
315
|
if (tuning.rapidLongitudinalPeakThreshold < tuning.rapidLongitudinalMeanThreshold) throwLoggedRangeError("resolveDrivingStatusTuning", "rapidLongitudinalPeakThreshold must be greater than or equal to rapidLongitudinalMeanThreshold");
|
|
297
316
|
if (tuning.turnYawThreshold <= tuning.turnExitYawThreshold) throwLoggedRangeError("resolveDrivingStatusTuning", "turnYawThreshold must be greater than turnExitYawThreshold");
|
|
298
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
317
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "resolveDrivingStatusTuning", "returned", { tuning });
|
|
299
318
|
return tuning;
|
|
300
319
|
};
|
|
301
320
|
const extractDrivingSnapshotMetrics = (info, tuning = DEFAULT_DRIVING_STATUS_TUNING, correction = {}) => {
|
|
302
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
321
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "called", {
|
|
303
322
|
info,
|
|
304
323
|
tuning,
|
|
305
324
|
correction
|
|
306
325
|
});
|
|
307
326
|
if (!info || !Number.isFinite(info.capturedAtMs)) {
|
|
308
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
327
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned invalid capture time", { info });
|
|
309
328
|
return null;
|
|
310
329
|
}
|
|
311
330
|
const linearAcceleration = extractFreshVector(info.linearAcceleration, info.capturedAtMs, tuning.maxSampleAgeMs);
|
|
@@ -316,7 +335,7 @@ const extractDrivingSnapshotMetrics = (info, tuning = DEFAULT_DRIVING_STATUS_TUN
|
|
|
316
335
|
sampledAtMs: gravityMetric.sampledAtMs
|
|
317
336
|
} : gravityMetric);
|
|
318
337
|
if (linearAcceleration === null || gyroscope === null || gravity === null) {
|
|
319
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
338
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned unavailable vectors", {
|
|
320
339
|
linearAcceleration,
|
|
321
340
|
gyroscope,
|
|
322
341
|
gravity
|
|
@@ -325,7 +344,7 @@ const extractDrivingSnapshotMetrics = (info, tuning = DEFAULT_DRIVING_STATUS_TUN
|
|
|
325
344
|
}
|
|
326
345
|
const frame = buildVehicleFrame(gravity.value, tuning.vehicleRightMinimumNorm);
|
|
327
346
|
if (frame === null) {
|
|
328
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
347
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned invalid vehicle frame", {
|
|
329
348
|
gravity: gravity.value,
|
|
330
349
|
vehicleRightMinimumNorm: tuning.vehicleRightMinimumNorm
|
|
331
350
|
});
|
|
@@ -348,28 +367,28 @@ const extractDrivingSnapshotMetrics = (info, tuning = DEFAULT_DRIVING_STATUS_TUN
|
|
|
348
367
|
rawGyroscope: gyroscope.value,
|
|
349
368
|
frame
|
|
350
369
|
};
|
|
351
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
370
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "extractDrivingSnapshotMetrics", "returned", { result });
|
|
352
371
|
return result;
|
|
353
372
|
};
|
|
354
373
|
const buildVehicleFrame = (gravity, rightMinimumNorm = DEFAULT_DRIVING_STATUS_TUNING.vehicleRightMinimumNorm) => {
|
|
355
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
374
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "buildVehicleFrame", "called", {
|
|
356
375
|
gravity,
|
|
357
376
|
rightMinimumNorm
|
|
358
377
|
});
|
|
359
378
|
const gravityDirection = normalize(gravity);
|
|
360
379
|
if (gravityDirection === null) {
|
|
361
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
380
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "buildVehicleFrame", "returned invalid gravity", { result: null });
|
|
362
381
|
return null;
|
|
363
382
|
}
|
|
364
383
|
const up = gravityDirection;
|
|
365
384
|
const projectedRight = subtract(DEVICE_RIGHT, scale(up, dot(DEVICE_RIGHT, up)));
|
|
366
385
|
if (magnitude(projectedRight) < rightMinimumNorm) {
|
|
367
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
386
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "buildVehicleFrame", "returned degenerate right axis", { result: null });
|
|
368
387
|
return null;
|
|
369
388
|
}
|
|
370
389
|
const right = normalize(projectedRight);
|
|
371
390
|
if (right === null) {
|
|
372
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
391
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "buildVehicleFrame", "returned invalid right axis", { result: null });
|
|
373
392
|
return null;
|
|
374
393
|
}
|
|
375
394
|
const forward = normalize(cross(right, up));
|
|
@@ -378,12 +397,13 @@ const buildVehicleFrame = (gravity, rightMinimumNorm = DEFAULT_DRIVING_STATUS_TU
|
|
|
378
397
|
right,
|
|
379
398
|
forward
|
|
380
399
|
};
|
|
381
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
400
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, "buildVehicleFrame", "returned", { result });
|
|
382
401
|
return result;
|
|
383
402
|
};
|
|
384
403
|
const classifyInstantaneousEvidence = (metrics, tuning) => {
|
|
404
|
+
const directionalTuning = resolveDirectionalLongitudinalTuning(tuning);
|
|
385
405
|
const longitudinalMagnitude = Math.abs(metrics.longitudinal);
|
|
386
|
-
if (longitudinalMagnitude >=
|
|
406
|
+
if (longitudinalMagnitude >= (metrics.longitudinal < 0 ? directionalTuning.suddenBrakingPeakThreshold : directionalTuning.rapidAccelerationPeakThreshold)) {
|
|
387
407
|
if (Math.abs(metrics.vertical) > longitudinalMagnitude * tuning.verticalBumpRatio) return {
|
|
388
408
|
candidateStatus: null,
|
|
389
409
|
rejectionReason: "vertical_bump"
|
|
@@ -397,7 +417,7 @@ const classifyInstantaneousEvidence = (metrics, tuning) => {
|
|
|
397
417
|
candidateStatus: metrics.yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN",
|
|
398
418
|
rejectionReason: null
|
|
399
419
|
};
|
|
400
|
-
if (longitudinalMagnitude >=
|
|
420
|
+
if (longitudinalMagnitude >= (metrics.longitudinal < 0 ? directionalTuning.brakingThreshold : directionalTuning.accelerationThreshold)) return {
|
|
401
421
|
candidateStatus: metrics.longitudinal > 0 ? "ACCELERATION" : "BRAKING",
|
|
402
422
|
rejectionReason: null
|
|
403
423
|
};
|
|
@@ -447,7 +467,7 @@ const normalize = (value) => {
|
|
|
447
467
|
};
|
|
448
468
|
const throwLoggedRangeError = (scope, message) => {
|
|
449
469
|
const error = new RangeError(message);
|
|
450
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
470
|
+
dialSdkDebugWarn(DEBUG_MODULE$5, scope, "threw", error);
|
|
451
471
|
throw error;
|
|
452
472
|
};
|
|
453
473
|
//#endregion
|
|
@@ -483,17 +503,17 @@ const invokeSafely = (callback, args, onError) => {
|
|
|
483
503
|
};
|
|
484
504
|
//#endregion
|
|
485
505
|
//#region src/driving_expression/driving_expressions.ts
|
|
486
|
-
const DEBUG_MODULE$
|
|
506
|
+
const DEBUG_MODULE$4 = "driving_expressions.ts";
|
|
487
507
|
const IS_RECORD_DEBUG$1 = {
|
|
488
|
-
moduleName: DEBUG_MODULE$
|
|
508
|
+
moduleName: DEBUG_MODULE$4,
|
|
489
509
|
scope: "isRecord"
|
|
490
510
|
};
|
|
491
511
|
const REQUIRE_POSITIVE_FINITE_DEBUG$1 = {
|
|
492
|
-
moduleName: DEBUG_MODULE$
|
|
512
|
+
moduleName: DEBUG_MODULE$4,
|
|
493
513
|
scope: "requirePositiveFinite"
|
|
494
514
|
};
|
|
495
515
|
const CREATE_ABORT_ERROR_DEBUG$1 = {
|
|
496
|
-
moduleName: DEBUG_MODULE$
|
|
516
|
+
moduleName: DEBUG_MODULE$4,
|
|
497
517
|
scope: "createAbortError"
|
|
498
518
|
};
|
|
499
519
|
const OFFICIAL_DRIVING_EXPRESSION_FALLBACKS = Object.freeze({
|
|
@@ -536,7 +556,7 @@ const OFFICIAL_DRIVING_EXPRESSIONS_CONFIG = Object.freeze({
|
|
|
536
556
|
});
|
|
537
557
|
var DrivingExpressionsConfigError = class extends Error {
|
|
538
558
|
constructor(code, message, state) {
|
|
539
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
559
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "DrivingExpressionsConfigError.constructor", "called", {
|
|
540
560
|
code,
|
|
541
561
|
message,
|
|
542
562
|
state
|
|
@@ -545,20 +565,20 @@ var DrivingExpressionsConfigError = class extends Error {
|
|
|
545
565
|
this.name = "DrivingExpressionsConfigError";
|
|
546
566
|
this.code = code;
|
|
547
567
|
this.state = state;
|
|
548
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
568
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "DrivingExpressionsConfigError.constructor", "created", { error: this });
|
|
549
569
|
}
|
|
550
570
|
};
|
|
551
571
|
var DrivingExpressionResolutionError = class extends Error {
|
|
552
572
|
constructor(status) {
|
|
553
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
573
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "DrivingExpressionResolutionError.constructor", "called", { status });
|
|
554
574
|
super(`No driving expression is configured for ${status}`);
|
|
555
575
|
this.name = "DrivingExpressionResolutionError";
|
|
556
576
|
this.status = status;
|
|
557
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
577
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "DrivingExpressionResolutionError.constructor", "created", { error: this });
|
|
558
578
|
}
|
|
559
579
|
};
|
|
560
580
|
const parseDrivingExpressionsConfig = (raw, options = {}) => {
|
|
561
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
581
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionsConfig", "called", {
|
|
562
582
|
raw,
|
|
563
583
|
options
|
|
564
584
|
});
|
|
@@ -576,24 +596,24 @@ const parseDrivingExpressionsConfig = (raw, options = {}) => {
|
|
|
576
596
|
schemaVersion: 1,
|
|
577
597
|
states
|
|
578
598
|
};
|
|
579
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
599
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionsConfig", "returned", { result });
|
|
580
600
|
return result;
|
|
581
601
|
};
|
|
582
602
|
const tryParseDrivingExpressionsConfig = (raw, options) => {
|
|
583
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
603
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "tryParseDrivingExpressionsConfig", "called", {
|
|
584
604
|
raw,
|
|
585
605
|
options
|
|
586
606
|
});
|
|
587
607
|
try {
|
|
588
608
|
const result = parseDrivingExpressionsConfig(raw, options);
|
|
589
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
609
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "tryParseDrivingExpressionsConfig", "returned", { result });
|
|
590
610
|
return result;
|
|
591
611
|
} catch (error) {
|
|
592
612
|
if (!(error instanceof DrivingExpressionsConfigError)) {
|
|
593
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
613
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "tryParseDrivingExpressionsConfig", "threw unexpected error", error);
|
|
594
614
|
throw error;
|
|
595
615
|
}
|
|
596
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
616
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "tryParseDrivingExpressionsConfig", "returned null after parse error", error);
|
|
597
617
|
return null;
|
|
598
618
|
}
|
|
599
619
|
};
|
|
@@ -602,13 +622,13 @@ const tryParseDrivingExpressionsConfig = (raw, options) => {
|
|
|
602
622
|
* It never installs official fallbacks implicitly.
|
|
603
623
|
*/
|
|
604
624
|
const readDrivingExpressionsConfig = (raw, options) => {
|
|
605
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
625
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "readDrivingExpressionsConfig", "called", {
|
|
606
626
|
raw,
|
|
607
627
|
options
|
|
608
628
|
});
|
|
609
629
|
const source = raw === void 0 ? readRuntimeDrivingExpressionsValue() : raw;
|
|
610
630
|
const result = source === void 0 ? null : tryParseDrivingExpressionsConfig(source, options);
|
|
611
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
631
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "readDrivingExpressionsConfig", "returned", {
|
|
612
632
|
source,
|
|
613
633
|
result
|
|
614
634
|
});
|
|
@@ -619,7 +639,7 @@ const readDrivingExpressionsConfig = (raw, options) => {
|
|
|
619
639
|
* It never installs official fallbacks implicitly.
|
|
620
640
|
*/
|
|
621
641
|
const waitForDrivingExpressionsConfig = (options = {}) => {
|
|
622
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
642
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig", "called", { options });
|
|
623
643
|
const timeoutMs = requireNonNegativeFinite("timeoutMs", options.timeoutMs ?? 3e3);
|
|
624
644
|
const pollIntervalMs = requirePositiveFinite("pollIntervalMs", options.pollIntervalMs ?? 100, REQUIRE_POSITIVE_FINITE_DEBUG$1);
|
|
625
645
|
const { signal } = options;
|
|
@@ -628,7 +648,7 @@ const waitForDrivingExpressionsConfig = (options = {}) => {
|
|
|
628
648
|
let timer;
|
|
629
649
|
let settled = false;
|
|
630
650
|
const cleanup = () => {
|
|
631
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
651
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.cleanup", "called", {
|
|
632
652
|
timer,
|
|
633
653
|
settled
|
|
634
654
|
});
|
|
@@ -637,50 +657,50 @@ const waitForDrivingExpressionsConfig = (options = {}) => {
|
|
|
637
657
|
timer = void 0;
|
|
638
658
|
}
|
|
639
659
|
signal?.removeEventListener("abort", handleAbort);
|
|
640
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
660
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.cleanup", "returned");
|
|
641
661
|
};
|
|
642
662
|
const finish = (config) => {
|
|
643
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
663
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.finish", "called", {
|
|
644
664
|
config,
|
|
645
665
|
settled
|
|
646
666
|
});
|
|
647
667
|
if (settled) {
|
|
648
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
668
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.finish", "ignored");
|
|
649
669
|
return;
|
|
650
670
|
}
|
|
651
671
|
settled = true;
|
|
652
672
|
cleanup();
|
|
653
673
|
resolve(config);
|
|
654
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
674
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.finish", "resolved", { config });
|
|
655
675
|
};
|
|
656
676
|
const fail = (error) => {
|
|
657
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
677
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.fail", "called", {
|
|
658
678
|
error,
|
|
659
679
|
settled
|
|
660
680
|
});
|
|
661
681
|
if (settled) {
|
|
662
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
682
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.fail", "ignored");
|
|
663
683
|
return;
|
|
664
684
|
}
|
|
665
685
|
settled = true;
|
|
666
686
|
cleanup();
|
|
667
687
|
reject(error);
|
|
668
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
688
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.fail", "rejected", error);
|
|
669
689
|
};
|
|
670
690
|
const handleAbort = () => {
|
|
671
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
691
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.handleAbort", "called");
|
|
672
692
|
fail(createAbortError("The operation was aborted", CREATE_ABORT_ERROR_DEBUG$1));
|
|
673
693
|
};
|
|
674
694
|
const read = () => {
|
|
675
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
695
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.read", "called");
|
|
676
696
|
const result = readDrivingExpressionsConfig(void 0, options.parseOptions);
|
|
677
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
697
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.read", "returned", { result });
|
|
678
698
|
return result;
|
|
679
699
|
};
|
|
680
700
|
const poll = () => {
|
|
681
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
701
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.poll", "called", { settled });
|
|
682
702
|
if (settled) {
|
|
683
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
703
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.poll", "ignored");
|
|
684
704
|
return;
|
|
685
705
|
}
|
|
686
706
|
if (signal?.aborted) {
|
|
@@ -704,7 +724,7 @@ const waitForDrivingExpressionsConfig = (options = {}) => {
|
|
|
704
724
|
return;
|
|
705
725
|
}
|
|
706
726
|
timer = globalThis.setTimeout(poll, Math.min(pollIntervalMs, remainingMs));
|
|
707
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
727
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "waitForDrivingExpressionsConfig.poll", "scheduled", {
|
|
708
728
|
remainingMs,
|
|
709
729
|
delayMs: Math.min(pollIntervalMs, remainingMs)
|
|
710
730
|
});
|
|
@@ -716,7 +736,7 @@ const waitForDrivingExpressionsConfig = (options = {}) => {
|
|
|
716
736
|
/** Original resolver behavior: missing legacy slots fall back to STEADY_DRIVING. */
|
|
717
737
|
const resolveDrivingExpression = (config, status) => {
|
|
718
738
|
const result = config.states[status] ?? config.states.STEADY_DRIVING;
|
|
719
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
739
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "resolveDrivingExpression", "returned", {
|
|
720
740
|
config,
|
|
721
741
|
status,
|
|
722
742
|
result
|
|
@@ -725,55 +745,55 @@ const resolveDrivingExpression = (config, status) => {
|
|
|
725
745
|
};
|
|
726
746
|
/** Strict resolver used by the player; official fallbacks are opt-in. */
|
|
727
747
|
const resolveDrivingExpressionStrict = (config, status, fallbacks) => {
|
|
728
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
748
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "resolveDrivingExpressionStrict", "called", {
|
|
729
749
|
config,
|
|
730
750
|
status,
|
|
731
751
|
fallbacks
|
|
732
752
|
});
|
|
733
753
|
const configured = config.states[status];
|
|
734
754
|
if (configured !== void 0) {
|
|
735
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
755
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "resolveDrivingExpressionStrict", "returned configured media", { configured });
|
|
736
756
|
return configured;
|
|
737
757
|
}
|
|
738
758
|
const fallback = fallbacks?.[status];
|
|
739
759
|
if (fallback !== void 0) {
|
|
740
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
760
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "resolveDrivingExpressionStrict", "returned fallback media", { fallback });
|
|
741
761
|
return fallback;
|
|
742
762
|
}
|
|
743
763
|
const error = new DrivingExpressionResolutionError(status);
|
|
744
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
764
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "resolveDrivingExpressionStrict", "threw", error);
|
|
745
765
|
throw error;
|
|
746
766
|
};
|
|
747
767
|
const isPublicDrivingMediaUrl = (value) => {
|
|
748
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
768
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicDrivingMediaUrl", "called", { value });
|
|
749
769
|
try {
|
|
750
770
|
const url = new URL(value);
|
|
751
771
|
if (url.protocol !== "https:" || url.username !== "" || url.password !== "") {
|
|
752
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
772
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicDrivingMediaUrl", "returned", {
|
|
753
773
|
result: false,
|
|
754
774
|
reason: "protocol_or_auth"
|
|
755
775
|
});
|
|
756
776
|
return false;
|
|
757
777
|
}
|
|
758
778
|
if (!isPublicHostname(url.hostname)) {
|
|
759
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
779
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicDrivingMediaUrl", "returned", {
|
|
760
780
|
result: false,
|
|
761
781
|
reason: "hostname"
|
|
762
782
|
});
|
|
763
783
|
return false;
|
|
764
784
|
}
|
|
765
785
|
for (const key of url.searchParams.keys()) if (TEMPORARY_SIGNATURE_QUERY_KEYS.has(key.toLowerCase())) {
|
|
766
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
786
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicDrivingMediaUrl", "returned", {
|
|
767
787
|
result: false,
|
|
768
788
|
reason: "temporary_signature",
|
|
769
789
|
key
|
|
770
790
|
});
|
|
771
791
|
return false;
|
|
772
792
|
}
|
|
773
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
793
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicDrivingMediaUrl", "returned", { result: true });
|
|
774
794
|
return true;
|
|
775
795
|
} catch (error) {
|
|
776
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
796
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicDrivingMediaUrl", "returned after URL parse error", {
|
|
777
797
|
result: false,
|
|
778
798
|
error
|
|
779
799
|
});
|
|
@@ -781,10 +801,10 @@ const isPublicDrivingMediaUrl = (value) => {
|
|
|
781
801
|
}
|
|
782
802
|
};
|
|
783
803
|
const isPublicHostname = (rawHostname) => {
|
|
784
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
804
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicHostname", "called", { rawHostname });
|
|
785
805
|
const hostname = rawHostname.toLowerCase().replace(/^\[|\]$/gu, "").replace(/\.+$/gu, "");
|
|
786
806
|
if (hostname === "") {
|
|
787
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
807
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicHostname", "returned", {
|
|
788
808
|
result: false,
|
|
789
809
|
hostname
|
|
790
810
|
});
|
|
@@ -793,7 +813,7 @@ const isPublicHostname = (rawHostname) => {
|
|
|
793
813
|
const ipv4 = parseIpv4(hostname);
|
|
794
814
|
if (ipv4 !== null) {
|
|
795
815
|
const result = !isRestrictedIpv4(ipv4);
|
|
796
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
816
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicHostname", "returned IPv4 result", {
|
|
797
817
|
hostname,
|
|
798
818
|
ipv4,
|
|
799
819
|
result
|
|
@@ -803,7 +823,7 @@ const isPublicHostname = (rawHostname) => {
|
|
|
803
823
|
const ipv6 = parseIpv6(hostname);
|
|
804
824
|
if (ipv6 !== null) {
|
|
805
825
|
const result = !isRestrictedIpv6(ipv6);
|
|
806
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
826
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicHostname", "returned IPv6 result", {
|
|
807
827
|
hostname,
|
|
808
828
|
ipv6,
|
|
809
829
|
result
|
|
@@ -811,14 +831,14 @@ const isPublicHostname = (rawHostname) => {
|
|
|
811
831
|
return result;
|
|
812
832
|
}
|
|
813
833
|
if (!hostname.includes(".")) {
|
|
814
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
834
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicHostname", "returned", {
|
|
815
835
|
hostname,
|
|
816
836
|
result: false
|
|
817
837
|
});
|
|
818
838
|
return false;
|
|
819
839
|
}
|
|
820
840
|
const result = !INTERNAL_HOST_SUFFIXES.some((suffix) => hostname === suffix || hostname.endsWith(`.${suffix}`));
|
|
821
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
841
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isPublicHostname", "returned DNS result", {
|
|
822
842
|
hostname,
|
|
823
843
|
result
|
|
824
844
|
});
|
|
@@ -837,37 +857,37 @@ const INTERNAL_HOST_SUFFIXES = [
|
|
|
837
857
|
"private"
|
|
838
858
|
];
|
|
839
859
|
const parseIpv4 = (hostname) => {
|
|
840
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
860
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv4", "called", { hostname });
|
|
841
861
|
const parts = hostname.split(".");
|
|
842
862
|
if (parts.length !== 4 || parts.some((part) => !/^\d{1,3}$/u.test(part))) {
|
|
843
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
863
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv4", "returned", { result: null });
|
|
844
864
|
return null;
|
|
845
865
|
}
|
|
846
866
|
const octets = parts.map(Number);
|
|
847
867
|
if (octets.some((octet) => octet > 255)) {
|
|
848
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
868
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv4", "returned", {
|
|
849
869
|
result: null,
|
|
850
870
|
octets
|
|
851
871
|
});
|
|
852
872
|
return null;
|
|
853
873
|
}
|
|
854
874
|
const result = octets;
|
|
855
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
875
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv4", "returned", { result });
|
|
856
876
|
return result;
|
|
857
877
|
};
|
|
858
878
|
const isRestrictedIpv4 = (value) => {
|
|
859
879
|
const [a, b, c] = value;
|
|
860
880
|
const result = a === 0 || a === 10 || a === 127 || a === 100 && b >= 64 && b <= 127 || a === 169 && b === 254 || a === 172 && b >= 16 && b <= 31 || a === 192 && b === 0 && c === 0 || a === 192 && b === 0 && c === 2 || a === 192 && b === 31 && c === 196 || a === 192 && b === 52 && c === 193 || a === 192 && b === 88 && c === 99 || a === 192 && b === 168 || a === 192 && b === 175 && c === 48 || a === 198 && (b === 18 || b === 19) || a === 198 && b === 51 && c === 100 || a === 203 && b === 0 && c === 113 || a >= 224;
|
|
861
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
881
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isRestrictedIpv4", "returned", {
|
|
862
882
|
value,
|
|
863
883
|
result
|
|
864
884
|
});
|
|
865
885
|
return result;
|
|
866
886
|
};
|
|
867
887
|
const parseIpv6 = (hostname) => {
|
|
868
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
888
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "called", { hostname });
|
|
869
889
|
if (!hostname.includes(":")) {
|
|
870
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
890
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned", { result: null });
|
|
871
891
|
return null;
|
|
872
892
|
}
|
|
873
893
|
let normalized = hostname;
|
|
@@ -875,14 +895,14 @@ const parseIpv6 = (hostname) => {
|
|
|
875
895
|
const lastColon = normalized.lastIndexOf(":");
|
|
876
896
|
const ipv4 = parseIpv4(normalized.slice(lastColon + 1));
|
|
877
897
|
if (ipv4 === null) {
|
|
878
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
898
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned invalid embedded IPv4", { result: null });
|
|
879
899
|
return null;
|
|
880
900
|
}
|
|
881
901
|
normalized = `${normalized.slice(0, lastColon)}:${(ipv4[0] << 8 | ipv4[1]).toString(16)}:${(ipv4[2] << 8 | ipv4[3]).toString(16)}`;
|
|
882
902
|
}
|
|
883
903
|
const halves = normalized.split("::");
|
|
884
904
|
if (halves.length > 2) {
|
|
885
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
905
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned invalid halves", {
|
|
886
906
|
result: null,
|
|
887
907
|
halves
|
|
888
908
|
});
|
|
@@ -891,7 +911,7 @@ const parseIpv6 = (hostname) => {
|
|
|
891
911
|
const left = halves[0] === "" ? [] : halves[0].split(":");
|
|
892
912
|
const right = halves.length === 1 || halves[1] === "" ? [] : halves[1].split(":");
|
|
893
913
|
if ([...left, ...right].some((part) => !/^[\da-f]{1,4}$/u.test(part))) {
|
|
894
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
914
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned invalid group", {
|
|
895
915
|
result: null,
|
|
896
916
|
left,
|
|
897
917
|
right
|
|
@@ -900,7 +920,7 @@ const parseIpv6 = (hostname) => {
|
|
|
900
920
|
}
|
|
901
921
|
const omitted = 8 - left.length - right.length;
|
|
902
922
|
if (halves.length === 1 && omitted !== 0 || halves.length === 2 && omitted < 1) {
|
|
903
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
923
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned invalid omission", {
|
|
904
924
|
result: null,
|
|
905
925
|
omitted
|
|
906
926
|
});
|
|
@@ -912,7 +932,7 @@ const parseIpv6 = (hostname) => {
|
|
|
912
932
|
...right
|
|
913
933
|
].map((part) => Number.parseInt(part, 16));
|
|
914
934
|
if (groups.length !== 8) {
|
|
915
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
935
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned invalid group count", {
|
|
916
936
|
result: null,
|
|
917
937
|
groups
|
|
918
938
|
});
|
|
@@ -923,21 +943,21 @@ const parseIpv6 = (hostname) => {
|
|
|
923
943
|
bytes[index * 2] = group >>> 8;
|
|
924
944
|
bytes[index * 2 + 1] = group & 255;
|
|
925
945
|
});
|
|
926
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
946
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseIpv6", "returned", { result: bytes });
|
|
927
947
|
return bytes;
|
|
928
948
|
};
|
|
929
949
|
const isRestrictedIpv6 = (bytes) => {
|
|
930
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
950
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isRestrictedIpv6", "called", { bytes });
|
|
931
951
|
const allZeroPrefix = (length) => {
|
|
932
952
|
const result = bytes.subarray(0, length).every((value) => value === 0);
|
|
933
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
953
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isRestrictedIpv6.allZeroPrefix", "returned", {
|
|
934
954
|
length,
|
|
935
955
|
result
|
|
936
956
|
});
|
|
937
957
|
return result;
|
|
938
958
|
};
|
|
939
959
|
const result = bytes.every((value) => value === 0) || allZeroPrefix(15) && bytes[15] === 1 || allZeroPrefix(12) || allZeroPrefix(10) && bytes[10] === 255 && bytes[11] === 255 || bytes[0] === 0 && bytes[1] === 100 && bytes[2] === 255 && bytes[3] === 155 || (bytes[0] & 254) === 252 || bytes[0] === 254 && (bytes[1] & 192) === 128 || bytes[0] === 255 || bytes[0] === 1 && bytes.subarray(1, 8).every((value) => value === 0) || bytes[0] === 32 && bytes[1] === 1 && bytes[2] === 13 && bytes[3] === 184 || bytes[0] === 32 && bytes[1] === 1 && bytes[2] <= 1 || bytes[0] === 32 && bytes[1] === 2 || bytes[0] === 63 && bytes[1] === 254;
|
|
940
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
960
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isRestrictedIpv6", "returned", { result });
|
|
941
961
|
return result;
|
|
942
962
|
};
|
|
943
963
|
const TEMPORARY_SIGNATURE_QUERY_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -974,7 +994,7 @@ const TEMPORARY_SIGNATURE_QUERY_KEYS = /* @__PURE__ */ new Set([
|
|
|
974
994
|
"x-oss-signature"
|
|
975
995
|
]);
|
|
976
996
|
const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
977
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
997
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "called", {
|
|
978
998
|
raw,
|
|
979
999
|
status,
|
|
980
1000
|
options
|
|
@@ -985,7 +1005,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
|
985
1005
|
kind: "image",
|
|
986
1006
|
url: raw
|
|
987
1007
|
};
|
|
988
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1008
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "returned legacy image", { result });
|
|
989
1009
|
return result;
|
|
990
1010
|
}
|
|
991
1011
|
if (!isRecord(raw, IS_RECORD_DEBUG$1) || typeof raw.kind !== "string") throw invalidMedia(status, "media must be a structured object with a supported kind");
|
|
@@ -1009,7 +1029,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
|
1009
1029
|
kind: "emoji",
|
|
1010
1030
|
text: raw.text.trim()
|
|
1011
1031
|
};
|
|
1012
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1032
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "returned emoji", { result });
|
|
1013
1033
|
return result;
|
|
1014
1034
|
}
|
|
1015
1035
|
case "image": {
|
|
@@ -1026,7 +1046,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
|
1026
1046
|
url,
|
|
1027
1047
|
mimeType
|
|
1028
1048
|
});
|
|
1029
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1049
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "returned image", { result });
|
|
1030
1050
|
return result;
|
|
1031
1051
|
}
|
|
1032
1052
|
case "video": {
|
|
@@ -1041,7 +1061,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
|
1041
1061
|
coverUrl,
|
|
1042
1062
|
mimeType
|
|
1043
1063
|
});
|
|
1044
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1064
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "returned video", { result });
|
|
1045
1065
|
return result;
|
|
1046
1066
|
}
|
|
1047
1067
|
case "live_photo": {
|
|
@@ -1058,7 +1078,7 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
|
1058
1078
|
coverUrl,
|
|
1059
1079
|
motionUrl
|
|
1060
1080
|
});
|
|
1061
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1081
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "returned live photo", { result });
|
|
1062
1082
|
return result;
|
|
1063
1083
|
}
|
|
1064
1084
|
case "tgs": {
|
|
@@ -1075,20 +1095,20 @@ const parseDrivingExpressionMedia = (raw, status, options) => {
|
|
|
1075
1095
|
url,
|
|
1076
1096
|
coverUrl
|
|
1077
1097
|
});
|
|
1078
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1098
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseDrivingExpressionMedia", "returned TGS", { result });
|
|
1079
1099
|
return result;
|
|
1080
1100
|
}
|
|
1081
1101
|
default: throw invalidMedia(status, `unsupported media kind: ${raw.kind}`);
|
|
1082
1102
|
}
|
|
1083
1103
|
};
|
|
1084
1104
|
const parseJsonObject = (raw) => {
|
|
1085
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1105
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseJsonObject", "called", { raw });
|
|
1086
1106
|
let value = raw;
|
|
1087
1107
|
if (typeof value === "string") try {
|
|
1088
1108
|
value = JSON.parse(value);
|
|
1089
1109
|
} catch (cause) {
|
|
1090
1110
|
const error = new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions is not valid JSON");
|
|
1091
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1111
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseJsonObject", "threw", {
|
|
1092
1112
|
error,
|
|
1093
1113
|
cause
|
|
1094
1114
|
});
|
|
@@ -1096,34 +1116,34 @@ const parseJsonObject = (raw) => {
|
|
|
1096
1116
|
}
|
|
1097
1117
|
if (!isRecord(value, IS_RECORD_DEBUG$1)) {
|
|
1098
1118
|
const error = new DrivingExpressionsConfigError("DRIVING_EXPRESSIONS_INVALID_SCHEMA", "drivingExpressions must be a JSON object or JSON object string");
|
|
1099
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1119
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseJsonObject", "threw", error);
|
|
1100
1120
|
throw error;
|
|
1101
1121
|
}
|
|
1102
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1122
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseJsonObject", "returned", { value });
|
|
1103
1123
|
return value;
|
|
1104
1124
|
};
|
|
1105
1125
|
const readRuntimeDrivingExpressionsValue = () => {
|
|
1106
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1126
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "readRuntimeDrivingExpressionsValue", "called");
|
|
1107
1127
|
const result = globalThis.__TOOOONY_DRIVING_EXPRESSIONS__;
|
|
1108
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1128
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "readRuntimeDrivingExpressionsValue", "returned typed injection", { result });
|
|
1109
1129
|
return result;
|
|
1110
1130
|
};
|
|
1111
1131
|
const parseMediaAssetId = (raw, status) => {
|
|
1112
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1132
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseMediaAssetId", "called", {
|
|
1113
1133
|
raw,
|
|
1114
1134
|
status
|
|
1115
1135
|
});
|
|
1116
1136
|
if (raw === void 0) {
|
|
1117
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1137
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseMediaAssetId", "returned", { result: void 0 });
|
|
1118
1138
|
return;
|
|
1119
1139
|
}
|
|
1120
1140
|
if (!Number.isSafeInteger(raw) || raw <= 0) throw invalidMedia(status, "mediaAssetId must be a positive safe integer when present");
|
|
1121
1141
|
const result = raw;
|
|
1122
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1142
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseMediaAssetId", "returned", { result });
|
|
1123
1143
|
return result;
|
|
1124
1144
|
};
|
|
1125
1145
|
const assertFieldsAbsent = (value, status, fields) => {
|
|
1126
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1146
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "assertFieldsAbsent", "called", {
|
|
1127
1147
|
value,
|
|
1128
1148
|
status,
|
|
1129
1149
|
fields
|
|
@@ -1131,72 +1151,72 @@ const assertFieldsAbsent = (value, status, fields) => {
|
|
|
1131
1151
|
const present = fields.find((field) => Object.prototype.hasOwnProperty.call(value, field));
|
|
1132
1152
|
if (present !== void 0) {
|
|
1133
1153
|
const error = invalidMedia(status, `${present} is not allowed for this media kind`);
|
|
1134
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1154
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "assertFieldsAbsent", "threw", error);
|
|
1135
1155
|
throw error;
|
|
1136
1156
|
}
|
|
1137
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1157
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "assertFieldsAbsent", "returned");
|
|
1138
1158
|
};
|
|
1139
1159
|
const parseRequiredUrl = (raw, status, field) => {
|
|
1140
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1160
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseRequiredUrl", "called", {
|
|
1141
1161
|
raw,
|
|
1142
1162
|
status,
|
|
1143
1163
|
field
|
|
1144
1164
|
});
|
|
1145
1165
|
if (typeof raw !== "string" || raw.length === 0) {
|
|
1146
1166
|
const error = invalidMedia(status, `${field} is required`);
|
|
1147
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1167
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseRequiredUrl", "threw", error);
|
|
1148
1168
|
throw error;
|
|
1149
1169
|
}
|
|
1150
1170
|
assertPublicUrl(raw, status, field);
|
|
1151
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1171
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseRequiredUrl", "returned", { result: raw });
|
|
1152
1172
|
return raw;
|
|
1153
1173
|
};
|
|
1154
1174
|
const parseOptionalUrl = (raw, status, field) => {
|
|
1155
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1175
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseOptionalUrl", "called", {
|
|
1156
1176
|
raw,
|
|
1157
1177
|
status,
|
|
1158
1178
|
field
|
|
1159
1179
|
});
|
|
1160
1180
|
if (raw === void 0) {
|
|
1161
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1181
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseOptionalUrl", "returned", { result: void 0 });
|
|
1162
1182
|
return;
|
|
1163
1183
|
}
|
|
1164
1184
|
const result = parseRequiredUrl(raw, status, field);
|
|
1165
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1185
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseOptionalUrl", "returned", { result });
|
|
1166
1186
|
return result;
|
|
1167
1187
|
};
|
|
1168
1188
|
const parseOptionalString = (raw, status, field) => {
|
|
1169
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1189
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseOptionalString", "called", {
|
|
1170
1190
|
raw,
|
|
1171
1191
|
status,
|
|
1172
1192
|
field
|
|
1173
1193
|
});
|
|
1174
1194
|
if (raw === void 0) {
|
|
1175
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1195
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseOptionalString", "returned", { result: void 0 });
|
|
1176
1196
|
return;
|
|
1177
1197
|
}
|
|
1178
1198
|
if (typeof raw !== "string" || raw.trim() === "" || raw.length > 255) throw invalidMedia(status, `${field} must be a non-empty string of at most 255 characters`);
|
|
1179
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1199
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "parseOptionalString", "returned", { result: raw });
|
|
1180
1200
|
return raw;
|
|
1181
1201
|
};
|
|
1182
1202
|
const assertPublicUrl = (value, status, field) => {
|
|
1183
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1203
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "assertPublicUrl", "called", {
|
|
1184
1204
|
value,
|
|
1185
1205
|
status,
|
|
1186
1206
|
field
|
|
1187
1207
|
});
|
|
1188
1208
|
if (!isPublicDrivingMediaUrl(value)) {
|
|
1189
1209
|
const error = new DrivingExpressionsConfigError("MEDIA_URL_NOT_PUBLIC_HTTPS", `${status}.${field} must be a long-lived public HTTPS URL`, status);
|
|
1190
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1210
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "assertPublicUrl", "threw", error);
|
|
1191
1211
|
throw error;
|
|
1192
1212
|
}
|
|
1193
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1213
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "assertPublicUrl", "returned");
|
|
1194
1214
|
};
|
|
1195
1215
|
const isOneVisibleGrapheme = (value) => {
|
|
1196
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1216
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isOneVisibleGrapheme", "called", { value });
|
|
1197
1217
|
const trimmed = value.trim();
|
|
1198
1218
|
if (trimmed === "" || trimmed.length > 32) {
|
|
1199
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1219
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isOneVisibleGrapheme", "returned", {
|
|
1200
1220
|
result: false,
|
|
1201
1221
|
trimmed
|
|
1202
1222
|
});
|
|
@@ -1205,7 +1225,7 @@ const isOneVisibleGrapheme = (value) => {
|
|
|
1205
1225
|
const Segmenter = Intl.Segmenter;
|
|
1206
1226
|
const graphemes = Segmenter ? Array.from(new Segmenter(void 0, { granularity: "grapheme" }).segment(trimmed)) : Array.from(trimmed);
|
|
1207
1227
|
const result = graphemes.length === 1;
|
|
1208
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1228
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "isOneVisibleGrapheme", "returned", {
|
|
1209
1229
|
graphemes,
|
|
1210
1230
|
result
|
|
1211
1231
|
});
|
|
@@ -1213,7 +1233,7 @@ const isOneVisibleGrapheme = (value) => {
|
|
|
1213
1233
|
};
|
|
1214
1234
|
const invalidMedia = (status, detail) => {
|
|
1215
1235
|
const result = new DrivingExpressionsConfigError("DRIVING_EXPRESSION_INVALID_MEDIA", `Invalid driving expression for ${status}: ${detail}`, status);
|
|
1216
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1236
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "invalidMedia", "returned", {
|
|
1217
1237
|
status,
|
|
1218
1238
|
detail,
|
|
1219
1239
|
result
|
|
@@ -1221,27 +1241,27 @@ const invalidMedia = (status, detail) => {
|
|
|
1221
1241
|
return result;
|
|
1222
1242
|
};
|
|
1223
1243
|
const compact = (value) => {
|
|
1224
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1244
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "compact", "called", { value });
|
|
1225
1245
|
for (const key of Object.keys(value)) if (value[key] === void 0) delete value[key];
|
|
1226
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1246
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "compact", "returned", { result: value });
|
|
1227
1247
|
return value;
|
|
1228
1248
|
};
|
|
1229
1249
|
const requireNonNegativeFinite = (name, value) => {
|
|
1230
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1250
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "requireNonNegativeFinite", "called", {
|
|
1231
1251
|
name,
|
|
1232
1252
|
value
|
|
1233
1253
|
});
|
|
1234
1254
|
if (!Number.isFinite(value) || value < 0) {
|
|
1235
1255
|
const error = /* @__PURE__ */ new RangeError(`${name} must be a non-negative finite number`);
|
|
1236
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1256
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "requireNonNegativeFinite", "threw", error);
|
|
1237
1257
|
throw error;
|
|
1238
1258
|
}
|
|
1239
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1259
|
+
dialSdkDebugWarn(DEBUG_MODULE$4, "requireNonNegativeFinite", "returned", { result: value });
|
|
1240
1260
|
return value;
|
|
1241
1261
|
};
|
|
1242
1262
|
//#endregion
|
|
1243
1263
|
//#region src/driving_expression/page_lifecycle.ts
|
|
1244
|
-
const DEBUG_MODULE$
|
|
1264
|
+
const DEBUG_MODULE$3 = "page_lifecycle.ts";
|
|
1245
1265
|
const subscribers = /* @__PURE__ */ new Set();
|
|
1246
1266
|
let installedWindow = null;
|
|
1247
1267
|
let installedDocument = null;
|
|
@@ -1252,7 +1272,7 @@ let hadOwnResumeHook = false;
|
|
|
1252
1272
|
let pauseHook = null;
|
|
1253
1273
|
let resumeHook = null;
|
|
1254
1274
|
const subscribeDrivingPageLifecycle = (pause, resume) => {
|
|
1255
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1275
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "subscribeDrivingPageLifecycle", "called", { subscriberCount: subscribers.size });
|
|
1256
1276
|
const subscriber = {
|
|
1257
1277
|
pause,
|
|
1258
1278
|
resume
|
|
@@ -1261,29 +1281,29 @@ const subscribeDrivingPageLifecycle = (pause, resume) => {
|
|
|
1261
1281
|
if (subscribers.size === 1) installLifecycleHooks();
|
|
1262
1282
|
if (isDrivingPageHidden()) safeInvoke(pause);
|
|
1263
1283
|
let subscribed = true;
|
|
1264
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1284
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "subscribeDrivingPageLifecycle", "subscribed", { subscriberCount: subscribers.size });
|
|
1265
1285
|
return () => {
|
|
1266
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1286
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "subscribeDrivingPageLifecycle.unsubscribe", "called", { subscribed });
|
|
1267
1287
|
if (!subscribed) {
|
|
1268
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1288
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "subscribeDrivingPageLifecycle.unsubscribe", "ignored");
|
|
1269
1289
|
return;
|
|
1270
1290
|
}
|
|
1271
1291
|
subscribed = false;
|
|
1272
1292
|
subscribers.delete(subscriber);
|
|
1273
1293
|
if (subscribers.size === 0) uninstallLifecycleHooks();
|
|
1274
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1294
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "subscribeDrivingPageLifecycle.unsubscribe", "returned", { subscriberCount: subscribers.size });
|
|
1275
1295
|
};
|
|
1276
1296
|
};
|
|
1277
1297
|
const isDrivingPageHidden = () => {
|
|
1278
1298
|
const result = typeof document !== "undefined" && document.visibilityState === "hidden";
|
|
1279
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1299
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "isDrivingPageHidden", "returned", {
|
|
1280
1300
|
visibilityState: typeof document === "undefined" ? void 0 : document.visibilityState,
|
|
1281
1301
|
result
|
|
1282
1302
|
});
|
|
1283
1303
|
return result;
|
|
1284
1304
|
};
|
|
1285
1305
|
const installLifecycleHooks = () => {
|
|
1286
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1306
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "installLifecycleHooks", "called");
|
|
1287
1307
|
installedDocument = typeof document === "undefined" ? null : document;
|
|
1288
1308
|
installedWindow = typeof window === "undefined" ? null : window;
|
|
1289
1309
|
installedDocument?.addEventListener("visibilitychange", handleVisibilityChange);
|
|
@@ -1294,7 +1314,7 @@ const installLifecycleHooks = () => {
|
|
|
1294
1314
|
installedWindow?.addEventListener("toooony-device-sensors-release", dispatchPause);
|
|
1295
1315
|
installedWindow?.addEventListener("toooony-device-sensors-resume", dispatchResume);
|
|
1296
1316
|
if (!installedWindow) {
|
|
1297
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1317
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "installLifecycleHooks", "returned without window");
|
|
1298
1318
|
return;
|
|
1299
1319
|
}
|
|
1300
1320
|
hadOwnPauseHook = Object.prototype.hasOwnProperty.call(installedWindow, "__watchFaceRuntimePause");
|
|
@@ -1302,20 +1322,20 @@ const installLifecycleHooks = () => {
|
|
|
1302
1322
|
previousPauseHook = installedWindow.__watchFaceRuntimePause;
|
|
1303
1323
|
previousResumeHook = installedWindow.__watchFaceRuntimeResume;
|
|
1304
1324
|
pauseHook = function(...args) {
|
|
1305
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1325
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "runtimePauseHook", "called", { args });
|
|
1306
1326
|
try {
|
|
1307
1327
|
const result = typeof previousPauseHook === "function" ? previousPauseHook.apply(this, args) : void 0;
|
|
1308
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1328
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "runtimePauseHook", "returned", { result });
|
|
1309
1329
|
return result;
|
|
1310
1330
|
} finally {
|
|
1311
1331
|
dispatchPause();
|
|
1312
1332
|
}
|
|
1313
1333
|
};
|
|
1314
1334
|
resumeHook = function(...args) {
|
|
1315
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1335
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "runtimeResumeHook", "called", { args });
|
|
1316
1336
|
try {
|
|
1317
1337
|
const result = typeof previousResumeHook === "function" ? previousResumeHook.apply(this, args) : void 0;
|
|
1318
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1338
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "runtimeResumeHook", "returned", { result });
|
|
1319
1339
|
return result;
|
|
1320
1340
|
} finally {
|
|
1321
1341
|
dispatchResume();
|
|
@@ -1323,13 +1343,13 @@ const installLifecycleHooks = () => {
|
|
|
1323
1343
|
};
|
|
1324
1344
|
installedWindow.__watchFaceRuntimePause = pauseHook;
|
|
1325
1345
|
installedWindow.__watchFaceRuntimeResume = resumeHook;
|
|
1326
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1346
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "installLifecycleHooks", "returned", {
|
|
1327
1347
|
hadOwnPauseHook,
|
|
1328
1348
|
hadOwnResumeHook
|
|
1329
1349
|
});
|
|
1330
1350
|
};
|
|
1331
1351
|
const uninstallLifecycleHooks = () => {
|
|
1332
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1352
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "uninstallLifecycleHooks", "called");
|
|
1333
1353
|
installedDocument?.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
1334
1354
|
installedWindow?.removeEventListener("pagehide", dispatchPause);
|
|
1335
1355
|
installedWindow?.removeEventListener("freeze", dispatchPause);
|
|
@@ -1349,54 +1369,54 @@ const uninstallLifecycleHooks = () => {
|
|
|
1349
1369
|
hadOwnResumeHook = false;
|
|
1350
1370
|
pauseHook = null;
|
|
1351
1371
|
resumeHook = null;
|
|
1352
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1372
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "uninstallLifecycleHooks", "returned");
|
|
1353
1373
|
};
|
|
1354
1374
|
const handleVisibilityChange = () => {
|
|
1355
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1375
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "handleVisibilityChange", "called");
|
|
1356
1376
|
if (isDrivingPageHidden()) dispatchPause();
|
|
1357
1377
|
else dispatchResume();
|
|
1358
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1378
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "handleVisibilityChange", "returned");
|
|
1359
1379
|
};
|
|
1360
1380
|
const dispatchPause = () => {
|
|
1361
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1381
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "dispatchPause", "called", { subscriberCount: subscribers.size });
|
|
1362
1382
|
for (const subscriber of [...subscribers]) safeInvoke(subscriber.pause);
|
|
1363
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1383
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "dispatchPause", "returned");
|
|
1364
1384
|
};
|
|
1365
1385
|
const dispatchResume = () => {
|
|
1366
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1386
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "dispatchResume", "called", { subscriberCount: subscribers.size });
|
|
1367
1387
|
if (isDrivingPageHidden()) {
|
|
1368
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1388
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "dispatchResume", "ignored while hidden");
|
|
1369
1389
|
return;
|
|
1370
1390
|
}
|
|
1371
1391
|
for (const subscriber of [...subscribers]) safeInvoke(subscriber.resume);
|
|
1372
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1392
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "dispatchResume", "returned");
|
|
1373
1393
|
};
|
|
1374
1394
|
const safeInvoke = (callback) => {
|
|
1375
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1395
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "safeInvoke", "called");
|
|
1376
1396
|
if (invokeSafely(callback, [], (error) => {
|
|
1377
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1378
|
-
})) dialSdkDebugWarn(DEBUG_MODULE$
|
|
1397
|
+
dialSdkDebugWarn(DEBUG_MODULE$3, "safeInvoke", "callback threw", error);
|
|
1398
|
+
})) dialSdkDebugWarn(DEBUG_MODULE$3, "safeInvoke", "returned");
|
|
1379
1399
|
};
|
|
1380
1400
|
//#endregion
|
|
1381
1401
|
//#region src/driving_expression/driving_status_controller.ts
|
|
1382
|
-
const DEBUG_MODULE$
|
|
1402
|
+
const DEBUG_MODULE$2 = "driving_status_controller.ts";
|
|
1383
1403
|
const ZERO_VECTOR = {
|
|
1384
1404
|
x: 0,
|
|
1385
1405
|
y: 0,
|
|
1386
1406
|
z: 0
|
|
1387
1407
|
};
|
|
1388
1408
|
const REQUIRE_POSITIVE_FINITE_DEBUG = {
|
|
1389
|
-
moduleName: DEBUG_MODULE$
|
|
1409
|
+
moduleName: DEBUG_MODULE$2,
|
|
1390
1410
|
scope: "requirePositiveFinite"
|
|
1391
1411
|
};
|
|
1392
1412
|
const createDrivingStatusController = (options = {}) => {
|
|
1393
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1394
|
-
const result = new
|
|
1395
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1413
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "createDrivingStatusController", "called", { options });
|
|
1414
|
+
const result = new DrivingStatusController(options);
|
|
1415
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "createDrivingStatusController", "returned", { snapshot: result.getSnapshot() });
|
|
1396
1416
|
return result;
|
|
1397
1417
|
};
|
|
1398
|
-
var
|
|
1399
|
-
constructor(options) {
|
|
1418
|
+
var DrivingStatusController = class {
|
|
1419
|
+
constructor(options = {}) {
|
|
1400
1420
|
this.listeners = /* @__PURE__ */ new Set();
|
|
1401
1421
|
this.longitudinalWindow = [];
|
|
1402
1422
|
this.yawWindow = [];
|
|
@@ -1407,6 +1427,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1407
1427
|
this.unavailableSinceMs = null;
|
|
1408
1428
|
this.fallbackApplied = false;
|
|
1409
1429
|
this.filteredGravity = null;
|
|
1430
|
+
this.rawGravity = null;
|
|
1410
1431
|
this.lastGravitySampledAtMs = null;
|
|
1411
1432
|
this.linearAccelerationBias = { ...ZERO_VECTOR };
|
|
1412
1433
|
this.gyroscopeBias = { ...ZERO_VECTOR };
|
|
@@ -1442,9 +1463,9 @@ var DefaultDrivingStatusController = class {
|
|
|
1442
1463
|
this.pendingRead = null;
|
|
1443
1464
|
this.unsubscribePageLifecycle = null;
|
|
1444
1465
|
this.handleLifecyclePause = () => {
|
|
1445
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1466
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.handleLifecyclePause", "called");
|
|
1446
1467
|
if (!this.requestedRunning || this.lifecycleSuspended) {
|
|
1447
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1468
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.handleLifecyclePause", "ignored", {
|
|
1448
1469
|
requestedRunning: this.requestedRunning,
|
|
1449
1470
|
lifecycleSuspended: this.lifecycleSuspended
|
|
1450
1471
|
});
|
|
@@ -1453,13 +1474,13 @@ var DefaultDrivingStatusController = class {
|
|
|
1453
1474
|
this.lifecycleSuspended = true;
|
|
1454
1475
|
this.deactivatePolling();
|
|
1455
1476
|
this.resetTransientRecognition();
|
|
1456
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1477
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.handleLifecyclePause", "returned");
|
|
1457
1478
|
};
|
|
1458
1479
|
this.handleLifecycleResume = () => {
|
|
1459
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1480
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.handleLifecycleResume", "called");
|
|
1460
1481
|
const pageHidden = this.requestedRunning && this.lifecycleSuspended && !this.destroyed ? isDrivingPageHidden() : false;
|
|
1461
1482
|
if (!this.requestedRunning || !this.lifecycleSuspended || this.destroyed || pageHidden) {
|
|
1462
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1483
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.handleLifecycleResume", "ignored", {
|
|
1463
1484
|
requestedRunning: this.requestedRunning,
|
|
1464
1485
|
lifecycleSuspended: this.lifecycleSuspended,
|
|
1465
1486
|
destroyed: this.destroyed,
|
|
@@ -1469,31 +1490,33 @@ var DefaultDrivingStatusController = class {
|
|
|
1469
1490
|
}
|
|
1470
1491
|
this.lifecycleSuspended = false;
|
|
1471
1492
|
this.activatePolling();
|
|
1472
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1493
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.handleLifecycleResume", "returned");
|
|
1473
1494
|
};
|
|
1474
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1495
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.constructor", "called", { options });
|
|
1475
1496
|
this.sensorProvider = options.sensorProvider ?? unifiedSensorInfo;
|
|
1476
1497
|
this.pollIntervalMs = requirePositiveFinite("pollIntervalMs", options.pollIntervalMs ?? 200, REQUIRE_POSITIVE_FINITE_DEBUG);
|
|
1477
1498
|
this.unavailableFallbackMs = requirePositiveFinite("unavailableFallbackMs", options.unavailableFallbackMs ?? 3e3, REQUIRE_POSITIVE_FINITE_DEBUG);
|
|
1478
1499
|
this.tuning = resolveDrivingStatusTuning(options.tuning);
|
|
1500
|
+
this.directionalLongitudinalTuning = resolveDirectionalLongitudinalTuning(this.tuning);
|
|
1479
1501
|
this.clock = options.clock ?? systemClock;
|
|
1480
1502
|
this.onDiagnostic = options.onDiagnostic;
|
|
1481
1503
|
this.managePageLifecycle = options.managePageLifecycle ?? true;
|
|
1482
1504
|
const initialStatus = options.initialStatus ?? "STOPPED";
|
|
1483
1505
|
if (!CAR_RUNNING_STATUSES.includes(initialStatus)) {
|
|
1484
1506
|
const error = /* @__PURE__ */ new TypeError(`Unsupported initialStatus: ${initialStatus}`);
|
|
1485
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1507
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.constructor", "threw", error);
|
|
1486
1508
|
throw error;
|
|
1487
1509
|
}
|
|
1488
1510
|
this.status = initialStatus;
|
|
1489
1511
|
this.baseStatus = isBaseStatus(initialStatus) ? initialStatus : "STOPPED";
|
|
1490
1512
|
this.statusCommittedAtMs = this.clock.now();
|
|
1491
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1513
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.constructor", "resolved directional longitudinal tuning", this.directionalLongitudinalTuning);
|
|
1514
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.constructor", "created", this.getSnapshot());
|
|
1492
1515
|
}
|
|
1493
1516
|
start() {
|
|
1494
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1517
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.start", "called", this.getSnapshot());
|
|
1495
1518
|
if (this.destroyed || this.requestedRunning) {
|
|
1496
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1519
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.start", "ignored", {
|
|
1497
1520
|
destroyed: this.destroyed,
|
|
1498
1521
|
requestedRunning: this.requestedRunning
|
|
1499
1522
|
});
|
|
@@ -1502,12 +1525,12 @@ var DefaultDrivingStatusController = class {
|
|
|
1502
1525
|
this.requestedRunning = true;
|
|
1503
1526
|
this.attachLifecycleListeners();
|
|
1504
1527
|
if (!this.lifecycleSuspended) this.activatePolling();
|
|
1505
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1528
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.start", "returned", this.getSnapshot());
|
|
1506
1529
|
}
|
|
1507
1530
|
stop() {
|
|
1508
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1531
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.stop", "called", this.getSnapshot());
|
|
1509
1532
|
if (this.destroyed || !this.requestedRunning) {
|
|
1510
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1533
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.stop", "ignored", {
|
|
1511
1534
|
destroyed: this.destroyed,
|
|
1512
1535
|
requestedRunning: this.requestedRunning
|
|
1513
1536
|
});
|
|
@@ -1518,12 +1541,12 @@ var DefaultDrivingStatusController = class {
|
|
|
1518
1541
|
this.detachLifecycleListeners();
|
|
1519
1542
|
this.deactivatePolling();
|
|
1520
1543
|
this.resetTransientRecognition();
|
|
1521
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1544
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.stop", "returned", this.getSnapshot());
|
|
1522
1545
|
}
|
|
1523
1546
|
destroy() {
|
|
1524
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1547
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.destroy", "called", this.getSnapshot());
|
|
1525
1548
|
if (this.destroyed) {
|
|
1526
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1549
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.destroy", "ignored");
|
|
1527
1550
|
return;
|
|
1528
1551
|
}
|
|
1529
1552
|
if (this.requestedRunning) this.stop();
|
|
@@ -1534,7 +1557,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1534
1557
|
this.destroyed = true;
|
|
1535
1558
|
this.listeners.clear();
|
|
1536
1559
|
this.resetTransientRecognition();
|
|
1537
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1560
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.destroy", "returned", this.getSnapshot());
|
|
1538
1561
|
}
|
|
1539
1562
|
getSnapshot() {
|
|
1540
1563
|
const result = {
|
|
@@ -1549,36 +1572,36 @@ var DefaultDrivingStatusController = class {
|
|
|
1549
1572
|
unavailableSinceMs: this.unavailableSinceMs,
|
|
1550
1573
|
tuningVersion: this.tuning.version
|
|
1551
1574
|
};
|
|
1552
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1575
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.getSnapshot", "returned", { result });
|
|
1553
1576
|
return result;
|
|
1554
1577
|
}
|
|
1555
1578
|
subscribe(listener) {
|
|
1556
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1579
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.subscribe", "called", {
|
|
1557
1580
|
listener,
|
|
1558
1581
|
destroyed: this.destroyed
|
|
1559
1582
|
});
|
|
1560
1583
|
if (this.destroyed) {
|
|
1561
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1584
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.subscribe", "ignored destroyed controller");
|
|
1562
1585
|
return noop;
|
|
1563
1586
|
}
|
|
1564
1587
|
this.listeners.add(listener);
|
|
1565
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1588
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.subscribe", "returned", { listenerCount: this.listeners.size });
|
|
1566
1589
|
let subscribed = true;
|
|
1567
1590
|
return () => {
|
|
1568
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1591
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.unsubscribe", "called", { subscribed });
|
|
1569
1592
|
if (!subscribed) {
|
|
1570
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1593
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.unsubscribe", "ignored");
|
|
1571
1594
|
return;
|
|
1572
1595
|
}
|
|
1573
1596
|
subscribed = false;
|
|
1574
1597
|
this.listeners.delete(listener);
|
|
1575
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1598
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.unsubscribe", "returned", { listenerCount: this.listeners.size });
|
|
1576
1599
|
};
|
|
1577
1600
|
}
|
|
1578
1601
|
activatePolling() {
|
|
1579
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1602
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.activatePolling", "called");
|
|
1580
1603
|
if (this.destroyed || this.polling || !this.requestedRunning || this.lifecycleSuspended) {
|
|
1581
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1604
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.activatePolling", "ignored", {
|
|
1582
1605
|
destroyed: this.destroyed,
|
|
1583
1606
|
polling: this.polling,
|
|
1584
1607
|
requestedRunning: this.requestedRunning,
|
|
@@ -1589,10 +1612,10 @@ var DefaultDrivingStatusController = class {
|
|
|
1589
1612
|
this.polling = true;
|
|
1590
1613
|
this.generation += 1;
|
|
1591
1614
|
this.schedulePoll(0, this.generation);
|
|
1592
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1615
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.activatePolling", "returned", { generation: this.generation });
|
|
1593
1616
|
}
|
|
1594
1617
|
deactivatePolling() {
|
|
1595
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1618
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.deactivatePolling", "called", {
|
|
1596
1619
|
generation: this.generation,
|
|
1597
1620
|
hasTimer: this.timer !== void 0,
|
|
1598
1621
|
hasPendingRead: this.pendingRead !== null
|
|
@@ -1605,7 +1628,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1605
1628
|
}
|
|
1606
1629
|
this.pendingRead?.abort();
|
|
1607
1630
|
this.pendingRead = null;
|
|
1608
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1631
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.deactivatePolling", "returned", { generation: this.generation });
|
|
1609
1632
|
}
|
|
1610
1633
|
schedulePoll(delayMs, generation) {
|
|
1611
1634
|
if (!this.polling || generation !== this.generation || this.timer !== void 0) return;
|
|
@@ -1616,9 +1639,9 @@ var DefaultDrivingStatusController = class {
|
|
|
1616
1639
|
}
|
|
1617
1640
|
async poll(generation) {
|
|
1618
1641
|
const pollStartedAtMs = this.clock.now();
|
|
1619
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1642
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "called", { generation });
|
|
1620
1643
|
if (!this.polling || generation !== this.generation || this.pendingRead !== null) {
|
|
1621
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1644
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "ignored", {
|
|
1622
1645
|
polling: this.polling,
|
|
1623
1646
|
generation,
|
|
1624
1647
|
currentGeneration: this.generation,
|
|
@@ -1631,7 +1654,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1631
1654
|
try {
|
|
1632
1655
|
const payload = await this.sensorProvider(pendingRead.signal);
|
|
1633
1656
|
if (!this.polling || generation !== this.generation || pendingRead.signal.aborted) {
|
|
1634
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1657
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "discarded provider result", {
|
|
1635
1658
|
generation,
|
|
1636
1659
|
currentGeneration: this.generation,
|
|
1637
1660
|
polling: this.polling,
|
|
@@ -1648,21 +1671,21 @@ var DefaultDrivingStatusController = class {
|
|
|
1648
1671
|
});
|
|
1649
1672
|
const accelerometerSample = extractFreshVector(payload.accelerometer, payload.capturedAtMs, this.tuning.maxSampleAgeMs);
|
|
1650
1673
|
if (gravity === null || metrics === null || accelerometerSample === null) {
|
|
1651
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1674
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "invalid or stale snapshot", {
|
|
1652
1675
|
metrics,
|
|
1653
1676
|
accelerometerSample
|
|
1654
1677
|
});
|
|
1655
1678
|
this.processUnavailable("invalid_or_stale_snapshot");
|
|
1656
1679
|
} else {
|
|
1657
1680
|
this.processAvailable(metrics, accelerometerSample, gravity);
|
|
1658
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1681
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "processed sample", { capturedAtMs: metrics.capturedAtMs });
|
|
1659
1682
|
}
|
|
1660
1683
|
} catch (error) {
|
|
1661
1684
|
if (!this.polling || generation !== this.generation || pendingRead.signal.aborted || isAbortError(error)) {
|
|
1662
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1685
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "ignored provider error", { error });
|
|
1663
1686
|
return;
|
|
1664
1687
|
}
|
|
1665
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1688
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "caught provider error", { error });
|
|
1666
1689
|
this.processUnavailable("provider_error");
|
|
1667
1690
|
} finally {
|
|
1668
1691
|
if (this.pendingRead === pendingRead) this.pendingRead = null;
|
|
@@ -1670,7 +1693,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1670
1693
|
const elapsedMs = Math.max(0, this.clock.now() - pollStartedAtMs);
|
|
1671
1694
|
this.schedulePoll(Math.max(0, this.pollIntervalMs - elapsedMs), generation);
|
|
1672
1695
|
}
|
|
1673
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1696
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.poll", "completed", {
|
|
1674
1697
|
generation,
|
|
1675
1698
|
polling: this.polling
|
|
1676
1699
|
});
|
|
@@ -1679,42 +1702,50 @@ var DefaultDrivingStatusController = class {
|
|
|
1679
1702
|
resolveGravityFrame(info) {
|
|
1680
1703
|
const sample = extractFreshVector(info.gravity, info.capturedAtMs, this.tuning.maxSampleAgeMs);
|
|
1681
1704
|
if (sample === null) {
|
|
1682
|
-
if (this.filteredGravity === null || this.lastGravitySampledAtMs === null) return null;
|
|
1705
|
+
if (this.filteredGravity === null || this.rawGravity === null || this.lastGravitySampledAtMs === null) return null;
|
|
1683
1706
|
const ageMs = info.capturedAtMs - this.lastGravitySampledAtMs;
|
|
1684
1707
|
return ageMs >= 0 && ageMs <= this.tuning.maxSampleAgeMs ? {
|
|
1685
1708
|
value: this.filteredGravity,
|
|
1686
1709
|
sampledAtMs: this.lastGravitySampledAtMs,
|
|
1687
|
-
source: "cached"
|
|
1710
|
+
source: "cached",
|
|
1711
|
+
rawValue: this.rawGravity
|
|
1688
1712
|
} : null;
|
|
1689
1713
|
}
|
|
1690
|
-
if (sample.sampledAtMs === this.lastGravitySampledAtMs && this.filteredGravity !== null)
|
|
1691
|
-
value
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1714
|
+
if (sample.sampledAtMs === this.lastGravitySampledAtMs && this.filteredGravity !== null) {
|
|
1715
|
+
this.rawGravity = { ...sample.value };
|
|
1716
|
+
return {
|
|
1717
|
+
value: this.filteredGravity,
|
|
1718
|
+
sampledAtMs: sample.sampledAtMs,
|
|
1719
|
+
source: "live",
|
|
1720
|
+
rawValue: this.rawGravity
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1695
1723
|
if (this.filteredGravity === null || this.lastGravitySampledAtMs === null) this.filteredGravity = { ...sample.value };
|
|
1696
1724
|
else {
|
|
1697
1725
|
if (sample.sampledAtMs < this.lastGravitySampledAtMs) {
|
|
1698
1726
|
const ageMs = info.capturedAtMs - this.lastGravitySampledAtMs;
|
|
1699
|
-
return ageMs >= 0 && ageMs <= this.tuning.maxSampleAgeMs ? {
|
|
1727
|
+
return ageMs >= 0 && ageMs <= this.tuning.maxSampleAgeMs && this.rawGravity !== null ? {
|
|
1700
1728
|
value: this.filteredGravity,
|
|
1701
1729
|
sampledAtMs: this.lastGravitySampledAtMs,
|
|
1702
|
-
source: "cached"
|
|
1730
|
+
source: "cached",
|
|
1731
|
+
rawValue: this.rawGravity
|
|
1703
1732
|
} : null;
|
|
1704
1733
|
}
|
|
1705
1734
|
const elapsedMs = Math.max(0, sample.sampledAtMs - this.lastGravitySampledAtMs);
|
|
1706
1735
|
const alpha = 1 - Math.exp(-elapsedMs / this.tuning.gravityFilterTimeConstantMs);
|
|
1707
1736
|
this.filteredGravity = lerpVector(this.filteredGravity, sample.value, alpha);
|
|
1708
1737
|
}
|
|
1738
|
+
this.rawGravity = { ...sample.value };
|
|
1709
1739
|
this.lastGravitySampledAtMs = sample.sampledAtMs;
|
|
1710
1740
|
return {
|
|
1711
1741
|
value: this.filteredGravity,
|
|
1712
1742
|
sampledAtMs: sample.sampledAtMs,
|
|
1713
|
-
source: "live"
|
|
1743
|
+
source: "live",
|
|
1744
|
+
rawValue: this.rawGravity
|
|
1714
1745
|
};
|
|
1715
1746
|
}
|
|
1716
1747
|
processAvailable(metrics, accelerometerSample, gravity) {
|
|
1717
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1748
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processAvailable", "called", {
|
|
1718
1749
|
metrics,
|
|
1719
1750
|
accelerometerSample
|
|
1720
1751
|
});
|
|
@@ -1731,12 +1762,15 @@ var DefaultDrivingStatusController = class {
|
|
|
1731
1762
|
tuningVersion: this.tuning.version
|
|
1732
1763
|
});
|
|
1733
1764
|
const longitudinalRetentionMs = Math.max(recognitionRetentionMs(this.tuning.longitudinalWindowMs, this.tuning.longitudinalMinimumSamples), recognitionRetentionMs(this.tuning.rapidLongitudinalWindowMs, this.tuning.rapidLongitudinalMinimumSamples));
|
|
1734
|
-
const addedLongitudinal =
|
|
1765
|
+
const addedLongitudinal = pushUniqueLongitudinalObservation(this.longitudinalWindow, {
|
|
1766
|
+
metrics,
|
|
1767
|
+
rawGravity: gravity.rawValue
|
|
1768
|
+
}, longitudinalRetentionMs);
|
|
1735
1769
|
const yawRetentionMs = Math.max(this.tuning.turnWindowMs, this.tuning.turnClosureWindowMs, recognitionRetentionMs(this.tuning.turnConfirmationMs, this.tuning.turnMinimumSamples));
|
|
1736
1770
|
const addedYaw = pushUniqueMetric(this.yawWindow, metrics, "gyroscopeSampledAtMs", yawRetentionMs);
|
|
1737
1771
|
const addedMotion = pushUniqueVector(this.motionWindow, accelerometerSample, recognitionRetentionMs(this.tuning.motionWindowMs, this.tuning.motionMinimumSamples));
|
|
1738
1772
|
if (!addedLongitudinal && !addedYaw && !addedMotion) {
|
|
1739
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1773
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processAvailable", "ignored duplicate sample");
|
|
1740
1774
|
return;
|
|
1741
1775
|
}
|
|
1742
1776
|
const motionCoverageWindow = selectCoverageWindow(this.motionWindow, this.tuning.motionMinimumSamples, this.tuning.motionWindowMs, (sample) => sample.sampledAtMs);
|
|
@@ -1747,7 +1781,11 @@ var DefaultDrivingStatusController = class {
|
|
|
1747
1781
|
const previousLongitudinalStatus = this.normalLongitudinalStatus;
|
|
1748
1782
|
const previousTurnStatus = this.turnStatus;
|
|
1749
1783
|
const baseCondition = this.updateBaseDetector(motionMad, metrics, accelerometerSample.sampledAtMs, addedMotion, motionCoverageWindow?.[0]?.sampledAtMs ?? accelerometerSample.sampledAtMs);
|
|
1750
|
-
const longitudinalEvidence = detectLongitudinalEvidence(this.longitudinalWindow, this.tuning);
|
|
1784
|
+
const longitudinalEvidence = detectLongitudinalEvidence(this.longitudinalWindow, this.tuning, this.directionalLongitudinalTuning);
|
|
1785
|
+
if (longitudinalEvidence.brakingQualityRejection !== null || longitudinalEvidence.suddenBrakingQualityRejection !== null) dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processAvailable", "rejected braking quality", {
|
|
1786
|
+
braking: longitudinalEvidence.brakingQualityRejection,
|
|
1787
|
+
suddenBraking: longitudinalEvidence.suddenBrakingQualityRejection
|
|
1788
|
+
});
|
|
1751
1789
|
if (addedLongitudinal) this.updateLongitudinalDetector(longitudinalEvidence, metrics.linearAccelerationSampledAtMs);
|
|
1752
1790
|
const turnEvidence = detectTurnEvidence(this.yawWindow, this.tuning);
|
|
1753
1791
|
if (addedYaw) this.updateTurnDetector(turnEvidence);
|
|
@@ -1778,7 +1816,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1778
1816
|
this.emitDetectorConfirmation("rapid_longitudinal", previousUrgentStatus, this.urgentStatus, statistics, now);
|
|
1779
1817
|
this.emitDetectorConfirmation("longitudinal", previousLongitudinalStatus, this.normalLongitudinalStatus, statistics, now);
|
|
1780
1818
|
this.emitDetectorConfirmation("turn", previousTurnStatus, this.turnStatus, statistics, now);
|
|
1781
|
-
const pendingCandidate = instantaneousCandidate(metrics, this.tuning);
|
|
1819
|
+
const pendingCandidate = instantaneousCandidate(metrics, this.tuning, this.directionalLongitudinalTuning);
|
|
1782
1820
|
this.setCandidate(pendingCandidate === this.status ? null : pendingCandidate, observationTime(metrics));
|
|
1783
1821
|
this.emitDiagnostic({
|
|
1784
1822
|
type: "detector_evidence",
|
|
@@ -1796,7 +1834,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1796
1834
|
});
|
|
1797
1835
|
const hasAction = this.urgentStatus !== null || this.turnStatus !== null || this.normalLongitudinalStatus !== null;
|
|
1798
1836
|
if (motionMad !== null || hasAction) this.commitSelectedStatus(now);
|
|
1799
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1837
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processAvailable", "returned", {
|
|
1800
1838
|
motionMad,
|
|
1801
1839
|
baseCondition,
|
|
1802
1840
|
status: this.status,
|
|
@@ -1845,7 +1883,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1845
1883
|
if (evidence.normalCandidate !== null) {
|
|
1846
1884
|
this.normalLongitudinalStatus = evidence.normalCandidate;
|
|
1847
1885
|
this.longitudinalClearSinceMs = null;
|
|
1848
|
-
} else if (this.normalLongitudinalStatus !== null) if (evidence.
|
|
1886
|
+
} else if (this.normalLongitudinalStatus !== null) if (this.normalLongitudinalStatus === "BRAKING" ? evidence.retainedBraking : evidence.retainedAcceleration) this.longitudinalClearSinceMs = null;
|
|
1849
1887
|
else {
|
|
1850
1888
|
if (this.longitudinalClearSinceMs === null) this.longitudinalClearSinceMs = sampledAtMs;
|
|
1851
1889
|
if (sampledAtMs - this.longitudinalClearSinceMs >= this.tuning.longitudinalReleaseMs) {
|
|
@@ -1937,7 +1975,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1937
1975
|
this.commit(selected, now, "candidate_confirmed");
|
|
1938
1976
|
}
|
|
1939
1977
|
processUnavailable(category) {
|
|
1940
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1978
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processUnavailable", "called", { category });
|
|
1941
1979
|
const now = this.clock.now();
|
|
1942
1980
|
if (this.unavailableSinceMs === null) this.unavailableSinceMs = now;
|
|
1943
1981
|
const unavailableForMs = Math.max(0, now - this.unavailableSinceMs);
|
|
@@ -1950,7 +1988,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1950
1988
|
tuningVersion: this.tuning.version
|
|
1951
1989
|
});
|
|
1952
1990
|
if (unavailableForMs < this.unavailableFallbackMs || this.fallbackApplied) {
|
|
1953
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
1991
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processUnavailable", "holding previous status", {
|
|
1954
1992
|
category,
|
|
1955
1993
|
unavailableForMs,
|
|
1956
1994
|
fallbackApplied: this.fallbackApplied
|
|
@@ -1967,14 +2005,14 @@ var DefaultDrivingStatusController = class {
|
|
|
1967
2005
|
tuningVersion: this.tuning.version
|
|
1968
2006
|
});
|
|
1969
2007
|
this.commit("STOPPED", now, "unavailable_fallback");
|
|
1970
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2008
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.processUnavailable", "returned fallback", {
|
|
1971
2009
|
unavailableForMs,
|
|
1972
2010
|
status: this.status
|
|
1973
2011
|
});
|
|
1974
2012
|
}
|
|
1975
2013
|
commit(nextStatus, now, reason) {
|
|
1976
2014
|
if (nextStatus === this.status) {
|
|
1977
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2015
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.commit", "ignored unchanged status", {
|
|
1978
2016
|
status: this.status,
|
|
1979
2017
|
reason
|
|
1980
2018
|
});
|
|
@@ -1992,7 +2030,7 @@ var DefaultDrivingStatusController = class {
|
|
|
1992
2030
|
atMs: now
|
|
1993
2031
|
};
|
|
1994
2032
|
for (const listener of [...this.listeners]) invokeSafely(listener, [event], (error) => {
|
|
1995
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2033
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "safeCall", "callback threw", {
|
|
1996
2034
|
error,
|
|
1997
2035
|
value: event
|
|
1998
2036
|
});
|
|
@@ -2005,7 +2043,7 @@ var DefaultDrivingStatusController = class {
|
|
|
2005
2043
|
reason,
|
|
2006
2044
|
tuningVersion: this.tuning.version
|
|
2007
2045
|
});
|
|
2008
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2046
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.commit", "status changed", { event });
|
|
2009
2047
|
}
|
|
2010
2048
|
setCandidate(candidate, atMs) {
|
|
2011
2049
|
if (candidate === this.candidate) return;
|
|
@@ -2019,7 +2057,7 @@ var DefaultDrivingStatusController = class {
|
|
|
2019
2057
|
previousCandidate,
|
|
2020
2058
|
tuningVersion: this.tuning.version
|
|
2021
2059
|
});
|
|
2022
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2060
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.setCandidate", "candidate changed", {
|
|
2023
2061
|
candidate,
|
|
2024
2062
|
previousCandidate,
|
|
2025
2063
|
candidateSinceMs: this.candidateSinceMs
|
|
@@ -2051,15 +2089,16 @@ var DefaultDrivingStatusController = class {
|
|
|
2051
2089
|
this.unavailableSinceMs = null;
|
|
2052
2090
|
this.fallbackApplied = false;
|
|
2053
2091
|
this.filteredGravity = null;
|
|
2092
|
+
this.rawGravity = null;
|
|
2054
2093
|
this.lastGravitySampledAtMs = null;
|
|
2055
2094
|
}
|
|
2056
2095
|
emitDiagnostic(event) {
|
|
2057
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2096
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "DrivingStatusController.emitDiagnostic", "called", {
|
|
2058
2097
|
event,
|
|
2059
2098
|
hasListener: this.onDiagnostic !== void 0
|
|
2060
2099
|
});
|
|
2061
2100
|
if (this.onDiagnostic) invokeSafely(this.onDiagnostic, [event], (error) => {
|
|
2062
|
-
dialSdkDebugWarn(DEBUG_MODULE$
|
|
2101
|
+
dialSdkDebugWarn(DEBUG_MODULE$2, "safeCall", "callback threw", {
|
|
2063
2102
|
error,
|
|
2064
2103
|
value: event
|
|
2065
2104
|
});
|
|
@@ -2074,27 +2113,31 @@ var DefaultDrivingStatusController = class {
|
|
|
2074
2113
|
this.unsubscribePageLifecycle = null;
|
|
2075
2114
|
}
|
|
2076
2115
|
};
|
|
2077
|
-
const detectLongitudinalEvidence = (window, tuning) => {
|
|
2078
|
-
const recentRapidWindow =
|
|
2079
|
-
const rapidCoverageWindow = selectCoverageWindow(window, tuning.rapidLongitudinalMinimumSamples, tuning.rapidLongitudinalWindowMs, (sample) => sample.linearAccelerationSampledAtMs);
|
|
2116
|
+
const detectLongitudinalEvidence = (window, tuning, directionalTuning) => {
|
|
2117
|
+
const recentRapidWindow = recentLongitudinalObservations(window, tuning.rapidLongitudinalWindowMs);
|
|
2118
|
+
const rapidCoverageWindow = selectCoverageWindow(window, tuning.rapidLongitudinalMinimumSamples, tuning.rapidLongitudinalWindowMs, (sample) => sample.metrics.linearAccelerationSampledAtMs);
|
|
2080
2119
|
const rapidWindow = rapidCoverageWindow ?? recentRapidWindow;
|
|
2081
|
-
const recentNormalWindow =
|
|
2082
|
-
const normalCoverageWindow = selectCoverageWindow(window, tuning.longitudinalMinimumSamples, tuning.longitudinalWindowMs, (sample) => sample.linearAccelerationSampledAtMs);
|
|
2120
|
+
const recentNormalWindow = recentLongitudinalObservations(window, tuning.longitudinalWindowMs);
|
|
2121
|
+
const normalCoverageWindow = selectCoverageWindow(window, tuning.longitudinalMinimumSamples, tuning.longitudinalWindowMs, (sample) => sample.metrics.linearAccelerationSampledAtMs);
|
|
2083
2122
|
const normalWindow = normalCoverageWindow ?? recentNormalWindow;
|
|
2084
2123
|
let rapidCandidate = null;
|
|
2085
2124
|
let rejectionReason = null;
|
|
2086
|
-
|
|
2125
|
+
let suddenBrakingQualityRejection = null;
|
|
2126
|
+
const rapidMetrics = rapidWindow.map((sample) => sample.metrics);
|
|
2127
|
+
const rapidValues = rapidMetrics.map((sample) => sample.longitudinal);
|
|
2087
2128
|
const rapidMean = trimmedMean(rapidValues);
|
|
2088
2129
|
const rapidDirection = Math.sign(rapidMean);
|
|
2089
|
-
const
|
|
2130
|
+
const rapidDeadband = rapidDirection < 0 ? directionalTuning.brakingExitThreshold : directionalTuning.accelerationExitThreshold;
|
|
2131
|
+
const rapidCoherence = signCoherence(rapidValues, rapidDirection, rapidDeadband);
|
|
2090
2132
|
const rapidPeak = maximumAbsolute(rapidValues);
|
|
2091
2133
|
const longitudinalRms = rootMeanSquare(rapidValues);
|
|
2092
|
-
const verticalRms = rootMeanSquare(
|
|
2093
|
-
const reversalWindow =
|
|
2094
|
-
const hasReversal = containsBothSigns(reversalWindow.map((sample) => sample.longitudinal), tuning.longitudinalThreshold);
|
|
2134
|
+
const verticalRms = rootMeanSquare(rapidMetrics.map((sample) => sample.vertical));
|
|
2135
|
+
const reversalWindow = recentLongitudinalObservations(window, tuning.longitudinalReversalWindowMs);
|
|
2136
|
+
const hasReversal = containsBothSigns(reversalWindow.map((sample) => sample.metrics.longitudinal), tuning.longitudinalThreshold);
|
|
2137
|
+
const rapidBrakingQuality = brakingQualityRejection(rapidWindow, directionalTuning.suddenBrakingMinimumDominance, directionalTuning.maximumBrakingGravityDirectionChangeRad);
|
|
2095
2138
|
const rapidStatistics = rapidWindow.length === 0 ? null : {
|
|
2096
2139
|
sampleCount: rapidWindow.length,
|
|
2097
|
-
durationMs: metricWindowDuration(
|
|
2140
|
+
durationMs: metricWindowDuration(rapidMetrics, "linearAccelerationSampledAtMs"),
|
|
2098
2141
|
mean: rapidMean,
|
|
2099
2142
|
peak: rapidPeak,
|
|
2100
2143
|
coherence: rapidCoherence,
|
|
@@ -2103,36 +2146,52 @@ const detectLongitudinalEvidence = (window, tuning) => {
|
|
|
2103
2146
|
hasReversal
|
|
2104
2147
|
};
|
|
2105
2148
|
if (rapidCoverageWindow !== null) {
|
|
2106
|
-
|
|
2149
|
+
const rapidPeakThreshold = rapidDirection < 0 ? directionalTuning.suddenBrakingPeakThreshold : directionalTuning.rapidAccelerationPeakThreshold;
|
|
2150
|
+
const rapidMeanThreshold = rapidDirection < 0 ? directionalTuning.suddenBrakingMeanThreshold : directionalTuning.rapidAccelerationMeanThreshold;
|
|
2151
|
+
if (rapidPeak >= rapidPeakThreshold && Math.abs(rapidMean) >= rapidMeanThreshold) {
|
|
2107
2152
|
if (verticalRms > longitudinalRms * tuning.verticalBumpRatio) rejectionReason = "vertical_bump";
|
|
2108
2153
|
else if (hasReversal) rejectionReason = "longitudinal_reversal";
|
|
2109
|
-
else if (rapidDirection !== 0 && rapidCoherence >= tuning.rapidLongitudinalSignCoherence)
|
|
2154
|
+
else if (rapidDirection !== 0 && rapidCoherence >= tuning.rapidLongitudinalSignCoherence) if (rapidDirection < 0 && rapidBrakingQuality !== null) suddenBrakingQualityRejection = rapidBrakingQuality;
|
|
2155
|
+
else rapidCandidate = rapidDirection > 0 ? "RAPID_ACCELERATION" : "SUDDEN_BRAKING";
|
|
2110
2156
|
}
|
|
2111
2157
|
}
|
|
2112
2158
|
let normalCandidate = null;
|
|
2113
|
-
let
|
|
2159
|
+
let retainedAcceleration = false;
|
|
2160
|
+
let retainedBraking = false;
|
|
2161
|
+
let brakingQualityRejectionResult = null;
|
|
2114
2162
|
let normalStatistics = null;
|
|
2115
2163
|
if (normalWindow.length > 0) {
|
|
2116
|
-
const
|
|
2164
|
+
const normalMetrics = normalWindow.map((sample) => sample.metrics);
|
|
2165
|
+
const values = normalMetrics.map((sample) => sample.longitudinal);
|
|
2117
2166
|
const mean = trimmedMean(values);
|
|
2118
2167
|
const direction = Math.sign(mean);
|
|
2119
|
-
const
|
|
2168
|
+
const deadband = direction < 0 ? directionalTuning.brakingExitThreshold : directionalTuning.accelerationExitThreshold;
|
|
2169
|
+
const coherence = signCoherence(values, direction, deadband);
|
|
2170
|
+
const normalBrakingQuality = brakingQualityRejection(normalWindow, directionalTuning.normalBrakingMinimumDominance, directionalTuning.maximumBrakingGravityDirectionChangeRad);
|
|
2120
2171
|
normalStatistics = {
|
|
2121
2172
|
sampleCount: normalWindow.length,
|
|
2122
|
-
durationMs: metricWindowDuration(
|
|
2173
|
+
durationMs: metricWindowDuration(normalMetrics, "linearAccelerationSampledAtMs"),
|
|
2123
2174
|
mean,
|
|
2124
2175
|
peak: maximumAbsolute(values),
|
|
2125
2176
|
coherence
|
|
2126
2177
|
};
|
|
2127
|
-
const retentionValues = recentNormalWindow.map((sample) => sample.longitudinal);
|
|
2128
|
-
|
|
2129
|
-
|
|
2178
|
+
const retentionValues = recentNormalWindow.map((sample) => sample.metrics.longitudinal);
|
|
2179
|
+
const retentionMean = trimmedMean(retentionValues);
|
|
2180
|
+
const retentionBrakingQuality = brakingQualityRejection(recentNormalWindow, directionalTuning.normalBrakingMinimumDominance, directionalTuning.maximumBrakingGravityDirectionChangeRad);
|
|
2181
|
+
retainedAcceleration = retentionMean >= directionalTuning.accelerationExitThreshold;
|
|
2182
|
+
retainedBraking = retentionMean <= -directionalTuning.brakingExitThreshold && retentionBrakingQuality === null;
|
|
2183
|
+
const threshold = direction < 0 ? directionalTuning.brakingThreshold : directionalTuning.accelerationThreshold;
|
|
2184
|
+
if (normalCoverageWindow !== null && Math.abs(mean) >= threshold && coherence >= tuning.longitudinalSignCoherence) if (direction < 0 && normalBrakingQuality !== null) brakingQualityRejectionResult = normalBrakingQuality;
|
|
2185
|
+
else normalCandidate = direction > 0 ? "ACCELERATION" : "BRAKING";
|
|
2130
2186
|
}
|
|
2131
2187
|
return {
|
|
2132
2188
|
rapidCandidate,
|
|
2133
2189
|
normalCandidate,
|
|
2134
|
-
|
|
2190
|
+
retainedAcceleration,
|
|
2191
|
+
retainedBraking,
|
|
2135
2192
|
rejectionReason,
|
|
2193
|
+
brakingQualityRejection: brakingQualityRejectionResult,
|
|
2194
|
+
suddenBrakingQualityRejection,
|
|
2136
2195
|
normalStatistics,
|
|
2137
2196
|
rapidStatistics
|
|
2138
2197
|
};
|
|
@@ -2188,13 +2247,17 @@ const detectTurnEvidence = (window, tuning) => {
|
|
|
2188
2247
|
}
|
|
2189
2248
|
};
|
|
2190
2249
|
};
|
|
2191
|
-
const instantaneousCandidate = (metrics, tuning) => {
|
|
2250
|
+
const instantaneousCandidate = (metrics, tuning, directionalTuning) => {
|
|
2192
2251
|
const longitudinalMagnitude = Math.abs(metrics.longitudinal);
|
|
2193
|
-
if (longitudinalMagnitude >=
|
|
2252
|
+
if (longitudinalMagnitude >= (metrics.longitudinal < 0 ? directionalTuning.suddenBrakingPeakThreshold : directionalTuning.rapidAccelerationPeakThreshold) && Math.abs(metrics.vertical) <= longitudinalMagnitude * tuning.verticalBumpRatio) return metrics.longitudinal > 0 ? "RAPID_ACCELERATION" : "SUDDEN_BRAKING";
|
|
2194
2253
|
if (Math.abs(metrics.yaw) >= tuning.turnYawThreshold) return metrics.yaw > 0 ? "LEFT_TURN" : "RIGHT_TURN";
|
|
2195
|
-
if (longitudinalMagnitude >=
|
|
2254
|
+
if (longitudinalMagnitude >= (metrics.longitudinal < 0 ? directionalTuning.brakingThreshold : directionalTuning.accelerationThreshold)) return metrics.longitudinal > 0 ? "ACCELERATION" : "BRAKING";
|
|
2196
2255
|
return null;
|
|
2197
2256
|
};
|
|
2257
|
+
const recentLongitudinalObservations = (values, windowMs) => {
|
|
2258
|
+
const latestAtMs = values[values.length - 1]?.metrics.linearAccelerationSampledAtMs ?? 0;
|
|
2259
|
+
return values.filter((value) => value.metrics.linearAccelerationSampledAtMs >= latestAtMs - windowMs);
|
|
2260
|
+
};
|
|
2198
2261
|
const recentMetrics = (values, windowMs, timestampKey) => {
|
|
2199
2262
|
const latestAtMs = values[values.length - 1]?.[timestampKey] ?? 0;
|
|
2200
2263
|
return values.filter((value) => value[timestampKey] >= latestAtMs - windowMs);
|
|
@@ -2245,6 +2308,23 @@ const signCoherence = (values, direction, deadband) => {
|
|
|
2245
2308
|
};
|
|
2246
2309
|
const containsBothSigns = (values, threshold) => values.some((value) => value >= threshold) && values.some((value) => value <= -threshold);
|
|
2247
2310
|
const rootMeanSquare = (values) => values.length === 0 ? 0 : Math.sqrt(values.reduce((sum, value) => sum + value ** 2, 0) / values.length);
|
|
2311
|
+
const brakingQualityRejection = (observations, minimumDominance, maximumGravityDirectionChangeRad) => {
|
|
2312
|
+
if (observations.length === 0) return null;
|
|
2313
|
+
if (rootMeanSquare(observations.map((sample) => sample.metrics.longitudinal)) < rootMeanSquare(observations.map((sample) => Math.hypot(sample.metrics.lateral, sample.metrics.vertical))) * minimumDominance) return "cross_axis_motion";
|
|
2314
|
+
return maximumVectorAngle(observations.map((sample) => sample.rawGravity)) > maximumGravityDirectionChangeRad ? "gravity_direction_change" : null;
|
|
2315
|
+
};
|
|
2316
|
+
const maximumVectorAngle = (values) => {
|
|
2317
|
+
let maximumAngle = 0;
|
|
2318
|
+
for (let leftIndex = 0; leftIndex < values.length; leftIndex += 1) for (let rightIndex = leftIndex + 1; rightIndex < values.length; rightIndex += 1) {
|
|
2319
|
+
const left = values[leftIndex];
|
|
2320
|
+
const right = values[rightIndex];
|
|
2321
|
+
const denominator = Math.hypot(left.x, left.y, left.z) * Math.hypot(right.x, right.y, right.z);
|
|
2322
|
+
if (denominator <= Number.EPSILON) return Number.POSITIVE_INFINITY;
|
|
2323
|
+
const cosine = (left.x * right.x + left.y * right.y + left.z * right.z) / denominator;
|
|
2324
|
+
maximumAngle = Math.max(maximumAngle, Math.acos(Math.max(-1, Math.min(1, cosine))));
|
|
2325
|
+
}
|
|
2326
|
+
return maximumAngle;
|
|
2327
|
+
};
|
|
2248
2328
|
const maximumAbsolute = (values) => values.length === 0 ? 0 : Math.max(...values.map(Math.abs));
|
|
2249
2329
|
const metricWindowDuration = (values, timestampKey) => {
|
|
2250
2330
|
const first = values[0];
|
|
@@ -2280,6 +2360,15 @@ const pushUniqueMetric = (window, metrics, timestampKey, windowMs) => {
|
|
|
2280
2360
|
while (window[0] && window[0][timestampKey] < cutoffMs) window.shift();
|
|
2281
2361
|
return true;
|
|
2282
2362
|
};
|
|
2363
|
+
const pushUniqueLongitudinalObservation = (window, observation, windowMs) => {
|
|
2364
|
+
const latest = window[window.length - 1];
|
|
2365
|
+
const sampledAtMs = observation.metrics.linearAccelerationSampledAtMs;
|
|
2366
|
+
if (latest && sampledAtMs <= latest.metrics.linearAccelerationSampledAtMs) return false;
|
|
2367
|
+
window.push(observation);
|
|
2368
|
+
const cutoffMs = sampledAtMs - windowMs;
|
|
2369
|
+
while (window[0] && window[0].metrics.linearAccelerationSampledAtMs < cutoffMs) window.shift();
|
|
2370
|
+
return true;
|
|
2371
|
+
};
|
|
2283
2372
|
const pushUniqueVector = (window, sample, windowMs) => {
|
|
2284
2373
|
const latest = window[window.length - 1];
|
|
2285
2374
|
if (latest && sample.sampledAtMs <= latest.sampledAtMs) return false;
|
|
@@ -2303,31 +2392,31 @@ const isBaseStatus = (status) => status === "STOPPED" || status === "STEADY_DRIV
|
|
|
2303
2392
|
const noop = () => void 0;
|
|
2304
2393
|
//#endregion
|
|
2305
2394
|
//#region src/driving_expression/driving_expression_player.ts
|
|
2306
|
-
const DEBUG_MODULE = "driving_expression_player.ts";
|
|
2395
|
+
const DEBUG_MODULE$1 = "driving_expression_player.ts";
|
|
2307
2396
|
const MAX_RETAINED_IMAGES = 3;
|
|
2308
2397
|
const POSITIVE_FINITE_DEBUG = {
|
|
2309
|
-
moduleName: DEBUG_MODULE,
|
|
2398
|
+
moduleName: DEBUG_MODULE$1,
|
|
2310
2399
|
scope: "positiveFinite"
|
|
2311
2400
|
};
|
|
2312
2401
|
const CREATE_ABORT_ERROR_DEBUG = {
|
|
2313
|
-
moduleName: DEBUG_MODULE,
|
|
2402
|
+
moduleName: DEBUG_MODULE$1,
|
|
2314
2403
|
scope: "createAbortError"
|
|
2315
2404
|
};
|
|
2316
2405
|
const IS_ABORT_ERROR_DEBUG = {
|
|
2317
|
-
moduleName: DEBUG_MODULE,
|
|
2406
|
+
moduleName: DEBUG_MODULE$1,
|
|
2318
2407
|
scope: "isAbortError"
|
|
2319
2408
|
};
|
|
2320
2409
|
const IS_RECORD_DEBUG = {
|
|
2321
|
-
moduleName: DEBUG_MODULE,
|
|
2410
|
+
moduleName: DEBUG_MODULE$1,
|
|
2322
2411
|
scope: "isRecord"
|
|
2323
2412
|
};
|
|
2324
2413
|
const createDrivingExpressionPlayer = (container, options) => {
|
|
2325
|
-
dialSdkDebugWarn(DEBUG_MODULE, "createDrivingExpressionPlayer", "called", {
|
|
2414
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "createDrivingExpressionPlayer", "called", {
|
|
2326
2415
|
container,
|
|
2327
2416
|
options
|
|
2328
2417
|
});
|
|
2329
2418
|
const result = new DefaultDrivingExpressionPlayer(container, options);
|
|
2330
|
-
dialSdkDebugWarn(DEBUG_MODULE, "createDrivingExpressionPlayer", "returned", { snapshot: result.getSnapshot() });
|
|
2419
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "createDrivingExpressionPlayer", "returned", { snapshot: result.getSnapshot() });
|
|
2331
2420
|
return result;
|
|
2332
2421
|
};
|
|
2333
2422
|
var DefaultDrivingExpressionPlayer = class {
|
|
@@ -2354,32 +2443,32 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2354
2443
|
this.retainedImages = /* @__PURE__ */ new Map();
|
|
2355
2444
|
this.preloadedHintUrls = /* @__PURE__ */ new Set();
|
|
2356
2445
|
this.handleLifecyclePause = () => {
|
|
2357
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "called");
|
|
2446
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "called");
|
|
2358
2447
|
if (this.destroyed || this.lifecycleSuspended) {
|
|
2359
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "ignored");
|
|
2448
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "ignored");
|
|
2360
2449
|
return;
|
|
2361
2450
|
}
|
|
2362
2451
|
this.lifecycleSuspended = true;
|
|
2363
2452
|
this.updatePauseState();
|
|
2364
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "returned");
|
|
2453
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleLifecyclePause", "returned");
|
|
2365
2454
|
};
|
|
2366
2455
|
this.handleLifecycleResume = () => {
|
|
2367
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "called");
|
|
2456
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "called");
|
|
2368
2457
|
if (this.destroyed || !this.lifecycleSuspended) {
|
|
2369
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "ignored");
|
|
2458
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "ignored");
|
|
2370
2459
|
return;
|
|
2371
2460
|
}
|
|
2372
2461
|
this.lifecycleSuspended = false;
|
|
2373
2462
|
this.updatePauseState();
|
|
2374
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "returned");
|
|
2463
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleLifecycleResume", "returned");
|
|
2375
2464
|
};
|
|
2376
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.constructor", "called", {
|
|
2465
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.constructor", "called", {
|
|
2377
2466
|
container,
|
|
2378
2467
|
options
|
|
2379
2468
|
});
|
|
2380
2469
|
if (!container || typeof container.replaceChildren !== "function") {
|
|
2381
2470
|
const error = /* @__PURE__ */ new TypeError("container must be an HTMLElement-like DOM container");
|
|
2382
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.constructor", "threw", error);
|
|
2471
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.constructor", "threw", error);
|
|
2383
2472
|
throw error;
|
|
2384
2473
|
}
|
|
2385
2474
|
this.container = container;
|
|
@@ -2396,7 +2485,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2396
2485
|
this.maxTgsJsonBytes = requirePositiveFinite("maxTgsJsonBytes", options.maxTgsJsonBytes ?? 8 * 1024 * 1024, POSITIVE_FINITE_DEBUG);
|
|
2397
2486
|
this.maxTgsLayers = requirePositiveFinite("maxTgsLayers", options.maxTgsLayers ?? 500, POSITIVE_FINITE_DEBUG);
|
|
2398
2487
|
if (options.managePageLifecycle ?? true) this.unsubscribePageLifecycle = subscribeDrivingPageLifecycle(this.handleLifecyclePause, this.handleLifecycleResume);
|
|
2399
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.constructor", "created", {
|
|
2488
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.constructor", "created", {
|
|
2400
2489
|
loadTimeoutMs: this.loadTimeoutMs,
|
|
2401
2490
|
retryBackoffMs: this.retryBackoffMs,
|
|
2402
2491
|
fit: this.fit,
|
|
@@ -2407,12 +2496,12 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2407
2496
|
});
|
|
2408
2497
|
}
|
|
2409
2498
|
async show(status) {
|
|
2410
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "called", {
|
|
2499
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "called", {
|
|
2411
2500
|
status,
|
|
2412
2501
|
snapshot: this.getSnapshot()
|
|
2413
2502
|
});
|
|
2414
2503
|
if (this.destroyed || status === this.status && this.phase !== "idle") {
|
|
2415
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "ignored");
|
|
2504
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "ignored");
|
|
2416
2505
|
return;
|
|
2417
2506
|
}
|
|
2418
2507
|
this.status = status;
|
|
@@ -2424,23 +2513,23 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2424
2513
|
this.desiredMedia = null;
|
|
2425
2514
|
this.desiredMediaRole = null;
|
|
2426
2515
|
this.handleFailure(status, null, new DrivingExpressionResolutionError(status), "invalid_config", operation, false);
|
|
2427
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned after missing config");
|
|
2516
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "returned after missing config");
|
|
2428
2517
|
return;
|
|
2429
2518
|
}
|
|
2430
2519
|
this.desiredMedia = fallback.media;
|
|
2431
2520
|
this.desiredMediaRole = "fallback";
|
|
2432
2521
|
if (this.paused) {
|
|
2433
2522
|
this.phase = "idle";
|
|
2434
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "deferred fallback while paused");
|
|
2523
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "deferred fallback while paused");
|
|
2435
2524
|
return;
|
|
2436
2525
|
}
|
|
2437
2526
|
if (fallback.type === "unsupported") {
|
|
2438
2527
|
this.handleFailure(status, fallback.media, unsupportedFallbackError(fallback.media), "invalid_config", operation, false, false);
|
|
2439
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned unsupported fallback");
|
|
2528
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "returned unsupported fallback");
|
|
2440
2529
|
return;
|
|
2441
2530
|
}
|
|
2442
2531
|
this.renderFallback(status, fallback.media);
|
|
2443
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "returned fallback", { snapshot: this.getSnapshot() });
|
|
2532
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "returned fallback", { snapshot: this.getSnapshot() });
|
|
2444
2533
|
return;
|
|
2445
2534
|
}
|
|
2446
2535
|
const media = normalizeMedia(configured);
|
|
@@ -2448,40 +2537,40 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2448
2537
|
this.desiredMediaRole = "primary";
|
|
2449
2538
|
if (this.paused) {
|
|
2450
2539
|
this.phase = "idle";
|
|
2451
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "deferred media while paused", { media });
|
|
2540
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "deferred media while paused", { media });
|
|
2452
2541
|
return;
|
|
2453
2542
|
}
|
|
2454
2543
|
await this.load(status, media, operation);
|
|
2455
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.show", "resolved", {
|
|
2544
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.show", "resolved", {
|
|
2456
2545
|
status,
|
|
2457
2546
|
media,
|
|
2458
2547
|
snapshot: this.getSnapshot()
|
|
2459
2548
|
});
|
|
2460
2549
|
}
|
|
2461
2550
|
pause() {
|
|
2462
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "called", this.getSnapshot());
|
|
2551
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.pause", "called", this.getSnapshot());
|
|
2463
2552
|
if (this.destroyed || this.userPaused) {
|
|
2464
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "ignored");
|
|
2553
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.pause", "ignored");
|
|
2465
2554
|
return;
|
|
2466
2555
|
}
|
|
2467
2556
|
this.userPaused = true;
|
|
2468
2557
|
this.updatePauseState();
|
|
2469
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.pause", "returned", this.getSnapshot());
|
|
2558
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.pause", "returned", this.getSnapshot());
|
|
2470
2559
|
}
|
|
2471
2560
|
resume() {
|
|
2472
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "called", this.getSnapshot());
|
|
2561
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.resume", "called", this.getSnapshot());
|
|
2473
2562
|
if (this.destroyed || !this.userPaused) {
|
|
2474
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "ignored");
|
|
2563
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.resume", "ignored");
|
|
2475
2564
|
return;
|
|
2476
2565
|
}
|
|
2477
2566
|
this.userPaused = false;
|
|
2478
2567
|
this.updatePauseState();
|
|
2479
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resume", "returned", this.getSnapshot());
|
|
2568
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.resume", "returned", this.getSnapshot());
|
|
2480
2569
|
}
|
|
2481
2570
|
destroy() {
|
|
2482
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "called", this.getSnapshot());
|
|
2571
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.destroy", "called", this.getSnapshot());
|
|
2483
2572
|
if (this.destroyed) {
|
|
2484
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "ignored");
|
|
2573
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.destroy", "ignored");
|
|
2485
2574
|
return;
|
|
2486
2575
|
}
|
|
2487
2576
|
this.destroyed = true;
|
|
@@ -2500,7 +2589,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2500
2589
|
this.phase = "idle";
|
|
2501
2590
|
this.mediaKind = null;
|
|
2502
2591
|
this.errorCategory = null;
|
|
2503
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.destroy", "returned", this.getSnapshot());
|
|
2592
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.destroy", "returned", this.getSnapshot());
|
|
2504
2593
|
}
|
|
2505
2594
|
getSnapshot() {
|
|
2506
2595
|
const result = {
|
|
@@ -2510,11 +2599,11 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2510
2599
|
mediaKind: this.mediaKind,
|
|
2511
2600
|
errorCategory: this.errorCategory
|
|
2512
2601
|
};
|
|
2513
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getSnapshot", "returned", { result });
|
|
2602
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.getSnapshot", "returned", { result });
|
|
2514
2603
|
return result;
|
|
2515
2604
|
}
|
|
2516
2605
|
beginOperation() {
|
|
2517
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.beginOperation", "called", {
|
|
2606
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.beginOperation", "called", {
|
|
2518
2607
|
operation: this.operation,
|
|
2519
2608
|
snapshot: this.getSnapshot()
|
|
2520
2609
|
});
|
|
@@ -2526,11 +2615,11 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2526
2615
|
this.phase = "loading";
|
|
2527
2616
|
this.mediaKind = null;
|
|
2528
2617
|
this.errorCategory = null;
|
|
2529
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.beginOperation", "returned", { operation: this.operation });
|
|
2618
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.beginOperation", "returned", { operation: this.operation });
|
|
2530
2619
|
return this.operation;
|
|
2531
2620
|
}
|
|
2532
2621
|
updatePauseState() {
|
|
2533
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "called", {
|
|
2622
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.updatePauseState", "called", {
|
|
2534
2623
|
userPaused: this.userPaused,
|
|
2535
2624
|
lifecycleSuspended: this.lifecycleSuspended,
|
|
2536
2625
|
paused: this.paused,
|
|
@@ -2538,7 +2627,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2538
2627
|
});
|
|
2539
2628
|
const shouldPause = this.userPaused || this.lifecycleSuspended;
|
|
2540
2629
|
if (shouldPause === this.paused) {
|
|
2541
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "ignored unchanged state");
|
|
2630
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.updatePauseState", "ignored unchanged state");
|
|
2542
2631
|
return;
|
|
2543
2632
|
}
|
|
2544
2633
|
this.paused = shouldPause;
|
|
@@ -2547,7 +2636,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2547
2636
|
this.cancelPendingWork();
|
|
2548
2637
|
this.activeVideo?.pause();
|
|
2549
2638
|
this.activeTgs?.pause?.();
|
|
2550
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "paused", this.getSnapshot());
|
|
2639
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.updatePauseState", "paused", this.getSnapshot());
|
|
2551
2640
|
return;
|
|
2552
2641
|
}
|
|
2553
2642
|
if (this.phase === "ready") {
|
|
@@ -2560,7 +2649,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2560
2649
|
video.play().catch((error) => this.handleActiveVideoFailure(video, status, media, operation, "decode", error));
|
|
2561
2650
|
}
|
|
2562
2651
|
this.activeTgs?.play?.();
|
|
2563
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "resumed ready media");
|
|
2652
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.updatePauseState", "resumed ready media");
|
|
2564
2653
|
return;
|
|
2565
2654
|
}
|
|
2566
2655
|
if (this.status !== null && this.desiredMedia !== null) {
|
|
@@ -2572,10 +2661,10 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2572
2661
|
else this.handleFailure(status, fallback, unsupportedFallbackError(fallback), "invalid_config", operation, false, false);
|
|
2573
2662
|
} else this.load(this.status, this.desiredMedia, operation);
|
|
2574
2663
|
}
|
|
2575
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.updatePauseState", "returned", this.getSnapshot());
|
|
2664
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.updatePauseState", "returned", this.getSnapshot());
|
|
2576
2665
|
}
|
|
2577
2666
|
async load(status, media, operation) {
|
|
2578
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "called", {
|
|
2667
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "called", {
|
|
2579
2668
|
status,
|
|
2580
2669
|
media,
|
|
2581
2670
|
operation
|
|
@@ -2585,13 +2674,13 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2585
2674
|
if (media.kind === "emoji") {
|
|
2586
2675
|
this.renderEmoji(media.text);
|
|
2587
2676
|
this.markReady(status, media.kind, startedAt, operation);
|
|
2588
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "resolved emoji", { snapshot: this.getSnapshot() });
|
|
2677
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "resolved emoji", { snapshot: this.getSnapshot() });
|
|
2589
2678
|
return;
|
|
2590
2679
|
}
|
|
2591
2680
|
const invalidUrl = firstInvalidMediaUrl(media);
|
|
2592
2681
|
if (invalidUrl !== null) {
|
|
2593
2682
|
this.handleFailure(status, media, /* @__PURE__ */ new Error("One or more media URLs are not long-lived public HTTPS URLs"), "invalid_config", operation);
|
|
2594
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "returned invalid URL", { invalidUrl });
|
|
2683
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "returned invalid URL", { invalidUrl });
|
|
2595
2684
|
return;
|
|
2596
2685
|
}
|
|
2597
2686
|
const loadAbort = new AbortController();
|
|
@@ -2614,7 +2703,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2614
2703
|
break;
|
|
2615
2704
|
}
|
|
2616
2705
|
if (!this.isCurrent(operation) || this.failedOperation === operation) {
|
|
2617
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "discarded completed load", {
|
|
2706
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "discarded completed load", {
|
|
2618
2707
|
operation,
|
|
2619
2708
|
failedOperation: this.failedOperation
|
|
2620
2709
|
});
|
|
@@ -2622,31 +2711,31 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2622
2711
|
}
|
|
2623
2712
|
this.markReady(status, media.kind, startedAt, operation);
|
|
2624
2713
|
this.startPreloading(status, operation);
|
|
2625
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "resolved", {
|
|
2714
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "resolved", {
|
|
2626
2715
|
status,
|
|
2627
2716
|
media,
|
|
2628
2717
|
operation,
|
|
2629
2718
|
snapshot: this.getSnapshot()
|
|
2630
2719
|
});
|
|
2631
2720
|
} catch (error) {
|
|
2632
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "caught error", {
|
|
2721
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "caught error", {
|
|
2633
2722
|
error,
|
|
2634
2723
|
operation
|
|
2635
2724
|
});
|
|
2636
2725
|
if (!this.isCurrent(operation) || isAbortError(error, IS_ABORT_ERROR_DEBUG)) {
|
|
2637
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "ignored error");
|
|
2726
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "ignored error");
|
|
2638
2727
|
return;
|
|
2639
2728
|
}
|
|
2640
2729
|
this.handleFailure(status, media, error, categorizeMediaError(error), operation);
|
|
2641
2730
|
} finally {
|
|
2642
2731
|
loadAbort.abort();
|
|
2643
2732
|
if (this.loadAbort === loadAbort) this.loadAbort = null;
|
|
2644
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.load", "completed", { operation });
|
|
2733
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.load", "completed", { operation });
|
|
2645
2734
|
}
|
|
2646
2735
|
}
|
|
2647
2736
|
async loadImage(status, media, signal, operation) {
|
|
2648
2737
|
const { url } = media;
|
|
2649
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "called", {
|
|
2738
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadImage", "called", {
|
|
2650
2739
|
status,
|
|
2651
2740
|
media,
|
|
2652
2741
|
signal,
|
|
@@ -2656,7 +2745,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2656
2745
|
const retained = this.takeRetainedImage(url);
|
|
2657
2746
|
if (retained !== null) {
|
|
2658
2747
|
this.container.replaceChildren(retained);
|
|
2659
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "resolved retained image", {
|
|
2748
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadImage", "resolved retained image", {
|
|
2660
2749
|
url,
|
|
2661
2750
|
operation,
|
|
2662
2751
|
image: retained
|
|
@@ -2670,12 +2759,12 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2670
2759
|
image.src = url;
|
|
2671
2760
|
});
|
|
2672
2761
|
if (!this.isCurrent(operation)) {
|
|
2673
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "discarded", { operation });
|
|
2762
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadImage", "discarded", { operation });
|
|
2674
2763
|
return;
|
|
2675
2764
|
}
|
|
2676
2765
|
if (isRetainableImage(media)) this.retainImage(url, image);
|
|
2677
2766
|
this.container.replaceChildren(image);
|
|
2678
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadImage", "resolved", {
|
|
2767
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadImage", "resolved", {
|
|
2679
2768
|
url,
|
|
2680
2769
|
operation,
|
|
2681
2770
|
image
|
|
@@ -2705,7 +2794,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2705
2794
|
this.retainedImages.clear();
|
|
2706
2795
|
}
|
|
2707
2796
|
async loadVideo(url, mimeType, status, media, signal, operation) {
|
|
2708
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "called", {
|
|
2797
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadVideo", "called", {
|
|
2709
2798
|
url,
|
|
2710
2799
|
mimeType,
|
|
2711
2800
|
status,
|
|
@@ -2722,7 +2811,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2722
2811
|
video.load();
|
|
2723
2812
|
});
|
|
2724
2813
|
if (!this.isCurrent(operation)) {
|
|
2725
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "discarded", { operation });
|
|
2814
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadVideo", "discarded", { operation });
|
|
2726
2815
|
return;
|
|
2727
2816
|
}
|
|
2728
2817
|
video.currentTime = 0;
|
|
@@ -2730,14 +2819,14 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2730
2819
|
this.activeVideo = video;
|
|
2731
2820
|
this.attachActiveVideoFailureListeners(video, status, media, operation);
|
|
2732
2821
|
await video.play();
|
|
2733
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadVideo", "resolved", {
|
|
2822
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadVideo", "resolved", {
|
|
2734
2823
|
url,
|
|
2735
2824
|
operation,
|
|
2736
2825
|
video
|
|
2737
2826
|
});
|
|
2738
2827
|
}
|
|
2739
2828
|
async loadLivePhoto(media, status, signal, operation) {
|
|
2740
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "called", {
|
|
2829
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadLivePhoto", "called", {
|
|
2741
2830
|
media,
|
|
2742
2831
|
status,
|
|
2743
2832
|
signal,
|
|
@@ -2749,25 +2838,25 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2749
2838
|
cover.src = media.coverUrl;
|
|
2750
2839
|
});
|
|
2751
2840
|
if (!this.isCurrent(operation)) {
|
|
2752
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "discarded", { operation });
|
|
2841
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadLivePhoto", "discarded", { operation });
|
|
2753
2842
|
return;
|
|
2754
2843
|
}
|
|
2755
2844
|
this.container.replaceChildren(cover);
|
|
2756
2845
|
await this.loadVideo(media.motionUrl, void 0, status, media, signal, operation);
|
|
2757
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadLivePhoto", "resolved", {
|
|
2846
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadLivePhoto", "resolved", {
|
|
2758
2847
|
media,
|
|
2759
2848
|
operation
|
|
2760
2849
|
});
|
|
2761
2850
|
}
|
|
2762
2851
|
async loadTgs(url, signal, operation) {
|
|
2763
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "called", {
|
|
2852
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadTgs", "called", {
|
|
2764
2853
|
url,
|
|
2765
2854
|
signal,
|
|
2766
2855
|
operation
|
|
2767
2856
|
});
|
|
2768
2857
|
if (!this.fetchImplementation) {
|
|
2769
2858
|
const error = new MediaPlayerError("unsupported", "fetch is unavailable");
|
|
2770
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "threw", error);
|
|
2859
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadTgs", "threw", error);
|
|
2771
2860
|
throw error;
|
|
2772
2861
|
}
|
|
2773
2862
|
const response = await withTimeout(this.fetchImplementation(url, {
|
|
@@ -2777,7 +2866,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2777
2866
|
}), this.loadTimeoutMs, signal);
|
|
2778
2867
|
if (!response.ok) throw new MediaPlayerError("network", `TGS request failed with HTTP ${response.status}`);
|
|
2779
2868
|
const contentType = response.headers.get("content-type")?.split(";", 1)[0]?.trim().toLowerCase() ?? "";
|
|
2780
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "received response", {
|
|
2869
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadTgs", "received response", {
|
|
2781
2870
|
ok: response.ok,
|
|
2782
2871
|
status: response.status,
|
|
2783
2872
|
contentType,
|
|
@@ -2795,7 +2884,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2795
2884
|
animationData = JSON.parse(new TextDecoder().decode(bytes));
|
|
2796
2885
|
} catch (cause) {
|
|
2797
2886
|
const error = new MediaPlayerError("decode", "TGS JSON is malformed");
|
|
2798
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "threw", {
|
|
2887
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadTgs", "threw", {
|
|
2799
2888
|
error,
|
|
2800
2889
|
cause
|
|
2801
2890
|
});
|
|
@@ -2807,12 +2896,12 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2807
2896
|
const handle = await withTimeout(Promise.resolve(this.tgsRenderer(host, animationData, signal)), this.loadTimeoutMs, signal);
|
|
2808
2897
|
if (!this.isCurrent(operation)) {
|
|
2809
2898
|
handle.destroy();
|
|
2810
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "discarded", { operation });
|
|
2899
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadTgs", "discarded", { operation });
|
|
2811
2900
|
return;
|
|
2812
2901
|
}
|
|
2813
2902
|
this.activeTgs = handle;
|
|
2814
2903
|
this.container.replaceChildren(host);
|
|
2815
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.loadTgs", "resolved", {
|
|
2904
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.loadTgs", "resolved", {
|
|
2816
2905
|
url,
|
|
2817
2906
|
operation,
|
|
2818
2907
|
animationData,
|
|
@@ -2820,7 +2909,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2820
2909
|
});
|
|
2821
2910
|
}
|
|
2822
2911
|
renderLoadingPlaceholder(status, coverUrl, operation, signal) {
|
|
2823
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "called", {
|
|
2912
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "called", {
|
|
2824
2913
|
status,
|
|
2825
2914
|
coverUrl,
|
|
2826
2915
|
operation,
|
|
@@ -2828,43 +2917,43 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2828
2917
|
});
|
|
2829
2918
|
this.renderConfiguredFallback(status, false);
|
|
2830
2919
|
if (!coverUrl) {
|
|
2831
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned no cover");
|
|
2920
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned no cover");
|
|
2832
2921
|
return;
|
|
2833
2922
|
}
|
|
2834
2923
|
const cover = this.createImage();
|
|
2835
2924
|
waitForElementEvent(cover, "load", "error", signal, this.loadTimeoutMs, () => {
|
|
2836
2925
|
cover.src = coverUrl;
|
|
2837
2926
|
}).then(() => {
|
|
2838
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.then", "called", {
|
|
2927
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.then", "called", {
|
|
2839
2928
|
operation,
|
|
2840
2929
|
cover
|
|
2841
2930
|
});
|
|
2842
2931
|
if (this.isCurrent(operation) && this.phase === "loading") this.container.replaceChildren(cover);
|
|
2843
2932
|
}).catch((error) => {
|
|
2844
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.catch", "called", {
|
|
2933
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder.catch", "called", {
|
|
2845
2934
|
operation,
|
|
2846
2935
|
error
|
|
2847
2936
|
});
|
|
2848
2937
|
if (this.isCurrent(operation) && this.phase === "loading") this.renderConfiguredFallback(status, false);
|
|
2849
2938
|
});
|
|
2850
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned");
|
|
2939
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderLoadingPlaceholder", "returned");
|
|
2851
2940
|
}
|
|
2852
2941
|
renderConfiguredFallback(status, report = true) {
|
|
2853
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "called", {
|
|
2942
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "called", {
|
|
2854
2943
|
status,
|
|
2855
2944
|
report
|
|
2856
2945
|
});
|
|
2857
2946
|
const fallback = this.resolveFallback(status);
|
|
2858
2947
|
if (fallback.type !== "static") {
|
|
2859
2948
|
this.container.replaceChildren();
|
|
2860
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", {
|
|
2949
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", {
|
|
2861
2950
|
result: false,
|
|
2862
2951
|
fallbackType: fallback.type
|
|
2863
2952
|
});
|
|
2864
2953
|
return false;
|
|
2865
2954
|
}
|
|
2866
2955
|
this.renderFallback(status, fallback.media, report);
|
|
2867
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", {
|
|
2956
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderConfiguredFallback", "returned", {
|
|
2868
2957
|
result: true,
|
|
2869
2958
|
fallback: fallback.media
|
|
2870
2959
|
});
|
|
@@ -2879,14 +2968,14 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2879
2968
|
type: "unsupported",
|
|
2880
2969
|
media: fallback
|
|
2881
2970
|
};
|
|
2882
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.resolveFallback", "returned", {
|
|
2971
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.resolveFallback", "returned", {
|
|
2883
2972
|
status,
|
|
2884
2973
|
result
|
|
2885
2974
|
});
|
|
2886
2975
|
return result;
|
|
2887
2976
|
}
|
|
2888
2977
|
renderFallback(status, fallback, report = true) {
|
|
2889
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderFallback", "called", {
|
|
2978
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderFallback", "called", {
|
|
2890
2979
|
status,
|
|
2891
2980
|
fallback,
|
|
2892
2981
|
report
|
|
@@ -2907,10 +2996,10 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2907
2996
|
status,
|
|
2908
2997
|
kind: fallback.kind
|
|
2909
2998
|
});
|
|
2910
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderFallback", "returned", { snapshot: this.getSnapshot() });
|
|
2999
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderFallback", "returned", { snapshot: this.getSnapshot() });
|
|
2911
3000
|
}
|
|
2912
3001
|
renderEmoji(text) {
|
|
2913
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderEmoji", "called", { text });
|
|
3002
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderEmoji", "called", { text });
|
|
2914
3003
|
const emoji = this.document.createElement("span");
|
|
2915
3004
|
emoji.textContent = text;
|
|
2916
3005
|
emoji.setAttribute("role", "img");
|
|
@@ -2926,17 +3015,17 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2926
3015
|
width: "100%"
|
|
2927
3016
|
});
|
|
2928
3017
|
this.container.replaceChildren(emoji);
|
|
2929
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.renderEmoji", "returned", { emoji });
|
|
3018
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.renderEmoji", "returned", { emoji });
|
|
2930
3019
|
}
|
|
2931
3020
|
markReady(status, kind, startedAt, operation) {
|
|
2932
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "called", {
|
|
3021
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.markReady", "called", {
|
|
2933
3022
|
status,
|
|
2934
3023
|
kind,
|
|
2935
3024
|
startedAt,
|
|
2936
3025
|
operation
|
|
2937
3026
|
});
|
|
2938
3027
|
if (!this.isCurrent(operation) || this.failedOperation === operation) {
|
|
2939
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "ignored");
|
|
3028
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.markReady", "ignored");
|
|
2940
3029
|
return;
|
|
2941
3030
|
}
|
|
2942
3031
|
this.phase = "ready";
|
|
@@ -2948,10 +3037,10 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2948
3037
|
kind,
|
|
2949
3038
|
elapsedMs: Math.max(0, Date.now() - startedAt)
|
|
2950
3039
|
});
|
|
2951
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.markReady", "returned", this.getSnapshot());
|
|
3040
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.markReady", "returned", this.getSnapshot());
|
|
2952
3041
|
}
|
|
2953
3042
|
handleFailure(status, media, error, category, operation, scheduleRetry = true, applyFallback = true) {
|
|
2954
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "called", {
|
|
3043
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleFailure", "called", {
|
|
2955
3044
|
status,
|
|
2956
3045
|
media,
|
|
2957
3046
|
error,
|
|
@@ -2961,7 +3050,7 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2961
3050
|
applyFallback
|
|
2962
3051
|
});
|
|
2963
3052
|
if (!this.isCurrent(operation) || this.failedOperation === operation) {
|
|
2964
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "ignored");
|
|
3053
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleFailure", "ignored");
|
|
2965
3054
|
return;
|
|
2966
3055
|
}
|
|
2967
3056
|
this.failedOperation = operation;
|
|
@@ -2998,42 +3087,42 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
2998
3087
|
this.errorCategory = category;
|
|
2999
3088
|
}
|
|
3000
3089
|
if (scheduleRetry && media !== null) this.scheduleRetry(status, media, operation);
|
|
3001
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleFailure", "returned", {
|
|
3090
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleFailure", "returned", {
|
|
3002
3091
|
fallbackApplied,
|
|
3003
3092
|
snapshot: this.getSnapshot()
|
|
3004
3093
|
});
|
|
3005
3094
|
}
|
|
3006
3095
|
scheduleRetry(status, media, failedOperation) {
|
|
3007
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "called", {
|
|
3096
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.scheduleRetry", "called", {
|
|
3008
3097
|
status,
|
|
3009
3098
|
media,
|
|
3010
3099
|
failedOperation
|
|
3011
3100
|
});
|
|
3012
3101
|
if (this.destroyed || this.paused || !this.isCurrent(failedOperation)) {
|
|
3013
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "ignored");
|
|
3102
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.scheduleRetry", "ignored");
|
|
3014
3103
|
return;
|
|
3015
3104
|
}
|
|
3016
3105
|
this.retryTimer = globalThis.setTimeout(() => {
|
|
3017
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "called", {
|
|
3106
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "called", {
|
|
3018
3107
|
status,
|
|
3019
3108
|
media,
|
|
3020
3109
|
failedOperation
|
|
3021
3110
|
});
|
|
3022
3111
|
this.retryTimer = void 0;
|
|
3023
3112
|
if (this.destroyed || this.paused || this.status !== status || !this.isCurrent(failedOperation)) {
|
|
3024
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "ignored");
|
|
3113
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.scheduleRetry.callback", "ignored");
|
|
3025
3114
|
return;
|
|
3026
3115
|
}
|
|
3027
3116
|
const operation = this.beginOperation();
|
|
3028
3117
|
this.load(status, media, operation);
|
|
3029
3118
|
}, this.retryBackoffMs);
|
|
3030
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.scheduleRetry", "scheduled", {
|
|
3119
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.scheduleRetry", "scheduled", {
|
|
3031
3120
|
retryTimer: this.retryTimer,
|
|
3032
3121
|
retryBackoffMs: this.retryBackoffMs
|
|
3033
3122
|
});
|
|
3034
3123
|
}
|
|
3035
3124
|
startPreloading(currentStatus, operation) {
|
|
3036
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading", "called", {
|
|
3125
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading", "called", {
|
|
3037
3126
|
currentStatus,
|
|
3038
3127
|
operation
|
|
3039
3128
|
});
|
|
@@ -3046,13 +3135,13 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3046
3135
|
...CAR_RUNNING_STATUSES
|
|
3047
3136
|
].filter((status, index, all) => all.indexOf(status) === index);
|
|
3048
3137
|
(async () => {
|
|
3049
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "started", {
|
|
3138
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading.worker", "started", {
|
|
3050
3139
|
statuses,
|
|
3051
3140
|
operation
|
|
3052
3141
|
});
|
|
3053
3142
|
for (const status of statuses) {
|
|
3054
3143
|
if (!this.isCurrent(operation) || preloadAbort.signal.aborted) {
|
|
3055
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "cancelled", {
|
|
3144
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading.worker", "cancelled", {
|
|
3056
3145
|
status,
|
|
3057
3146
|
operation
|
|
3058
3147
|
});
|
|
@@ -3071,12 +3160,12 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3071
3160
|
});
|
|
3072
3161
|
this.preloadedHintUrls.add(hintUrl);
|
|
3073
3162
|
image.removeAttribute("src");
|
|
3074
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "preloaded", {
|
|
3163
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading.worker", "preloaded", {
|
|
3075
3164
|
status,
|
|
3076
3165
|
hintUrl
|
|
3077
3166
|
});
|
|
3078
3167
|
} catch (error) {
|
|
3079
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "preload failed", {
|
|
3168
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading.worker", "preload failed", {
|
|
3080
3169
|
status,
|
|
3081
3170
|
hintUrl,
|
|
3082
3171
|
error
|
|
@@ -3084,21 +3173,21 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3084
3173
|
if (preloadAbort.signal.aborted) return;
|
|
3085
3174
|
}
|
|
3086
3175
|
}
|
|
3087
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading.worker", "completed", { operation });
|
|
3176
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading.worker", "completed", { operation });
|
|
3088
3177
|
})();
|
|
3089
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.startPreloading", "returned", { statuses });
|
|
3178
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.startPreloading", "returned", { statuses });
|
|
3090
3179
|
}
|
|
3091
3180
|
createImage() {
|
|
3092
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.createImage", "called");
|
|
3181
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.createImage", "called");
|
|
3093
3182
|
const image = this.document.createElement("img");
|
|
3094
3183
|
image.alt = "";
|
|
3095
3184
|
image.decoding = "async";
|
|
3096
3185
|
styleMediaElement(image, this.fit);
|
|
3097
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.createImage", "returned", { image });
|
|
3186
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.createImage", "returned", { image });
|
|
3098
3187
|
return image;
|
|
3099
3188
|
}
|
|
3100
3189
|
getReusableVideo() {
|
|
3101
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getReusableVideo", "called", { hasReusableVideo: this.reusableVideo !== null });
|
|
3190
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.getReusableVideo", "called", { hasReusableVideo: this.reusableVideo !== null });
|
|
3102
3191
|
if (!this.reusableVideo) {
|
|
3103
3192
|
this.reusableVideo = this.document.createElement("video");
|
|
3104
3193
|
this.reusableVideo.muted = true;
|
|
@@ -3108,11 +3197,11 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3108
3197
|
this.reusableVideo.setAttribute("playsinline", "");
|
|
3109
3198
|
styleMediaElement(this.reusableVideo, this.fit);
|
|
3110
3199
|
}
|
|
3111
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.getReusableVideo", "returned", { video: this.reusableVideo });
|
|
3200
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.getReusableVideo", "returned", { video: this.reusableVideo });
|
|
3112
3201
|
return this.reusableVideo;
|
|
3113
3202
|
}
|
|
3114
3203
|
attachActiveVideoFailureListeners(video, status, media, operation) {
|
|
3115
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "called", {
|
|
3204
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "called", {
|
|
3116
3205
|
video,
|
|
3117
3206
|
status,
|
|
3118
3207
|
media,
|
|
@@ -3121,19 +3210,19 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3121
3210
|
this.detachActiveVideoFailureListeners();
|
|
3122
3211
|
let attached = true;
|
|
3123
3212
|
const cleanup = () => {
|
|
3124
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "called", { attached });
|
|
3213
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "called", { attached });
|
|
3125
3214
|
if (!attached) {
|
|
3126
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "ignored");
|
|
3215
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "ignored");
|
|
3127
3216
|
return;
|
|
3128
3217
|
}
|
|
3129
3218
|
attached = false;
|
|
3130
3219
|
video.removeEventListener("error", handleError);
|
|
3131
3220
|
video.removeEventListener("stalled", handleStalled);
|
|
3132
3221
|
if (this.activeVideoListenersCleanup === cleanup) this.activeVideoListenersCleanup = null;
|
|
3133
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "returned");
|
|
3222
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.videoListenerCleanup", "returned");
|
|
3134
3223
|
};
|
|
3135
3224
|
const failed = (category, event) => {
|
|
3136
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.videoListenerFailed", "called", {
|
|
3225
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.videoListenerFailed", "called", {
|
|
3137
3226
|
category,
|
|
3138
3227
|
event,
|
|
3139
3228
|
attached
|
|
@@ -3142,20 +3231,20 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3142
3231
|
this.handleActiveVideoFailure(video, status, media, operation, category, new MediaPlayerError(category, `${event.type} after video playback started`));
|
|
3143
3232
|
};
|
|
3144
3233
|
const handleError = (event) => {
|
|
3145
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleVideoError", "called", { event });
|
|
3234
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleVideoError", "called", { event });
|
|
3146
3235
|
failed("decode", event);
|
|
3147
3236
|
};
|
|
3148
3237
|
const handleStalled = (event) => {
|
|
3149
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleVideoStalled", "called", { event });
|
|
3238
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleVideoStalled", "called", { event });
|
|
3150
3239
|
failed("network", event);
|
|
3151
3240
|
};
|
|
3152
3241
|
video.addEventListener("error", handleError);
|
|
3153
3242
|
video.addEventListener("stalled", handleStalled);
|
|
3154
3243
|
this.activeVideoListenersCleanup = cleanup;
|
|
3155
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "returned");
|
|
3244
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.attachActiveVideoFailureListeners", "returned");
|
|
3156
3245
|
}
|
|
3157
3246
|
handleActiveVideoFailure(video, status, media, operation, category, error) {
|
|
3158
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "called", {
|
|
3247
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "called", {
|
|
3159
3248
|
video,
|
|
3160
3249
|
status,
|
|
3161
3250
|
media,
|
|
@@ -3164,33 +3253,33 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3164
3253
|
error
|
|
3165
3254
|
});
|
|
3166
3255
|
if (this.activeVideo !== video || !this.isCurrent(operation)) {
|
|
3167
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "ignored");
|
|
3256
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "ignored");
|
|
3168
3257
|
return;
|
|
3169
3258
|
}
|
|
3170
3259
|
this.stopActiveVideo();
|
|
3171
3260
|
this.handleFailure(status, media, error, category, operation);
|
|
3172
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "returned");
|
|
3261
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.handleActiveVideoFailure", "returned");
|
|
3173
3262
|
}
|
|
3174
3263
|
detachActiveVideoFailureListeners() {
|
|
3175
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "called");
|
|
3264
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "called");
|
|
3176
3265
|
const cleanup = this.activeVideoListenersCleanup;
|
|
3177
3266
|
this.activeVideoListenersCleanup = null;
|
|
3178
3267
|
cleanup?.();
|
|
3179
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "returned");
|
|
3268
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.detachActiveVideoFailureListeners", "returned");
|
|
3180
3269
|
}
|
|
3181
3270
|
stopActiveVideo() {
|
|
3182
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "called", { activeVideo: this.activeVideo });
|
|
3271
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.stopActiveVideo", "called", { activeVideo: this.activeVideo });
|
|
3183
3272
|
this.detachActiveVideoFailureListeners();
|
|
3184
3273
|
if (!this.activeVideo) {
|
|
3185
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned no active video");
|
|
3274
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned no active video");
|
|
3186
3275
|
return;
|
|
3187
3276
|
}
|
|
3188
3277
|
resetVideo(this.activeVideo);
|
|
3189
3278
|
this.activeVideo = null;
|
|
3190
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned");
|
|
3279
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.stopActiveVideo", "returned");
|
|
3191
3280
|
}
|
|
3192
3281
|
releaseActiveMedia() {
|
|
3193
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "called", {
|
|
3282
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "called", {
|
|
3194
3283
|
activeVideo: this.activeVideo,
|
|
3195
3284
|
activeTgs: this.activeTgs
|
|
3196
3285
|
});
|
|
@@ -3199,10 +3288,10 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3199
3288
|
safeDestroy(this.activeTgs);
|
|
3200
3289
|
this.activeTgs = null;
|
|
3201
3290
|
}
|
|
3202
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "returned");
|
|
3291
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.releaseActiveMedia", "returned");
|
|
3203
3292
|
}
|
|
3204
3293
|
cancelPendingWork() {
|
|
3205
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.cancelPendingWork", "called", {
|
|
3294
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.cancelPendingWork", "called", {
|
|
3206
3295
|
hasLoad: this.loadAbort !== null,
|
|
3207
3296
|
hasPreload: this.preloadAbort !== null,
|
|
3208
3297
|
retryTimer: this.retryTimer
|
|
@@ -3217,11 +3306,11 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3217
3306
|
globalThis.clearTimeout(this.retryTimer);
|
|
3218
3307
|
this.retryTimer = void 0;
|
|
3219
3308
|
}
|
|
3220
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.cancelPendingWork", "returned");
|
|
3309
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.cancelPendingWork", "returned");
|
|
3221
3310
|
}
|
|
3222
3311
|
isCurrent(operation) {
|
|
3223
3312
|
const result = !this.destroyed && !this.paused && operation === this.operation;
|
|
3224
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.isCurrent", "returned", {
|
|
3313
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.isCurrent", "returned", {
|
|
3225
3314
|
operation,
|
|
3226
3315
|
currentOperation: this.operation,
|
|
3227
3316
|
destroyed: this.destroyed,
|
|
@@ -3231,29 +3320,29 @@ var DefaultDrivingExpressionPlayer = class {
|
|
|
3231
3320
|
return result;
|
|
3232
3321
|
}
|
|
3233
3322
|
emitDiagnostic(event) {
|
|
3234
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "called", {
|
|
3323
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.emitDiagnostic", "called", {
|
|
3235
3324
|
event,
|
|
3236
3325
|
hasListener: this.onDiagnostic !== void 0
|
|
3237
3326
|
});
|
|
3238
3327
|
if (!this.onDiagnostic) {
|
|
3239
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned no listener");
|
|
3328
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned no listener");
|
|
3240
3329
|
return;
|
|
3241
3330
|
}
|
|
3242
3331
|
if (invokeSafely(this.onDiagnostic, [event], (error) => {
|
|
3243
|
-
dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "listener threw", error);
|
|
3244
|
-
})) dialSdkDebugWarn(DEBUG_MODULE, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned", { event });
|
|
3332
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.emitDiagnostic", "listener threw", error);
|
|
3333
|
+
})) dialSdkDebugWarn(DEBUG_MODULE$1, "DefaultDrivingExpressionPlayer.emitDiagnostic", "returned", { event });
|
|
3245
3334
|
}
|
|
3246
3335
|
};
|
|
3247
3336
|
var MediaPlayerError = class extends Error {
|
|
3248
3337
|
constructor(category, message) {
|
|
3249
|
-
dialSdkDebugWarn(DEBUG_MODULE, "MediaPlayerError.constructor", "called", {
|
|
3338
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "MediaPlayerError.constructor", "called", {
|
|
3250
3339
|
category,
|
|
3251
3340
|
message
|
|
3252
3341
|
});
|
|
3253
3342
|
super(message);
|
|
3254
3343
|
this.name = "MediaPlayerError";
|
|
3255
3344
|
this.category = category;
|
|
3256
|
-
dialSdkDebugWarn(DEBUG_MODULE, "MediaPlayerError.constructor", "created", { error: this });
|
|
3345
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "MediaPlayerError.constructor", "created", { error: this });
|
|
3257
3346
|
}
|
|
3258
3347
|
};
|
|
3259
3348
|
const SUPPORTED_TGS_CONTENT_TYPES = /* @__PURE__ */ new Set([
|
|
@@ -3268,7 +3357,7 @@ const normalizeMedia = (media) => {
|
|
|
3268
3357
|
kind: "image",
|
|
3269
3358
|
url: media
|
|
3270
3359
|
} : media;
|
|
3271
|
-
dialSdkDebugWarn(DEBUG_MODULE, "normalizeMedia", "returned", {
|
|
3360
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "normalizeMedia", "returned", {
|
|
3272
3361
|
media,
|
|
3273
3362
|
result
|
|
3274
3363
|
});
|
|
@@ -3285,7 +3374,7 @@ const isRetainableImage = (media) => {
|
|
|
3285
3374
|
}
|
|
3286
3375
|
};
|
|
3287
3376
|
const firstInvalidMediaUrl = (media) => {
|
|
3288
|
-
dialSdkDebugWarn(DEBUG_MODULE, "firstInvalidMediaUrl", "called", { media });
|
|
3377
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "firstInvalidMediaUrl", "called", { media });
|
|
3289
3378
|
let values;
|
|
3290
3379
|
switch (media.kind) {
|
|
3291
3380
|
case "emoji":
|
|
@@ -3303,14 +3392,14 @@ const firstInvalidMediaUrl = (media) => {
|
|
|
3303
3392
|
break;
|
|
3304
3393
|
}
|
|
3305
3394
|
const result = values.find((value) => typeof value === "string" && !isPublicDrivingMediaUrl(value)) ?? null;
|
|
3306
|
-
dialSdkDebugWarn(DEBUG_MODULE, "firstInvalidMediaUrl", "returned", {
|
|
3395
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "firstInvalidMediaUrl", "returned", {
|
|
3307
3396
|
values,
|
|
3308
3397
|
result
|
|
3309
3398
|
});
|
|
3310
3399
|
return result;
|
|
3311
3400
|
};
|
|
3312
3401
|
const mediaPreloadHint = (media) => {
|
|
3313
|
-
dialSdkDebugWarn(DEBUG_MODULE, "mediaPreloadHint", "called", { media });
|
|
3402
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "mediaPreloadHint", "called", { media });
|
|
3314
3403
|
let result;
|
|
3315
3404
|
switch (media.kind) {
|
|
3316
3405
|
case "image":
|
|
@@ -3327,11 +3416,11 @@ const mediaPreloadHint = (media) => {
|
|
|
3327
3416
|
result = void 0;
|
|
3328
3417
|
break;
|
|
3329
3418
|
}
|
|
3330
|
-
dialSdkDebugWarn(DEBUG_MODULE, "mediaPreloadHint", "returned", { result });
|
|
3419
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "mediaPreloadHint", "returned", { result });
|
|
3331
3420
|
return result;
|
|
3332
3421
|
};
|
|
3333
3422
|
const waitForElementEvent = (element, successEvent, failureEvent, signal, timeoutMs, start) => {
|
|
3334
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent", "called", {
|
|
3423
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent", "called", {
|
|
3335
3424
|
element,
|
|
3336
3425
|
successEvent,
|
|
3337
3426
|
failureEvent,
|
|
@@ -3341,25 +3430,25 @@ const waitForElementEvent = (element, successEvent, failureEvent, signal, timeou
|
|
|
3341
3430
|
const result = new Promise((resolve, reject) => {
|
|
3342
3431
|
let timer;
|
|
3343
3432
|
const cleanup = () => {
|
|
3344
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.cleanup", "called", { timer });
|
|
3433
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent.cleanup", "called", { timer });
|
|
3345
3434
|
element.removeEventListener(successEvent, handleSuccess);
|
|
3346
3435
|
element.removeEventListener(failureEvent, handleFailure);
|
|
3347
3436
|
signal.removeEventListener("abort", handleAbort);
|
|
3348
3437
|
if (timer !== void 0) globalThis.clearTimeout(timer);
|
|
3349
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.cleanup", "returned");
|
|
3438
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent.cleanup", "returned");
|
|
3350
3439
|
};
|
|
3351
3440
|
const handleSuccess = () => {
|
|
3352
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.handleSuccess", "called", { successEvent });
|
|
3441
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent.handleSuccess", "called", { successEvent });
|
|
3353
3442
|
cleanup();
|
|
3354
3443
|
resolve();
|
|
3355
3444
|
};
|
|
3356
3445
|
const handleFailure = () => {
|
|
3357
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.handleFailure", "called", { failureEvent });
|
|
3446
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent.handleFailure", "called", { failureEvent });
|
|
3358
3447
|
cleanup();
|
|
3359
3448
|
reject(new MediaPlayerError("decode", `${failureEvent} while loading media`));
|
|
3360
3449
|
};
|
|
3361
3450
|
const handleAbort = () => {
|
|
3362
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.handleAbort", "called");
|
|
3451
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent.handleAbort", "called");
|
|
3363
3452
|
cleanup();
|
|
3364
3453
|
reject(createAbortError("Aborted", CREATE_ABORT_ERROR_DEBUG));
|
|
3365
3454
|
};
|
|
@@ -3367,7 +3456,7 @@ const waitForElementEvent = (element, successEvent, failureEvent, signal, timeou
|
|
|
3367
3456
|
element.addEventListener(failureEvent, handleFailure, { once: true });
|
|
3368
3457
|
signal.addEventListener("abort", handleAbort, { once: true });
|
|
3369
3458
|
timer = globalThis.setTimeout(() => {
|
|
3370
|
-
dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent.timeout", "called", { timeoutMs });
|
|
3459
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent.timeout", "called", { timeoutMs });
|
|
3371
3460
|
cleanup();
|
|
3372
3461
|
reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
|
|
3373
3462
|
}, timeoutMs);
|
|
@@ -3378,11 +3467,11 @@ const waitForElementEvent = (element, successEvent, failureEvent, signal, timeou
|
|
|
3378
3467
|
reject(error);
|
|
3379
3468
|
}
|
|
3380
3469
|
});
|
|
3381
|
-
result.then(() => dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent", "resolved"), (error) => dialSdkDebugWarn(DEBUG_MODULE, "waitForElementEvent", "rejected", error));
|
|
3470
|
+
result.then(() => dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent", "resolved"), (error) => dialSdkDebugWarn(DEBUG_MODULE$1, "waitForElementEvent", "rejected", error));
|
|
3382
3471
|
return result;
|
|
3383
3472
|
};
|
|
3384
3473
|
const withTimeout = (promise, timeoutMs, signal) => {
|
|
3385
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout", "called", {
|
|
3474
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout", "called", {
|
|
3386
3475
|
promise,
|
|
3387
3476
|
timeoutMs,
|
|
3388
3477
|
signal
|
|
@@ -3390,37 +3479,37 @@ const withTimeout = (promise, timeoutMs, signal) => {
|
|
|
3390
3479
|
const result = new Promise((resolve, reject) => {
|
|
3391
3480
|
let timer;
|
|
3392
3481
|
const cleanup = () => {
|
|
3393
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.cleanup", "called", { timer });
|
|
3482
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout.cleanup", "called", { timer });
|
|
3394
3483
|
signal.removeEventListener("abort", handleAbort);
|
|
3395
3484
|
if (timer !== void 0) globalThis.clearTimeout(timer);
|
|
3396
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.cleanup", "returned");
|
|
3485
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout.cleanup", "returned");
|
|
3397
3486
|
};
|
|
3398
3487
|
const handleAbort = () => {
|
|
3399
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.handleAbort", "called");
|
|
3488
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout.handleAbort", "called");
|
|
3400
3489
|
cleanup();
|
|
3401
3490
|
reject(createAbortError("Aborted", CREATE_ABORT_ERROR_DEBUG));
|
|
3402
3491
|
};
|
|
3403
3492
|
signal.addEventListener("abort", handleAbort, { once: true });
|
|
3404
3493
|
timer = globalThis.setTimeout(() => {
|
|
3405
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.timeout", "called", { timeoutMs });
|
|
3494
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout.timeout", "called", { timeoutMs });
|
|
3406
3495
|
cleanup();
|
|
3407
3496
|
reject(new MediaPlayerError("timeout", `media load timed out after ${timeoutMs}ms`));
|
|
3408
3497
|
}, timeoutMs);
|
|
3409
3498
|
promise.then((value) => {
|
|
3410
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.promiseResolved", "called", { value });
|
|
3499
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout.promiseResolved", "called", { value });
|
|
3411
3500
|
cleanup();
|
|
3412
3501
|
resolve(value);
|
|
3413
3502
|
}, (error) => {
|
|
3414
|
-
dialSdkDebugWarn(DEBUG_MODULE, "withTimeout.promiseRejected", "called", { error });
|
|
3503
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout.promiseRejected", "called", { error });
|
|
3415
3504
|
cleanup();
|
|
3416
3505
|
reject(error);
|
|
3417
3506
|
});
|
|
3418
3507
|
});
|
|
3419
|
-
result.then((value) => dialSdkDebugWarn(DEBUG_MODULE, "withTimeout", "resolved", { value }), (error) => dialSdkDebugWarn(DEBUG_MODULE, "withTimeout", "rejected", error));
|
|
3508
|
+
result.then((value) => dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout", "resolved", { value }), (error) => dialSdkDebugWarn(DEBUG_MODULE$1, "withTimeout", "rejected", error));
|
|
3420
3509
|
return result;
|
|
3421
3510
|
};
|
|
3422
3511
|
const defaultTgsRenderer = async (container, animationData, signal) => {
|
|
3423
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer", "called", {
|
|
3512
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer", "called", {
|
|
3424
3513
|
container,
|
|
3425
3514
|
animationData,
|
|
3426
3515
|
signal
|
|
@@ -3438,27 +3527,27 @@ const defaultTgsRenderer = async (container, animationData, signal) => {
|
|
|
3438
3527
|
});
|
|
3439
3528
|
await new Promise((resolve, reject) => {
|
|
3440
3529
|
const ready = () => {
|
|
3441
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.ready", "called");
|
|
3530
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.ready", "called");
|
|
3442
3531
|
cleanup();
|
|
3443
3532
|
resolve();
|
|
3444
3533
|
};
|
|
3445
3534
|
const failed = () => {
|
|
3446
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.failed", "called");
|
|
3535
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.failed", "called");
|
|
3447
3536
|
cleanup();
|
|
3448
3537
|
reject(new MediaPlayerError("decode", "Lottie could not initialize the TGS animation"));
|
|
3449
3538
|
};
|
|
3450
3539
|
const aborted = () => {
|
|
3451
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.aborted", "called");
|
|
3540
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.aborted", "called");
|
|
3452
3541
|
cleanup();
|
|
3453
3542
|
animation.destroy();
|
|
3454
3543
|
reject(createAbortError("Aborted", CREATE_ABORT_ERROR_DEBUG));
|
|
3455
3544
|
};
|
|
3456
3545
|
const cleanup = () => {
|
|
3457
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.cleanup", "called");
|
|
3546
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.cleanup", "called");
|
|
3458
3547
|
animation.removeEventListener("DOMLoaded", ready);
|
|
3459
3548
|
animation.removeEventListener("data_failed", failed);
|
|
3460
3549
|
signal.removeEventListener("abort", aborted);
|
|
3461
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.cleanup", "returned");
|
|
3550
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.cleanup", "returned");
|
|
3462
3551
|
};
|
|
3463
3552
|
animation.addEventListener("DOMLoaded", ready);
|
|
3464
3553
|
animation.addEventListener("data_failed", failed);
|
|
@@ -3466,27 +3555,27 @@ const defaultTgsRenderer = async (container, animationData, signal) => {
|
|
|
3466
3555
|
});
|
|
3467
3556
|
const result = {
|
|
3468
3557
|
destroy: () => {
|
|
3469
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.destroy", "called");
|
|
3558
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.handle.destroy", "called");
|
|
3470
3559
|
animation.destroy();
|
|
3471
3560
|
},
|
|
3472
3561
|
pause: () => {
|
|
3473
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.pause", "called");
|
|
3562
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.handle.pause", "called");
|
|
3474
3563
|
animation.pause();
|
|
3475
3564
|
},
|
|
3476
3565
|
play: () => {
|
|
3477
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.play", "called");
|
|
3566
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.handle.play", "called");
|
|
3478
3567
|
animation.play();
|
|
3479
3568
|
},
|
|
3480
3569
|
restart: () => {
|
|
3481
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer.handle.restart", "called");
|
|
3570
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer.handle.restart", "called");
|
|
3482
3571
|
animation.goToAndPlay(0, true);
|
|
3483
3572
|
}
|
|
3484
3573
|
};
|
|
3485
|
-
dialSdkDebugWarn(DEBUG_MODULE, "defaultTgsRenderer", "resolved", { result });
|
|
3574
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "defaultTgsRenderer", "resolved", { result });
|
|
3486
3575
|
return result;
|
|
3487
3576
|
};
|
|
3488
3577
|
function validateTgsAnimation(value, maxLayers) {
|
|
3489
|
-
dialSdkDebugWarn(DEBUG_MODULE, "validateTgsAnimation", "called", {
|
|
3578
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "validateTgsAnimation", "called", {
|
|
3490
3579
|
value,
|
|
3491
3580
|
maxLayers
|
|
3492
3581
|
});
|
|
@@ -3494,10 +3583,10 @@ function validateTgsAnimation(value, maxLayers) {
|
|
|
3494
3583
|
if (value.layers.length > maxLayers) throw new MediaPlayerError("decode", "TGS animation has too many layers");
|
|
3495
3584
|
if (typeof value.fr === "number" && (!Number.isFinite(value.fr) || value.fr <= 0 || value.fr > 120)) throw new MediaPlayerError("decode", "TGS animation frame rate is outside the supported range");
|
|
3496
3585
|
if (typeof value.ip === "number" && typeof value.op === "number" && (value.op <= value.ip || value.op - value.ip > 3e4)) throw new MediaPlayerError("decode", "TGS animation duration is outside the supported range");
|
|
3497
|
-
dialSdkDebugWarn(DEBUG_MODULE, "validateTgsAnimation", "returned");
|
|
3586
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "validateTgsAnimation", "returned");
|
|
3498
3587
|
}
|
|
3499
3588
|
const gunzipWithLimit = (compressed, maxOutputBytes) => {
|
|
3500
|
-
dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "called", {
|
|
3589
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "gunzipWithLimit", "called", {
|
|
3501
3590
|
compressed,
|
|
3502
3591
|
maxOutputBytes
|
|
3503
3592
|
});
|
|
@@ -3507,7 +3596,7 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
|
|
|
3507
3596
|
let outputBytes = 0;
|
|
3508
3597
|
try {
|
|
3509
3598
|
const gunzip = new Gunzip((chunk) => {
|
|
3510
|
-
dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit.onChunk", "called", {
|
|
3599
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "gunzipWithLimit.onChunk", "called", {
|
|
3511
3600
|
chunk,
|
|
3512
3601
|
outputBytes,
|
|
3513
3602
|
maxOutputBytes
|
|
@@ -3522,10 +3611,10 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
|
|
|
3522
3611
|
gunzip.push(compressed.subarray(offset, end), end === compressed.byteLength);
|
|
3523
3612
|
}
|
|
3524
3613
|
} catch (error) {
|
|
3525
|
-
dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "caught error", error);
|
|
3614
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "gunzipWithLimit", "caught error", error);
|
|
3526
3615
|
if (error instanceof MediaPlayerError) throw error;
|
|
3527
3616
|
const wrapped = new MediaPlayerError("decode", "TGS gzip decompression failed");
|
|
3528
|
-
dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "threw", wrapped);
|
|
3617
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "gunzipWithLimit", "threw", wrapped);
|
|
3529
3618
|
throw wrapped;
|
|
3530
3619
|
}
|
|
3531
3620
|
const output = new Uint8Array(outputBytes);
|
|
@@ -3534,22 +3623,22 @@ const gunzipWithLimit = (compressed, maxOutputBytes) => {
|
|
|
3534
3623
|
output.set(chunk, offset);
|
|
3535
3624
|
offset += chunk.byteLength;
|
|
3536
3625
|
}
|
|
3537
|
-
dialSdkDebugWarn(DEBUG_MODULE, "gunzipWithLimit", "returned", {
|
|
3626
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "gunzipWithLimit", "returned", {
|
|
3538
3627
|
output,
|
|
3539
3628
|
outputBytes
|
|
3540
3629
|
});
|
|
3541
3630
|
return output;
|
|
3542
3631
|
};
|
|
3543
3632
|
const resetVideo = (video) => {
|
|
3544
|
-
dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "called", { video });
|
|
3633
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "resetVideo", "called", { video });
|
|
3545
3634
|
video.pause();
|
|
3546
3635
|
video.removeAttribute("src");
|
|
3547
3636
|
video.removeAttribute("type");
|
|
3548
3637
|
video.load();
|
|
3549
|
-
dialSdkDebugWarn(DEBUG_MODULE, "resetVideo", "returned", { video });
|
|
3638
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "resetVideo", "returned", { video });
|
|
3550
3639
|
};
|
|
3551
3640
|
const styleMediaElement = (element, fit) => {
|
|
3552
|
-
dialSdkDebugWarn(DEBUG_MODULE, "styleMediaElement", "called", {
|
|
3641
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "styleMediaElement", "called", {
|
|
3553
3642
|
element,
|
|
3554
3643
|
fit
|
|
3555
3644
|
});
|
|
@@ -3561,27 +3650,27 @@ const styleMediaElement = (element, fit) => {
|
|
|
3561
3650
|
objectFit: fit,
|
|
3562
3651
|
width: "100%"
|
|
3563
3652
|
});
|
|
3564
|
-
dialSdkDebugWarn(DEBUG_MODULE, "styleMediaElement", "returned", { element });
|
|
3653
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "styleMediaElement", "returned", { element });
|
|
3565
3654
|
};
|
|
3566
3655
|
const categorizeMediaError = (error) => {
|
|
3567
3656
|
const result = error instanceof MediaPlayerError ? error.category : error instanceof TypeError ? "network" : "decode";
|
|
3568
|
-
dialSdkDebugWarn(DEBUG_MODULE, "categorizeMediaError", "returned", {
|
|
3657
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "categorizeMediaError", "returned", {
|
|
3569
3658
|
error,
|
|
3570
3659
|
result
|
|
3571
3660
|
});
|
|
3572
3661
|
return result;
|
|
3573
3662
|
};
|
|
3574
3663
|
const safeErrorMessage = (error) => {
|
|
3575
|
-
dialSdkDebugWarn(DEBUG_MODULE, "safeErrorMessage", "called", { error });
|
|
3664
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "safeErrorMessage", "called", { error });
|
|
3576
3665
|
const message = error instanceof Error ? error.message : String(error);
|
|
3577
3666
|
const result = redactUrlQueries(message).slice(0, 240);
|
|
3578
|
-
dialSdkDebugWarn(DEBUG_MODULE, "safeErrorMessage", "returned", { result });
|
|
3667
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "safeErrorMessage", "returned", { result });
|
|
3579
3668
|
return result;
|
|
3580
3669
|
};
|
|
3581
3670
|
const redactUrlQueries = (message) => {
|
|
3582
|
-
dialSdkDebugWarn(DEBUG_MODULE, "redactUrlQueries", "called", { message });
|
|
3671
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "redactUrlQueries", "called", { message });
|
|
3583
3672
|
const result = message.replace(/https:\/\/[^\s"'<>]+/gu, (candidate) => {
|
|
3584
|
-
dialSdkDebugWarn(DEBUG_MODULE, "redactUrlQueries.replace", "called", { candidate });
|
|
3673
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "redactUrlQueries.replace", "called", { candidate });
|
|
3585
3674
|
try {
|
|
3586
3675
|
const url = new URL(candidate);
|
|
3587
3676
|
return `${url.origin}${url.pathname}`;
|
|
@@ -3589,17 +3678,311 @@ const redactUrlQueries = (message) => {
|
|
|
3589
3678
|
return "[url]";
|
|
3590
3679
|
}
|
|
3591
3680
|
});
|
|
3592
|
-
dialSdkDebugWarn(DEBUG_MODULE, "redactUrlQueries", "returned", { result });
|
|
3681
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "redactUrlQueries", "returned", { result });
|
|
3593
3682
|
return result;
|
|
3594
3683
|
};
|
|
3595
3684
|
const safeDestroy = (handle) => {
|
|
3596
|
-
dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "called", { handle });
|
|
3685
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "safeDestroy", "called", { handle });
|
|
3597
3686
|
try {
|
|
3598
3687
|
handle.destroy();
|
|
3599
|
-
dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "returned");
|
|
3688
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "safeDestroy", "returned");
|
|
3600
3689
|
} catch (error) {
|
|
3601
|
-
dialSdkDebugWarn(DEBUG_MODULE, "safeDestroy", "destroy threw", error);
|
|
3690
|
+
dialSdkDebugWarn(DEBUG_MODULE$1, "safeDestroy", "destroy threw", error);
|
|
3691
|
+
}
|
|
3692
|
+
};
|
|
3693
|
+
//#endregion
|
|
3694
|
+
//#region src/bridge/native_multimedia_bridge.ts
|
|
3695
|
+
const getAndroidCarBridge = () => window.AndroidCarBridge;
|
|
3696
|
+
const resolveNativeMultimediaBridgeProtocol = () => {
|
|
3697
|
+
return typeof getAndroidCarBridge().onBridgeLifecycle === "function" ? "lifecycle" : "legacy";
|
|
3698
|
+
};
|
|
3699
|
+
const notifyNativeMultimediaBridgeReady = (instanceId, protocol) => {
|
|
3700
|
+
const bridge = getAndroidCarBridge();
|
|
3701
|
+
const version = `dial-sdk@0.0.17`;
|
|
3702
|
+
if (protocol === "lifecycle" && typeof bridge.onBridgeLifecycle === "function") {
|
|
3703
|
+
bridge.onBridgeLifecycle(JSON.stringify({
|
|
3704
|
+
event: "ready",
|
|
3705
|
+
instanceId,
|
|
3706
|
+
version
|
|
3707
|
+
}));
|
|
3708
|
+
return;
|
|
3709
|
+
}
|
|
3710
|
+
bridge.onBridgeReady(version);
|
|
3711
|
+
};
|
|
3712
|
+
const notifyNativeMultimediaBridgeDestroyed = (instanceId, protocol) => {
|
|
3713
|
+
if (protocol !== "lifecycle") return;
|
|
3714
|
+
const bridge = getAndroidCarBridge();
|
|
3715
|
+
if (typeof bridge.onBridgeLifecycle !== "function") return;
|
|
3716
|
+
bridge.onBridgeLifecycle(JSON.stringify({
|
|
3717
|
+
event: "destroyed",
|
|
3718
|
+
instanceId
|
|
3719
|
+
}));
|
|
3720
|
+
};
|
|
3721
|
+
const reportNativeMultimediaState = (state) => {
|
|
3722
|
+
getAndroidCarBridge().onPlayerState(JSON.stringify({
|
|
3723
|
+
isPlaying: state.isPlaying,
|
|
3724
|
+
title: state.title,
|
|
3725
|
+
artist: state.artist,
|
|
3726
|
+
canNext: state.canNext,
|
|
3727
|
+
canPrevious: state.canPrevious
|
|
3728
|
+
}));
|
|
3729
|
+
};
|
|
3730
|
+
const logNativeMultimediaBridge = (level, message) => {
|
|
3731
|
+
try {
|
|
3732
|
+
getAndroidCarBridge().log(level, message);
|
|
3733
|
+
return true;
|
|
3734
|
+
} catch {
|
|
3735
|
+
return false;
|
|
3736
|
+
}
|
|
3737
|
+
};
|
|
3738
|
+
//#endregion
|
|
3739
|
+
//#region src/multimedia/multimedia_controller.ts
|
|
3740
|
+
const DEBUG_MODULE = "multimedia_controller.ts";
|
|
3741
|
+
const DEFAULT_REPORT_INTERVAL_MS = 1e3;
|
|
3742
|
+
const REPORT_INTERVAL_DEBUG = {
|
|
3743
|
+
moduleName: DEBUG_MODULE,
|
|
3744
|
+
scope: "reportIntervalMs"
|
|
3745
|
+
};
|
|
3746
|
+
var MultimediaBridgeError = class extends Error {
|
|
3747
|
+
constructor(code, message, cause) {
|
|
3748
|
+
super(message);
|
|
3749
|
+
this.name = "MultimediaBridgeError";
|
|
3750
|
+
this.code = code;
|
|
3751
|
+
this.cause = cause;
|
|
3752
|
+
}
|
|
3753
|
+
};
|
|
3754
|
+
let activeController = null;
|
|
3755
|
+
let multimediaBridgeInstanceSequence = 0;
|
|
3756
|
+
const createMultimediaBridgeInstanceId = () => {
|
|
3757
|
+
multimediaBridgeInstanceSequence += 1;
|
|
3758
|
+
return `media-${Date.now().toString(36)}-${multimediaBridgeInstanceSequence.toString(36)}-${Math.random().toString(36).slice(2, 12)}`;
|
|
3759
|
+
};
|
|
3760
|
+
const createMultimediaController = (options) => {
|
|
3761
|
+
dialSdkDebugWarn(DEBUG_MODULE, "createMultimediaController", "called", { options });
|
|
3762
|
+
const controller = new MultimediaController(options);
|
|
3763
|
+
dialSdkDebugWarn(DEBUG_MODULE, "createMultimediaController", "returned");
|
|
3764
|
+
return controller;
|
|
3765
|
+
};
|
|
3766
|
+
var MultimediaController = class {
|
|
3767
|
+
constructor(options) {
|
|
3768
|
+
this.bridgeInstanceId = createMultimediaBridgeInstanceId();
|
|
3769
|
+
this.reportTimer = null;
|
|
3770
|
+
this.bridgeProtocol = null;
|
|
3771
|
+
this.lastKnownState = {
|
|
3772
|
+
isPlaying: false,
|
|
3773
|
+
title: "",
|
|
3774
|
+
artist: "",
|
|
3775
|
+
canNext: false,
|
|
3776
|
+
canPrevious: false
|
|
3777
|
+
};
|
|
3778
|
+
this.destroyed = false;
|
|
3779
|
+
this.handleMediaCommand = (event) => {
|
|
3780
|
+
if (this.destroyed) return;
|
|
3781
|
+
const detail = event.detail;
|
|
3782
|
+
if (!detail || typeof detail !== "object") return;
|
|
3783
|
+
const command = detail.command;
|
|
3784
|
+
if (!this.isMultimediaCommand(command)) return;
|
|
3785
|
+
if (command === "seekToMs") this.dispatchControl(command, detail.positionMs);
|
|
3786
|
+
else this.dispatchControl(command);
|
|
3787
|
+
};
|
|
3788
|
+
this.handleMediaStateRequest = () => {
|
|
3789
|
+
this.reportState();
|
|
3790
|
+
};
|
|
3791
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.constructor", "called", { options });
|
|
3792
|
+
if (activeController !== null) {
|
|
3793
|
+
const error = new MultimediaBridgeError("MULTIMEDIA_BRIDGE_CONFLICT", "A multimedia controller is already active in this window");
|
|
3794
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.constructor", "threw", error);
|
|
3795
|
+
throw error;
|
|
3796
|
+
}
|
|
3797
|
+
this.assertOptions(options);
|
|
3798
|
+
this.runtimeWindow = window;
|
|
3799
|
+
if ("__carBridge" in this.runtimeWindow) {
|
|
3800
|
+
const error = new MultimediaBridgeError("MULTIMEDIA_BRIDGE_CONFLICT", "window.__carBridge already exists; destroy the existing media bridge before creating a controller");
|
|
3801
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.constructor", "threw", error);
|
|
3802
|
+
throw error;
|
|
3803
|
+
}
|
|
3804
|
+
this.getStateProvider = options.getState;
|
|
3805
|
+
this.controls = options.controls;
|
|
3806
|
+
this.reportIntervalMs = requirePositiveFinite("reportIntervalMs", options.reportIntervalMs ?? DEFAULT_REPORT_INTERVAL_MS, REPORT_INTERVAL_DEBUG);
|
|
3807
|
+
this.runtimeBridge = {
|
|
3808
|
+
play: () => this.dispatchControl("play"),
|
|
3809
|
+
pause: () => this.dispatchControl("pause"),
|
|
3810
|
+
toggle: () => this.dispatchControl("toggle"),
|
|
3811
|
+
next: () => this.dispatchControl("next"),
|
|
3812
|
+
previous: () => this.dispatchControl("previous"),
|
|
3813
|
+
seekToMs: (positionMs) => this.dispatchControl("seekToMs", positionMs),
|
|
3814
|
+
getState: () => this.readState()
|
|
3815
|
+
};
|
|
3816
|
+
activeController = this;
|
|
3817
|
+
try {
|
|
3818
|
+
const initialState = this.readState();
|
|
3819
|
+
this.lastKnownState = initialState;
|
|
3820
|
+
this.runtimeWindow.__carBridge = this.runtimeBridge;
|
|
3821
|
+
this.runtimeWindow.addEventListener("toooony:media-command", this.handleMediaCommand);
|
|
3822
|
+
this.runtimeWindow.addEventListener("toooony:media-state-request", this.handleMediaStateRequest);
|
|
3823
|
+
this.bridgeProtocol = resolveNativeMultimediaBridgeProtocol();
|
|
3824
|
+
notifyNativeMultimediaBridgeReady(this.bridgeInstanceId, this.bridgeProtocol);
|
|
3825
|
+
logNativeMultimediaBridge("INFO", "Dial SDK multimedia bridge initialized");
|
|
3826
|
+
this.reportInitialState(initialState);
|
|
3827
|
+
} catch (error) {
|
|
3828
|
+
if (activeController === this) activeController = null;
|
|
3829
|
+
this.closeNativeBridge();
|
|
3830
|
+
this.cleanupInstalledResources();
|
|
3831
|
+
const wrapped = new MultimediaBridgeError("MULTIMEDIA_BRIDGE_INITIALIZATION_FAILED", "Failed to initialize the multimedia bridge", error);
|
|
3832
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.constructor", "threw", wrapped);
|
|
3833
|
+
throw wrapped;
|
|
3834
|
+
}
|
|
3835
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.constructor", "created", { reportIntervalMs: this.reportIntervalMs });
|
|
3836
|
+
}
|
|
3837
|
+
reportState() {
|
|
3838
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.reportState", "called");
|
|
3839
|
+
if (this.destroyed) {
|
|
3840
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.reportState", "ignored after destroy");
|
|
3841
|
+
return false;
|
|
3842
|
+
}
|
|
3843
|
+
try {
|
|
3844
|
+
const state = this.readState();
|
|
3845
|
+
this.lastKnownState = state;
|
|
3846
|
+
this.syncHeartbeat(state.isPlaying);
|
|
3847
|
+
reportNativeMultimediaState(state);
|
|
3848
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.reportState", "returned", {
|
|
3849
|
+
result: true,
|
|
3850
|
+
state
|
|
3851
|
+
});
|
|
3852
|
+
return true;
|
|
3853
|
+
} catch (error) {
|
|
3854
|
+
this.reportFailure("state report failed", error);
|
|
3855
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.reportState", "returned", { result: false });
|
|
3856
|
+
return false;
|
|
3857
|
+
}
|
|
3858
|
+
}
|
|
3859
|
+
destroy() {
|
|
3860
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.destroy", "called", { destroyed: this.destroyed });
|
|
3861
|
+
if (this.destroyed) {
|
|
3862
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.destroy", "ignored");
|
|
3863
|
+
return;
|
|
3864
|
+
}
|
|
3865
|
+
this.destroyed = true;
|
|
3866
|
+
this.closeNativeBridge();
|
|
3867
|
+
this.cleanupInstalledResources();
|
|
3868
|
+
if (activeController === this) activeController = null;
|
|
3869
|
+
logNativeMultimediaBridge("INFO", "Dial SDK multimedia bridge destroyed");
|
|
3870
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.destroy", "returned");
|
|
3871
|
+
}
|
|
3872
|
+
assertOptions(options) {
|
|
3873
|
+
if (!options || typeof options !== "object") throw new TypeError("options must be an object");
|
|
3874
|
+
if (typeof options.getState !== "function") throw new TypeError("getState must be a function");
|
|
3875
|
+
if (!options.controls || typeof options.controls !== "object") throw new TypeError("controls must be an object");
|
|
3876
|
+
if (typeof options.controls.play !== "function") throw new TypeError("controls.play must be a function");
|
|
3877
|
+
if (typeof options.controls.pause !== "function") throw new TypeError("controls.pause must be a function");
|
|
3878
|
+
for (const name of [
|
|
3879
|
+
"toggle",
|
|
3880
|
+
"next",
|
|
3881
|
+
"previous",
|
|
3882
|
+
"seekToMs"
|
|
3883
|
+
]) {
|
|
3884
|
+
const control = options.controls[name];
|
|
3885
|
+
if (control !== void 0 && typeof control !== "function") throw new TypeError(`controls.${name} must be a function when provided`);
|
|
3886
|
+
}
|
|
3887
|
+
}
|
|
3888
|
+
readState() {
|
|
3889
|
+
const state = this.getStateProvider();
|
|
3890
|
+
if (!state || typeof state !== "object") throw new TypeError("getState must return a multimedia player state");
|
|
3891
|
+
if (typeof state.isPlaying !== "boolean") throw new TypeError("state.isPlaying must be a boolean");
|
|
3892
|
+
if (typeof state.title !== "string") throw new TypeError("state.title must be a string");
|
|
3893
|
+
if (typeof state.artist !== "string") throw new TypeError("state.artist must be a string");
|
|
3894
|
+
if (typeof state.canNext !== "boolean") throw new TypeError("state.canNext must be a boolean");
|
|
3895
|
+
if (typeof state.canPrevious !== "boolean") throw new TypeError("state.canPrevious must be a boolean");
|
|
3896
|
+
return {
|
|
3897
|
+
isPlaying: state.isPlaying,
|
|
3898
|
+
title: state.title,
|
|
3899
|
+
artist: state.artist,
|
|
3900
|
+
canNext: state.canNext,
|
|
3901
|
+
canPrevious: state.canPrevious
|
|
3902
|
+
};
|
|
3903
|
+
}
|
|
3904
|
+
reportInitialState(state) {
|
|
3905
|
+
this.syncHeartbeat(state.isPlaying);
|
|
3906
|
+
reportNativeMultimediaState(state);
|
|
3907
|
+
}
|
|
3908
|
+
dispatchControl(command, rawPositionMs) {
|
|
3909
|
+
if (this.destroyed) return;
|
|
3910
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController.dispatchControl", "called", {
|
|
3911
|
+
command,
|
|
3912
|
+
positionMs: rawPositionMs
|
|
3913
|
+
});
|
|
3914
|
+
try {
|
|
3915
|
+
let result;
|
|
3916
|
+
switch (command) {
|
|
3917
|
+
case "play":
|
|
3918
|
+
result = this.controls.play();
|
|
3919
|
+
break;
|
|
3920
|
+
case "pause":
|
|
3921
|
+
result = this.controls.pause();
|
|
3922
|
+
break;
|
|
3923
|
+
case "toggle":
|
|
3924
|
+
result = this.controls.toggle ? this.controls.toggle() : this.readState().isPlaying ? this.controls.pause() : this.controls.play();
|
|
3925
|
+
break;
|
|
3926
|
+
case "next":
|
|
3927
|
+
result = this.controls.next?.();
|
|
3928
|
+
break;
|
|
3929
|
+
case "previous":
|
|
3930
|
+
result = this.controls.previous?.();
|
|
3931
|
+
break;
|
|
3932
|
+
case "seekToMs":
|
|
3933
|
+
if (typeof rawPositionMs !== "number" || !Number.isFinite(rawPositionMs) || rawPositionMs < 0) {
|
|
3934
|
+
this.reportFailure("ignored invalid seekToMs position", rawPositionMs);
|
|
3935
|
+
return;
|
|
3936
|
+
}
|
|
3937
|
+
result = this.controls.seekToMs?.(rawPositionMs);
|
|
3938
|
+
break;
|
|
3939
|
+
}
|
|
3940
|
+
Promise.resolve(result).then(() => {
|
|
3941
|
+
if (!this.destroyed) this.reportState();
|
|
3942
|
+
}, (error) => this.reportFailure(`media command ${command} failed`, error));
|
|
3943
|
+
} catch (error) {
|
|
3944
|
+
this.reportFailure(`media command ${command} failed`, error);
|
|
3945
|
+
}
|
|
3946
|
+
}
|
|
3947
|
+
syncHeartbeat(isPlaying) {
|
|
3948
|
+
if (isPlaying) {
|
|
3949
|
+
if (this.reportTimer === null) this.reportTimer = globalThis.setInterval(() => this.reportState(), this.reportIntervalMs);
|
|
3950
|
+
return;
|
|
3951
|
+
}
|
|
3952
|
+
this.stopHeartbeat();
|
|
3953
|
+
}
|
|
3954
|
+
stopHeartbeat() {
|
|
3955
|
+
if (this.reportTimer === null) return;
|
|
3956
|
+
globalThis.clearInterval(this.reportTimer);
|
|
3957
|
+
this.reportTimer = null;
|
|
3958
|
+
}
|
|
3959
|
+
cleanupInstalledResources() {
|
|
3960
|
+
this.stopHeartbeat();
|
|
3961
|
+
this.runtimeWindow.removeEventListener("toooony:media-command", this.handleMediaCommand);
|
|
3962
|
+
this.runtimeWindow.removeEventListener("toooony:media-state-request", this.handleMediaStateRequest);
|
|
3963
|
+
if (this.runtimeWindow.__carBridge === this.runtimeBridge) Reflect.deleteProperty(this.runtimeWindow, "__carBridge");
|
|
3964
|
+
}
|
|
3965
|
+
closeNativeBridge() {
|
|
3966
|
+
const protocol = this.bridgeProtocol;
|
|
3967
|
+
if (protocol === null) return;
|
|
3968
|
+
this.bridgeProtocol = null;
|
|
3969
|
+
try {
|
|
3970
|
+
if (protocol === "lifecycle") notifyNativeMultimediaBridgeDestroyed(this.bridgeInstanceId, protocol);
|
|
3971
|
+
else reportNativeMultimediaState({
|
|
3972
|
+
...this.lastKnownState,
|
|
3973
|
+
isPlaying: false
|
|
3974
|
+
});
|
|
3975
|
+
} catch (error) {
|
|
3976
|
+
this.reportFailure("media bridge destroy notification failed", error);
|
|
3977
|
+
}
|
|
3978
|
+
}
|
|
3979
|
+
reportFailure(message, error) {
|
|
3980
|
+
dialSdkDebugWarn(DEBUG_MODULE, "MultimediaController", message, { error });
|
|
3981
|
+
logNativeMultimediaBridge("ERROR", `${message}: ${error instanceof Error ? `${error.name}: ${error.message}` : String(error)}`);
|
|
3982
|
+
}
|
|
3983
|
+
isMultimediaCommand(value) {
|
|
3984
|
+
return value === "play" || value === "pause" || value === "toggle" || value === "next" || value === "previous" || value === "seekToMs";
|
|
3602
3985
|
}
|
|
3603
3986
|
};
|
|
3604
3987
|
//#endregion
|
|
3605
|
-
export { BATTERY_HEALTH_LABELS, CAR_RUNNING_LABELS, CAR_RUNNING_STATUSES, CAR_RUNNING_STATUS_PRIORITY, DEFAULT_DRIVING_STATUS_TUNING, DrivingExpressionResolutionError, DrivingExpressionsConfigError, OFFICIAL_DRIVING_EXPRESSIONS_CONFIG, OFFICIAL_DRIVING_EXPRESSION_FALLBACKS, buildVehicleFrame, classifyDrivingSnapshot, createDrivingExpressionPlayer, createDrivingStatusController, extractDrivingSnapshotMetrics, isPublicDrivingMediaUrl, parseDrivingExpressionsConfig, readDrivingExpressionsConfig, resolveDrivingExpression, resolveDrivingExpressionStrict, resolveDrivingStatusTuning, tryParseDrivingExpressionsConfig, unifiedSensorInfo, waitForDrivingExpressionsConfig };
|
|
3988
|
+
export { BATTERY_HEALTH_LABELS, CAR_RUNNING_LABELS, CAR_RUNNING_STATUSES, CAR_RUNNING_STATUS_PRIORITY, DEFAULT_DRIVING_STATUS_TUNING, DrivingExpressionResolutionError, DrivingExpressionsConfigError, DrivingStatusController, MultimediaBridgeError, MultimediaController, OFFICIAL_DRIVING_EXPRESSIONS_CONFIG, OFFICIAL_DRIVING_EXPRESSION_FALLBACKS, buildVehicleFrame, classifyDrivingSnapshot, createDrivingExpressionPlayer, createDrivingStatusController, createMultimediaController, extractDrivingSnapshotMetrics, isPublicDrivingMediaUrl, parseDrivingExpressionsConfig, readDrivingExpressionsConfig, resolveDrivingExpression, resolveDrivingExpressionStrict, resolveDrivingStatusTuning, tryParseDrivingExpressionsConfig, unifiedSensorInfo, waitForDrivingExpressionsConfig };
|