@clikvn/showroom-visualizer 0.3.4-dev-09 → 0.3.4-dev-10

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 (39) hide show
  1. package/.claude/settings.local.json +19 -0
  2. package/CLAUDE.md +145 -145
  3. package/DEVELOPMENT.md +120 -120
  4. package/EXAMPLES.md +967 -967
  5. package/README.md +489 -489
  6. package/SETUP_COMPLETE.md +149 -149
  7. package/base.json +21 -21
  8. package/dist/components/SkinLayer/Floorplan/Minimap/test01.d.ts +15 -0
  9. package/dist/components/SkinLayer/Floorplan/Minimap/test01.d.ts.map +1 -0
  10. package/dist/fonts/icomoon.svg +633 -633
  11. package/dist/index.js +1 -1
  12. package/dist/web.d.ts.map +1 -1
  13. package/dist/web.js +1 -1
  14. package/example/CSS_HANDLING.md +141 -141
  15. package/example/FIXES_SUMMARY.md +121 -121
  16. package/example/PATH_ALIASES.md +103 -103
  17. package/example/README.md +64 -64
  18. package/example/index.html +13 -13
  19. package/example/package.json +25 -25
  20. package/example/postcss.config.cjs +5 -5
  21. package/example/tailwind.config.cjs +12 -12
  22. package/example/tsconfig.node.json +12 -12
  23. package/example/vite.config.ts +142 -142
  24. package/package.json +132 -132
  25. package/rollup.config.js +400 -400
  26. package/tailwind.config.cjs +151 -151
  27. package/dist/components/SkinLayer/Drawer/PoiHeader/index.d.ts +0 -16
  28. package/dist/components/SkinLayer/Drawer/PoiHeader/index.d.ts.map +0 -1
  29. package/dist/components/SkinLayer/Drawer/index.d.ts +0 -29
  30. package/dist/components/SkinLayer/Drawer/index.d.ts.map +0 -1
  31. package/dist/components/SkinLayer/PlayAll/index.d.ts +0 -8
  32. package/dist/components/SkinLayer/PlayAll/index.d.ts.map +0 -1
  33. package/dist/features/VirtualTourVisualizer/index.d.ts +0 -20
  34. package/dist/features/VirtualTourVisualizer/index.d.ts.map +0 -1
  35. package/dist/features/VirtualTourVisualizerUI/index.d.ts +0 -17
  36. package/dist/features/VirtualTourVisualizerUI/index.d.ts.map +0 -1
  37. package/dist/index.html +0 -32
  38. /package/dist/features/ShowroomVisualizer/{cssStyles.d.ts → CssStyles.d.ts} +0 -0
  39. /package/dist/features/ShowroomVisualizer/{cssStyles.d.ts.map → CssStyles.d.ts.map} +0 -0
@@ -0,0 +1,19 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(find:*)",
5
+ "Bash(npm run build:*)",
6
+ "Bash(grep:*)",
7
+ "Bash(rm:*)",
8
+ "Bash(ls:*)",
9
+ "Bash(sed:*)",
10
+ "Bash(yarn build)",
11
+ "Bash(yalc push:*)",
12
+ "Bash(yarn dev)",
13
+ "Bash(yarn list:*)",
14
+ "Bash(mv:*)",
15
+ "Bash(rg:*)"
16
+ ],
17
+ "deny": []
18
+ }
19
+ }
package/CLAUDE.md CHANGED
@@ -1,145 +1,145 @@
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 comprehensive **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
- - **35+ tracking actions** covering all user interactions
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
- **Complete Coverage**:
99
-
100
- 1. **Search & Discovery** - All category clicks, search, individual item clicks (products, POIs, features, etc.)
101
- 2. **POI Detail Panel** - Open/close, action buttons (AI, Save, Audio, Share), tab switching, gallery clicks
102
- 3. **Scenario Playback** - Play/pause, skip, loop, sound toggle, scenario selection
103
- 4. **Navigation** - Scene groups, floorplan changes, minimap controls
104
- 5. **UI Components** - Guide, playbar, all interactive elements
105
-
106
- **Key Features**:
107
-
108
- - **Deep-level tracking** - Tracks not just categories but individual items within each category
109
- - **Rich payloads** - Each event includes codes, names, types, and contextual data
110
- - **User journey mapping** - Complete visibility into user interactions from discovery to engagement
111
- - **Analytics-ready** - Designed for integration with GA4, Mixpanel, or custom backends
112
-
113
- **Documentation**:
114
-
115
- - 📚 **[Complete Tracking Guide](Planning/README-tracking-complete.md)** - Full reference of all 35+ tracking actions with examples
116
- - 📖 **[Middleware Architecture](Planning/README-middleware.md)** - Core middleware system documentation
117
- - 📝 **[Changes Summary](Planning/TRACKING-CHANGES-SUMMARY.md)** - List of all modified files and implementation details
118
-
119
- ### Multi-language Support
120
-
121
- 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.
122
-
123
- ## Development Notes
124
-
125
- **TypeScript Paths**: Uses path aliases with `baseUrl: "./src"` so imports like `import { Tour } from 'models/Visualizer/Tour'` work without relative paths.
126
-
127
- **Rollup Build**: Configured for ESM output with PostCSS (Tailwind), TypeScript compilation, and tree-shaking. Development mode skips uglify/terser/babel for faster rebuilds.
128
-
129
- **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.
130
-
131
- **State Persistence**: No localStorage/sessionStorage - state is ephemeral per session. Tours are fetched fresh via SWR caching.
132
-
133
- **Mobile vs Desktop**: The `mobile` prop controls UI layout significantly - different slide-in behaviors, hotspot positioning, and touch controls.
134
-
135
- ## Common Patterns
136
-
137
- **Finding POIs**: Use `tour.getPoiByType(POI_TYPE.*)` or `tour.getPoisByIds(ids)`
138
-
139
- **Scene Navigation**: `tour.changeScene(sceneCode)` or through navigation POIs
140
-
141
- **Coordinate Conversion**: Always use `krpano.screentosphere()` / `spheretoscreen()` for position calculations between screen and 3D space
142
-
143
- **Adding Listeners**: Tour emits signals for scene changes, POI interactions, scenario events - hook into these via `tour.signals.*`
144
-
145
- **ESLint Rules**: The project uses TypeScript ESLint with Prettier integration. Note that `no-console` allows `info`, `warn`, `error` but not plain `log`.
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 comprehensive **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
+ - **35+ tracking actions** covering all user interactions
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
+ **Complete Coverage**:
99
+
100
+ 1. **Search & Discovery** - All category clicks, search, individual item clicks (products, POIs, features, etc.)
101
+ 2. **POI Detail Panel** - Open/close, action buttons (AI, Save, Audio, Share), tab switching, gallery clicks
102
+ 3. **Scenario Playback** - Play/pause, skip, loop, sound toggle, scenario selection
103
+ 4. **Navigation** - Scene groups, floorplan changes, minimap controls
104
+ 5. **UI Components** - Guide, playbar, all interactive elements
105
+
106
+ **Key Features**:
107
+
108
+ - **Deep-level tracking** - Tracks not just categories but individual items within each category
109
+ - **Rich payloads** - Each event includes codes, names, types, and contextual data
110
+ - **User journey mapping** - Complete visibility into user interactions from discovery to engagement
111
+ - **Analytics-ready** - Designed for integration with GA4, Mixpanel, or custom backends
112
+
113
+ **Documentation**:
114
+
115
+ - 📚 **[Complete Tracking Guide](Planning/README-tracking-complete.md)** - Full reference of all 35+ tracking actions with examples
116
+ - 📖 **[Middleware Architecture](Planning/README-middleware.md)** - Core middleware system documentation
117
+ - 📝 **[Changes Summary](Planning/TRACKING-CHANGES-SUMMARY.md)** - List of all modified files and implementation details
118
+
119
+ ### Multi-language Support
120
+
121
+ 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.
122
+
123
+ ## Development Notes
124
+
125
+ **TypeScript Paths**: Uses path aliases with `baseUrl: "./src"` so imports like `import { Tour } from 'models/Visualizer/Tour'` work without relative paths.
126
+
127
+ **Rollup Build**: Configured for ESM output with PostCSS (Tailwind), TypeScript compilation, and tree-shaking. Development mode skips uglify/terser/babel for faster rebuilds.
128
+
129
+ **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.
130
+
131
+ **State Persistence**: No localStorage/sessionStorage - state is ephemeral per session. Tours are fetched fresh via SWR caching.
132
+
133
+ **Mobile vs Desktop**: The `mobile` prop controls UI layout significantly - different slide-in behaviors, hotspot positioning, and touch controls.
134
+
135
+ ## Common Patterns
136
+
137
+ **Finding POIs**: Use `tour.getPoiByType(POI_TYPE.*)` or `tour.getPoisByIds(ids)`
138
+
139
+ **Scene Navigation**: `tour.changeScene(sceneCode)` or through navigation POIs
140
+
141
+ **Coordinate Conversion**: Always use `krpano.screentosphere()` / `spheretoscreen()` for position calculations between screen and 3D space
142
+
143
+ **Adding Listeners**: Tour emits signals for scene changes, POI interactions, scenario events - hook into these via `tour.signals.*`
144
+
145
+ **ESLint Rules**: The project uses TypeScript ESLint with Prettier integration. Note that `no-console` allows `info`, `warn`, `error` but not plain `log`.
package/DEVELOPMENT.md CHANGED
@@ -1,120 +1,120 @@
1
- # 🛠️ Development Guide
2
-
3
- Hướng dẫn phát triển thư viện `@clikvn/showroom-visualizer`.
4
-
5
- ## 📦 Cấu trúc Project
6
-
7
- ```
8
- showroom-visualizer/
9
- ├── src/ # Source code của thư viện
10
- ├── dist/ # Build output (NPM package & Web Component)
11
- ├── example/ # Example app để test local (Vite + React)
12
- ├── rollup.config.js # Build configuration
13
- └── package.json
14
- ```
15
-
16
- ## 🚀 Development Workflows
17
-
18
- ### Workflow 1: Test trong Example App (Khuyến nghị ⭐)
19
-
20
- **Ưu điểm:**
21
- - ✅ Import trực tiếp từ source (`src/`) - không cần build
22
- - ✅ Hot reload cực nhanh
23
- - ✅ Debug dễ dàng với source maps
24
- - ✅ Test custom layout overrides và tất cả features
25
- - ✅ Không cần publish hoặc yalc
26
-
27
- **Cách dùng:**
28
-
29
- ```bash
30
- # Bước 1: Cài đặt dependencies cho example (chỉ lần đầu)
31
- cd example
32
- yarn install
33
-
34
- # Bước 2: Chạy example app
35
- yarn dev
36
- # hoặc từ root: yarn dev:demo
37
-
38
- # App sẽ chạy tại: http://localhost:3001
39
- ```
40
-
41
- **Modify và test:**
42
- - Thay đổi code trong `src/` → Auto reload
43
- - Thay đổi code trong `example/src/App.tsx` → Auto reload
44
- - Test custom layout bằng checkbox trong UI
45
-
46
- ### Workflow 2: Build và Test Web Component
47
-
48
- **Test Web Component:**
49
-
50
- ```bash
51
- # Build
52
- yarn build
53
-
54
- # Serve dist folder
55
- cd dist
56
- npx serve
57
- # hoặc: python3 -m http.server 8080
58
-
59
- # Mở browser: http://localhost:8080
60
- ```
61
-
62
- Xem file `dist/index.html` để biết cách dùng Web Component.
63
-
64
- ---
65
-
66
- ## 🏗️ Build Strategy
67
-
68
- Thư viện này có **2 build outputs**:
69
-
70
- ### 1. NPM Package (`dist/index.js`)
71
- - **Dùng cho:** React/Next.js apps
72
- - **React:** External (dùng React của project)
73
- - **Hỗ trợ:** Custom layout overrides, custom components
74
- - **Import:**
75
- ```tsx
76
- import { ShowroomVisualizer } from '@clikvn/showroom-visualizer';
77
- ```
78
-
79
- ### 2. Web Component (`dist/web.js`)
80
- - **Dùng cho:** Vanilla HTML/JS
81
- - **React:** Bundled (React 18 đã được bundle sẵn)
82
- - **Không hỗ trợ:** Custom layout overrides
83
- - **Import:**
84
- ```html
85
- <script type="module" src="web.js"></script>
86
- <showroom-visualizer api-url="..." showroom-id="..."></showroom-visualizer>
87
- ```
88
-
89
- ---
90
-
91
- ## 📝 Common Tasks
92
-
93
- ### Thêm feature mới
94
-
95
- 1. Code trong `src/`
96
- 2. Test trong `example/` app
97
- 3. Build: `yarn build`
98
-
99
-
100
- ## 🐛 Troubleshooting
101
-
102
- ### Build errors
103
-
104
- ```bash
105
- # Clean và rebuild
106
- rm -rf dist
107
- yarn build
108
- ```
109
- ---
110
-
111
- ## ✨ Tips
112
-
113
- 1. **Luôn dùng Example app khi develop** - Nhanh và tiện nhất
114
- 2. **Commit example app vào git** để team members cùng dùng
115
- 3. **Không commit `dist/` vào git** - Chỉ build khi deploy
116
-
117
- ---
118
-
119
- Happy coding! 🚀
120
-
1
+ # 🛠️ Development Guide
2
+
3
+ Hướng dẫn phát triển thư viện `@clikvn/showroom-visualizer`.
4
+
5
+ ## 📦 Cấu trúc Project
6
+
7
+ ```
8
+ showroom-visualizer/
9
+ ├── src/ # Source code của thư viện
10
+ ├── dist/ # Build output (NPM package & Web Component)
11
+ ├── example/ # Example app để test local (Vite + React)
12
+ ├── rollup.config.js # Build configuration
13
+ └── package.json
14
+ ```
15
+
16
+ ## 🚀 Development Workflows
17
+
18
+ ### Workflow 1: Test trong Example App (Khuyến nghị ⭐)
19
+
20
+ **Ưu điểm:**
21
+ - ✅ Import trực tiếp từ source (`src/`) - không cần build
22
+ - ✅ Hot reload cực nhanh
23
+ - ✅ Debug dễ dàng với source maps
24
+ - ✅ Test custom layout overrides và tất cả features
25
+ - ✅ Không cần publish hoặc yalc
26
+
27
+ **Cách dùng:**
28
+
29
+ ```bash
30
+ # Bước 1: Cài đặt dependencies cho example (chỉ lần đầu)
31
+ cd example
32
+ yarn install
33
+
34
+ # Bước 2: Chạy example app
35
+ yarn dev
36
+ # hoặc từ root: yarn dev:demo
37
+
38
+ # App sẽ chạy tại: http://localhost:3001
39
+ ```
40
+
41
+ **Modify và test:**
42
+ - Thay đổi code trong `src/` → Auto reload
43
+ - Thay đổi code trong `example/src/App.tsx` → Auto reload
44
+ - Test custom layout bằng checkbox trong UI
45
+
46
+ ### Workflow 2: Build và Test Web Component
47
+
48
+ **Test Web Component:**
49
+
50
+ ```bash
51
+ # Build
52
+ yarn build
53
+
54
+ # Serve dist folder
55
+ cd dist
56
+ npx serve
57
+ # hoặc: python3 -m http.server 8080
58
+
59
+ # Mở browser: http://localhost:8080
60
+ ```
61
+
62
+ Xem file `dist/index.html` để biết cách dùng Web Component.
63
+
64
+ ---
65
+
66
+ ## 🏗️ Build Strategy
67
+
68
+ Thư viện này có **2 build outputs**:
69
+
70
+ ### 1. NPM Package (`dist/index.js`)
71
+ - **Dùng cho:** React/Next.js apps
72
+ - **React:** External (dùng React của project)
73
+ - **Hỗ trợ:** Custom layout overrides, custom components
74
+ - **Import:**
75
+ ```tsx
76
+ import { ShowroomVisualizer } from '@clikvn/showroom-visualizer';
77
+ ```
78
+
79
+ ### 2. Web Component (`dist/web.js`)
80
+ - **Dùng cho:** Vanilla HTML/JS
81
+ - **React:** Bundled (React 18 đã được bundle sẵn)
82
+ - **Không hỗ trợ:** Custom layout overrides
83
+ - **Import:**
84
+ ```html
85
+ <script type="module" src="web.js"></script>
86
+ <showroom-visualizer api-url="..." showroom-id="..."></showroom-visualizer>
87
+ ```
88
+
89
+ ---
90
+
91
+ ## 📝 Common Tasks
92
+
93
+ ### Thêm feature mới
94
+
95
+ 1. Code trong `src/`
96
+ 2. Test trong `example/` app
97
+ 3. Build: `yarn build`
98
+
99
+
100
+ ## 🐛 Troubleshooting
101
+
102
+ ### Build errors
103
+
104
+ ```bash
105
+ # Clean và rebuild
106
+ rm -rf dist
107
+ yarn build
108
+ ```
109
+ ---
110
+
111
+ ## ✨ Tips
112
+
113
+ 1. **Luôn dùng Example app khi develop** - Nhanh và tiện nhất
114
+ 2. **Commit example app vào git** để team members cùng dùng
115
+ 3. **Không commit `dist/` vào git** - Chỉ build khi deploy
116
+
117
+ ---
118
+
119
+ Happy coding! 🚀
120
+