@zonetrix/viewer 2.12.0 → 2.13.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zonetrix/viewer",
3
- "version": "2.12.0",
3
+ "version": "2.13.1",
4
4
  "type": "module",
5
5
  "description": "Lightweight React component for rendering interactive seat maps",
6
6
  "main": "./dist/index.js",
@@ -1,30 +0,0 @@
1
- import { Database } from 'firebase/database';
2
- /**
3
- * Initialize the Firebase database instance for the viewer
4
- * This should be called by the host application after Firebase is initialized
5
- *
6
- * @example
7
- * ```tsx
8
- * import { initializeApp } from 'firebase/app';
9
- * import { getDatabase } from 'firebase/database';
10
- * import { initializeFirebaseForViewer } from '@zonetrix/viewer';
11
- *
12
- * const app = initializeApp(firebaseConfig);
13
- * const db = getDatabase(app);
14
- * initializeFirebaseForViewer(db);
15
- * ```
16
- */
17
- export declare function initializeFirebaseForViewer(database: Database): void;
18
- /**
19
- * Get the Firebase database instance
20
- * @throws Error if Firebase hasn't been initialized
21
- */
22
- export declare function getFirebaseDatabase(): Database;
23
- /**
24
- * Check if Firebase has been initialized for the viewer
25
- */
26
- export declare function isFirebaseInitialized(): boolean;
27
- /**
28
- * Clear the Firebase database instance (useful for testing)
29
- */
30
- export declare function clearFirebaseInstance(): void;
@@ -1,41 +0,0 @@
1
- import { SeatMapConfig } from '../types';
2
- export interface UseFirebaseConfigOptions {
3
- /** The seat map ID to load */
4
- seatMapId: string | null;
5
- /** Whether loading is enabled (default: true) */
6
- enabled?: boolean;
7
- /** Subscribe to design changes in real-time (default: false) */
8
- subscribeToChanges?: boolean;
9
- /** Callback when config loads or changes */
10
- onConfigLoad?: (config: SeatMapConfig) => void;
11
- /** Callback on error */
12
- onError?: (error: Error) => void;
13
- }
14
- export interface UseFirebaseConfigResult {
15
- /** The loaded configuration */
16
- config: SeatMapConfig | null;
17
- /** Whether loading is in progress */
18
- loading: boolean;
19
- /** Any error that occurred */
20
- error: Error | null;
21
- /** Manually refetch the config */
22
- refetch: () => Promise<void>;
23
- }
24
- /**
25
- * Load seat map configuration from Firebase
26
- *
27
- * @example
28
- * ```tsx
29
- * // One-time load
30
- * const { config, loading, error } = useFirebaseConfig({
31
- * seatMapId: '123',
32
- * });
33
- *
34
- * // With real-time design updates (for admin/editor preview)
35
- * const { config } = useFirebaseConfig({
36
- * seatMapId: '123',
37
- * subscribeToChanges: true,
38
- * });
39
- * ```
40
- */
41
- export declare function useFirebaseConfig(options: UseFirebaseConfigOptions): UseFirebaseConfigResult;
@@ -1,53 +0,0 @@
1
- import { FirebaseSeatStates } from '@zonetrix/shared';
2
- export interface UseFirebaseSeatStatesOptions {
3
- /** The seat map ID to subscribe to */
4
- seatMapId: string | null;
5
- /** Current user ID for user-aware state derivation */
6
- currentUserId?: string;
7
- /** Whether the subscription is enabled (default: true) */
8
- enabled?: boolean;
9
- /** Callback when states change */
10
- onStateChange?: (states: FirebaseSeatStates) => void;
11
- /** Callback on error */
12
- onError?: (error: Error) => void;
13
- }
14
- export interface UseFirebaseSeatStatesResult {
15
- /** Current seat states map */
16
- states: FirebaseSeatStates | null;
17
- /** Whether initial load is in progress */
18
- loading: boolean;
19
- /** Any error that occurred */
20
- error: Error | null;
21
- /** Timestamp of last update */
22
- lastUpdated: number | null;
23
- /** Seats reserved by current user (show as selected) */
24
- myReservedSeats: string[];
25
- /** Seats reserved by other users (show as reserved) */
26
- otherReservedSeats: string[];
27
- /** Seats unavailable for everyone */
28
- unavailableSeats: string[];
29
- /** @deprecated Use otherReservedSeats instead */
30
- reservedSeats: string[];
31
- }
32
- /**
33
- * Subscribe to real-time seat state updates from Firebase
34
- * Uses useSyncExternalStore for stable snapshot handling
35
- *
36
- * @example
37
- * ```tsx
38
- * const { myReservedSeats, otherReservedSeats, unavailableSeats, loading } = useFirebaseSeatStates({
39
- * seatMapId: '123',
40
- * currentUserId: 'user-abc',
41
- * });
42
- *
43
- * return (
44
- * <SeatMapViewer
45
- * config={config}
46
- * myReservedSeats={myReservedSeats}
47
- * reservedSeats={otherReservedSeats}
48
- * unavailableSeats={unavailableSeats}
49
- * />
50
- * );
51
- * ```
52
- */
53
- export declare function useFirebaseSeatStates(options: UseFirebaseSeatStatesOptions): UseFirebaseSeatStatesResult;
@@ -1,74 +0,0 @@
1
- import { SeatMapConfig } from '../types';
2
- import { FirebaseSeatStates } from '@zonetrix/shared';
3
- export interface UseRealtimeSeatMapOptions {
4
- /** The seat map ID to load and subscribe to */
5
- seatMapId: string | null;
6
- /** Current user ID for user-aware state derivation */
7
- userId?: string;
8
- /** Whether the hook is enabled (default: true) */
9
- enabled?: boolean;
10
- /** Subscribe to design changes in real-time (default: false) */
11
- subscribeToDesignChanges?: boolean;
12
- /** Callback when config loads */
13
- onConfigLoad?: (config: SeatMapConfig) => void;
14
- /** Callback when seat states change */
15
- onStateChange?: (states: FirebaseSeatStates) => void;
16
- /** Callback on any error */
17
- onError?: (error: Error) => void;
18
- }
19
- export interface UseRealtimeSeatMapResult {
20
- /** The seat map configuration */
21
- config: SeatMapConfig | null;
22
- /** Whether initial loading is in progress */
23
- loading: boolean;
24
- /** Any error that occurred */
25
- error: Error | null;
26
- /** Seats reserved by current user (show as selected) */
27
- myReservedSeats: string[];
28
- /** Seats reserved by other users (show as reserved) */
29
- otherReservedSeats: string[];
30
- /** Seats unavailable for everyone */
31
- unavailableSeats: string[];
32
- /** @deprecated Use otherReservedSeats instead */
33
- reservedSeats: string[];
34
- /** Raw seat states map */
35
- seatStates: FirebaseSeatStates | null;
36
- /** Timestamp of last state update */
37
- lastUpdated: number | null;
38
- /** Manually refetch the config */
39
- refetch: () => Promise<void>;
40
- }
41
- /**
42
- * Combined hook for loading config and subscribing to real-time seat states
43
- *
44
- * @example
45
- * ```tsx
46
- * import { useRealtimeSeatMap, SeatMapViewer } from '@zonetrix/viewer';
47
- *
48
- * function BookingPage({ seatMapId, userId }) {
49
- * const {
50
- * config,
51
- * myReservedSeats,
52
- * otherReservedSeats,
53
- * unavailableSeats,
54
- * loading,
55
- * error
56
- * } = useRealtimeSeatMap({ seatMapId, userId });
57
- *
58
- * if (loading) return <LoadingSpinner />;
59
- * if (error) return <ErrorMessage error={error} />;
60
- * if (!config) return null;
61
- *
62
- * return (
63
- * <SeatMapViewer
64
- * config={config}
65
- * myReservedSeats={myReservedSeats}
66
- * reservedSeats={otherReservedSeats}
67
- * unavailableSeats={unavailableSeats}
68
- * onSeatSelect={handleSeatSelect}
69
- * />
70
- * );
71
- * }
72
- * ```
73
- */
74
- export declare function useRealtimeSeatMap(options: UseRealtimeSeatMapOptions): UseRealtimeSeatMapResult;