blanchon commited on
Commit
b2a6461
·
1 Parent(s): befd3bb

Resolve merge conflicts

Browse files
demo/src/lib/index.ts CHANGED
@@ -1,35 +1 @@
1
  // place files you want to import through the `$lib` alias in this folder.
2
-
3
- /**
4
- * Get the server URL based on environment variables and dev/prod mode
5
- * Priority: ENV variable > dev mode (localhost:8000) > prod mode (HF Space)
6
- */
7
- export function getServerUrl(): string {
8
- // Check for environment variable first
9
- if (typeof window !== 'undefined') {
10
- // Client-side: check for runtime environment variable
11
- const envUrl = (window as any).__SERVER_URL__;
12
- if (envUrl) {
13
- return envUrl;
14
- }
15
- } else {
16
- // Server-side: check for build-time environment variable
17
- const envUrl = process.env.PUBLIC_SERVER_URL;
18
- if (envUrl) {
19
- return envUrl;
20
- }
21
- }
22
-
23
- // Fall back to dev/prod detection
24
- if (typeof window !== 'undefined') {
25
- // Client-side: check if we're in development
26
- const isDev = window.location.hostname === 'localhost' ||
27
- window.location.hostname === '127.0.0.1' ||
28
- window.location.hostname.startsWith('192.168.');
29
-
30
- return isDev ? 'http://localhost:8000' : 'https://blanchon-robottransportserver.hf.space/api';
31
- }
32
-
33
- // Server-side fallback
34
- return 'http://localhost:8000';
35
- }
 
1
  // place files you want to import through the `$lib` alias in this folder.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
demo/src/lib/settings.svelte.ts DELETED
@@ -1,9 +0,0 @@
1
- import { getServerUrl } from './index.js';
2
-
3
- interface Settings {
4
- transportServerUrl: string;
5
- }
6
-
7
- export const settings: Settings = $state({
8
- transportServerUrl: getServerUrl()
9
- });
 
 
 
 
 
 
 
 
 
 
demo/src/routes/+page.svelte CHANGED
@@ -3,8 +3,6 @@
3
  import { robotics } from '@robothub/transport-server-client';
4
  import type { robotics as roboticsTypes } from '@robothub/transport-server-client';
5
  import { goto } from '$app/navigation';
6
- import { settings } from '$lib/settings.svelte.js';
7
-
8
 
9
  // Server status
10
  let serverStatus = $state<'checking' | 'connected' | 'error'>('checking');
@@ -32,7 +30,7 @@
32
 
33
  try {
34
  // Use the configured server URL
35
- const client = new robotics.RoboticsClientCore(settings.transportServerUrl);
36
  const roomList = await client.listRooms('');
37
  rooms = roomList;
38
  serverInfo = { rooms: roomList.length, version: '1.0.0' };
 
3
  import { robotics } from '@robothub/transport-server-client';
4
  import type { robotics as roboticsTypes } from '@robothub/transport-server-client';
5
  import { goto } from '$app/navigation';
 
 
6
 
7
  // Server status
8
  let serverStatus = $state<'checking' | 'connected' | 'error'>('checking');
 
30
 
31
  try {
32
  // Use the configured server URL
33
+ const client = new robotics.RoboticsClientCore('https://blanchon-robothub-transportserver.hf.space/api');
34
  const roomList = await client.listRooms('');
35
  rooms = roomList;
36
  serverInfo = { rooms: roomList.length, version: '1.0.0' };
demo/src/routes/[workspaceId]/+page.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { settings } from '$lib/settings.svelte.js';
3
  import { onMount } from 'svelte';
4
  import { robotics, video } from '@robothub/transport-server-client';
5
  import type { robotics as roboticsTypes, video as videoTypes } from '@robothub/transport-server-client';
@@ -43,11 +42,7 @@
43
 
44
  // Load robotics rooms
45
  try {
46
- <<<<<<< HEAD
47
  roboticsClient = new robotics.RoboticsClientCore('https://blanchon-robothub-transportserver.hf.space/api');
48
- =======
49
- roboticsClient = new robotics.RoboticsClientCore(settings.transportServerUrl);
50
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
51
  roboticsRooms = await roboticsClient.listRooms(workspaceId);
52
  } catch (err) {
53
  roboticsError = 'Failed to load robotics rooms';
@@ -56,11 +51,7 @@
56
 
57
  // Load video rooms
58
  try {
59
- <<<<<<< HEAD
60
  videoClient = new video.VideoClientCore('https://blanchon-robothub-transportserver.hf.space/api');
61
- =======
62
- videoClient = new video.VideoClientCore(settings.transportServerUrl);
63
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
64
  videoRooms = await videoClient.listRooms(workspaceId);
65
  } catch (err) {
66
  videoError = 'Failed to load video rooms';
 
1
  <script lang="ts">
 
2
  import { onMount } from 'svelte';
3
  import { robotics, video } from '@robothub/transport-server-client';
4
  import type { robotics as roboticsTypes, video as videoTypes } from '@robothub/transport-server-client';
 
42
 
43
  // Load robotics rooms
44
  try {
 
45
  roboticsClient = new robotics.RoboticsClientCore('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
46
  roboticsRooms = await roboticsClient.listRooms(workspaceId);
47
  } catch (err) {
48
  roboticsError = 'Failed to load robotics rooms';
 
51
 
52
  // Load video rooms
53
  try {
 
54
  videoClient = new video.VideoClientCore('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
55
  videoRooms = await videoClient.listRooms(workspaceId);
56
  } catch (err) {
57
  videoError = 'Failed to load video rooms';
demo/src/routes/[workspaceId]/robotics/+page.svelte CHANGED
@@ -43,11 +43,7 @@
43
  try {
44
  loading = true;
45
  error = '';
46
- <<<<<<< HEAD
47
  client = new robotics.RoboticsClientCore('https://blanchon-robothub-transportserver.hf.space/api');
48
- =======
49
- client = new robotics.RoboticsClientCore(settings.transportServerUrl);
50
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
51
  rooms = await client.listRooms(workspaceId);
52
  debugInfo.responseTime = Date.now() - startTime;
53
  } catch (err) {
 
43
  try {
44
  loading = true;
45
  error = '';
 
46
  client = new robotics.RoboticsClientCore('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
47
  rooms = await client.listRooms(workspaceId);
48
  debugInfo.responseTime = Date.now() - startTime;
49
  } catch (err) {
demo/src/routes/[workspaceId]/robotics/consumer/+page.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { settings } from '$lib/settings.svelte.js';
3
  import { onMount } from 'svelte';
4
  import { robotics } from '@robothub/transport-server-client';
5
  import type { robotics as roboticsTypes } from '@robothub/transport-server-client';
@@ -72,11 +71,7 @@
72
  connecting = true;
73
  error = '';
74
 
75
- <<<<<<< HEAD
76
  consumer = new robotics.RoboticsConsumer('https://blanchon-robothub-transportserver.hf.space/api');
77
- =======
78
- consumer = new robotics.RoboticsConsumer(settings.transportServerUrl);
79
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
80
 
81
  // Set up event handlers
82
  consumer.onConnected(() => {
 
1
  <script lang="ts">
 
2
  import { onMount } from 'svelte';
3
  import { robotics } from '@robothub/transport-server-client';
4
  import type { robotics as roboticsTypes } from '@robothub/transport-server-client';
 
71
  connecting = true;
72
  error = '';
73
 
 
74
  consumer = new robotics.RoboticsConsumer('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
75
 
76
  // Set up event handlers
77
  consumer.onConnected(() => {
demo/src/routes/[workspaceId]/robotics/producer/+page.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { settings } from '$lib/settings.svelte.js';
3
  import { onMount } from 'svelte';
4
  import { robotics } from '@robothub/transport-server-client';
5
 
@@ -100,11 +99,7 @@
100
  connecting = true;
101
  error = '';
102
 
103
- <<<<<<< HEAD
104
  producer = new robotics.RoboticsProducer('https://blanchon-robothub-transportserver.hf.space/api');
105
- =======
106
- producer = new robotics.RoboticsProducer(settings.transportServerUrl);
107
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
108
 
109
  producer.onConnected(() => {
110
  connected = true;
@@ -144,11 +139,7 @@
144
  connecting = true;
145
  error = '';
146
 
147
- <<<<<<< HEAD
148
  producer = new robotics.RoboticsProducer('https://blanchon-robothub-transportserver.hf.space/api');
149
- =======
150
- producer = new robotics.RoboticsProducer(settings.transportServerUrl);
151
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
152
 
153
  producer.onConnected(() => {
154
  connected = true;
 
1
  <script lang="ts">
 
2
  import { onMount } from 'svelte';
3
  import { robotics } from '@robothub/transport-server-client';
4
 
 
99
  connecting = true;
100
  error = '';
101
 
 
102
  producer = new robotics.RoboticsProducer('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
103
 
104
  producer.onConnected(() => {
105
  connected = true;
 
139
  connecting = true;
140
  error = '';
141
 
 
142
  producer = new robotics.RoboticsProducer('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
143
 
144
  producer.onConnected(() => {
145
  connected = true;
demo/src/routes/[workspaceId]/video/+page.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { settings } from '$lib/settings.svelte.js';
3
  import { onMount } from 'svelte';
4
  import { video } from '@robothub/transport-server-client';
5
  import type { video as videoTypes } from '@robothub/transport-server-client';
@@ -44,11 +43,7 @@
44
  try {
45
  loading = true;
46
  error = '';
47
- <<<<<<< HEAD
48
  client = new video.VideoClientCore('https://blanchon-robothub-transportserver.hf.space/api');
49
- =======
50
- client = new video.VideoClientCore(settings.transportServerUrl);
51
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
52
  rooms = await client.listRooms(workspaceId);
53
  debugInfo.responseTime = Date.now() - startTime;
54
  } catch (err) {
 
1
  <script lang="ts">
 
2
  import { onMount } from 'svelte';
3
  import { video } from '@robothub/transport-server-client';
4
  import type { video as videoTypes } from '@robothub/transport-server-client';
 
43
  try {
44
  loading = true;
45
  error = '';
 
46
  client = new video.VideoClientCore('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
47
  rooms = await client.listRooms(workspaceId);
48
  debugInfo.responseTime = Date.now() - startTime;
49
  } catch (err) {
demo/src/routes/[workspaceId]/video/consumer/+page.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { settings } from '$lib/settings.svelte.js';
3
  import { onMount } from 'svelte';
4
  import { video } from '@robothub/transport-server-client';
5
 
@@ -19,7 +18,7 @@
19
 
20
  // Remote video stream
21
  let remoteVideoStream = $state<MediaStream | null>(null);
22
- let remoteVideoRef: HTMLVideoElement;
23
 
24
  // Stream status
25
  let streamActive = $state<boolean>(false);
@@ -80,11 +79,7 @@
80
  connecting = true;
81
  error = '';
82
 
83
- <<<<<<< HEAD
84
  consumer = new video.VideoConsumer('https://blanchon-robothub-transportserver.hf.space/api');
85
- =======
86
- consumer = new video.VideoConsumer(settings.transportServerUrl);
87
- >>>>>>> ccb03a313c3f3278e408a849294738a50b7ec4d0
88
 
89
  // Set up event handlers
90
  consumer.onConnected(() => {
@@ -259,6 +254,7 @@
259
  remoteVideoRef.play().catch((err) => {
260
  console.warn('Auto-play failed:', err);
261
  // Try to play with user gesture required
 
262
  remoteVideoRef.muted = true;
263
  remoteVideoRef.play().catch((err2) => {
264
  console.error('Failed to play video even when muted:', err2);
@@ -514,6 +510,7 @@
514
  {#if streamActive && remoteVideoRef}
515
  <button
516
  onclick={() => {
 
517
  if (remoteVideoRef.requestFullscreen) {
518
  remoteVideoRef.requestFullscreen();
519
  }
 
1
  <script lang="ts">
 
2
  import { onMount } from 'svelte';
3
  import { video } from '@robothub/transport-server-client';
4
 
 
18
 
19
  // Remote video stream
20
  let remoteVideoStream = $state<MediaStream | null>(null);
21
+ let remoteVideoRef: HTMLVideoElement | null = $state(null);
22
 
23
  // Stream status
24
  let streamActive = $state<boolean>(false);
 
79
  connecting = true;
80
  error = '';
81
 
 
82
  consumer = new video.VideoConsumer('https://blanchon-robothub-transportserver.hf.space/api');
 
 
 
83
 
84
  // Set up event handlers
85
  consumer.onConnected(() => {
 
254
  remoteVideoRef.play().catch((err) => {
255
  console.warn('Auto-play failed:', err);
256
  // Try to play with user gesture required
257
+ if (!remoteVideoRef) return;
258
  remoteVideoRef.muted = true;
259
  remoteVideoRef.play().catch((err2) => {
260
  console.error('Failed to play video even when muted:', err2);
 
510
  {#if streamActive && remoteVideoRef}
511
  <button
512
  onclick={() => {
513
+ if (!remoteVideoRef) return;
514
  if (remoteVideoRef.requestFullscreen) {
515
  remoteVideoRef.requestFullscreen();
516
  }
demo/src/routes/[workspaceId]/video/producer/+page.svelte CHANGED
@@ -1,5 +1,4 @@
1
  <script lang="ts">
2
- import { settings } from '$lib/settings.svelte.js';
3
  import { onMount } from 'svelte';
4
  import { video } from '@robothub/transport-server-client';
5
 
@@ -131,7 +130,7 @@
131
  connecting = true;
132
  error = '';
133
 
134
- producer = new video.VideoProducer(settings.transportServerUrl);
135
 
136
  producer.onConnected(() => {
137
  connected = true;
@@ -195,7 +194,7 @@
195
  connecting = true;
196
  error = '';
197
 
198
- producer = new video.VideoProducer(settings.transportServerUrl);
199
 
200
  producer.onConnected(() => {
201
  connected = true;
 
1
  <script lang="ts">
 
2
  import { onMount } from 'svelte';
3
  import { video } from '@robothub/transport-server-client';
4
 
 
130
  connecting = true;
131
  error = '';
132
 
133
+ producer = new video.VideoProducer("https://blanchon-robothub-transportserver.hf.space/api");
134
 
135
  producer.onConnected(() => {
136
  connected = true;
 
194
  connecting = true;
195
  error = '';
196
 
197
+ producer = new video.VideoProducer('https://blanchon-robothub-transportserver.hf.space/api');
198
 
199
  producer.onConnected(() => {
200
  connected = true;