@ngenux/ngage-whiteboarding 1.0.1 → 1.0.3

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 CHANGED
@@ -15,18 +15,102 @@ A React component library for creating collaborative whiteboards with real-time
15
15
  - ⚡ **Real-time sync** - Ultra-smooth 60fps collaborative drawing experience
16
16
  - 🎯 **TypeScript support** - Fully typed for better development experience
17
17
 
18
+ ## 📋 Prerequisites
19
+
20
+ This package requires the following dependencies in your project:
21
+
22
+ - **React** 16.8+ (with Hooks support)
23
+ - **Tailwind CSS** 3.0+ (for styling)
24
+ - **Vite** or similar modern bundler (recommended)
25
+
26
+ ### Optional but Recommended:
27
+ - **shadcn/ui** setup for consistent design system
28
+
18
29
  ## 📦 Installation
19
30
 
31
+ ### Step 1: Install the Package
32
+
20
33
  ```bash
21
34
  npm install @ngenux/ngage-whiteboarding
22
35
  ```
23
36
 
37
+ ### Step 2: Setup Tailwind CSS (if not already installed)
38
+
39
+ ```bash
40
+ npm install -D tailwindcss postcss autoprefixer
41
+ npx tailwindcss init -p
42
+ ```
43
+
44
+ ### Step 3: Configure Tailwind
45
+
46
+ Update your `tailwind.config.js` to include the package components:
47
+
48
+ ```js
49
+ /** @type {import('tailwindcss').Config} */
50
+ module.exports = {
51
+ content: [
52
+ "./src/**/*.{js,ts,jsx,tsx}",
53
+ "./node_modules/@ngenux/ngage-whiteboarding/**/*.{js,jsx,ts,tsx}",
54
+ ],
55
+ theme: {
56
+ extend: {},
57
+ },
58
+ plugins: [],
59
+ }
60
+ ```
61
+
62
+ ### Step 4: Import Styles
63
+
64
+ Add the package CSS to your main CSS file or import it in your main component:
65
+
66
+ ```css
67
+ /* In your main CSS file (e.g., src/index.css) */
68
+ @tailwind base;
69
+ @tailwind components;
70
+ @tailwind utilities;
71
+ ```
72
+
73
+ ```tsx
74
+ // Or import in your main component
75
+ import '@ngenux/ngage-whiteboarding/dist/styles.css';
76
+ ```
77
+
78
+ ### Step 5: Verify Setup
79
+
80
+ Create a simple test component to verify everything is working:
81
+
82
+ ```tsx
83
+ import React from 'react';
84
+ import '@ngenux/ngage-whiteboarding/dist/styles.css';
85
+ import { WhiteboardProvider, Whiteboard } from '@ngenux/ngage-whiteboarding';
86
+
87
+ function TestWhiteboard() {
88
+ return (
89
+ <div style={{ width: '100vw', height: '100vh' }}>
90
+ <WhiteboardProvider webSocketUrl="ws://localhost:3001">
91
+ <Whiteboard
92
+ roomId="test-room"
93
+ userId="test-user"
94
+ isAdmin={true}
95
+ allowedUsers={['test-user']}
96
+ />
97
+ </WhiteboardProvider>
98
+ </div>
99
+ );
100
+ }
101
+
102
+ export default TestWhiteboard;
103
+ ```
104
+
105
+ If you see a styled whiteboard with a toolbar and sidebar, your setup is complete! 🎉
106
+
24
107
  ## 🚀 Quick Start
25
108
 
26
109
  ### Basic Setup
27
110
 
28
111
  ```tsx
29
112
  import React from 'react';
113
+ import '@ngenux/ngage-whiteboarding/dist/styles.css'; // Import the CSS
30
114
  import { WhiteboardProvider, Whiteboard } from '@ngenux/ngage-whiteboarding';
31
115
 
32
116
  function App() {
@@ -45,6 +129,36 @@ function App() {
45
129
  export default App;
46
130
  ```
47
131
 
132
+ ### For Vite Projects
133
+
134
+ If you're using Vite, make sure your `vite.config.js` includes:
135
+
136
+ ```js
137
+ import { defineConfig } from 'vite'
138
+ import react from '@vitejs/plugin-react'
139
+
140
+ export default defineConfig({
141
+ plugins: [react()],
142
+ css: {
143
+ postcss: './postcss.config.js', // Ensure PostCSS is configured
144
+ },
145
+ })
146
+ ```
147
+
148
+ ### For shadcn/ui Projects
149
+
150
+ If you're using shadcn/ui, you can enhance the integration with our utility functions:
151
+
152
+ ```tsx
153
+ import { cn } from '@ngenux/ngage-whiteboarding'; // Use our cn utility
154
+
155
+ // Or use with your existing shadcn/ui cn function
156
+ import { cn } from '@/lib/utils';
157
+ import { Whiteboard } from '@ngenux/ngage-whiteboarding';
158
+
159
+ const customClasses = cn('your-custom-classes', 'conditional-class');
160
+ ```
161
+
48
162
  ### Advanced Usage with Multiple Rooms
49
163
 
50
164
  ```tsx
@@ -76,6 +190,100 @@ function CollaborativeApp() {
76
190
  }
77
191
  ```
78
192
 
193
+ ### Transparent Background Configuration
194
+
195
+ If you want to enforce a transparent background and prevent users from changing it:
196
+
197
+ ```tsx
198
+ import { WhiteboardProvider, Whiteboard } from '@ngenux/ngage-whiteboarding';
199
+
200
+ function TransparentWhiteboard() {
201
+ return (
202
+ <WhiteboardProvider webSocketUrl="ws://localhost:3001">
203
+ <Whiteboard
204
+ roomId="transparent-room"
205
+ userId="user-123"
206
+ isAdmin={true}
207
+ allowedUsers={['user-123']}
208
+ transparentBackground={true} // Forces transparent & locks background
209
+ />
210
+ </WhiteboardProvider>
211
+ );
212
+ }
213
+ ```
214
+
215
+ **Behavior:**
216
+ - When `transparentBackground={true}`:
217
+ - ✅ Background is automatically set to transparent
218
+ - 🔒 Background color picker is disabled and shows "Transparent background locked"
219
+ - Perfect for overlaying the whiteboard on existing content
220
+
221
+ - When `transparentBackground={false}` (default):
222
+ - ✅ Background defaults to white
223
+ - 🎨 Users can change background color freely
224
+
225
+ ### Video Background for Annotation
226
+
227
+ Annotate over live video streams (screen-share, webcam, etc.):
228
+
229
+ ```tsx
230
+ import { WhiteboardProvider, Whiteboard } from '@ngenux/ngage-whiteboarding';
231
+ import { useEffect, useState } from 'react';
232
+
233
+ function VideoAnnotationWhiteboard() {
234
+ const [videoStream, setVideoStream] = useState<MediaStream | undefined>();
235
+
236
+ // Get screen share or webcam stream
237
+ useEffect(() => {
238
+ async function getStream() {
239
+ try {
240
+ // Screen share example
241
+ const stream = await navigator.mediaDevices.getDisplayMedia({
242
+ video: { width: 1920, height: 1080 }
243
+ });
244
+ setVideoStream(stream);
245
+ } catch (err) {
246
+ console.error('Failed to get video stream:', err);
247
+ }
248
+ }
249
+ getStream();
250
+
251
+ return () => {
252
+ // Cleanup: stop all tracks when component unmounts
253
+ if (videoStream) {
254
+ videoStream.getTracks().forEach(track => track.stop());
255
+ }
256
+ };
257
+ }, []);
258
+
259
+ return (
260
+ <WhiteboardProvider webSocketUrl="ws://localhost:3001">
261
+ <Whiteboard
262
+ roomId="video-annotation-room"
263
+ userId="user-123"
264
+ isAdmin={true}
265
+ allowedUsers={['user-123']}
266
+ videoStream={videoStream} // Video renders as background layer
267
+ />
268
+ </WhiteboardProvider>
269
+ );
270
+ }
271
+ ```
272
+
273
+ **Features:**
274
+ - 🎥 **Video as background**: Stream renders behind whiteboard canvas
275
+ - 🖊️ **Draw over video**: All drawing tools work normally over the video
276
+ - 🔒 **Auto-transparent**: Background automatically set to transparent
277
+ - ⚡ **60fps performance**: HTML video layer, no canvas copying
278
+ - 📐 **Auto-scaling**: Video maintains aspect ratio with letterbox
279
+ - 🎯 **Pointer-events handled**: Video doesn't interfere with drawing
280
+
281
+ **Use cases:**
282
+ - Screen-share annotation for remote presentations
283
+ - Video call annotation
284
+ - Educational content markup
285
+ - Live streaming annotation
286
+
79
287
  ## 📝 API Reference
80
288
 
81
289
  ### WhiteboardProvider Props
@@ -93,6 +301,8 @@ function CollaborativeApp() {
93
301
  | `userId` | `string` | ✅ | - | Unique identifier for the current user |
94
302
  | `isAdmin` | `boolean` | ❌ | `false` | Whether user has admin privileges (clear, lock/unlock) |
95
303
  | `allowedUsers` | `string[]` | ❌ | `[]` | Array of user IDs who have drawing permissions |
304
+ | `transparentBackground` | `boolean` | ❌ | `false` | Forces transparent background and disables color picker |
305
+ | `videoStream` | `MediaStream` | ❌ | `undefined` | Live video stream for background layer (screen-share/video annotation) |
96
306
 
97
307
  ### Hooks
98
308
 
@@ -167,6 +377,8 @@ const MyWhiteboard: React.FC<WhiteboardProps> = (props) => {
167
377
  - Safari 13+
168
378
  - Edge 80+
169
379
 
380
+ **Note:** Requires a modern browser with WebSocket support and ES6+ features.
381
+
170
382
  ## 📱 Responsive Design
171
383
 
172
384
  The whiteboard automatically adapts to different screen sizes and supports touch interactions on mobile devices.
@@ -182,19 +394,31 @@ The whiteboard automatically adapts to different screen sizes and supports touch
182
394
 
183
395
  ### Common Issues
184
396
 
185
- 1. **WebSocket connection fails**
397
+ 1. **Styles not appearing / Components look unstyled**
398
+ - ✅ Ensure Tailwind CSS is installed and configured in your project
399
+ - ✅ Add the package path to your `tailwind.config.js` content array
400
+ - ✅ Import the package CSS: `import '@ngenux/ngage-whiteboarding/dist/styles.css'`
401
+ - ✅ Verify your PostCSS configuration is working
402
+
403
+ 2. **WebSocket connection fails**
186
404
  - Ensure your WebSocket server is running and accessible
187
405
  - Check CORS configuration on your server
188
406
  - Verify the `webSocketUrl` is correct
189
407
 
190
- 2. **Drawing doesn't sync between users**
408
+ 3. **Drawing doesn't sync between users**
191
409
  - Verify all users are in the same `roomId`
192
410
  - Check WebSocket server is properly broadcasting messages
193
411
  - Ensure `userId` is unique for each user
194
412
 
195
- 3. **TypeScript errors**
413
+ 4. **TypeScript errors**
196
414
  - Make sure you're importing types correctly
197
415
  - Verify your TypeScript configuration includes the package types
416
+ - Ensure React types are properly installed
417
+
418
+ 5. **Build errors with Vite/bundler**
419
+ - Update to the latest version of your bundler
420
+ - Ensure PostCSS and Tailwind plugins are properly configured
421
+ - Check that the package is included in your bundler's dependency optimization
198
422
 
199
423
  ## 📄 License
200
424
 
package/dist/index.d.ts CHANGED
@@ -1,8 +1,10 @@
1
+ import './src/styles.css';
1
2
  import { Whiteboard } from './src/components/Whiteboard';
2
3
  import { WhiteboardProvider } from './src/context/WhiteboardContext';
3
4
  import { useCapture } from './src/hooks/useCapture';
4
- export { Whiteboard, WhiteboardProvider, useCapture as useWhiteboardStream };
5
- export type { WhiteboardProps } from './src/components/Whiteboard';
5
+ import { cn } from './src/lib/utils';
6
+ export { Whiteboard, WhiteboardProvider, useCapture as useWhiteboardStream, cn };
7
+ export type { WhiteboardProps } from './src/components/Whiteboard/index';
6
8
  export type { ShapeProps, ToolType, StrokeStyle, WhiteboardState, DrawingAction, CompressedData } from './src/types';
7
9
  export interface WhiteboardProviderProps {
8
10
  children: React.ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEpD,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,IAAI,mBAAmB,EAAE,CAAC;AAG7E,YAAY,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AACnE,YAAY,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,eAAe,EACf,aAAa,EACb,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.tsx"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AACpD,OAAO,EAAE,EAAE,EAAE,MAAM,iBAAiB,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,UAAU,IAAI,mBAAmB,EAAE,EAAE,EAAE,CAAC;AAGjF,YAAY,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACzE,YAAY,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,eAAe,EACf,aAAa,EACb,cAAc,EACf,MAAM,aAAa,CAAC;AAGrB,MAAM,WAAW,uBAAuB;IACtC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB"}