@clikvn/showroom-visualizer 0.3.0-dev-05 → 0.3.0-dev-07

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.
Files changed (67) hide show
  1. package/CLAUDE.md +140 -0
  2. package/Planning/README-middleware.md +582 -0
  3. package/Planning/README.md +67 -0
  4. package/Planning/TEMPLATE.md +270 -0
  5. package/README.md +181 -15
  6. package/dist/commons/SkinLayer/components/LazyImage/index.d.ts +15 -1
  7. package/dist/commons/SkinLayer/components/LazyImage/index.d.ts.map +1 -1
  8. package/dist/components/SkinLayer/GalleryFullScreen/Content/index.d.ts.map +1 -1
  9. package/dist/components/SkinLayer/HotspotOverview/index.d.ts.map +1 -1
  10. package/dist/components/SkinLayer/PinActionButtons/index.d.ts.map +1 -1
  11. package/dist/components/SkinLayer/SceneCategories/index.d.ts.map +1 -1
  12. package/dist/components/SkinLayer/SearchAndDiscoverySlideIn/PoiInfoActionPart/index.d.ts.map +1 -1
  13. package/dist/components/SkinLayer/TourScenarios/index.d.ts.map +1 -1
  14. package/dist/features/ShowroomVisualizer/index.d.ts +2 -1
  15. package/dist/features/ShowroomVisualizer/index.d.ts.map +1 -1
  16. package/dist/hooks/Visualizer/useTourVisualizer.d.ts.map +1 -1
  17. package/dist/hooks/useActionMiddleware.d.ts +25 -0
  18. package/dist/hooks/useActionMiddleware.d.ts.map +1 -0
  19. package/dist/hooks/useConfiguration.d.ts +3 -1
  20. package/dist/hooks/useConfiguration.d.ts.map +1 -1
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/models/Visualizer/Plugins/BasePlugin.d.ts.map +1 -1
  24. package/dist/models/Visualizer/Poi/PoiLensFlare.d.ts.map +1 -1
  25. package/dist/models/Visualizer/Poi/PoiMultimedia/PoiSound.d.ts.map +1 -1
  26. package/dist/models/Visualizer/Poi/PoiMultimedia/PoiVideo.d.ts.map +1 -1
  27. package/dist/register.d.ts +2 -1
  28. package/dist/register.d.ts.map +1 -1
  29. package/dist/types/SkinLayer/index.d.ts +1 -0
  30. package/dist/types/SkinLayer/index.d.ts.map +1 -1
  31. package/dist/types/SkinLayer/middleware.type.d.ts +41 -0
  32. package/dist/types/SkinLayer/middleware.type.d.ts.map +1 -0
  33. package/dist/types/SkinLayer/visualizer.type.d.ts +2 -0
  34. package/dist/types/SkinLayer/visualizer.type.d.ts.map +1 -1
  35. package/dist/types/Visualizer/tourScenario/tourScenario.type.d.ts.map +1 -1
  36. package/dist/utils/Visualizer/image.utils.d.ts.map +1 -1
  37. package/dist/utils/middleware/listenerWrapper.d.ts +31 -0
  38. package/dist/utils/middleware/listenerWrapper.d.ts.map +1 -0
  39. package/dist/web.js +1 -1
  40. package/package.json +3 -3
  41. package/.claude/settings.local.json +0 -19
  42. package/dist/components/SkinLayer/DefaultLayout/index.d.ts +0 -8
  43. package/dist/components/SkinLayer/DefaultLayout/index.d.ts.map +0 -1
  44. package/dist/context/CustomLayoutContext.d.ts +0 -20
  45. package/dist/context/CustomLayoutContext.d.ts.map +0 -1
  46. package/dist/context/SwizzleContext.d.ts +0 -21
  47. package/dist/context/SwizzleContext.d.ts.map +0 -1
  48. package/dist/hooks/headless/index.d.ts +0 -150
  49. package/dist/hooks/headless/index.d.ts.map +0 -1
  50. package/dist/hooks/headless/useFloorplanControl.d.ts +0 -18
  51. package/dist/hooks/headless/useFloorplanControl.d.ts.map +0 -1
  52. package/dist/hooks/headless/usePOIInteraction.d.ts +0 -23
  53. package/dist/hooks/headless/usePOIInteraction.d.ts.map +0 -1
  54. package/dist/hooks/headless/useScenarioControl.d.ts +0 -22
  55. package/dist/hooks/headless/useScenarioControl.d.ts.map +0 -1
  56. package/dist/hooks/headless/useSceneNavigation.d.ts +0 -26
  57. package/dist/hooks/headless/useSceneNavigation.d.ts.map +0 -1
  58. package/dist/hooks/headless/useTourCore.d.ts +0 -23
  59. package/dist/hooks/headless/useTourCore.d.ts.map +0 -1
  60. package/dist/hooks/headless/useViewportControl.d.ts +0 -22
  61. package/dist/hooks/headless/useViewportControl.d.ts.map +0 -1
  62. package/dist/index.html +0 -110
  63. package/dist/index.js +0 -1
  64. package/dist/types/custom-layout.d.ts +0 -63
  65. package/dist/types/custom-layout.d.ts.map +0 -1
  66. package/dist/types/swizzle.d.ts +0 -59
  67. package/dist/types/swizzle.d.ts.map +0 -1
package/CLAUDE.md ADDED
@@ -0,0 +1,140 @@
1
+ # CLAUDE.md
2
+
3
+ This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
+
5
+ ## Project Overview
6
+
7
+ This is a React-based 3D showroom visualizer library built with TypeScript that renders interactive 360-degree virtual tours. The library is published as `@clikvn/showroom-visualizer` and integrates with Krpano panoramic viewer technology to create immersive experiences with POIs (Points of Interest), scenarios, and multimedia content.
8
+
9
+ ## Build Commands
10
+
11
+ ```bash
12
+ # Development with hot reload
13
+ yarn dev
14
+
15
+ # Production build
16
+ yarn build
17
+
18
+ # Linting
19
+ yarn lint
20
+ yarn lint:fix
21
+
22
+ # Code formatting
23
+ yarn prettier
24
+
25
+ # Publish to npm
26
+ yarn deploy # Builds and publishes
27
+ ```
28
+
29
+ ## Code Architecture
30
+
31
+ ### Entry Points
32
+
33
+ - `src/web.ts` - Main entry point that exports the visualizer API to `window.ShowroomVisualizer`
34
+ - `src/window.ts` - Handles browser integration: `initVisualizer()` and `destroy()` methods
35
+ - `src/features/ShowroomVisualizer/index.tsx` - Root React component that sets up providers and layout
36
+
37
+ ### Core Architecture Layers
38
+
39
+ The codebase follows a layered architecture:
40
+
41
+ 1. **Visualizer Layer** (`src/models/Visualizer/`) - Domain models that manage 3D tour logic
42
+ - `Tour.ts` - Central orchestrator managing scenes, POIs, sounds, and scenarios
43
+ - `Krpano.ts` - Wrapper around Krpano API with coordinate transformation utilities
44
+ - `Scene.ts` - Individual 360° panorama scenes
45
+ - `Poi/` - Various POI types (Gallery, Info, Navigation, Multimedia, Texture, etc.)
46
+ - `TourScenario/` - Automated tour playback with actions (LookingAt, Moving, Rotation, Sleep, etc.)
47
+ - `Plugins/` - Gyro, Radar, Sound plugins
48
+
49
+ 2. **SkinLayer** (`src/components/SkinLayer/`) - React UI components
50
+ - Components overlay on the 3D viewer providing interactivity
51
+ - Key components: Floorplan/Minimap, HotspotOverview, PlayBar, SearchAndDiscovery, PoiDetailSlideIn
52
+ - Uses Ant Design components with custom styling
53
+
54
+ 3. **State Management** (`src/hooks/useStore.tsx`)
55
+ - Context-based global state management
56
+ - Manages UI state, active POIs, scenarios, galleries, slide-ins
57
+ - Provides selectors for component consumption
58
+
59
+ 4. **Services Layer** (`src/services/Visualizer/`)
60
+ - `tour.service.ts` - Fetches tour data from API
61
+ - `poi.service.ts` - POI-related API calls
62
+ - `webRotate.service.ts` - Web rotation functionality
63
+ - `request.ts` - HTTP client wrapper
64
+
65
+ ### Key Architectural Patterns
66
+
67
+ **Krpano Integration**: The `Krpano` class wraps the Krpano viewer API and provides coordinate transformation utilities (`screentosphere`, `spheretoscreen`, `spheretospace`, `spacetosphere`). All 3D position calculations go through this abstraction.
68
+
69
+ **POI System**: POIs are polymorphic with a base `Poi` class and specialized subtypes (PoiInfo, PoiGallery, PoiVideo, PoiSound, etc.). Each type handles its own rendering and interaction logic within the Krpano viewer.
70
+
71
+ **Tour Scenario System**: Scenarios are composed of `TourScenarioStep` objects containing `TourScenarioAction` implementations. The `TourScenarioPlayer` executes actions sequentially (LookingAt → Moving → Rotation → Sleep patterns). Actions can have associated sounds managed by `ScenarioSound`.
72
+
73
+ **Signal-based Events**: Uses the `signals` library extensively for decoupled event handling between Visualizer and SkinLayer.
74
+
75
+ **Web Component Registration**: The library registers `<showroom-visualizer>` as a custom element (see `src/register.ts`) for easy embedding.
76
+
77
+ ### Configuration System
78
+
79
+ Configuration flows through multiple layers:
80
+
81
+ - External config passed to `initVisualizer()`
82
+ - `ConfigurationProvider` (src/hooks/useConfiguration.tsx) merges API host, override configs, listeners, middleware
83
+ - `StoreProvider` maintains runtime state
84
+ - `TourContext` provides global access to the Tour instance
85
+
86
+ ### Middleware System
87
+
88
+ The library supports a **tracking middleware** system for analytics and monitoring:
89
+
90
+ **Architecture**:
91
+
92
+ - Middleware function passed to `initVisualizer({ middleware: (event) => {...} })`
93
+ - `useActionMiddleware` hook provides `trackAction()` function to components
94
+ - Tracks 12 action types across UI layer and Krpano/POI layer
95
+ - **Tracking-only** - does not block or cancel actions (fire-and-forget pattern)
96
+ - Works independently of listeners (fires even without listeners configured)
97
+
98
+ **Implementation Locations**:
99
+
100
+ 1. **UI Components** (`src/components/SkinLayer/`)
101
+ - `PinActionButtons` - Pin action clicks
102
+ - `SceneCategories` - Scene navigation
103
+ - `TourScenarios` - Scenario playback
104
+ - `HotspotOverview` - View more, gallery, texture interactions
105
+
106
+ 2. **Krpano/POI Layer** (`src/hooks/Visualizer/useTourVisualizer.ts`)
107
+ - POI clicks, moving POI, texture POI
108
+ - Background sound toggle
109
+ - Function button opens
110
+ - Minimap fullscreen toggle
111
+
112
+ **See**: `Planning/README-middleware.md` for complete documentation with all tracked actions and usage examples.
113
+
114
+ ### Multi-language Support
115
+
116
+ Uses `i18next` with JSON translation files in `src/assets/locales/{en,cn,jp,kr,vi}/` covering chatbot, common, guide, nav, onboarding-screen, and skin-layer namespaces.
117
+
118
+ ## Development Notes
119
+
120
+ **TypeScript Paths**: Uses path aliases with `baseUrl: "./src"` so imports like `import { Tour } from 'models/Visualizer/Tour'` work without relative paths.
121
+
122
+ **Rollup Build**: Configured for ESM output with PostCSS (Tailwind), TypeScript compilation, and tree-shaking. Development mode skips uglify/terser/babel for faster rebuilds.
123
+
124
+ **CSS Architecture**: Mix of component-scoped CSS files (`src/assets/*.css`) and Tailwind utilities. Custom CSS variables set dynamically for modal positioning and hotspot states.
125
+
126
+ **State Persistence**: No localStorage/sessionStorage - state is ephemeral per session. Tours are fetched fresh via SWR caching.
127
+
128
+ **Mobile vs Desktop**: The `mobile` prop controls UI layout significantly - different slide-in behaviors, hotspot positioning, and touch controls.
129
+
130
+ ## Common Patterns
131
+
132
+ **Finding POIs**: Use `tour.getPoiByType(POI_TYPE.*)` or `tour.getPoisByIds(ids)`
133
+
134
+ **Scene Navigation**: `tour.changeScene(sceneCode)` or through navigation POIs
135
+
136
+ **Coordinate Conversion**: Always use `krpano.screentosphere()` / `spheretoscreen()` for position calculations between screen and 3D space
137
+
138
+ **Adding Listeners**: Tour emits signals for scene changes, POI interactions, scenario events - hook into these via `tour.signals.*`
139
+
140
+ **ESLint Rules**: The project uses TypeScript ESLint with Prettier integration. Note that `no-console` allows `info`, `warn`, `error` but not plain `log`.