@trillboards/connect 1.0.0
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/CHANGELOG.md +16 -0
- package/README.md +122 -0
- package/dist/index.js +2146 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2144 -0
- package/dist/index.mjs.map +1 -0
- package/dist/trillboards-connect.global.js +104 -0
- package/dist/trillboards-connect.global.js.map +1 -0
- package/package.json +51 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 1.0.0 (2026-02-19)
|
|
4
|
+
|
|
5
|
+
Initial public release.
|
|
6
|
+
|
|
7
|
+
### Features
|
|
8
|
+
|
|
9
|
+
- **Device registration** — Automatic device fingerprinting (FNV-1a hash), registration via Partner API, and heartbeat loop with exponential backoff
|
|
10
|
+
- **Ad auction** — Fetch ads by fingerprint, VAST XML parsing with media file/tracking extraction, and impression tracking via image beacons
|
|
11
|
+
- **Ad rotation** — Configurable ad rotation manager with automatic cycling, video/image rendering, and completion callbacks
|
|
12
|
+
- **Offline support** — IndexedDB-backed ad caching and impression queue with automatic sync on reconnect
|
|
13
|
+
- **Branding** — Default CSS injection for ad containers with white-label custom CSS loading support
|
|
14
|
+
- **Analytics** — Client-side event buffering with batch sending, `sendBeacon` on page unload, and visibility change tracking
|
|
15
|
+
- **Socket.io integration** — Real-time commands (refresh ads, update config, force reload, content updates) via optional Socket.io connection
|
|
16
|
+
- **Event system** — Full lifecycle events: `ready`, `device_registered`, `ad_start`, `ad_complete`, `impression`, `sync_complete`, `error`, and more
|
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @trillboards/connect
|
|
2
|
+
|
|
3
|
+
Zero-friction partner onboarding SDK for digital signage ad monetization. One `init()` call handles device registration, ad fetching, rendering, offline caching, and analytics.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @trillboards/connect
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Or via CDN:
|
|
12
|
+
|
|
13
|
+
```html
|
|
14
|
+
<script src="https://unpkg.com/@trillboards/connect/dist/trillboards-connect.global.js"></script>
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
const TrillboardsConnect = require('@trillboards/connect');
|
|
21
|
+
// or: import TrillboardsConnect from '@trillboards/connect';
|
|
22
|
+
|
|
23
|
+
const trillboards = TrillboardsConnect.init({
|
|
24
|
+
apiKey: 'trb_partner_xxx',
|
|
25
|
+
deviceId: 'my-screen-001',
|
|
26
|
+
containerId: 'ad-container',
|
|
27
|
+
options: {
|
|
28
|
+
heartbeatInterval: 60000,
|
|
29
|
+
adInterval: 60,
|
|
30
|
+
muted: true,
|
|
31
|
+
offlineCache: true,
|
|
32
|
+
analytics: true,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
trillboards.on('ready', (data) => {
|
|
37
|
+
console.log('SDK ready:', data.fingerprint);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
trillboards.on('ad_start', (data) => {
|
|
41
|
+
console.log('Ad started:', data.ad.id);
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
| Option | Type | Default | Description |
|
|
48
|
+
|--------|------|---------|-------------|
|
|
49
|
+
| `apiKey` | `string` | *required* | Partner API key (`trb_partner_xxx`) |
|
|
50
|
+
| `deviceId` | `string` | *required* | Unique device identifier |
|
|
51
|
+
| `containerId` | `string \| HTMLElement` | `null` | DOM container for ad rendering |
|
|
52
|
+
| `options.heartbeatInterval` | `number` | `60000` | Heartbeat interval in ms |
|
|
53
|
+
| `options.adInterval` | `number` | `60` | Ad rotation interval in seconds |
|
|
54
|
+
| `options.muted` | `boolean` | `true` | Start video ads muted |
|
|
55
|
+
| `options.offlineCache` | `boolean` | `true` | Enable IndexedDB offline caching |
|
|
56
|
+
| `options.analytics` | `boolean` | `true` | Enable analytics event buffering |
|
|
57
|
+
| `options.deviceType` | `string` | `'digital_signage'` | Device type for registration |
|
|
58
|
+
| `options.deviceName` | `string` | `'SDK Device: <deviceId>'` | Friendly device name |
|
|
59
|
+
| `options.display` | `object` | auto-detected | Display specs `{ width, height }` |
|
|
60
|
+
| `options.location` | `object` | `{}` | Location `{ lat, lng, address, venue_type }` |
|
|
61
|
+
| `options.metadata` | `object` | `{}` | Custom metadata sent with registration |
|
|
62
|
+
| `options.objectFit` | `string` | `'cover'` | CSS `object-fit` for ad rendering |
|
|
63
|
+
|
|
64
|
+
## Events
|
|
65
|
+
|
|
66
|
+
| Event | Data | Description |
|
|
67
|
+
|-------|------|-------------|
|
|
68
|
+
| `ready` | `{ deviceId, fingerprint, screenId, embedUrl }` | SDK fully initialized |
|
|
69
|
+
| `device_registered` | `{ fingerprint, screen_id, embed_url }` | Device registered with API |
|
|
70
|
+
| `device_status` | `{ from, to, deviceId }` | Device status changed |
|
|
71
|
+
| `ad_start` | `{ ad, type, timestamp }` | Ad started rendering |
|
|
72
|
+
| `ad_complete` | `{ ad, type, duration, completed }` | Ad finished rendering |
|
|
73
|
+
| `ad_error` | `{ ad, type, error }` | Ad rendering error |
|
|
74
|
+
| `impression` | `{ ad, result, totalImpressions }` | Impression tracked |
|
|
75
|
+
| `heartbeat` | `{ beat, status, timestamp }` | Heartbeat sent |
|
|
76
|
+
| `heartbeat_error` | `{ error, consecutiveFailures, willRetry }` | Heartbeat failed |
|
|
77
|
+
| `sync_complete` | `{ total, synced, failed }` | Offline impressions synced |
|
|
78
|
+
| `connectivity_change` | `{ online }` | Online/offline status changed |
|
|
79
|
+
| `analytics_flush` | `{ flushed, errors }` | Analytics buffer flushed |
|
|
80
|
+
| `socket_connected` | `{ socketId }` | Socket.io connected |
|
|
81
|
+
| `socket_disconnected` | `{ reason }` | Socket.io disconnected |
|
|
82
|
+
| `config_updated` | `{ config, source }` | Config updated via socket |
|
|
83
|
+
| `error` | `{ phase, error, fatal? }` | General error |
|
|
84
|
+
|
|
85
|
+
## API
|
|
86
|
+
|
|
87
|
+
### `TrillboardsConnect.init(config)`
|
|
88
|
+
|
|
89
|
+
Initialize the SDK. Returns a `ConnectInstance` that begins initialization asynchronously.
|
|
90
|
+
|
|
91
|
+
### `TrillboardsConnect.create(config)`
|
|
92
|
+
|
|
93
|
+
Create an uninitialized instance for advanced use cases. Call `instance.initialize()` manually.
|
|
94
|
+
|
|
95
|
+
### Instance Methods
|
|
96
|
+
|
|
97
|
+
| Method | Description |
|
|
98
|
+
|--------|-------------|
|
|
99
|
+
| `on(event, callback)` | Register an event listener |
|
|
100
|
+
| `off(event, callback)` | Remove an event listener |
|
|
101
|
+
| `nextAd()` | Skip to the next ad |
|
|
102
|
+
| `pause()` | Pause ad rotation |
|
|
103
|
+
| `resume()` | Resume ad rotation |
|
|
104
|
+
| `getState()` | Get complete SDK state |
|
|
105
|
+
| `queueOfflineImpression(data)` | Queue an impression for offline sync |
|
|
106
|
+
| `syncOffline()` | Force sync offline impressions |
|
|
107
|
+
| `cacheAdsOffline(ads)` | Cache ads for offline playback |
|
|
108
|
+
| `destroy()` | Clean up all resources |
|
|
109
|
+
|
|
110
|
+
### Sub-Modules
|
|
111
|
+
|
|
112
|
+
For advanced usage, sub-modules are exposed directly:
|
|
113
|
+
|
|
114
|
+
- `TrillboardsConnect.device` — Registration, fingerprinting, heartbeat
|
|
115
|
+
- `TrillboardsConnect.auction` — Ad fetching, rendering, VAST parsing
|
|
116
|
+
- `TrillboardsConnect.offline` — IndexedDB caching and impression queue
|
|
117
|
+
- `TrillboardsConnect.branding` — CSS injection and white-labeling
|
|
118
|
+
- `TrillboardsConnect.analytics` — Event buffering and batch sending
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|