@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.
Files changed (49) hide show
  1. package/dist/index.cjs +874 -0
  2. package/dist/index.cjs.map +1 -0
  3. package/dist/index.d.cts +522 -0
  4. package/dist/index.d.mts +522 -0
  5. package/dist/index.mjs +870 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +8 -1
  8. package/.github/workflows/build-js-sdk.yml +0 -70
  9. package/eslint.config.js +0 -3
  10. package/examples/react-app/README.md +0 -73
  11. package/examples/react-app/eslint.config.js +0 -22
  12. package/examples/react-app/index.html +0 -13
  13. package/examples/react-app/package-lock.json +0 -2239
  14. package/examples/react-app/package.json +0 -31
  15. package/examples/react-app/public/favicon.svg +0 -1
  16. package/examples/react-app/public/icons.svg +0 -24
  17. package/examples/react-app/src/App.css +0 -184
  18. package/examples/react-app/src/App.tsx +0 -157
  19. package/examples/react-app/src/EmergencyTicker.tsx +0 -25
  20. package/examples/react-app/src/HeadlessExample.tsx +0 -66
  21. package/examples/react-app/src/RendererExample.tsx +0 -70
  22. package/examples/react-app/src/assets/hero.png +0 -0
  23. package/examples/react-app/src/assets/react.svg +0 -1
  24. package/examples/react-app/src/assets/vite.svg +0 -1
  25. package/examples/react-app/src/index.css +0 -183
  26. package/examples/react-app/src/main.tsx +0 -10
  27. package/examples/react-app/src/mockNetworkDataSource.ts +0 -116
  28. package/examples/react-app/src/usePlayer.ts +0 -71
  29. package/examples/react-app/tsconfig.app.json +0 -25
  30. package/examples/react-app/tsconfig.json +0 -7
  31. package/examples/react-app/tsconfig.node.json +0 -24
  32. package/examples/react-app/vite.config.ts +0 -7
  33. package/examples/react-app/yarn.lock +0 -1089
  34. package/src/__tests__/cache/SquareScreenCache.test.ts +0 -375
  35. package/src/__tests__/network/NetworkClient.test.ts +0 -217
  36. package/src/__tests__/network/mappers.test.ts +0 -163
  37. package/src/__tests__/player/SquareScreenPlayer.test.ts +0 -840
  38. package/src/cache/SquareScreenCache.ts +0 -154
  39. package/src/constants.ts +0 -9
  40. package/src/core/types.ts +0 -251
  41. package/src/env.d.ts +0 -4
  42. package/src/index.ts +0 -34
  43. package/src/network/NetworkClient.ts +0 -234
  44. package/src/network/apiTypes.ts +0 -89
  45. package/src/network/mappers.ts +0 -106
  46. package/src/player/SquareScreenPlayer.ts +0 -414
  47. package/src/renderer/SquareScreenRenderer.ts +0 -282
  48. package/tsconfig.json +0 -12
  49. 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
- });