@xiboplayer/xmds 0.7.2 → 0.7.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/src/rest-client.js +5 -17
- package/src/status-enrichment.js +29 -0
- package/src/xmds-client.js +2 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xiboplayer/xmds",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.4",
|
|
4
4
|
"description": "XMDS SOAP client for Xibo CMS communication",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"./schedule-parser": "./src/schedule-parser.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@xiboplayer/utils": "0.7.
|
|
15
|
+
"@xiboplayer/utils": "0.7.4"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"vitest": "^2.
|
|
18
|
+
"vitest": "^2.1.9"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"xibo",
|
package/src/rest-client.js
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
* Same public API as XmdsClient — drop-in replacement.
|
|
16
16
|
*/
|
|
17
17
|
import { createLogger, fetchWithRetry, PLAYER_API } from '@xiboplayer/utils';
|
|
18
|
+
import { enrichStatus } from './status-enrichment.js';
|
|
18
19
|
|
|
19
20
|
const log = createLogger('REST');
|
|
20
21
|
|
|
@@ -441,21 +442,7 @@ export class RestClient {
|
|
|
441
442
|
* PUT /displays/{id}/status → JSON acknowledgement
|
|
442
443
|
*/
|
|
443
444
|
async notifyStatus(status) {
|
|
444
|
-
|
|
445
|
-
try {
|
|
446
|
-
const estimate = await navigator.storage.estimate();
|
|
447
|
-
status.availableSpace = estimate.quota - estimate.usage;
|
|
448
|
-
status.totalSpace = estimate.quota;
|
|
449
|
-
} catch (_) { /* storage estimate not supported */ }
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
if (!status.timeZone && typeof Intl !== 'undefined') {
|
|
453
|
-
status.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
if (!status.statusDialog) {
|
|
457
|
-
status.statusDialog = `Current Layout: ${status.currentLayoutId || 'None'}`;
|
|
458
|
-
}
|
|
445
|
+
await enrichStatus(status);
|
|
459
446
|
|
|
460
447
|
return this.restSend('PUT', `/displays/${this._displayId}/status`, {
|
|
461
448
|
statusData: status,
|
|
@@ -556,9 +543,10 @@ export class RestClient {
|
|
|
556
543
|
(window.electronAPI?.isElectron || window.location.hostname === 'localhost');
|
|
557
544
|
const base = isProxy ? '' : cmsUrl.replace(/\/+$/, '');
|
|
558
545
|
const url = `${base}${PLAYER_API}/health`;
|
|
559
|
-
const timeoutMs = retryOptions?.timeoutMs ||
|
|
546
|
+
const timeoutMs = retryOptions?.timeoutMs || 8000;
|
|
560
547
|
const fetchOptions = { method: 'GET' };
|
|
561
|
-
// Apply timeout via AbortSignal (
|
|
548
|
+
// Apply timeout via AbortSignal (generous on first probe — TLS cold start
|
|
549
|
+
// from the proxy to the CMS can take 5-6s on first connection)
|
|
562
550
|
if (typeof AbortSignal !== 'undefined' && AbortSignal.timeout) {
|
|
563
551
|
fetchOptions.signal = AbortSignal.timeout(timeoutMs);
|
|
564
552
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
// Copyright (c) 2024-2026 Pau Aliagas <linuxnow@gmail.com>
|
|
3
|
+
/**
|
|
4
|
+
* Shared notifyStatus enrichment — adds storage estimate, timezone,
|
|
5
|
+
* and statusDialog to the status object before submission.
|
|
6
|
+
*
|
|
7
|
+
* @param {Object} status - Mutable status object to enrich in place
|
|
8
|
+
* @returns {Promise<void>}
|
|
9
|
+
*/
|
|
10
|
+
export async function enrichStatus(status) {
|
|
11
|
+
// Add storage estimate if available
|
|
12
|
+
if (typeof navigator !== 'undefined' && navigator.storage?.estimate) {
|
|
13
|
+
try {
|
|
14
|
+
const estimate = await navigator.storage.estimate();
|
|
15
|
+
status.availableSpace = estimate.quota - estimate.usage;
|
|
16
|
+
status.totalSpace = estimate.quota;
|
|
17
|
+
} catch (_) { /* storage estimate not supported */ }
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Add timezone if not already provided
|
|
21
|
+
if (!status.timeZone && typeof Intl !== 'undefined') {
|
|
22
|
+
status.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Add statusDialog (summary for CMS display status page) if not provided
|
|
26
|
+
if (!status.statusDialog) {
|
|
27
|
+
status.statusDialog = `Current Layout: ${status.currentLayoutId || 'None'}`;
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/xmds-client.js
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* Protocol: https://github.com/linuxnow/xibo_players_docs
|
|
10
10
|
*/
|
|
11
11
|
import { createLogger, fetchWithRetry, PLAYER_API } from '@xiboplayer/utils';
|
|
12
|
+
import { enrichStatus } from './status-enrichment.js';
|
|
12
13
|
import { parseScheduleResponse } from './schedule-parser.js';
|
|
13
14
|
|
|
14
15
|
const log = createLogger('XMDS');
|
|
@@ -335,24 +336,7 @@ export class XmdsClient {
|
|
|
335
336
|
* @param {Object} status - Status object with currentLayoutId, deviceName, etc.
|
|
336
337
|
*/
|
|
337
338
|
async notifyStatus(status) {
|
|
338
|
-
|
|
339
|
-
if (typeof navigator !== 'undefined' && navigator.storage?.estimate) {
|
|
340
|
-
try {
|
|
341
|
-
const estimate = await navigator.storage.estimate();
|
|
342
|
-
status.availableSpace = estimate.quota - estimate.usage;
|
|
343
|
-
status.totalSpace = estimate.quota;
|
|
344
|
-
} catch (_) { /* storage estimate not supported */ }
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
// Add timezone if not already provided
|
|
348
|
-
if (!status.timeZone && typeof Intl !== 'undefined') {
|
|
349
|
-
status.timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
// Add statusDialog (summary for CMS display status page) if not provided
|
|
353
|
-
if (!status.statusDialog) {
|
|
354
|
-
status.statusDialog = `Current Layout: ${status.currentLayoutId || 'None'}`;
|
|
355
|
-
}
|
|
339
|
+
await enrichStatus(status);
|
|
356
340
|
|
|
357
341
|
return await this.call('NotifyStatus', {
|
|
358
342
|
serverKey: this.config.cmsKey,
|