@sansavision/create-pulse 0.4.3 → 0.4.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/README.md +1 -1
- package/dist/index.js +1 -1
- package/package.json +2 -2
- package/templates/nextjs-auth-demo/README.md +1 -1
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/arena-game/page.tsx +623 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/chat/page.tsx +21 -5
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/encrypted-chat/page.tsx +220 -7
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/game-sync/page.tsx +199 -47
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/video-call/page.tsx +740 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/demos/watch-together/page.tsx +364 -51
- package/templates/nextjs-auth-demo/src/app/dashboard/layout.tsx +4 -0
- package/templates/nextjs-auth-demo/src/app/dashboard/page.tsx +53 -5
- package/templates/nextjs-auth-demo/src/app/layout.tsx +1 -1
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
3
4
|
import Link from "next/link";
|
|
4
5
|
import { useSession } from "@/lib/auth-client";
|
|
6
|
+
import { connectWithAuth } from "@/lib/pulse";
|
|
5
7
|
import {
|
|
6
8
|
MessageSquare,
|
|
7
9
|
Video,
|
|
10
|
+
PhoneCall,
|
|
8
11
|
Database,
|
|
9
12
|
Gamepad2,
|
|
10
13
|
Lock,
|
|
11
14
|
ArrowRight,
|
|
12
15
|
Shield,
|
|
13
|
-
|
|
16
|
+
Zap,
|
|
14
17
|
Activity,
|
|
18
|
+
Circle,
|
|
19
|
+
Swords,
|
|
15
20
|
} from "lucide-react";
|
|
21
|
+
import type { PulseConnection } from "@sansavision/pulse-sdk";
|
|
16
22
|
|
|
17
23
|
const demos = [
|
|
18
24
|
{
|
|
@@ -23,6 +29,14 @@ const demos = [
|
|
|
23
29
|
color: "from-blue-500 to-blue-600",
|
|
24
30
|
badge: "Pub/Sub",
|
|
25
31
|
},
|
|
32
|
+
{
|
|
33
|
+
href: "/dashboard/demos/video-call",
|
|
34
|
+
icon: PhoneCall,
|
|
35
|
+
title: "Video Call",
|
|
36
|
+
desc: "Zoom-like peer-to-peer video calls using Pulse as the signaling layer. Camera, mic, screen sharing, and dynamic grid layout.",
|
|
37
|
+
color: "from-indigo-500 to-sky-500",
|
|
38
|
+
badge: "WebRTC",
|
|
39
|
+
},
|
|
26
40
|
{
|
|
27
41
|
href: "/dashboard/demos/watch-together",
|
|
28
42
|
icon: Video,
|
|
@@ -47,6 +61,14 @@ const demos = [
|
|
|
47
61
|
color: "from-green-500 to-emerald-600",
|
|
48
62
|
badge: "State",
|
|
49
63
|
},
|
|
64
|
+
{
|
|
65
|
+
href: "/dashboard/demos/arena-game",
|
|
66
|
+
icon: Swords,
|
|
67
|
+
title: "Arena Game",
|
|
68
|
+
desc: "Real-time multiplayer arena. Create a room, share the code, and compete to collect golden orbs. 30 updates/sec state sync.",
|
|
69
|
+
color: "from-orange-500 to-red-600",
|
|
70
|
+
badge: "Multiplayer",
|
|
71
|
+
},
|
|
50
72
|
{
|
|
51
73
|
href: "/dashboard/demos/encrypted-chat",
|
|
52
74
|
icon: Lock,
|
|
@@ -59,13 +81,29 @@ const demos = [
|
|
|
59
81
|
|
|
60
82
|
export default function DashboardPage() {
|
|
61
83
|
const { data: session } = useSession();
|
|
84
|
+
const [relayConnected, setRelayConnected] = useState(false);
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!session) return;
|
|
88
|
+
let conn: PulseConnection | null = null;
|
|
89
|
+
connectWithAuth().then((c) => {
|
|
90
|
+
conn = c;
|
|
91
|
+
setRelayConnected(true);
|
|
92
|
+
c.on("disconnect", () => setRelayConnected(false));
|
|
93
|
+
c.on("reconnected", () => setRelayConnected(true));
|
|
94
|
+
}).catch(() => setRelayConnected(false));
|
|
95
|
+
return () => { conn?.disconnect(); };
|
|
96
|
+
}, [session]);
|
|
97
|
+
|
|
98
|
+
const relayUrl = process.env.NEXT_PUBLIC_PULSE_URL || "ws://localhost:4001";
|
|
99
|
+
const plpUrl = relayUrl.replace(/^ws:\/\//, "plp://").replace(/^wss:\/\//, "plps://");
|
|
62
100
|
|
|
63
101
|
return (
|
|
64
102
|
<div className="p-8">
|
|
65
103
|
{/* Header */}
|
|
66
104
|
<div className="mb-8">
|
|
67
105
|
<h1 className="text-3xl font-bold mb-2">
|
|
68
|
-
Welcome, {session?.user?.name?.split(" ")[0] || "there"}
|
|
106
|
+
Welcome, {session?.user?.name?.split(" ")[0] || "there"}
|
|
69
107
|
</h1>
|
|
70
108
|
<p className="text-slate-400 text-lg">
|
|
71
109
|
Choose a demo to explore Pulse's capabilities with authenticated
|
|
@@ -74,7 +112,17 @@ export default function DashboardPage() {
|
|
|
74
112
|
</div>
|
|
75
113
|
|
|
76
114
|
{/* Connection status */}
|
|
77
|
-
<div className="glass rounded-xl p-5 mb-8 flex items-center gap-6">
|
|
115
|
+
<div className="glass rounded-xl p-5 mb-8 flex items-center gap-6 flex-wrap">
|
|
116
|
+
<div className="flex items-center gap-2">
|
|
117
|
+
{relayConnected ? (
|
|
118
|
+
<Circle className="w-3 h-3 text-green-400 fill-green-400 animate-pulse" />
|
|
119
|
+
) : (
|
|
120
|
+
<Circle className="w-3 h-3 text-red-400 fill-red-400" />
|
|
121
|
+
)}
|
|
122
|
+
<span className={`text-sm font-medium ${relayConnected ? 'text-green-400' : 'text-red-400'}`}>
|
|
123
|
+
{relayConnected ? 'Connected' : 'Disconnected'}
|
|
124
|
+
</span>
|
|
125
|
+
</div>
|
|
78
126
|
<div className="flex items-center gap-2">
|
|
79
127
|
<Shield className="w-4 h-4 text-green-400" />
|
|
80
128
|
<span className="text-sm text-green-400 font-medium">
|
|
@@ -82,11 +130,11 @@ export default function DashboardPage() {
|
|
|
82
130
|
</span>
|
|
83
131
|
</div>
|
|
84
132
|
<div className="flex items-center gap-2">
|
|
85
|
-
<
|
|
133
|
+
<Zap className="w-4 h-4 text-cyan-400" />
|
|
86
134
|
<span className="text-sm text-slate-400">
|
|
87
135
|
Relay:{" "}
|
|
88
136
|
<code className="text-cyan-400 bg-cyan-500/10 px-1.5 py-0.5 rounded text-xs">
|
|
89
|
-
{
|
|
137
|
+
{plpUrl}
|
|
90
138
|
</code>
|
|
91
139
|
</span>
|
|
92
140
|
</div>
|
|
@@ -4,7 +4,7 @@ import "./globals.css";
|
|
|
4
4
|
export const metadata: Metadata = {
|
|
5
5
|
title: "Pulse — Real-Time Protocol Demo",
|
|
6
6
|
description:
|
|
7
|
-
"
|
|
7
|
+
"Full-featured demo showcasing PLP (Pulse Line Protocol) with auth, video calls, real-time chat, synchronized video, durable queues, and encrypted messaging.",
|
|
8
8
|
keywords: ["pulse", "real-time", "websocket", "protocol", "auth"],
|
|
9
9
|
};
|
|
10
10
|
|