@glivion/square-screen-js-sdk 0.1.0 → 1.0.1
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/dist/index.cjs +874 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +522 -0
- package/dist/index.d.mts +522 -0
- package/dist/index.mjs +870 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +8 -1
- package/.github/workflows/build-js-sdk.yml +0 -70
- package/eslint.config.js +0 -3
- package/examples/react-app/README.md +0 -73
- package/examples/react-app/eslint.config.js +0 -22
- package/examples/react-app/index.html +0 -13
- package/examples/react-app/package-lock.json +0 -2239
- package/examples/react-app/package.json +0 -31
- package/examples/react-app/public/favicon.svg +0 -1
- package/examples/react-app/public/icons.svg +0 -24
- package/examples/react-app/src/App.css +0 -184
- package/examples/react-app/src/App.tsx +0 -157
- package/examples/react-app/src/EmergencyTicker.tsx +0 -25
- package/examples/react-app/src/HeadlessExample.tsx +0 -66
- package/examples/react-app/src/RendererExample.tsx +0 -70
- package/examples/react-app/src/assets/hero.png +0 -0
- package/examples/react-app/src/assets/react.svg +0 -1
- package/examples/react-app/src/assets/vite.svg +0 -1
- package/examples/react-app/src/index.css +0 -183
- package/examples/react-app/src/main.tsx +0 -10
- package/examples/react-app/src/mockNetworkDataSource.ts +0 -116
- package/examples/react-app/src/usePlayer.ts +0 -71
- package/examples/react-app/tsconfig.app.json +0 -25
- package/examples/react-app/tsconfig.json +0 -7
- package/examples/react-app/tsconfig.node.json +0 -24
- package/examples/react-app/vite.config.ts +0 -7
- package/examples/react-app/yarn.lock +0 -1089
- package/src/__tests__/cache/SquareScreenCache.test.ts +0 -375
- package/src/__tests__/network/NetworkClient.test.ts +0 -217
- package/src/__tests__/network/mappers.test.ts +0 -163
- package/src/__tests__/player/SquareScreenPlayer.test.ts +0 -840
- package/src/cache/SquareScreenCache.ts +0 -154
- package/src/constants.ts +0 -9
- package/src/core/types.ts +0 -251
- package/src/env.d.ts +0 -4
- package/src/index.ts +0 -34
- package/src/network/NetworkClient.ts +0 -234
- package/src/network/apiTypes.ts +0 -89
- package/src/network/mappers.ts +0 -106
- package/src/player/SquareScreenPlayer.ts +0 -414
- package/src/renderer/SquareScreenRenderer.ts +0 -282
- package/tsconfig.json +0 -12
- package/tsdown.config.ts +0 -23
|
@@ -1,163 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, afterEach } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
mapEmergencyResponse,
|
|
4
|
-
mapHeartbeatAck,
|
|
5
|
-
mapHeartbeatPayload,
|
|
6
|
-
mapPlaybackStrategy,
|
|
7
|
-
mapPlaylistItem,
|
|
8
|
-
mapPlaylistResponse,
|
|
9
|
-
} from "../../network/mappers";
|
|
10
|
-
import type {
|
|
11
|
-
ApiEmergencyResponse,
|
|
12
|
-
ApiPlaylistResponse,
|
|
13
|
-
ApiPlaylistItem,
|
|
14
|
-
} from "../../network/apiTypes";
|
|
15
|
-
|
|
16
|
-
afterEach(() => {
|
|
17
|
-
vi.restoreAllMocks();
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
describe("mappers", () => {
|
|
21
|
-
it("maps playlist item shape from API to core model", () => {
|
|
22
|
-
const raw: ApiPlaylistItem = {
|
|
23
|
-
uuid: "item-1",
|
|
24
|
-
name: "Hero",
|
|
25
|
-
type: "image",
|
|
26
|
-
url: "https://cdn.example.com/hero.jpg",
|
|
27
|
-
duration_seconds: 12,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
expect(mapPlaylistItem(raw)).toEqual({
|
|
31
|
-
uuid: "item-1",
|
|
32
|
-
name: "Hero",
|
|
33
|
-
type: "image",
|
|
34
|
-
url: "https://cdn.example.com/hero.jpg",
|
|
35
|
-
duration: 12,
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it("returns undefined strategy when API sends empty array", () => {
|
|
40
|
-
expect(mapPlaybackStrategy([])).toBeUndefined();
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("maps strategy and defaults preloadCount to 0", () => {
|
|
44
|
-
expect(
|
|
45
|
-
mapPlaybackStrategy({
|
|
46
|
-
loop: true,
|
|
47
|
-
shuffle: false,
|
|
48
|
-
}),
|
|
49
|
-
).toEqual({
|
|
50
|
-
loop: true,
|
|
51
|
-
shuffle: false,
|
|
52
|
-
preloadCount: 0,
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it("maps a full playlist response and stamps cachedAt", () => {
|
|
57
|
-
vi.spyOn(Date, "now").mockReturnValue(1_717_171_717_171);
|
|
58
|
-
const raw: ApiPlaylistResponse = {
|
|
59
|
-
playlist: { uuid: "playlist-1", name: "Morning" },
|
|
60
|
-
items: [
|
|
61
|
-
{
|
|
62
|
-
uuid: "item-1",
|
|
63
|
-
name: "Hero",
|
|
64
|
-
type: "image",
|
|
65
|
-
url: "https://cdn.example.com/hero.jpg",
|
|
66
|
-
duration_seconds: 12,
|
|
67
|
-
},
|
|
68
|
-
],
|
|
69
|
-
strategy: {
|
|
70
|
-
loop: true,
|
|
71
|
-
shuffle: true,
|
|
72
|
-
preload_count: 3,
|
|
73
|
-
},
|
|
74
|
-
schedule: {
|
|
75
|
-
uuid: "schedule-1",
|
|
76
|
-
name: "weekday",
|
|
77
|
-
priority: 5,
|
|
78
|
-
},
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
expect(mapPlaylistResponse(raw)).toEqual({
|
|
82
|
-
uuid: "playlist-1",
|
|
83
|
-
items: [
|
|
84
|
-
{
|
|
85
|
-
uuid: "item-1",
|
|
86
|
-
name: "Hero",
|
|
87
|
-
type: "image",
|
|
88
|
-
url: "https://cdn.example.com/hero.jpg",
|
|
89
|
-
duration: 12,
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
strategy: {
|
|
93
|
-
loop: true,
|
|
94
|
-
shuffle: true,
|
|
95
|
-
preloadCount: 3,
|
|
96
|
-
},
|
|
97
|
-
schedule: {
|
|
98
|
-
uuid: "schedule-1",
|
|
99
|
-
name: "weekday",
|
|
100
|
-
priority: 5,
|
|
101
|
-
},
|
|
102
|
-
playlistMeta: { uuid: "playlist-1", name: "Morning" },
|
|
103
|
-
cachedAt: 1_717_171_717_171,
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("maps emergency response to null when inactive", () => {
|
|
108
|
-
const raw: ApiEmergencyResponse = { emergency: null };
|
|
109
|
-
expect(mapEmergencyResponse(raw)).toBeNull();
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it("maps emergency response to core alert when active", () => {
|
|
113
|
-
const raw: ApiEmergencyResponse = {
|
|
114
|
-
emergency: {
|
|
115
|
-
id: 1,
|
|
116
|
-
uuid: "em-1",
|
|
117
|
-
company_id: 42,
|
|
118
|
-
title: "Emergency",
|
|
119
|
-
message: "Shelter in place",
|
|
120
|
-
background_color: "#aa0000",
|
|
121
|
-
text_color: "#ffffff",
|
|
122
|
-
target_scope: "all",
|
|
123
|
-
is_active: true,
|
|
124
|
-
started_at: "2026-01-01T00:00:00Z",
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
expect(mapEmergencyResponse(raw)).toEqual({
|
|
129
|
-
id: 1,
|
|
130
|
-
uuid: "em-1",
|
|
131
|
-
companyId: 42,
|
|
132
|
-
title: "Emergency",
|
|
133
|
-
message: "Shelter in place",
|
|
134
|
-
backgroundColor: "#aa0000",
|
|
135
|
-
textColor: "#ffffff",
|
|
136
|
-
targetScope: "all",
|
|
137
|
-
isActive: true,
|
|
138
|
-
startedAt: "2026-01-01T00:00:00Z",
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it("maps heartbeat ack and payload fields", () => {
|
|
143
|
-
expect(mapHeartbeatAck({ received: true })).toEqual({ received: true });
|
|
144
|
-
|
|
145
|
-
expect(
|
|
146
|
-
mapHeartbeatPayload({
|
|
147
|
-
cpuUsage: 10,
|
|
148
|
-
memoryUsage: 20,
|
|
149
|
-
diskUsage: 30,
|
|
150
|
-
temperature: 40,
|
|
151
|
-
osVersion: "macOS",
|
|
152
|
-
playerVersion: "1.2.3",
|
|
153
|
-
}),
|
|
154
|
-
).toEqual({
|
|
155
|
-
cpu_usage: 10,
|
|
156
|
-
memory_usage: 20,
|
|
157
|
-
disk_usage: 30,
|
|
158
|
-
temperature: 40,
|
|
159
|
-
os_version: "macOS",
|
|
160
|
-
app_version: "1.2.3",
|
|
161
|
-
});
|
|
162
|
-
});
|
|
163
|
-
});
|