@tomorrowos/sdk 0.9.3 → 0.9.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/REPLIT_SETUP.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomorrowos/sdk",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "TomorrowOS CMS server SDK - WebSocket transport, pairing, device commands, optional static CMS UI. Includes CLI (tomorrowos init / build) and starter templates.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-cms",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.4",
|
|
4
4
|
"description": "CMS server on @tomorrowos/sdk. Add your UI (React, static files, etc.) alongside this server.",
|
|
5
5
|
"private": true,
|
|
6
6
|
"type": "module",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"build-player": "tomorrowos build --platform tizen"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@tomorrowos/sdk": "^0.9.
|
|
16
|
+
"@tomorrowos/sdk": "^0.9.4",
|
|
17
17
|
"dotenv": "^17.2.3",
|
|
18
18
|
"tsx": "^4.19.0"
|
|
19
19
|
},
|
|
@@ -566,21 +566,32 @@ function parseScheduleDateTimeMs(dateStr, timeStr, defaultTime) {
|
|
|
566
566
|
return Number.isNaN(ms) ? null : ms;
|
|
567
567
|
}
|
|
568
568
|
|
|
569
|
+
/** True when the playlist has no start/end date or time (always-on / default content). */
|
|
570
|
+
function isUnscheduledPublishedPlaylist(playlist) {
|
|
571
|
+
const schedule = playlist?.schedule;
|
|
572
|
+
if (!schedule) return true;
|
|
573
|
+
return !(
|
|
574
|
+
schedule.startDate ||
|
|
575
|
+
schedule.endDate ||
|
|
576
|
+
schedule.start ||
|
|
577
|
+
schedule.end
|
|
578
|
+
);
|
|
579
|
+
}
|
|
580
|
+
|
|
569
581
|
function getPublishedPlaylistStartMs(playlist) {
|
|
570
582
|
const schedule = playlist?.schedule;
|
|
571
|
-
if (!schedule) return null;
|
|
583
|
+
if (isUnscheduledPublishedPlaylist(playlist) || !schedule) return null;
|
|
572
584
|
return parseScheduleDateTimeMs(schedule.startDate, schedule.start, "00:00");
|
|
573
585
|
}
|
|
574
586
|
|
|
575
587
|
function getPublishedPlaylistEndMs(playlist) {
|
|
576
588
|
const schedule = playlist?.schedule;
|
|
577
|
-
if (!schedule) return null;
|
|
589
|
+
if (isUnscheduledPublishedPlaylist(playlist) || !schedule) return null;
|
|
578
590
|
return parseScheduleDateTimeMs(schedule.endDate, schedule.end, "23:59");
|
|
579
591
|
}
|
|
580
592
|
|
|
581
593
|
function isPublishedPlaylistActiveNow(playlist, now = new Date()) {
|
|
582
|
-
|
|
583
|
-
if (!schedule) return true;
|
|
594
|
+
if (isUnscheduledPublishedPlaylist(playlist)) return true;
|
|
584
595
|
const nowMs = now.getTime();
|
|
585
596
|
const startMs = getPublishedPlaylistStartMs(playlist);
|
|
586
597
|
const endMs = getPublishedPlaylistEndMs(playlist);
|
|
@@ -589,24 +600,39 @@ function isPublishedPlaylistActiveNow(playlist, now = new Date()) {
|
|
|
589
600
|
return true;
|
|
590
601
|
}
|
|
591
602
|
|
|
603
|
+
/**
|
|
604
|
+
* Green-light target for the device card.
|
|
605
|
+
* - Prefer an in-window scheduled playlist (latest start wins).
|
|
606
|
+
* - Else among always-on (no schedule) playlists, prefer the latest publishedAt
|
|
607
|
+
* so a later publish overrides earlier ones in the activity indicator.
|
|
608
|
+
*/
|
|
592
609
|
function pickScheduledPlaylistForIndicator(playlists, now = new Date()) {
|
|
593
|
-
const
|
|
594
|
-
|
|
595
|
-
|
|
610
|
+
const list = Array.isArray(playlists) ? playlists : [];
|
|
611
|
+
const active = list
|
|
612
|
+
.map((playlist, index) => ({ playlist, index }))
|
|
613
|
+
.filter(({ playlist }) => isPublishedPlaylistActiveNow(playlist, now));
|
|
596
614
|
if (!active.length) return null;
|
|
597
615
|
|
|
598
|
-
active.
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
616
|
+
const scheduled = active.filter(
|
|
617
|
+
({ playlist }) => !isUnscheduledPublishedPlaylist(playlist)
|
|
618
|
+
);
|
|
619
|
+
// Match player: scheduled takeovers beat always-on; always-on uses latest publish.
|
|
620
|
+
const pool = scheduled.length ? scheduled : active;
|
|
621
|
+
|
|
622
|
+
pool.sort((a, b) => {
|
|
623
|
+
if (scheduled.length) {
|
|
624
|
+
const aStart = getPublishedPlaylistStartMs(a.playlist) ?? 0;
|
|
625
|
+
const bStart = getPublishedPlaylistStartMs(b.playlist) ?? 0;
|
|
626
|
+
if (aStart !== bStart) return bStart - aStart;
|
|
627
|
+
}
|
|
628
|
+
const aPublished = new Date(a.playlist?.publishedAt || 0).getTime() || 0;
|
|
629
|
+
const bPublished = new Date(b.playlist?.publishedAt || 0).getTime() || 0;
|
|
630
|
+
if (aPublished !== bPublished) return bPublished - aPublished;
|
|
631
|
+
// Same publish time → later entry in the assignments list (last published) wins.
|
|
632
|
+
return b.index - a.index;
|
|
607
633
|
});
|
|
608
634
|
|
|
609
|
-
return
|
|
635
|
+
return pool[0]?.playlist || null;
|
|
610
636
|
}
|
|
611
637
|
|
|
612
638
|
function getSelectedPlaylist() {
|
|
@@ -1151,7 +1177,7 @@ function renderDeviceCards() {
|
|
|
1151
1177
|
if (isPlaying) {
|
|
1152
1178
|
const playingLight = document.createElement("span");
|
|
1153
1179
|
playingLight.className = "playlist-playing-light";
|
|
1154
|
-
playingLight.title = "Active now
|
|
1180
|
+
playingLight.title = "Active now";
|
|
1155
1181
|
label.appendChild(playingLight);
|
|
1156
1182
|
}
|
|
1157
1183
|
const rm = document.createElement("button");
|