@clikvn/showroom-visualizer 0.4.1-dev-11 → 0.4.1-dev-13

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 (43) 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/components/SkinLayer/PoiDetailSlideIn/Detail.d.ts +1 -1
  11. package/dist/components/SkinLayer/PoiDetailSlideIn/Detail.d.ts.map +1 -1
  12. package/dist/components/SkinLayer/PoiDetailSlideIn/GroupActionButton.d.ts +1 -0
  13. package/dist/components/SkinLayer/PoiDetailSlideIn/GroupActionButton.d.ts.map +1 -1
  14. package/dist/fonts/icomoon.svg +633 -633
  15. package/dist/index.js +1 -1
  16. package/dist/web.d.ts.map +1 -1
  17. package/dist/web.js +1 -1
  18. package/example/CSS_HANDLING.md +141 -141
  19. package/example/FIXES_SUMMARY.md +131 -121
  20. package/example/PATH_ALIASES.md +102 -103
  21. package/example/README.md +63 -64
  22. package/example/index.html +12 -13
  23. package/example/package.json +25 -25
  24. package/example/postcss.config.cjs +6 -6
  25. package/example/tailwind.config.cjs +12 -12
  26. package/example/tsconfig.node.json +11 -12
  27. package/example/vite.config.ts +142 -142
  28. package/package.json +133 -133
  29. package/rollup.config.js +400 -400
  30. package/tailwind.config.cjs +151 -151
  31. package/dist/components/SkinLayer/Drawer/PoiHeader/index.d.ts +0 -16
  32. package/dist/components/SkinLayer/Drawer/PoiHeader/index.d.ts.map +0 -1
  33. package/dist/components/SkinLayer/Drawer/index.d.ts +0 -29
  34. package/dist/components/SkinLayer/Drawer/index.d.ts.map +0 -1
  35. package/dist/components/SkinLayer/PlayAll/index.d.ts +0 -8
  36. package/dist/components/SkinLayer/PlayAll/index.d.ts.map +0 -1
  37. package/dist/features/VirtualTourVisualizer/index.d.ts +0 -20
  38. package/dist/features/VirtualTourVisualizer/index.d.ts.map +0 -1
  39. package/dist/features/VirtualTourVisualizerUI/index.d.ts +0 -17
  40. package/dist/features/VirtualTourVisualizerUI/index.d.ts.map +0 -1
  41. package/dist/index.html +0 -36
  42. /package/dist/features/ShowroomVisualizer/{cssStyles.d.ts → CssStyles.d.ts} +0 -0
  43. /package/dist/features/ShowroomVisualizer/{cssStyles.d.ts.map → CssStyles.d.ts.map} +0 -0
@@ -1,141 +1,141 @@
1
- # 🎨 CSS Handling in Example App
2
-
3
- ## Vấn đề
4
-
5
- ```
6
- Uncaught SyntaxError: The requested module '.../actionsChangeSceneStyles.css' does not provide an export named 'default'
7
- ```
8
-
9
- ## Nguyên nhân
10
-
11
- ### Thư viện (Rollup Build)
12
-
13
- Thư viện sử dụng Rollup với PostCSS plugin config:
14
-
15
- ```javascript
16
- postcss({
17
- inject: false, // ← Không inject CSS vào DOM
18
- extract: false, // ← Export CSS as string
19
- })
20
- ```
21
-
22
- Điều này cho phép import CSS như strings:
23
-
24
- ```typescript
25
- import styles from './styles.css';
26
- // styles = "css content as string"
27
- ```
28
-
29
- Và render trong component `CssStyles.tsx`:
30
-
31
- ```tsx
32
- <style>{styles}</style>
33
- ```
34
-
35
- ### Vite (Development)
36
-
37
- Vite mặc định **inject CSS trực tiếp vào DOM** và không export CSS as strings.
38
-
39
- ```typescript
40
- import styles from './styles.css';
41
- // Vite inject CSS → styles = undefined
42
- // ❌ Error: does not provide an export named 'default'
43
- ```
44
-
45
- ## Giải pháp
46
-
47
- ### Custom Vite Plugin: `cssAsStringPlugin`
48
-
49
- Tạo plugin trong `vite.config.ts` để xử lý CSS từ thư viện như strings:
50
-
51
- ```typescript
52
- const cssAsStringPlugin = () => ({
53
- name: 'css-as-string',
54
- enforce: 'pre', // ⭐ Run BEFORE other plugins (critical!)
55
- load(id: string) {
56
- // Chỉ xử lý CSS từ thư viện
57
- if (
58
- id.endsWith('.css') &&
59
- (id.includes('/src/assets/') || id.includes('/@clikvn/'))
60
- ) {
61
- const cssContent = fs.readFileSync(id, 'utf-8');
62
- return `export default ${JSON.stringify(cssContent)}`;
63
- }
64
- return null;
65
- },
66
- });
67
-
68
- // Plugin order matters!
69
- plugins: [cssAsStringPlugin(), react()]
70
- ```
71
-
72
- **Key Points:**
73
- - ⭐ **`enforce: 'pre'`**: Chạy trước Vite's built-in CSS plugin
74
- - ⭐ **`load` hook**: Intercept file loading, không dùng `transform`
75
- - ⭐ **Plugin order**: `cssAsStringPlugin()` phải đứng TRƯỚC `react()`
76
-
77
- ### Cách hoạt động
78
-
79
- 1. **CSS từ thư viện** (`/src/assets/`) → Export as string
80
- 2. **CSS từ @clikvn packages** → Export as string
81
- 3. **CSS khác** (antd, example app CSS) Vite xử lý bình thường
82
-
83
- ### Files được xử lý
84
-
85
- Plugin chỉ xử lý CSS files trong:
86
-
87
- - ✅ `/Users/tungthai/Desktop/Develop/showroom-visualizer/src/assets/*.css`
88
- - ✅ `node_modules/@clikvn/*/dist/**/*.css`
89
- - `node_modules/antd/**/*.css` (Vite xử lý bình thường)
90
- - ❌ `example/src/**/*.css` (Vite xử lý bình thường)
91
-
92
- ## Kết quả
93
-
94
- ### ✅ Trước (Rollup Build):
95
-
96
- ```typescript
97
- import styles from './styles.css';
98
- <style>{styles}</style> // ✅ Works
99
- ```
100
-
101
- ### ✅ Sau (Vite Dev with Plugin):
102
-
103
- ```typescript
104
- import styles from './styles.css';
105
- <style>{styles}</style> // ✅ Works (plugin export CSS as string)
106
- ```
107
-
108
- ### ✅ CSS từ example app:
109
-
110
- ```typescript
111
- // example/src/App.css
112
- import './App.css'; // ✅ Vite inject vào DOM bình thường
113
- ```
114
-
115
- ## 🔍 Debug
116
-
117
- Nếu vẫn có lỗi CSS, kiểm tra:
118
-
119
- ```bash
120
- # 1. Restart dev server
121
- cd example
122
- yarn dev
123
-
124
- # 2. Clear Vite cache
125
- rm -rf node_modules/.vite
126
- yarn dev
127
-
128
- # 3. Kiểm tra plugin đang hoạt động
129
- # Trong browser console, check xem CSS đã được inject chưa
130
- ```
131
-
132
- ## 📚 Related Files
133
-
134
- - `example/vite.config.ts` - Chứa `cssAsStringPlugin`
135
- - `src/features/ShowroomVisualizer/CssStyles.tsx` - Render CSS as `<style>` tags
136
- - `rollup.config.js` - PostCSS config của thư viện
137
-
138
- ---
139
-
140
- ✅ **Fixed!** CSS từ thư viện giờ được export as strings trong Vite dev mode.
141
-
1
+ # 🎨 CSS Handling in Example App
2
+
3
+ ## Vấn đề
4
+
5
+ ```
6
+ Uncaught SyntaxError: The requested module '.../actionsChangeSceneStyles.css' does not provide an export named 'default'
7
+ ```
8
+
9
+ ## Nguyên nhân
10
+
11
+ ### Thư viện (Rollup Build)
12
+
13
+ Thư viện sử dụng Rollup với PostCSS plugin config:
14
+
15
+ ```javascript
16
+ postcss({
17
+ inject: false, // ← Không inject CSS vào DOM
18
+ extract: false, // ← Export CSS as string
19
+ });
20
+ ```
21
+
22
+ Điều này cho phép import CSS như strings:
23
+
24
+ ```typescript
25
+ import styles from './styles.css';
26
+ // styles = "css content as string"
27
+ ```
28
+
29
+ Và render trong component `CssStyles.tsx`:
30
+
31
+ ```tsx
32
+ <style>{styles}</style>
33
+ ```
34
+
35
+ ### Vite (Development)
36
+
37
+ Vite mặc định **inject CSS trực tiếp vào DOM** và không export CSS as strings.
38
+
39
+ ```typescript
40
+ import styles from './styles.css';
41
+ // Vite inject CSS → styles = undefined
42
+ // ❌ Error: does not provide an export named 'default'
43
+ ```
44
+
45
+ ## Giải pháp
46
+
47
+ ### Custom Vite Plugin: `cssAsStringPlugin`
48
+
49
+ Tạo plugin trong `vite.config.ts` để xử lý CSS từ thư viện như strings:
50
+
51
+ ```typescript
52
+ const cssAsStringPlugin = () => ({
53
+ name: 'css-as-string',
54
+ enforce: 'pre', // ⭐ Run BEFORE other plugins (critical!)
55
+ load(id: string) {
56
+ // Chỉ xử lý CSS từ thư viện
57
+ if (
58
+ id.endsWith('.css') &&
59
+ (id.includes('/src/assets/') || id.includes('/@clikvn/'))
60
+ ) {
61
+ const cssContent = fs.readFileSync(id, 'utf-8');
62
+ return `export default ${JSON.stringify(cssContent)}`;
63
+ }
64
+ return null;
65
+ },
66
+ });
67
+
68
+ // Plugin order matters!
69
+ plugins: [cssAsStringPlugin(), react()];
70
+ ```
71
+
72
+ **Key Points:**
73
+
74
+ - ⭐ **`enforce: 'pre'`**: Chạy trước Vite's built-in CSS plugin
75
+ - ⭐ **`load` hook**: Intercept file loading, không dùng `transform`
76
+ - ⭐ **Plugin order**: `cssAsStringPlugin()` phải đứng TRƯỚC `react()`
77
+
78
+ ### Cách hoạt động
79
+
80
+ 1. **CSS từ thư viện** (`/src/assets/`) → Export as string
81
+ 2. **CSS từ @clikvn packages**Export as string
82
+ 3. **CSS khác** (antd, example app CSS) → Vite xử lý bình thường
83
+
84
+ ### Files được xử lý
85
+
86
+ Plugin chỉ xử lý CSS files trong:
87
+
88
+ - ✅ `/Users/tungthai/Desktop/Develop/showroom-visualizer/src/assets/*.css`
89
+ - `node_modules/@clikvn/*/dist/**/*.css`
90
+ - ❌ `node_modules/antd/**/*.css` (Vite xử lý bình thường)
91
+ - ❌ `example/src/**/*.css` (Vite xử lý bình thường)
92
+
93
+ ## Kết quả
94
+
95
+ ### ✅ Trước (Rollup Build):
96
+
97
+ ```typescript
98
+ import styles from './styles.css';
99
+ <style>{styles}</style> // ✅ Works
100
+ ```
101
+
102
+ ### ✅ Sau (Vite Dev with Plugin):
103
+
104
+ ```typescript
105
+ import styles from './styles.css';
106
+ <style>{styles}</style> // ✅ Works (plugin export CSS as string)
107
+ ```
108
+
109
+ ### ✅ CSS từ example app:
110
+
111
+ ```typescript
112
+ // example/src/App.css
113
+ import './App.css'; // ✅ Vite inject vào DOM bình thường
114
+ ```
115
+
116
+ ## 🔍 Debug
117
+
118
+ Nếu vẫn có lỗi CSS, kiểm tra:
119
+
120
+ ```bash
121
+ # 1. Restart dev server
122
+ cd example
123
+ yarn dev
124
+
125
+ # 2. Clear Vite cache
126
+ rm -rf node_modules/.vite
127
+ yarn dev
128
+
129
+ # 3. Kiểm tra plugin đang hoạt động
130
+ # Trong browser console, check xem CSS đã được inject chưa
131
+ ```
132
+
133
+ ## 📚 Related Files
134
+
135
+ - `example/vite.config.ts` - Chứa `cssAsStringPlugin`
136
+ - `src/features/ShowroomVisualizer/CssStyles.tsx` - Render CSS as `<style>` tags
137
+ - `rollup.config.js` - PostCSS config của thư viện
138
+
139
+ ---
140
+
141
+ ✅ **Fixed!** CSS từ thư viện giờ được export as strings trong Vite dev mode.
@@ -1,121 +1,131 @@
1
- # 🎯 Example App - Fixes Summary
2
-
3
- ## 2 vấn đề đã được fix:
4
-
5
- ---
6
-
7
- ## 1️⃣ Path Aliases Resolution ✅
8
-
9
- ### Lỗi:
10
- ```
11
- [plugin:vite:import-analysis] Failed to resolve import "commons/SkinLayer/components/Drawer"
12
- ```
13
-
14
- ### Root Cause:
15
- Thư viện sử dụng `baseUrl: "./src"` cho phép imports:
16
- ```typescript
17
- import Drawer from 'commons/SkinLayer/components/Drawer';
18
- ```
19
-
20
- Example app không biết về aliases này.
21
-
22
- ### Fix:
23
- Thêm 10 path aliases vào `vite.config.ts` và `tsconfig.json`:
24
- - `commons/*`, `components/*`, `constants/*`, `context/*`, `features/*`
25
- - `hooks/*`, `models/*`, `services/*`, `types/*`, `utils/*`
26
-
27
- ### Status: Fixed
28
-
29
- ---
30
-
31
- ## 2️⃣ CSS Imports as Strings ✅
32
-
33
- ### Lỗi:
34
- ```
35
- Uncaught SyntaxError: The requested module '.../actionsChangeSceneStyles.css'
36
- does not provide an export named 'default'
37
- ```
38
-
39
- ### Root Cause:
40
- - **Thư viện (Rollup)**: CSS exported as strings với `postcss({ inject: false })`
41
- - **Vite**: Mặc định inject CSS, không export strings
42
- - **CssStyles.tsx**: Cần CSS as strings để render `<style>{css}</style>`
43
-
44
- ### Fix:
45
- Tạo custom Vite plugin `cssAsStringPlugin` với 3 key points:
46
-
47
- ```typescript
48
- const cssAsStringPlugin = () => ({
49
- name: 'css-as-string',
50
- enforce: 'pre', // ⭐ Critical: Run BEFORE other plugins
51
- load(id: string) { // ⭐ Use 'load' hook, not 'transform'
52
- if (
53
- id.endsWith('.css') &&
54
- (id.includes('/src/assets/') || id.includes('/@clikvn/'))
55
- ) {
56
- const cssContent = fs.readFileSync(id, 'utf-8');
57
- return `export default ${JSON.stringify(cssContent)}`;
58
- }
59
- },
60
- });
61
-
62
- // ⭐ Plugin order matters!
63
- plugins: [cssAsStringPlugin(), react()]
64
- ```
65
-
66
- **3 điều quan trọng:**
67
- 1. `enforce: 'pre'` - Chạy trước Vite CSS plugin
68
- 2. `load()` hook - Intercept file loading sớm
69
- 3. Plugin order - Đặt TRƯỚC `react()`
70
-
71
- Plugin chỉ xử lý:
72
- - CSS từ `/src/assets/` → Export as string
73
- - ✅ CSS từ `@clikvn/*` packages → Export as string
74
- - ❌ CSS khác (antd, example CSS) → Vite xử lý bình thường
75
-
76
- ### Status: ✅ Fixed
77
-
78
- ---
79
-
80
- ## 📊 Tổng kết
81
-
82
- | Issue | Status | Files Changed |
83
- |-------|--------|---------------|
84
- | Path Aliases | Fixed | `vite.config.ts`, `tsconfig.json` |
85
- | CSS Imports | Fixed | `vite.config.ts` (plugin) |
86
-
87
- ---
88
-
89
- ## 🚀 Kết quả
90
-
91
- **Example app giờ hoạt động 100%!**
92
-
93
- Dev server: http://localhost:3001
94
- Import từ `src/` trực tiếp
95
- Hot reload
96
- Path aliases
97
- ✅ CSS handling
98
- ✅ Test custom layout
99
-
100
- ---
101
-
102
- ## 📚 Documents
103
-
104
- - [PATH_ALIASES.md](./PATH_ALIASES.md) - Chi tiết về path aliases
105
- - [CSS_HANDLING.md](./CSS_HANDLING.md) - Chi tiết về CSS plugin
106
- - [CHANGELOG.md](./CHANGELOG.md) - Lịch sử thay đổi
107
- - [README.md](./README.md) - Hướng dẫn sử dụng
108
-
109
- ---
110
-
111
- ## 🎉 Ready to Use!
112
-
113
- ```bash
114
- cd example
115
- yarn dev
116
-
117
- # Open: http://localhost:3001
118
- ```
119
-
120
- Thay đổi code trong `../src/` → Tự động reload! 🔥
121
-
1
+ # 🎯 Example App - Fixes Summary
2
+
3
+ ## 2 vấn đề đã được fix:
4
+
5
+ ---
6
+
7
+ ## 1️⃣ Path Aliases Resolution ✅
8
+
9
+ ### Lỗi:
10
+
11
+ ```
12
+ [plugin:vite:import-analysis] Failed to resolve import "commons/SkinLayer/components/Drawer"
13
+ ```
14
+
15
+ ### Root Cause:
16
+
17
+ Thư viện sử dụng `baseUrl: "./src"` cho phép imports:
18
+
19
+ ```typescript
20
+ import Drawer from 'commons/SkinLayer/components/Drawer';
21
+ ```
22
+
23
+ Example app không biết về aliases này.
24
+
25
+ ### Fix:
26
+
27
+ Thêm 10 path aliases vào `vite.config.ts` và `tsconfig.json`:
28
+
29
+ - `commons/*`, `components/*`, `constants/*`, `context/*`, `features/*`
30
+ - `hooks/*`, `models/*`, `services/*`, `types/*`, `utils/*`
31
+
32
+ ### Status: ✅ Fixed
33
+
34
+ ---
35
+
36
+ ## 2️⃣ CSS Imports as Strings
37
+
38
+ ### Lỗi:
39
+
40
+ ```
41
+ Uncaught SyntaxError: The requested module '.../actionsChangeSceneStyles.css'
42
+ does not provide an export named 'default'
43
+ ```
44
+
45
+ ### Root Cause:
46
+
47
+ - **Thư viện (Rollup)**: CSS exported as strings với `postcss({ inject: false })`
48
+ - **Vite**: Mặc định inject CSS, không export strings
49
+ - **CssStyles.tsx**: Cần CSS as strings để render `<style>{css}</style>`
50
+
51
+ ### Fix:
52
+
53
+ Tạo custom Vite plugin `cssAsStringPlugin` với 3 key points:
54
+
55
+ ```typescript
56
+ const cssAsStringPlugin = () => ({
57
+ name: 'css-as-string',
58
+ enforce: 'pre', // ⭐ Critical: Run BEFORE other plugins
59
+ load(id: string) {
60
+ // ⭐ Use 'load' hook, not 'transform'
61
+ if (
62
+ id.endsWith('.css') &&
63
+ (id.includes('/src/assets/') || id.includes('/@clikvn/'))
64
+ ) {
65
+ const cssContent = fs.readFileSync(id, 'utf-8');
66
+ return `export default ${JSON.stringify(cssContent)}`;
67
+ }
68
+ },
69
+ });
70
+
71
+ // ⭐ Plugin order matters!
72
+ plugins: [cssAsStringPlugin(), react()];
73
+ ```
74
+
75
+ **3 điều quan trọng:**
76
+
77
+ 1. `enforce: 'pre'` - Chạy trước Vite CSS plugin
78
+ 2. `load()` hook - Intercept file loading sớm
79
+ 3. Plugin order - Đặt TRƯỚC `react()`
80
+
81
+ Plugin chỉ xử lý:
82
+
83
+ - ✅ CSS từ `/src/assets/` → Export as string
84
+ - CSS từ `@clikvn/*` packages Export as string
85
+ - CSS khác (antd, example CSS) Vite xử lý bình thường
86
+
87
+ ### Status: ✅ Fixed
88
+
89
+ ---
90
+
91
+ ## 📊 Tổng kết
92
+
93
+ | Issue | Status | Files Changed |
94
+ | ------------ | -------- | --------------------------------- |
95
+ | Path Aliases | Fixed | `vite.config.ts`, `tsconfig.json` |
96
+ | CSS Imports | Fixed | `vite.config.ts` (plugin) |
97
+
98
+ ---
99
+
100
+ ## 🚀 Kết quả
101
+
102
+ **Example app giờ hoạt động 100%!**
103
+
104
+ Dev server: http://localhost:3001
105
+ Import từ `src/` trực tiếp
106
+ Hot reload
107
+ Path aliases
108
+ ✅ CSS handling
109
+ ✅ Test custom layout
110
+
111
+ ---
112
+
113
+ ## 📚 Documents
114
+
115
+ - [PATH_ALIASES.md](./PATH_ALIASES.md) - Chi tiết về path aliases
116
+ - [CSS_HANDLING.md](./CSS_HANDLING.md) - Chi tiết về CSS plugin
117
+ - [CHANGELOG.md](./CHANGELOG.md) - Lịch sử thay đổi
118
+ - [README.md](./README.md) - Hướng dẫn sử dụng
119
+
120
+ ---
121
+
122
+ ## 🎉 Ready to Use!
123
+
124
+ ```bash
125
+ cd example
126
+ yarn dev
127
+
128
+ # Open: http://localhost:3001
129
+ ```
130
+
131
+ Thay đổi code trong `../src/` → Tự động reload! 🔥