@tomorrowos/sdk 0.9.28 → 0.9.29
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/README.md +6 -1
- package/VERCEL_SETUP.md +1 -1
- package/dist/cli.js +42 -11
- package/package.json +1 -1
- package/templates/cms-starter/package.json +2 -2
- package/templates/cms-starter/server.ts +2 -2
- package/templates/cms-starter-v0/.env.example +19 -0
- package/templates/cms-starter-v0/README.md +60 -0
- package/templates/cms-starter-v0/assets/logo.svg +4 -0
- package/templates/cms-starter-v0/brand.json +23 -0
- package/templates/cms-starter-v0/cms-panel/assets/player-download/android.svg +1 -0
- package/templates/cms-starter-v0/cms-panel/assets/player-download/brightsign.svg +1 -0
- package/templates/cms-starter-v0/cms-panel/assets/player-download/lg-webos.svg +1 -0
- package/templates/cms-starter-v0/cms-panel/assets/player-download/samsung.svg +1 -0
- package/templates/cms-starter-v0/cms-panel/assets/player-download/toolbox.svg +1 -0
- package/templates/cms-starter-v0/cms-panel/index.html +290 -0
- package/templates/cms-starter-v0/cms-panel/methods.js +2361 -0
- package/templates/cms-starter-v0/cms-panel/panel.css +1127 -0
- package/templates/cms-starter-v0/cms-panel/uploads/.gitkeep +1 -0
- package/templates/cms-starter-v0/package.json +35 -0
- package/templates/cms-starter-v0/policy.example.json +30 -0
- package/templates/cms-starter-v0/preview/app/layout.tsx +11 -0
- package/templates/cms-starter-v0/preview/app/page.tsx +3 -0
- package/templates/cms-starter-v0/preview/next-env.d.ts +2 -0
- package/templates/cms-starter-v0/preview/next.config.mjs +18 -0
- package/templates/cms-starter-v0/preview/tsconfig.json +20 -0
- package/templates/cms-starter-v0/server.ts +75 -0
- package/templates/cms-starter-v0/tsconfig.json +13 -0
- package/templates/cms-starter-v0/vercel.json +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-cms",
|
|
3
|
+
"version": "0.9.29",
|
|
4
|
+
"description": "TomorrowOS CMS for Vercel / v0 Publish (Node Fluid + optional Next Preview shell).",
|
|
5
|
+
"private": true,
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=20"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"dev": "tsx watch server.ts",
|
|
12
|
+
"dev:tomorrowos": "cross-env TOMORROWOS_INTERNAL_PORT=3001 tsx watch server.ts",
|
|
13
|
+
"dev:next": "cd preview && next dev -p 3000",
|
|
14
|
+
"dev:preview": "concurrently -k \"npm:dev:tomorrowos\" \"npm:dev:next\"",
|
|
15
|
+
"start": "tsx server.ts",
|
|
16
|
+
"build": "node -e \"process.exit(0)\"",
|
|
17
|
+
"build-player": "tomorrowos build --platform tizen"
|
|
18
|
+
},
|
|
19
|
+
"dependencies": {
|
|
20
|
+
"@tomorrowos/sdk": "^0.9.29",
|
|
21
|
+
"dotenv": "^17.2.3",
|
|
22
|
+
"tsx": "^4.19.0"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.0.0",
|
|
26
|
+
"@types/react": "^19.0.0",
|
|
27
|
+
"@types/react-dom": "^19.0.0",
|
|
28
|
+
"concurrently": "^9.1.2",
|
|
29
|
+
"cross-env": "^7.0.3",
|
|
30
|
+
"next": "^15.1.0",
|
|
31
|
+
"react": "^19.0.0",
|
|
32
|
+
"react-dom": "^19.0.0",
|
|
33
|
+
"typescript": "^5.5.0"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"policy": {
|
|
3
|
+
"playlists": [
|
|
4
|
+
{
|
|
5
|
+
"id": "weekday-promo",
|
|
6
|
+
"name": "Weekday promo",
|
|
7
|
+
"schedule": {
|
|
8
|
+
"startDate": "2026-05-01",
|
|
9
|
+
"endDate": "2026-05-31",
|
|
10
|
+
"daysOfWeek": [1, 2, 3, 4, 5],
|
|
11
|
+
"start": "09:00",
|
|
12
|
+
"end": "17:00"
|
|
13
|
+
},
|
|
14
|
+
"items": [
|
|
15
|
+
{
|
|
16
|
+
"url": "https://example.com/hero.jpg",
|
|
17
|
+
"type": "image",
|
|
18
|
+
"durationMs": 10000
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
"url": "https://example.com/spot.mp4",
|
|
22
|
+
"type": "video",
|
|
23
|
+
"durationMs": 30000
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
],
|
|
28
|
+
"fallback": { "type": "brand" }
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const internalUrl =
|
|
2
|
+
process.env.TOMORROWOS_INTERNAL_URL || "http://127.0.0.1:3001";
|
|
3
|
+
|
|
4
|
+
/** @type {import('next').NextConfig} */
|
|
5
|
+
const nextConfig = {
|
|
6
|
+
async rewrites() {
|
|
7
|
+
return {
|
|
8
|
+
fallback: [
|
|
9
|
+
{
|
|
10
|
+
source: "/:path*",
|
|
11
|
+
destination: `${internalUrl}/:path*`
|
|
12
|
+
}
|
|
13
|
+
]
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default nextConfig;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"lib": ["dom", "dom.iterable", "esnext"],
|
|
5
|
+
"allowJs": true,
|
|
6
|
+
"skipLibCheck": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"noEmit": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"module": "esnext",
|
|
11
|
+
"moduleResolution": "bundler",
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"jsx": "preserve",
|
|
15
|
+
"incremental": true,
|
|
16
|
+
"plugins": [{ "name": "next" }]
|
|
17
|
+
},
|
|
18
|
+
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
|
|
19
|
+
"exclude": ["node_modules"]
|
|
20
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TomorrowOS CMS server — Vercel / v0 starter.
|
|
3
|
+
* Production: root server.ts + Fluid (see vercel.json).
|
|
4
|
+
* Preview: npm run dev:preview (Next in preview/ proxies to this server on :3001).
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import "dotenv/config";
|
|
8
|
+
import { readFileSync } from "fs";
|
|
9
|
+
import { fileURLToPath } from "url";
|
|
10
|
+
import { dirname, join } from "path";
|
|
11
|
+
import { createTomorrowOSStore, TomorrowOS } from "@tomorrowos/sdk";
|
|
12
|
+
|
|
13
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
14
|
+
const brand = JSON.parse(readFileSync(join(__dirname, "brand.json"), "utf8"));
|
|
15
|
+
const store = createTomorrowOSStore({
|
|
16
|
+
databaseUrl:
|
|
17
|
+
process.env.SUPABASE_URL ||
|
|
18
|
+
process.env.NEON_DATABASE_URL ||
|
|
19
|
+
process.env.DATABASE_URL,
|
|
20
|
+
sqlitePath: join(__dirname, "data", "tomorrowos.db")
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const tomorrowos = new TomorrowOS({ brand, store });
|
|
24
|
+
|
|
25
|
+
const port = Number(
|
|
26
|
+
process.env.TOMORROWOS_INTERNAL_PORT || process.env.PORT || 3000
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const server = tomorrowos.listen({
|
|
30
|
+
port,
|
|
31
|
+
host: "0.0.0.0",
|
|
32
|
+
staticRoot: join(__dirname, "cms-panel")
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
tomorrowos.on("device.paired", (event) => {
|
|
36
|
+
console.log(`[TomorrowOS] device paired: ${event.deviceId}`);
|
|
37
|
+
void tomorrowos.pushLatestPolicyToDevice(event.deviceId).then((r) => {
|
|
38
|
+
if (r.pushed) {
|
|
39
|
+
console.log(`[TomorrowOS] pushed latest policy to ${event.deviceId} (paired)`);
|
|
40
|
+
}
|
|
41
|
+
}).catch((err) => {
|
|
42
|
+
console.error(`[TomorrowOS] policy push on paired failed for ${event.deviceId}:`, err);
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
tomorrowos.on("device.online", (event) => {
|
|
47
|
+
console.log(`[TomorrowOS] device online: ${event.deviceId}`);
|
|
48
|
+
void tomorrowos.pushLatestPolicyToDevice(event.deviceId).then((r) => {
|
|
49
|
+
if (r.pushed) {
|
|
50
|
+
console.log(`[TomorrowOS] pushed latest policy to ${event.deviceId}`);
|
|
51
|
+
}
|
|
52
|
+
}).catch((err) => {
|
|
53
|
+
console.error(`[TomorrowOS] latest policy push failed for ${event.deviceId}:`, err);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
tomorrowos.on("device.offline", (event) => {
|
|
58
|
+
console.log(
|
|
59
|
+
`[TomorrowOS] device offline: ${event.deviceId} (lastSeen: ${event.lastSeen})`
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
tomorrowos.on("command.verified", (event) => {
|
|
64
|
+
console.log(
|
|
65
|
+
`[TomorrowOS] command verified: ${event.commandId} (${event.method})`
|
|
66
|
+
);
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
tomorrowos.on("command.failed", (event) => {
|
|
70
|
+
console.error(
|
|
71
|
+
`[TomorrowOS] command failed: ${event.commandId} (${event.method}) — ${event.error.message}`
|
|
72
|
+
);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
export default server;
|