@clikvn/showroom-visualizer 0.2.2-dev-11 → 0.2.2-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.
- package/README.md +26 -133
- package/base.json +21 -21
- package/dist/components/SkinLayer/Floorplan/Map.d.ts.map +1 -1
- package/dist/components/SkinLayer/Floorplan/Minimap/MiniMapMarker.d.ts.map +1 -1
- package/dist/components/SkinLayer/Floorplan/Minimap/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/Layout/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/index.d.ts +0 -32
- package/dist/components/SkinLayer/index.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/VirtualTour.d.ts +0 -5
- package/dist/features/ShowroomVisualizer/VirtualTour.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/VirtualTourContainer.d.ts +3 -4
- package/dist/features/ShowroomVisualizer/VirtualTourContainer.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/index.d.ts +3 -24
- package/dist/features/ShowroomVisualizer/index.d.ts.map +1 -1
- package/dist/fonts/icomoon.svg +633 -633
- package/dist/hooks/useToolConfig.d.ts.map +1 -1
- package/dist/index.d.ts +0 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +27 -102
- package/dist/models/Visualizer/Tour.d.ts +1 -0
- package/dist/models/Visualizer/Tour.d.ts.map +1 -1
- package/dist/models/Visualizer/TourScenario/TourScenarioPlayer.d.ts +1 -0
- package/dist/models/Visualizer/TourScenario/TourScenarioPlayer.d.ts.map +1 -1
- package/dist/register.d.ts +0 -3
- package/dist/register.d.ts.map +1 -1
- package/dist/types/SkinLayer/tool.type.d.ts +1 -6
- package/dist/types/SkinLayer/tool.type.d.ts.map +1 -1
- package/dist/types/SkinLayer/visualizer.type.d.ts +0 -3
- package/dist/types/SkinLayer/visualizer.type.d.ts.map +1 -1
- package/dist/web.d.ts.map +1 -1
- package/dist/web.js +1 -1
- package/package.json +1 -9
- package/rollup.config.js +97 -365
- package/tailwind.config.cjs +151 -151
- package/.idea/inspectionProfiles/Project_Default.xml +0 -36
- package/.idea/jsLinters/eslint.xml +0 -7
- package/.idea/misc.xml +0 -9
- package/.idea/modules.xml +0 -8
- package/.idea/prettier.xml +0 -8
- package/.idea/showroom-visualizer.iml +0 -9
- package/.idea/vcs.xml +0 -6
- package/DEVELOPMENT.md +0 -120
- package/EXAMPLES.md +0 -967
- package/SETUP_COMPLETE.md +0 -149
- package/dist/components/SkinLayer/DefaultLayout/index.d.ts +0 -8
- package/dist/components/SkinLayer/DefaultLayout/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/GalleryFullScreen/Content/ARViewer.d.ts +0 -30
- package/dist/components/SkinLayer/GalleryFullScreen/Content/ARViewer.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/Description.d.ts +0 -10
- package/dist/components/SkinLayer/ModalItemInfo/Description.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/Intro.d.ts +0 -9
- package/dist/components/SkinLayer/ModalItemInfo/Intro.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/Media.d.ts +0 -13
- package/dist/components/SkinLayer/ModalItemInfo/Media.d.ts.map +0 -1
- package/dist/components/SkinLayer/ModalItemInfo/index.d.ts +0 -10
- package/dist/components/SkinLayer/ModalItemInfo/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/HorizontalMenu/index.d.ts +0 -13
- package/dist/components/SkinLayer/PoiTextureOptions/HorizontalMenu/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/SemicircleMenu/index.d.ts +0 -13
- package/dist/components/SkinLayer/PoiTextureOptions/SemicircleMenu/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/TextureMenuItem/index.d.ts +0 -15
- package/dist/components/SkinLayer/PoiTextureOptions/TextureMenuItem/index.d.ts.map +0 -1
- package/dist/components/SkinLayer/PoiTextureOptions/VerticalMenu/index.d.ts +0 -13
- package/dist/components/SkinLayer/PoiTextureOptions/VerticalMenu/index.d.ts.map +0 -1
- package/dist/context/CustomLayoutContext.d.ts +0 -20
- package/dist/context/CustomLayoutContext.d.ts.map +0 -1
- package/dist/context/StoreContext.d.ts +0 -5
- package/dist/context/StoreContext.d.ts.map +0 -1
- package/dist/features/ShowroomVisualizer/Scripts.d.ts +0 -4
- package/dist/features/ShowroomVisualizer/Scripts.d.ts.map +0 -1
- package/dist/features/ShowroomVisualizer/TourContainer.d.ts +0 -9
- package/dist/features/ShowroomVisualizer/TourContainer.d.ts.map +0 -1
- package/dist/features/ShowroomVisualizer/Tours.d.ts +0 -3
- package/dist/features/ShowroomVisualizer/Tours.d.ts.map +0 -1
- package/dist/hooks/Visualizer/reducer.d.ts +0 -116
- package/dist/hooks/Visualizer/reducer.d.ts.map +0 -1
- package/dist/hooks/headless/index.d.ts +0 -150
- package/dist/hooks/headless/index.d.ts.map +0 -1
- package/dist/hooks/headless/useFloorplanControl.d.ts +0 -18
- package/dist/hooks/headless/useFloorplanControl.d.ts.map +0 -1
- package/dist/hooks/headless/usePOIInteraction.d.ts +0 -23
- package/dist/hooks/headless/usePOIInteraction.d.ts.map +0 -1
- package/dist/hooks/headless/useScenarioControl.d.ts +0 -22
- package/dist/hooks/headless/useScenarioControl.d.ts.map +0 -1
- package/dist/hooks/headless/useSceneNavigation.d.ts +0 -26
- package/dist/hooks/headless/useSceneNavigation.d.ts.map +0 -1
- package/dist/hooks/headless/useTourCore.d.ts +0 -23
- package/dist/hooks/headless/useTourCore.d.ts.map +0 -1
- package/dist/hooks/headless/useViewportControl.d.ts +0 -22
- package/dist/hooks/headless/useViewportControl.d.ts.map +0 -1
- package/dist/index.js +0 -1
- package/dist/types/custom-layout.d.ts +0 -63
- package/dist/types/custom-layout.d.ts.map +0 -1
- package/example/CSS_HANDLING.md +0 -141
- package/example/FIXES_SUMMARY.md +0 -121
- package/example/PATH_ALIASES.md +0 -103
- package/example/README.md +0 -64
- package/example/index.html +0 -13
- package/example/package.json +0 -25
- package/example/postcss.config.cjs +0 -6
- package/example/tailwind.config.cjs +0 -12
- package/example/tsconfig.node.json +0 -12
- package/example/vite.config.ts +0 -126
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
/**
|
|
3
|
-
* Custom Layout Config - Cho phép override từng component thông qua cấu trúc object lồng nhau.
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```tsx
|
|
7
|
-
* customLayout={{
|
|
8
|
-
* Floorplan: {
|
|
9
|
-
* Minimap: {
|
|
10
|
-
* Marker: CustomMarker,
|
|
11
|
-
* Polygon: CustomPolygon,
|
|
12
|
-
* },
|
|
13
|
-
* },
|
|
14
|
-
* }}
|
|
15
|
-
* ```
|
|
16
|
-
*
|
|
17
|
-
* @important Pass component functions, NOT React elements!
|
|
18
|
-
*/
|
|
19
|
-
export type CustomLayoutComponent<T = any> = ComponentType<T>;
|
|
20
|
-
export type CustomLayoutNode = CustomLayoutComponent | {
|
|
21
|
-
[key: string]: CustomLayoutNode;
|
|
22
|
-
};
|
|
23
|
-
export type CustomLayoutConfig = {
|
|
24
|
-
[key: string]: CustomLayoutNode;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Resolve helper để tìm component theo path (ví dụ ['Floorplan', 'Minimap', 'Marker'])
|
|
28
|
-
*/
|
|
29
|
-
export declare const resolveCustomLayoutComponent: (config: CustomLayoutConfig | undefined, path: string[]) => CustomLayoutComponent | undefined;
|
|
30
|
-
/**
|
|
31
|
-
* Registry document các component có thể custom layout
|
|
32
|
-
*/
|
|
33
|
-
export declare const CUSTOM_LAYOUT_COMPONENTS: {
|
|
34
|
-
readonly Floorplan: {
|
|
35
|
-
readonly path: "src/components/SkinLayer/Floorplan/index.tsx";
|
|
36
|
-
readonly description: "Main Floorplan container with bottom sheet";
|
|
37
|
-
readonly children: {
|
|
38
|
-
readonly Map: {
|
|
39
|
-
readonly path: "src/components/SkinLayer/Floorplan/Map.tsx";
|
|
40
|
-
readonly description: "Floorplan map wrapper with controls";
|
|
41
|
-
};
|
|
42
|
-
readonly Minimap: {
|
|
43
|
-
readonly path: "src/components/SkinLayer/Floorplan/Minimap/index.tsx";
|
|
44
|
-
readonly description: "Interactive minimap with markers and polygons";
|
|
45
|
-
readonly children: {
|
|
46
|
-
readonly Marker: {
|
|
47
|
-
readonly path: "src/components/SkinLayer/Floorplan/Minimap/MiniMapMarker.tsx";
|
|
48
|
-
readonly description: "Individual marker on minimap";
|
|
49
|
-
};
|
|
50
|
-
readonly Polygon: {
|
|
51
|
-
readonly path: "src/components/SkinLayer/Floorplan/Minimap/MiniMapPolygons/index.tsx";
|
|
52
|
-
readonly description: "Polygon areas on minimap";
|
|
53
|
-
};
|
|
54
|
-
readonly Radar: {
|
|
55
|
-
readonly path: "src/components/SkinLayer/Floorplan/Minimap/index.tsx";
|
|
56
|
-
readonly description: "Radar element inside minimap";
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
|
-
};
|
|
62
|
-
};
|
|
63
|
-
//# sourceMappingURL=custom-layout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"custom-layout.d.ts","sourceRoot":"","sources":["../../src/types/custom-layout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAEtC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,GAAG,GAAG,IAAI,aAAa,CAAC,CAAC,CAAC,CAAC;AAE9D,MAAM,MAAM,gBAAgB,GACxB,qBAAqB,GACrB;IACE,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC,CAAC;AAEN,MAAM,MAAM,kBAAkB,GAAG;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACvC,QAAQ,kBAAkB,GAAG,SAAS,EACtC,MAAM,MAAM,EAAE,KACb,qBAAqB,GAAG,SAgD1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B3B,CAAC"}
|
package/example/CSS_HANDLING.md
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
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
|
-
|
package/example/FIXES_SUMMARY.md
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
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
|
-
|
package/example/PATH_ALIASES.md
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
# 📁 Path Aliases Configuration
|
|
2
|
-
|
|
3
|
-
## Vấn đề
|
|
4
|
-
|
|
5
|
-
Thư viện `showroom-visualizer` sử dụng `baseUrl: "./src"` trong `tsconfig.json`, cho phép import trực tiếp từ root của `src/`:
|
|
6
|
-
|
|
7
|
-
```typescript
|
|
8
|
-
// Thay vì:
|
|
9
|
-
import Drawer from '../../commons/SkinLayer/components/Drawer';
|
|
10
|
-
|
|
11
|
-
// Có thể viết:
|
|
12
|
-
import Drawer from 'commons/SkinLayer/components/Drawer';
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Giải pháp
|
|
16
|
-
|
|
17
|
-
Example app cần cấu hình tương ứng để Vite và TypeScript có thể resolve các imports này.
|
|
18
|
-
|
|
19
|
-
### 1. Vite Config (`vite.config.ts`)
|
|
20
|
-
|
|
21
|
-
```typescript
|
|
22
|
-
resolve: {
|
|
23
|
-
alias: {
|
|
24
|
-
'@clikvn/showroom-visualizer': path.resolve(__dirname, '../src'),
|
|
25
|
-
'commons': path.resolve(__dirname, '../src/commons'),
|
|
26
|
-
'components': path.resolve(__dirname, '../src/components'),
|
|
27
|
-
'constants': path.resolve(__dirname, '../src/constants'),
|
|
28
|
-
'context': path.resolve(__dirname, '../src/context'),
|
|
29
|
-
'features': path.resolve(__dirname, '../src/features'),
|
|
30
|
-
'hooks': path.resolve(__dirname, '../src/hooks'),
|
|
31
|
-
'models': path.resolve(__dirname, '../src/models'),
|
|
32
|
-
'services': path.resolve(__dirname, '../src/services'),
|
|
33
|
-
'types': path.resolve(__dirname, '../src/types'),
|
|
34
|
-
'utils': path.resolve(__dirname, '../src/utils'),
|
|
35
|
-
},
|
|
36
|
-
}
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
### 2. TypeScript Config (`tsconfig.json`)
|
|
40
|
-
|
|
41
|
-
```json
|
|
42
|
-
{
|
|
43
|
-
"compilerOptions": {
|
|
44
|
-
"baseUrl": ".",
|
|
45
|
-
"paths": {
|
|
46
|
-
"commons": ["../src/commons"],
|
|
47
|
-
"commons/*": ["../src/commons/*"],
|
|
48
|
-
"components": ["../src/components"],
|
|
49
|
-
"components/*": ["../src/components/*"],
|
|
50
|
-
// ... các aliases khác
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
## Các Aliases Được Hỗ Trợ
|
|
57
|
-
|
|
58
|
-
| Alias | Trỏ đến | Ví dụ |
|
|
59
|
-
|-------|---------|-------|
|
|
60
|
-
| `commons/*` | `../src/commons/*` | `import Drawer from 'commons/SkinLayer/components/Drawer'` |
|
|
61
|
-
| `components/*` | `../src/components/*` | `import Layout from 'components/SkinLayer/Layout'` |
|
|
62
|
-
| `constants/*` | `../src/constants/*` | `import { WIDTH_SLIDE_IN } from 'constants/SkinLayer'` |
|
|
63
|
-
| `context/*` | `../src/context/*` | `import { useCustomLayout } from 'context/CustomLayoutContext'` |
|
|
64
|
-
| `features/*` | `../src/features/*` | `import Visualizer from 'features/ShowroomVisualizer'` |
|
|
65
|
-
| `hooks/*` | `../src/hooks/*` | `import { useStore } from 'hooks/useStore'` |
|
|
66
|
-
| `models/*` | `../src/models/*` | `import PoiItemInfo from 'models/Visualizer/Poi/PoiItemInfo'` |
|
|
67
|
-
| `services/*` | `../src/services/*` | `import ApiService from 'services/Visualizer/ApiService'` |
|
|
68
|
-
| `types/*` | `../src/types/*` | `import { CustomLayoutConfig } from 'types/custom-layout'` |
|
|
69
|
-
| `utils/*` | `../src/utils/*` | `import { formatDate } from 'utils/Visualizer/date'` |
|
|
70
|
-
|
|
71
|
-
## ⚠️ Lưu ý
|
|
72
|
-
|
|
73
|
-
1. **Restart dev server** sau khi thay đổi `vite.config.ts` hoặc `tsconfig.json`
|
|
74
|
-
2. **Không cần** thêm aliases này vào thư viện chính - chỉ cần trong example app
|
|
75
|
-
3. Nếu thêm folder mới trong `src/`, cần thêm alias tương ứng
|
|
76
|
-
|
|
77
|
-
## 🐛 Troubleshooting
|
|
78
|
-
|
|
79
|
-
### Lỗi: "Failed to resolve import"
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
# Kiểm tra alias có đúng không
|
|
83
|
-
cat example/vite.config.ts
|
|
84
|
-
|
|
85
|
-
# Restart dev server
|
|
86
|
-
cd example
|
|
87
|
-
yarn dev
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
### TypeScript không tìm thấy types
|
|
91
|
-
|
|
92
|
-
```bash
|
|
93
|
-
# Kiểm tra paths trong tsconfig.json
|
|
94
|
-
cat example/tsconfig.json
|
|
95
|
-
|
|
96
|
-
# Restart TypeScript server trong VSCode
|
|
97
|
-
# Cmd/Ctrl + Shift + P → "TypeScript: Restart TS Server"
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
---
|
|
101
|
-
|
|
102
|
-
✅ Đã cấu hình xong! Example app giờ có thể import từ source code giống như thư viện chính.
|
|
103
|
-
|
package/example/README.md
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
# Showroom Visualizer - Example App
|
|
2
|
-
|
|
3
|
-
Đây là example app để test và develop thư viện `@clikvn/showroom-visualizer` trong môi trường local.
|
|
4
|
-
|
|
5
|
-
## 🚀 Cách sử dụng
|
|
6
|
-
|
|
7
|
-
### 1. Cài đặt dependencies
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
cd example
|
|
11
|
-
yarn install
|
|
12
|
-
# hoặc
|
|
13
|
-
npm install
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
### 2. Chạy dev server
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
yarn dev
|
|
20
|
-
# hoặc
|
|
21
|
-
npm run dev
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
App sẽ chạy tại: http://localhost:3001
|
|
25
|
-
|
|
26
|
-
### 3. Test thư viện
|
|
27
|
-
|
|
28
|
-
- **Import trực tiếp từ source**: Example app sẽ import trực tiếp từ `../src/` thay vì build
|
|
29
|
-
- **Hot reload**: Mọi thay đổi trong `../src/` hoặc `example/src/` đều tự động reload
|
|
30
|
-
- **Test custom layout**: Bật/tắt custom components bằng checkbox trong UI
|
|
31
|
-
- **Test props**: Thay đổi language, API URL, etc.
|
|
32
|
-
|
|
33
|
-
## 📝 Lưu ý
|
|
34
|
-
|
|
35
|
-
1. **Không cần build**: Example app import trực tiếp từ TypeScript source
|
|
36
|
-
2. **React version**: Đảm bảo cùng version (18.3.1) với thư viện chính
|
|
37
|
-
3. **Không publish**: Folder này chỉ dùng cho development, không publish lên npm
|
|
38
|
-
|
|
39
|
-
## 🎯 Use Cases
|
|
40
|
-
|
|
41
|
-
- ✅ Test features mới
|
|
42
|
-
- ✅ Debug issues
|
|
43
|
-
- ✅ Test custom layout components
|
|
44
|
-
- ✅ Kiểm tra performance
|
|
45
|
-
- ✅ Preview trước khi publish
|
|
46
|
-
|
|
47
|
-
## 🔗 Import từ source
|
|
48
|
-
|
|
49
|
-
Trong `vite.config.ts`, chúng ta đã setup alias:
|
|
50
|
-
|
|
51
|
-
```typescript
|
|
52
|
-
resolve: {
|
|
53
|
-
alias: {
|
|
54
|
-
'@clikvn/showroom-visualizer': path.resolve(__dirname, '../src'),
|
|
55
|
-
},
|
|
56
|
-
}
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
Nên bạn có thể import như thật:
|
|
60
|
-
|
|
61
|
-
```typescript
|
|
62
|
-
import { ShowroomVisualizer } from '@clikvn/showroom-visualizer';
|
|
63
|
-
```
|
|
64
|
-
|
package/example/index.html
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<meta charset="UTF-8" />
|
|
5
|
-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
-
<title>Showroom Visualizer - Example</title>
|
|
7
|
-
</head>
|
|
8
|
-
<body>
|
|
9
|
-
<div id="root"></div>
|
|
10
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
11
|
-
</body>
|
|
12
|
-
</html>
|
|
13
|
-
|
package/example/package.json
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "showroom-visualizer-example",
|
|
3
|
-
"private": true,
|
|
4
|
-
"version": "0.0.0",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"dev": "vite",
|
|
8
|
-
"build": "tsc && vite build",
|
|
9
|
-
"preview": "vite preview"
|
|
10
|
-
},
|
|
11
|
-
"dependencies": {
|
|
12
|
-
"react": "^19.1.0",
|
|
13
|
-
"react-dom": "^19.1.0"
|
|
14
|
-
},
|
|
15
|
-
"devDependencies": {
|
|
16
|
-
"@types/react": "^19.1.0",
|
|
17
|
-
"@types/react-dom": "^19.1.0",
|
|
18
|
-
"@vitejs/plugin-react": "^5.0.0",
|
|
19
|
-
"autoprefixer": "^10.4.22",
|
|
20
|
-
"postcss": "^8.5.6",
|
|
21
|
-
"tailwindcss": "^3.4.0",
|
|
22
|
-
"typescript": "^5.6.3",
|
|
23
|
-
"vite": "^6.0.0"
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/** @type {import('tailwindcss').Config} */
|
|
2
|
-
module.exports = {
|
|
3
|
-
// Extend the parent tailwind config
|
|
4
|
-
presets: [require('../tailwind.config.cjs')],
|
|
5
|
-
content: [
|
|
6
|
-
'./index.html',
|
|
7
|
-
'./src/**/*.{js,ts,jsx,tsx}',
|
|
8
|
-
// Include parent library source files
|
|
9
|
-
'../src/**/*.{js,ts,jsx,tsx}',
|
|
10
|
-
],
|
|
11
|
-
important: true,
|
|
12
|
-
};
|