@clikvn/showroom-visualizer 0.4.1-dev-02 → 0.4.1-dev-04
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/.claude/settings.local.json +1 -1
- package/DEVELOPMENT.md +6 -3
- package/EXAMPLES.md +193 -153
- package/README.md +7 -6
- package/SETUP_COMPLETE.md +10 -8
- package/dist/components/SkinLayer/HotspotCategorySlideIn/ProductSlideIn/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/SearchAndDiscoverySlideIn/HelpActionPart.d.ts.map +1 -1
- package/dist/components/SkinLayer/SearchAndDiscoverySlideIn/PoiInfoActionPart/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/SearchAndDiscoverySlideIn/ScenariosPart/index.d.ts.map +1 -1
- package/dist/constants/SkinLayer/customLayoutPaths.d.ts.map +1 -1
- package/dist/hooks/SkinLayer/useProductShake.d.ts +15 -0
- package/dist/hooks/SkinLayer/useProductShake.d.ts.map +1 -0
- package/dist/hooks/headless/useScenarioControl.d.ts.map +1 -1
- package/dist/hooks/useToolConfig.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/models/Visualizer/Tour.d.ts +7 -0
- package/dist/models/Visualizer/Tour.d.ts.map +1 -1
- package/dist/models/Visualizer/TourScenario/TourScenarioPlayer.d.ts.map +1 -1
- package/dist/types/SkinLayer/tool.type.d.ts +4 -0
- package/dist/types/SkinLayer/tool.type.d.ts.map +1 -1
- package/dist/types/custom-layout.d.ts.map +1 -1
- package/dist/web.js +1 -1
- package/example/CSS_HANDLING.md +4 -4
- package/example/FIXES_SUMMARY.md +18 -8
- package/example/PATH_ALIASES.md +13 -14
- package/example/README.md +0 -1
- package/example/index.html +0 -1
- package/example/postcss.config.cjs +1 -1
- package/example/tsconfig.node.json +0 -1
- package/package.json +1 -1
package/example/CSS_HANDLING.md
CHANGED
|
@@ -14,9 +14,9 @@ Thư viện sử dụng Rollup với PostCSS plugin config:
|
|
|
14
14
|
|
|
15
15
|
```javascript
|
|
16
16
|
postcss({
|
|
17
|
-
inject: false,
|
|
17
|
+
inject: false, // ← Không inject CSS vào DOM
|
|
18
18
|
extract: false, // ← Export CSS as string
|
|
19
|
-
})
|
|
19
|
+
});
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Điều này cho phép import CSS như strings:
|
|
@@ -66,10 +66,11 @@ const cssAsStringPlugin = () => ({
|
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
// Plugin order matters!
|
|
69
|
-
plugins: [cssAsStringPlugin(), react()]
|
|
69
|
+
plugins: [cssAsStringPlugin(), react()];
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
**Key Points:**
|
|
73
|
+
|
|
73
74
|
- ⭐ **`enforce: 'pre'`**: Chạy trước Vite's built-in CSS plugin
|
|
74
75
|
- ⭐ **`load` hook**: Intercept file loading, không dùng `transform`
|
|
75
76
|
- ⭐ **Plugin order**: `cssAsStringPlugin()` phải đứng TRƯỚC `react()`
|
|
@@ -138,4 +139,3 @@ yarn dev
|
|
|
138
139
|
---
|
|
139
140
|
|
|
140
141
|
✅ **Fixed!** CSS từ thư viện giờ được export as strings trong Vite dev mode.
|
|
141
|
-
|
package/example/FIXES_SUMMARY.md
CHANGED
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
## 1️⃣ Path Aliases Resolution ✅
|
|
8
8
|
|
|
9
9
|
### Lỗi:
|
|
10
|
+
|
|
10
11
|
```
|
|
11
12
|
[plugin:vite:import-analysis] Failed to resolve import "commons/SkinLayer/components/Drawer"
|
|
12
13
|
```
|
|
13
14
|
|
|
14
15
|
### Root Cause:
|
|
16
|
+
|
|
15
17
|
Thư viện sử dụng `baseUrl: "./src"` cho phép imports:
|
|
18
|
+
|
|
16
19
|
```typescript
|
|
17
20
|
import Drawer from 'commons/SkinLayer/components/Drawer';
|
|
18
21
|
```
|
|
@@ -20,7 +23,9 @@ import Drawer from 'commons/SkinLayer/components/Drawer';
|
|
|
20
23
|
Example app không biết về aliases này.
|
|
21
24
|
|
|
22
25
|
### Fix:
|
|
26
|
+
|
|
23
27
|
Thêm 10 path aliases vào `vite.config.ts` và `tsconfig.json`:
|
|
28
|
+
|
|
24
29
|
- `commons/*`, `components/*`, `constants/*`, `context/*`, `features/*`
|
|
25
30
|
- `hooks/*`, `models/*`, `services/*`, `types/*`, `utils/*`
|
|
26
31
|
|
|
@@ -31,24 +36,28 @@ Thêm 10 path aliases vào `vite.config.ts` và `tsconfig.json`:
|
|
|
31
36
|
## 2️⃣ CSS Imports as Strings ✅
|
|
32
37
|
|
|
33
38
|
### Lỗi:
|
|
39
|
+
|
|
34
40
|
```
|
|
35
|
-
Uncaught SyntaxError: The requested module '.../actionsChangeSceneStyles.css'
|
|
41
|
+
Uncaught SyntaxError: The requested module '.../actionsChangeSceneStyles.css'
|
|
36
42
|
does not provide an export named 'default'
|
|
37
43
|
```
|
|
38
44
|
|
|
39
45
|
### Root Cause:
|
|
46
|
+
|
|
40
47
|
- **Thư viện (Rollup)**: CSS exported as strings với `postcss({ inject: false })`
|
|
41
48
|
- **Vite**: Mặc định inject CSS, không export strings
|
|
42
49
|
- **CssStyles.tsx**: Cần CSS as strings để render `<style>{css}</style>`
|
|
43
50
|
|
|
44
51
|
### Fix:
|
|
52
|
+
|
|
45
53
|
Tạo custom Vite plugin `cssAsStringPlugin` với 3 key points:
|
|
46
54
|
|
|
47
55
|
```typescript
|
|
48
56
|
const cssAsStringPlugin = () => ({
|
|
49
57
|
name: 'css-as-string',
|
|
50
58
|
enforce: 'pre', // ⭐ Critical: Run BEFORE other plugins
|
|
51
|
-
load(id: string) {
|
|
59
|
+
load(id: string) {
|
|
60
|
+
// ⭐ Use 'load' hook, not 'transform'
|
|
52
61
|
if (
|
|
53
62
|
id.endsWith('.css') &&
|
|
54
63
|
(id.includes('/src/assets/') || id.includes('/@clikvn/'))
|
|
@@ -60,15 +69,17 @@ const cssAsStringPlugin = () => ({
|
|
|
60
69
|
});
|
|
61
70
|
|
|
62
71
|
// ⭐ Plugin order matters!
|
|
63
|
-
plugins: [cssAsStringPlugin(), react()]
|
|
72
|
+
plugins: [cssAsStringPlugin(), react()];
|
|
64
73
|
```
|
|
65
74
|
|
|
66
75
|
**3 điều quan trọng:**
|
|
76
|
+
|
|
67
77
|
1. `enforce: 'pre'` - Chạy trước Vite CSS plugin
|
|
68
78
|
2. `load()` hook - Intercept file loading sớm
|
|
69
79
|
3. Plugin order - Đặt TRƯỚC `react()`
|
|
70
80
|
|
|
71
81
|
Plugin chỉ xử lý:
|
|
82
|
+
|
|
72
83
|
- ✅ CSS từ `/src/assets/` → Export as string
|
|
73
84
|
- ✅ CSS từ `@clikvn/*` packages → Export as string
|
|
74
85
|
- ❌ CSS khác (antd, example CSS) → Vite xử lý bình thường
|
|
@@ -79,10 +90,10 @@ Plugin chỉ xử lý:
|
|
|
79
90
|
|
|
80
91
|
## 📊 Tổng kết
|
|
81
92
|
|
|
82
|
-
| Issue
|
|
83
|
-
|
|
93
|
+
| Issue | Status | Files Changed |
|
|
94
|
+
| ------------ | -------- | --------------------------------- |
|
|
84
95
|
| Path Aliases | ✅ Fixed | `vite.config.ts`, `tsconfig.json` |
|
|
85
|
-
| CSS Imports
|
|
96
|
+
| CSS Imports | ✅ Fixed | `vite.config.ts` (plugin) |
|
|
86
97
|
|
|
87
98
|
---
|
|
88
99
|
|
|
@@ -95,7 +106,7 @@ Plugin chỉ xử lý:
|
|
|
95
106
|
✅ Hot reload
|
|
96
107
|
✅ Path aliases
|
|
97
108
|
✅ CSS handling
|
|
98
|
-
✅ Test custom layout
|
|
109
|
+
✅ Test custom layout
|
|
99
110
|
|
|
100
111
|
---
|
|
101
112
|
|
|
@@ -118,4 +129,3 @@ yarn dev
|
|
|
118
129
|
```
|
|
119
130
|
|
|
120
131
|
Thay đổi code trong `../src/` → Tự động reload! 🔥
|
|
121
|
-
|
package/example/PATH_ALIASES.md
CHANGED
|
@@ -46,7 +46,7 @@ resolve: {
|
|
|
46
46
|
"commons": ["../src/commons"],
|
|
47
47
|
"commons/*": ["../src/commons/*"],
|
|
48
48
|
"components": ["../src/components"],
|
|
49
|
-
"components/*": ["../src/components/*"]
|
|
49
|
+
"components/*": ["../src/components/*"]
|
|
50
50
|
// ... các aliases khác
|
|
51
51
|
}
|
|
52
52
|
}
|
|
@@ -55,18 +55,18 @@ resolve: {
|
|
|
55
55
|
|
|
56
56
|
## Các Aliases Được Hỗ Trợ
|
|
57
57
|
|
|
58
|
-
| Alias
|
|
59
|
-
|
|
60
|
-
| `commons/*`
|
|
61
|
-
| `components/*` | `../src/components/*` | `import Layout from 'components/SkinLayer/Layout'`
|
|
62
|
-
| `constants/*`
|
|
63
|
-
| `context/*`
|
|
64
|
-
| `features/*`
|
|
65
|
-
| `hooks/*`
|
|
66
|
-
| `models/*`
|
|
67
|
-
| `services/*`
|
|
68
|
-
| `types/*`
|
|
69
|
-
| `utils/*`
|
|
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
70
|
|
|
71
71
|
## ⚠️ Lưu ý
|
|
72
72
|
|
|
@@ -100,4 +100,3 @@ cat example/tsconfig.json
|
|
|
100
100
|
---
|
|
101
101
|
|
|
102
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
CHANGED
package/example/index.html
CHANGED