@clikvn/showroom-visualizer 0.2.2-dev-09 → 0.2.2-dev-11
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/.idea/inspectionProfiles/Project_Default.xml +36 -0
- package/.idea/jsLinters/eslint.xml +7 -0
- package/.idea/misc.xml +9 -0
- package/.idea/modules.xml +8 -0
- package/.idea/prettier.xml +8 -0
- package/.idea/showroom-visualizer.iml +9 -0
- package/.idea/vcs.xml +6 -0
- package/DEVELOPMENT.md +120 -0
- package/EXAMPLES.md +967 -0
- package/README.md +139 -32
- package/SETUP_COMPLETE.md +149 -0
- package/dist/components/SkinLayer/DefaultLayout/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/Drawer/PoiHeader/index.d.ts +16 -0
- package/dist/components/SkinLayer/Drawer/PoiHeader/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/Drawer/index.d.ts +29 -0
- package/dist/components/SkinLayer/Drawer/index.d.ts.map +1 -0
- 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/GalleryFullScreen/Content/ARViewer.d.ts +30 -0
- package/dist/components/SkinLayer/GalleryFullScreen/Content/ARViewer.d.ts.map +1 -0
- package/dist/components/SkinLayer/Layout/index.d.ts.map +1 -1
- package/dist/components/SkinLayer/ModalItemInfo/Description.d.ts +10 -0
- package/dist/components/SkinLayer/ModalItemInfo/Description.d.ts.map +1 -0
- package/dist/components/SkinLayer/ModalItemInfo/Intro.d.ts +9 -0
- package/dist/components/SkinLayer/ModalItemInfo/Intro.d.ts.map +1 -0
- package/dist/components/SkinLayer/ModalItemInfo/Media.d.ts +13 -0
- package/dist/components/SkinLayer/ModalItemInfo/Media.d.ts.map +1 -0
- package/dist/components/SkinLayer/ModalItemInfo/index.d.ts +10 -0
- package/dist/components/SkinLayer/ModalItemInfo/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/PlayAll/index.d.ts +8 -0
- package/dist/components/SkinLayer/PlayAll/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/PoiTextureOptions/HorizontalMenu/index.d.ts +13 -0
- package/dist/components/SkinLayer/PoiTextureOptions/HorizontalMenu/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/PoiTextureOptions/SemicircleMenu/index.d.ts +13 -0
- package/dist/components/SkinLayer/PoiTextureOptions/SemicircleMenu/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/PoiTextureOptions/TextureMenuItem/index.d.ts +15 -0
- package/dist/components/SkinLayer/PoiTextureOptions/TextureMenuItem/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/PoiTextureOptions/VerticalMenu/index.d.ts +13 -0
- package/dist/components/SkinLayer/PoiTextureOptions/VerticalMenu/index.d.ts.map +1 -0
- package/dist/components/SkinLayer/index.d.ts +32 -0
- package/dist/components/SkinLayer/index.d.ts.map +1 -1
- package/dist/context/CustomLayoutContext.d.ts +20 -0
- package/dist/context/CustomLayoutContext.d.ts.map +1 -0
- package/dist/context/StoreContext.d.ts +5 -0
- package/dist/context/StoreContext.d.ts.map +1 -0
- package/dist/features/ShowroomVisualizer/Scripts.d.ts +4 -0
- package/dist/features/ShowroomVisualizer/Scripts.d.ts.map +1 -0
- package/dist/features/ShowroomVisualizer/TourContainer.d.ts +9 -0
- package/dist/features/ShowroomVisualizer/TourContainer.d.ts.map +1 -0
- package/dist/features/ShowroomVisualizer/Tours.d.ts +3 -0
- package/dist/features/ShowroomVisualizer/Tours.d.ts.map +1 -0
- package/dist/features/ShowroomVisualizer/VirtualTour.d.ts +5 -0
- package/dist/features/ShowroomVisualizer/VirtualTour.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/VirtualTourContainer.d.ts +4 -3
- package/dist/features/ShowroomVisualizer/VirtualTourContainer.d.ts.map +1 -1
- package/dist/features/ShowroomVisualizer/index.d.ts +24 -3
- package/dist/features/ShowroomVisualizer/index.d.ts.map +1 -1
- package/dist/features/VirtualTourVisualizer/index.d.ts +20 -0
- package/dist/features/VirtualTourVisualizer/index.d.ts.map +1 -0
- package/dist/features/VirtualTourVisualizerUI/index.d.ts +17 -0
- package/dist/features/VirtualTourVisualizerUI/index.d.ts.map +1 -0
- package/dist/hooks/Visualizer/reducer.d.ts +116 -0
- package/dist/hooks/Visualizer/reducer.d.ts.map +1 -0
- package/dist/hooks/headless/index.d.ts +0 -31
- package/dist/hooks/headless/index.d.ts.map +1 -1
- package/dist/hooks/useToolConfig.d.ts.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.html +95 -95
- package/dist/index.js +1 -1
- package/dist/register.d.ts +3 -0
- package/dist/register.d.ts.map +1 -1
- package/dist/types/SkinLayer/tool.type.d.ts +6 -0
- package/dist/types/SkinLayer/tool.type.d.ts.map +1 -1
- package/dist/types/SkinLayer/visualizer.type.d.ts +3 -0
- package/dist/types/SkinLayer/visualizer.type.d.ts.map +1 -1
- package/dist/types/custom-layout.d.ts +63 -0
- package/dist/types/custom-layout.d.ts.map +1 -0
- package/dist/web.js +1 -1
- package/example/CSS_HANDLING.md +141 -0
- package/example/FIXES_SUMMARY.md +121 -0
- package/example/PATH_ALIASES.md +103 -0
- package/example/README.md +64 -0
- package/example/index.html +13 -0
- package/example/package.json +25 -0
- package/example/postcss.config.cjs +6 -0
- package/example/tailwind.config.cjs +12 -0
- package/example/tsconfig.node.json +12 -0
- package/example/vite.config.ts +126 -0
- package/package.json +132 -124
- package/rollup.config.js +272 -4
- package/.claude/settings.local.json +0 -19
- package/dist/context/SwizzleContext.d.ts +0 -21
- package/dist/context/SwizzleContext.d.ts.map +0 -1
- package/dist/types/swizzle.d.ts +0 -59
- package/dist/types/swizzle.d.ts.map +0 -1
- /package/dist/features/ShowroomVisualizer/{CssStyles.d.ts → cssStyles.d.ts} +0 -0
- /package/dist/features/ShowroomVisualizer/{CssStyles.d.ts.map → cssStyles.d.ts.map} +0 -0
package/package.json
CHANGED
|
@@ -1,124 +1,132 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@clikvn/showroom-visualizer",
|
|
3
|
-
"description": "Showroom Visualizer",
|
|
4
|
-
"version": "0.2.2-dev-
|
|
5
|
-
"author": "Clik JSC",
|
|
6
|
-
"license": "ISC",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"main": "dist/index.js",
|
|
9
|
-
"types": "dist/index.d.ts",
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"@
|
|
29
|
-
"@
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"react
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"react
|
|
54
|
-
"
|
|
55
|
-
"react
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
"
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
"
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
"@
|
|
92
|
-
"@
|
|
93
|
-
"@
|
|
94
|
-
"@
|
|
95
|
-
"@
|
|
96
|
-
"@
|
|
97
|
-
"@
|
|
98
|
-
"@
|
|
99
|
-
"@
|
|
100
|
-
"@
|
|
101
|
-
"@
|
|
102
|
-
"@
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
"
|
|
114
|
-
"
|
|
115
|
-
"
|
|
116
|
-
"
|
|
117
|
-
"
|
|
118
|
-
"
|
|
119
|
-
"
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
"
|
|
123
|
-
|
|
124
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@clikvn/showroom-visualizer",
|
|
3
|
+
"description": "Showroom Visualizer",
|
|
4
|
+
"version": "0.2.2-dev-11",
|
|
5
|
+
"author": "Clik JSC",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./dist/web": "./dist/web.js",
|
|
16
|
+
"./dist/web.js": "./dist/web.js"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "rollup --watch --config rollup.config.js",
|
|
20
|
+
"build": "rollup --config rollup.config.js",
|
|
21
|
+
"lint": "eslint src",
|
|
22
|
+
"lint:fix": "eslint --fix src",
|
|
23
|
+
"prettier": "prettier --write .",
|
|
24
|
+
"pub": "publish --access public",
|
|
25
|
+
"deploy": "yarn build && yarn publish --access public"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@clikvn/react-bottom-sheet": "^1.0.3",
|
|
29
|
+
"@clikvn/react-gallery-viewer": "^1.2.3-dev",
|
|
30
|
+
"@fortawesome/fontawesome-svg-core": "^6.6.0",
|
|
31
|
+
"@fortawesome/free-brands-svg-icons": "^6.6.0",
|
|
32
|
+
"@fortawesome/free-regular-svg-icons": "^6.6.0",
|
|
33
|
+
"@fortawesome/free-solid-svg-icons": "^6.6.0",
|
|
34
|
+
"@fortawesome/react-fontawesome": "^0.2.2",
|
|
35
|
+
"@radix-ui/react-slot": "^1.1.1",
|
|
36
|
+
"@ts-stack/markdown": "1.4.0",
|
|
37
|
+
"@types/moment": "^2.13.0",
|
|
38
|
+
"antd": "^5.27.2",
|
|
39
|
+
"axios": "^1.11.0",
|
|
40
|
+
"class-variance-authority": "^0.7.1",
|
|
41
|
+
"classnames": "^2.5.1",
|
|
42
|
+
"clsx": "^2.1.1",
|
|
43
|
+
"date-fns": "^4.1.0",
|
|
44
|
+
"device-detector-js": "^3.0.3",
|
|
45
|
+
"embla-carousel-react": "^8.6.0",
|
|
46
|
+
"framer-motion": "^12.23.12",
|
|
47
|
+
"howler": "^2.2.4",
|
|
48
|
+
"i18next": "^25.5.1",
|
|
49
|
+
"lodash": "^4.17.21",
|
|
50
|
+
"lucide-react": "^0.544.0",
|
|
51
|
+
"moment": "^2.30.1",
|
|
52
|
+
"node-fetch": "^3.3.2",
|
|
53
|
+
"qrcode.react": "^4.2.0",
|
|
54
|
+
"rc-progress": "^4.0.0",
|
|
55
|
+
"react": "^18.3.1",
|
|
56
|
+
"react-dom": "^18.3.1",
|
|
57
|
+
"react-i18next": "^15.7.3",
|
|
58
|
+
"react-intersection-image": "^2.1.2",
|
|
59
|
+
"react-markdown": "^9.0.3",
|
|
60
|
+
"react-planet": "^1.0.1-ie11",
|
|
61
|
+
"react-slick": "^0.31.0",
|
|
62
|
+
"react-truncate-markup": "^5.1.2",
|
|
63
|
+
"react-zoom-pan-pinch": "^3.7.0",
|
|
64
|
+
"remark-gfm": "^4.0.0",
|
|
65
|
+
"signals": "^1.0.0",
|
|
66
|
+
"sonner": "^2.0.7",
|
|
67
|
+
"swr": "^2.3.0",
|
|
68
|
+
"usehooks-ts": "^3.1.0",
|
|
69
|
+
"vtt.js": "^0.13.0",
|
|
70
|
+
"web-vitals": "^2.1.0"
|
|
71
|
+
},
|
|
72
|
+
"eslintConfig": {
|
|
73
|
+
"extends": [
|
|
74
|
+
"react-app",
|
|
75
|
+
"react-app/jest"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"browserslist": {
|
|
79
|
+
"production": [
|
|
80
|
+
">0.2%",
|
|
81
|
+
"not dead",
|
|
82
|
+
"not op_mini all"
|
|
83
|
+
],
|
|
84
|
+
"development": [
|
|
85
|
+
"last 1 chrome version",
|
|
86
|
+
"last 1 firefox version",
|
|
87
|
+
"last 1 safari version"
|
|
88
|
+
]
|
|
89
|
+
},
|
|
90
|
+
"devDependencies": {
|
|
91
|
+
"@rollup-extras/plugin-copy": "^1.11.1",
|
|
92
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
93
|
+
"@rollup/plugin-commonjs": "^28.0.1",
|
|
94
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
95
|
+
"@rollup/plugin-node-resolve": "^15.3.0",
|
|
96
|
+
"@rollup/plugin-typescript": "^12.1.1",
|
|
97
|
+
"@tailwindcss/typography": "^0.5.15",
|
|
98
|
+
"@testing-library/jest-dom": "^5.14.1",
|
|
99
|
+
"@testing-library/react": "^13.0.0",
|
|
100
|
+
"@testing-library/user-event": "^13.2.1",
|
|
101
|
+
"@types/howler": "^2.2.12",
|
|
102
|
+
"@types/jest": "^29.5.14",
|
|
103
|
+
"@types/lodash": "^4.17.20",
|
|
104
|
+
"@types/node": "^22.9.0",
|
|
105
|
+
"@types/node-fetch": "^2.6.13",
|
|
106
|
+
"@types/react": "^18.3.12",
|
|
107
|
+
"@types/react-dom": "^18.3.1",
|
|
108
|
+
"@types/signals": "^1.0.4",
|
|
109
|
+
"@typescript-eslint/eslint-plugin": "^8.20.0",
|
|
110
|
+
"@typescript-eslint/parser": "^8.20.0",
|
|
111
|
+
"autoprefixer": "^10.4.20",
|
|
112
|
+
"eslint": "^8.57.0",
|
|
113
|
+
"eslint-config-prettier": "^10.0.1",
|
|
114
|
+
"eslint-plugin-prettier": "^5.2.2",
|
|
115
|
+
"prettier": "^3.4.2",
|
|
116
|
+
"react-scripts": "5.0.1",
|
|
117
|
+
"rollup": "^4.26.0",
|
|
118
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
119
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
120
|
+
"rollup-plugin-replace": "^2.2.0",
|
|
121
|
+
"rollup-plugin-terser": "^7.0.2",
|
|
122
|
+
"rollup-plugin-typescript-paths": "^1.5.0",
|
|
123
|
+
"rollup-plugin-uglify": "^6.0.4",
|
|
124
|
+
"tailwind-merge": "^2.6.0",
|
|
125
|
+
"tailwindcss": "^3.4.15",
|
|
126
|
+
"tailwindcss-animate": "^1.0.7",
|
|
127
|
+
"typescript": "^5.6.3"
|
|
128
|
+
},
|
|
129
|
+
"engines": {
|
|
130
|
+
"node": ">=18.18.0"
|
|
131
|
+
}
|
|
132
|
+
}
|
package/rollup.config.js
CHANGED
|
@@ -1,3 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ============================================================================
|
|
3
|
+
* SHOWROOM VISUALIZER - ROLLUP BUILD CONFIGURATION
|
|
4
|
+
* ============================================================================
|
|
5
|
+
*
|
|
6
|
+
* 🎯 MỤC TIÊU:
|
|
7
|
+
* Tạo ra 2 build outputs phục vụ 2 use cases khác nhau:
|
|
8
|
+
*
|
|
9
|
+
* 1️⃣ NPM Package (dist/index.js) - EXTERNAL REACT
|
|
10
|
+
* - Dùng React từ host app (Next.js, React apps)
|
|
11
|
+
* - ✅ Hỗ trợ Custom Layout overrides
|
|
12
|
+
* - File nhỏ hơn (~1.8MB)
|
|
13
|
+
* - Use: import { ShowroomVisualizer } from '@clikvn/showroom-visualizer'
|
|
14
|
+
*
|
|
15
|
+
* 2️⃣ Web Component (dist/web.js) - BUNDLED REACT
|
|
16
|
+
* - Bundle React 19 vào file
|
|
17
|
+
* - ❌ KHÔNG hỗ trợ custom layout overrides
|
|
18
|
+
* - File lớn hơn (~2.0MB)
|
|
19
|
+
* - Use: <script type="module" src="web.js"></script>
|
|
20
|
+
*
|
|
21
|
+
* ────────────────────────────────────────────────────────────────────────────
|
|
22
|
+
*
|
|
23
|
+
* 📊 SO SÁNH:
|
|
24
|
+
*
|
|
25
|
+
* | Feature | NPM Package | Web Component |
|
|
26
|
+
* |----------------------|-------------|---------------|
|
|
27
|
+
* | React Source | Host app | Bundled |
|
|
28
|
+
* | Custom Layout | ✅ Yes | ❌ No |
|
|
29
|
+
* | File Size | ~1.8MB | ~2.0MB |
|
|
30
|
+
* | Dependencies | Need React | Standalone |
|
|
31
|
+
* | Use Case | React apps | Vanilla JS |
|
|
32
|
+
*
|
|
33
|
+
* ────────────────────────────────────────────────────────────────────────────
|
|
34
|
+
*/
|
|
35
|
+
|
|
1
36
|
import resolve from '@rollup/plugin-node-resolve';
|
|
2
37
|
import commonjs from '@rollup/plugin-commonjs';
|
|
3
38
|
import typescript from '@rollup/plugin-typescript';
|
|
@@ -16,8 +51,163 @@ const extensions = ['.ts', '.tsx', '.js'];
|
|
|
16
51
|
const isDev =
|
|
17
52
|
process.env.NODE_ENV === 'development' || process.env.ROLLUP_WATCH === 'true';
|
|
18
53
|
|
|
54
|
+
// ============================================================================
|
|
55
|
+
// CUSTOM PLUGIN: Fix React-DOM Imports
|
|
56
|
+
// ============================================================================
|
|
57
|
+
// React 18's ESM build không export findDOMNode, nhưng CommonJS build có.
|
|
58
|
+
// Plugin này rewrite code để chỉ dùng default import và access properties,
|
|
59
|
+
// tránh Rollup extract named imports.
|
|
60
|
+
const fixReactDomImports = () => ({
|
|
61
|
+
name: 'fix-react-dom-imports',
|
|
62
|
+
renderChunk(code) {
|
|
63
|
+
let fixed = code;
|
|
64
|
+
|
|
65
|
+
// Fix invalid variable declarations with dots in the name
|
|
66
|
+
// This pattern appears in minified code from third-party libraries
|
|
67
|
+
fixed = fixed.replace(
|
|
68
|
+
/var\s+_ReactDOM\$ReactDOM__default\.findDOMNode;/g,
|
|
69
|
+
'var _ReactDOM$findDOMNode;'
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
// Fix all occurrences of the invalid variable name
|
|
73
|
+
fixed = fixed.replace(
|
|
74
|
+
/_ReactDOM\$ReactDOM__default\.findDOMNode/g,
|
|
75
|
+
'_ReactDOM$findDOMNode'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// Fix double ReactDOM__default references
|
|
79
|
+
fixed = fixed.replace(
|
|
80
|
+
/ReactDOM__default\.ReactDOM__default\./g,
|
|
81
|
+
'ReactDOM__default.'
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
// Additional fix for similar patterns with other methods
|
|
85
|
+
fixed = fixed.replace(
|
|
86
|
+
/var\s+_ReactDOM\$ReactDOM__default\.(\w+);/g,
|
|
87
|
+
'var _ReactDOM$$1;'
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
// Fix minified code that creates invalid variable names
|
|
91
|
+
fixed = fixed.replace(
|
|
92
|
+
/var\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\$([a-zA-Z_$][a-zA-Z0-9_$]*)\.[a-zA-Z_$][a-zA-Z0-9_$]*;/g,
|
|
93
|
+
function (match, prefix, suffix) {
|
|
94
|
+
return `var ${prefix}$${suffix}_temp;`;
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
// First, remove any findDOMNode from named imports
|
|
99
|
+
fixed = fixed.replace(
|
|
100
|
+
/import\s*\{([^}]*)\}\s*from\s*['"]react-dom['"]/g,
|
|
101
|
+
(match, imports) => {
|
|
102
|
+
if (imports.includes('findDOMNode')) {
|
|
103
|
+
const cleanedImports = imports
|
|
104
|
+
.split(',')
|
|
105
|
+
.map((imp) => imp.trim())
|
|
106
|
+
.filter((imp) => !imp.includes('findDOMNode'))
|
|
107
|
+
.join(', ');
|
|
108
|
+
|
|
109
|
+
if (cleanedImports.trim()) {
|
|
110
|
+
return `import { ${cleanedImports} } from 'react-dom'`;
|
|
111
|
+
}
|
|
112
|
+
return '';
|
|
113
|
+
}
|
|
114
|
+
return match;
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
// Handle combined default and named imports
|
|
119
|
+
fixed = fixed.replace(
|
|
120
|
+
/import\s+(\w+),\s*\{\s*([^}]+)\s*\}\s*from\s*['"]react-dom['"]/g,
|
|
121
|
+
(match, defaultImport, namedImports) => {
|
|
122
|
+
// Check if named imports contains invalid syntax like "ReactDOM__default.createPortal"
|
|
123
|
+
if (
|
|
124
|
+
namedImports.includes('ReactDOM__default.') ||
|
|
125
|
+
namedImports.includes('findDOMNode')
|
|
126
|
+
) {
|
|
127
|
+
// Extract valid imports only
|
|
128
|
+
const validImports = namedImports
|
|
129
|
+
.split(',')
|
|
130
|
+
.map((imp) => imp.trim())
|
|
131
|
+
.filter((imp) => {
|
|
132
|
+
// Remove any import that has dots or includes findDOMNode
|
|
133
|
+
return !imp.includes('.') && !imp.includes('findDOMNode');
|
|
134
|
+
})
|
|
135
|
+
.map((imp) => {
|
|
136
|
+
// Clean up "as" aliases
|
|
137
|
+
const parts = imp.split(/\s+as\s+/);
|
|
138
|
+
if (parts.length === 2 && !parts[0].includes('.')) {
|
|
139
|
+
return imp;
|
|
140
|
+
}
|
|
141
|
+
return '';
|
|
142
|
+
})
|
|
143
|
+
.filter(Boolean)
|
|
144
|
+
.join(', ');
|
|
145
|
+
|
|
146
|
+
if (validImports) {
|
|
147
|
+
return `import ${defaultImport}, { ${validImports} } from 'react-dom'`;
|
|
148
|
+
}
|
|
149
|
+
return `import ${defaultImport} from 'react-dom'`;
|
|
150
|
+
}
|
|
151
|
+
return match;
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// Replace all variations of findDOMNode (but not in function declarations)
|
|
156
|
+
fixed = fixed.replace(/\bfindDOMNode\$?\d*\b/g, (match, offset) => {
|
|
157
|
+
// Check if this is a function declaration
|
|
158
|
+
const beforeMatch = fixed.substring(Math.max(0, offset - 20), offset);
|
|
159
|
+
if (beforeMatch.trim().endsWith('function')) {
|
|
160
|
+
return match; // Don't replace in function declarations
|
|
161
|
+
}
|
|
162
|
+
return 'ReactDOM__default.findDOMNode';
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// Fix property access patterns
|
|
166
|
+
fixed = fixed.replace(/(\w+)\.findDOMNode\b/g, (match, obj) => {
|
|
167
|
+
if (obj === 'ReactDOM__default') return match;
|
|
168
|
+
return 'ReactDOM__default.findDOMNode';
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
// Replace other methods - but NOT when they're being used in import statements
|
|
172
|
+
const methodsToReplace = [
|
|
173
|
+
'createPortal',
|
|
174
|
+
'unstable_batchedUpdates',
|
|
175
|
+
'flushSync',
|
|
176
|
+
];
|
|
177
|
+
|
|
178
|
+
methodsToReplace.forEach((method) => {
|
|
179
|
+
// Only replace when not in import context
|
|
180
|
+
const regex = new RegExp(
|
|
181
|
+
`\\b${method}\\$?\\d*\\b(?![:\\.]|\\s*as\\s*\\w+)`,
|
|
182
|
+
'g'
|
|
183
|
+
);
|
|
184
|
+
fixed = fixed.replace(regex, (match, offset) => {
|
|
185
|
+
// Check if this is within an import statement
|
|
186
|
+
const beforeMatch = fixed.substring(Math.max(0, offset - 100), offset);
|
|
187
|
+
if (beforeMatch.includes('import') && beforeMatch.includes('{')) {
|
|
188
|
+
return match;
|
|
189
|
+
}
|
|
190
|
+
return `ReactDOM__default.${method}`;
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return { code: fixed, map: null };
|
|
195
|
+
},
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
// ============================================================================
|
|
199
|
+
// CONFIG CHO NPM PACKAGE - External React
|
|
200
|
+
// ============================================================================
|
|
201
|
+
// Dùng khi: import { ShowroomVisualizer } from '@clikvn/showroom-visualizer'
|
|
202
|
+
// - React được external → Dùng React version của host app (Next.js, React app)
|
|
203
|
+
// - Cho phép custom layout overrides vì share cùng React instance
|
|
204
|
+
// - File nhỏ hơn vì không bundle React
|
|
19
205
|
const indexConfig = {
|
|
20
206
|
context: 'this',
|
|
207
|
+
|
|
208
|
+
// ✅ External React - Library sẽ dùng React từ host app
|
|
209
|
+
external: ['react', 'react-dom', 'react/jsx-runtime', 'react-dom/client'],
|
|
210
|
+
|
|
21
211
|
onwarn(warning, warn) {
|
|
22
212
|
// Bỏ qua warning về "use client" directive
|
|
23
213
|
if (
|
|
@@ -33,11 +223,24 @@ const indexConfig = {
|
|
|
33
223
|
resolve({
|
|
34
224
|
extensions,
|
|
35
225
|
browser: true,
|
|
36
|
-
|
|
226
|
+
preferBuiltins: false,
|
|
227
|
+
dedupe: [
|
|
228
|
+
'react',
|
|
229
|
+
'react-dom',
|
|
230
|
+
'useTranslation',
|
|
231
|
+
'i18n',
|
|
232
|
+
'I18nextProvider',
|
|
233
|
+
],
|
|
234
|
+
}),
|
|
235
|
+
commonjs({
|
|
236
|
+
esmExternals: true,
|
|
237
|
+
requireReturnsDefault: 'auto',
|
|
238
|
+
// Không extract named imports từ external modules
|
|
239
|
+
ignoreDynamicRequires: false,
|
|
37
240
|
}),
|
|
38
|
-
commonjs(),
|
|
39
241
|
// Skip uglify in dev mode - tốn thời gian
|
|
40
|
-
|
|
242
|
+
// uglify does not support ES2015+ properly — and React’s ESM builds rely heavily on ES2015+ semantics
|
|
243
|
+
// !isDev && uglify(),
|
|
41
244
|
json(),
|
|
42
245
|
// Skip babel in dev mode - giảm thời gian compile
|
|
43
246
|
!isDev &&
|
|
@@ -79,10 +282,75 @@ const indexConfig = {
|
|
|
79
282
|
typescriptPaths({ preserveExtensions: true }),
|
|
80
283
|
// Skip terser trong dev - tốn rất nhiều thời gian
|
|
81
284
|
!isDev && terser({ output: { comments: false } }),
|
|
285
|
+
// ⚠️ QUAN TRỌNG: Fix react-dom imports sau khi bundle
|
|
286
|
+
// Phải đặt ở cuối để chạy sau tất cả transformations
|
|
287
|
+
fixReactDomImports(),
|
|
82
288
|
].filter(Boolean), // Remove false values
|
|
83
289
|
};
|
|
84
290
|
|
|
291
|
+
// ============================================================================
|
|
292
|
+
// CONFIG CHO WEB COMPONENT - Bundled React
|
|
293
|
+
// ============================================================================
|
|
294
|
+
// Dùng khi: <script src="web.js"> hoặc dynamic import('web.js')
|
|
295
|
+
// - React được BUNDLE vào → Standalone, không cần dependencies
|
|
296
|
+
// - KHÔNG hỗ trợ custom layout overrides (vì khác React instance với host app)
|
|
297
|
+
// - File lớn hơn vì bundle React (~200KB extra)
|
|
298
|
+
// - Phù hợp cho vanilla JS/HTML projects
|
|
299
|
+
const browserConfig = {
|
|
300
|
+
context: 'this',
|
|
301
|
+
// ❌ KHÔNG external React - Bundle React version 19 vào file
|
|
302
|
+
// external: [], // Không khai báo external = bundle tất cả
|
|
303
|
+
onwarn: indexConfig.onwarn,
|
|
304
|
+
plugins: indexConfig.plugins,
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
// ============================================================================
|
|
308
|
+
// DUAL BUILD STRATEGY
|
|
309
|
+
// ============================================================================
|
|
85
310
|
const configs = [
|
|
311
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
312
|
+
// BUILD 1: NPM Package (dist/index.js)
|
|
313
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
314
|
+
// 📦 Sử dụng: import { ShowroomVisualizer } from '@clikvn/showroom-visualizer'
|
|
315
|
+
//
|
|
316
|
+
// ✅ Ưu điểm:
|
|
317
|
+
// - Dùng React version của host app (Next.js, React app)
|
|
318
|
+
// - Cho phép SWIZZLE components (share React instance)
|
|
319
|
+
// - File nhỏ (~1.8MB) vì không bundle React
|
|
320
|
+
//
|
|
321
|
+
// 📝 Use cases:
|
|
322
|
+
// - React/Next.js applications
|
|
323
|
+
// - Cần customize components qua custom layout overrides
|
|
324
|
+
// - Muốn kiểm soát React version
|
|
325
|
+
{
|
|
326
|
+
input: './src/index.ts',
|
|
327
|
+
output: {
|
|
328
|
+
file: 'dist/index.js',
|
|
329
|
+
format: 'esm',
|
|
330
|
+
inlineDynamicImports: true,
|
|
331
|
+
},
|
|
332
|
+
...indexConfig, // ✅ External React dependencies
|
|
333
|
+
},
|
|
334
|
+
|
|
335
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
336
|
+
// BUILD 2: Web Component (dist/web.js)
|
|
337
|
+
// ────────────────────────────────────────────────────────────────────────
|
|
338
|
+
// 🌐 Sử dụng: <script type="module" src="web.js"></script>
|
|
339
|
+
// hoặc: await import('web.js')
|
|
340
|
+
//
|
|
341
|
+
// ✅ Ưu điểm:
|
|
342
|
+
// - Standalone, không cần install dependencies
|
|
343
|
+
// - Hoạt động trong vanilla JS/HTML
|
|
344
|
+
// - Không cần build tools
|
|
345
|
+
//
|
|
346
|
+
// ❌ Hạn chế:
|
|
347
|
+
// - KHÔNG hỗ trợ custom layout overrides (khác React instance)
|
|
348
|
+
// - File lớn hơn (~2.0MB) vì bundle React
|
|
349
|
+
//
|
|
350
|
+
// 📝 Use cases:
|
|
351
|
+
// - Vanilla JS/HTML projects
|
|
352
|
+
// - Không cần customize UI
|
|
353
|
+
// - Quick integration
|
|
86
354
|
{
|
|
87
355
|
input: './src/web.ts',
|
|
88
356
|
output: {
|
|
@@ -90,7 +358,7 @@ const configs = [
|
|
|
90
358
|
format: 'esm',
|
|
91
359
|
inlineDynamicImports: true,
|
|
92
360
|
},
|
|
93
|
-
...
|
|
361
|
+
...browserConfig, // ✅ Bundle React version 19
|
|
94
362
|
},
|
|
95
363
|
];
|
|
96
364
|
|
|
@@ -1,19 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, { ReactNode, ComponentType } from 'react';
|
|
2
|
-
import { SwizzleConfig, SwizzlePath } from '../types/swizzle';
|
|
3
|
-
type SwizzleContextType = {
|
|
4
|
-
swizzle: SwizzleConfig;
|
|
5
|
-
getSwizzledComponent: <T = unknown>(path: SwizzlePath, defaultComponent: ComponentType<T>) => ComponentType<T>;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Hook để access swizzle configuration
|
|
9
|
-
*/
|
|
10
|
-
export declare const useSwizzle: () => SwizzleContextType;
|
|
11
|
-
type Props = {
|
|
12
|
-
swizzle?: SwizzleConfig;
|
|
13
|
-
children: ReactNode;
|
|
14
|
-
};
|
|
15
|
-
/**
|
|
16
|
-
* SwizzleProvider - Wrap app với provider này để enable component swizzling
|
|
17
|
-
* Giống như Docusaurus swizzle pattern
|
|
18
|
-
*/
|
|
19
|
-
export declare const SwizzleProvider: React.FC<Props>;
|
|
20
|
-
export {};
|
|
21
|
-
//# sourceMappingURL=SwizzleContext.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SwizzleContext.d.ts","sourceRoot":"","sources":["../../src/context/SwizzleContext.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAGZ,SAAS,EACT,aAAa,EAGd,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ9D,KAAK,kBAAkB,GAAG;IACxB,OAAO,EAAE,aAAa,CAAC;IACvB,oBAAoB,EAAE,CAAC,CAAC,GAAG,OAAO,EAChC,IAAI,EAAE,WAAW,EACjB,gBAAgB,EAAE,aAAa,CAAC,CAAC,CAAC,KAC/B,aAAa,CAAC,CAAC,CAAC,CAAC;CACvB,CAAC;AAOF;;GAEG;AACH,eAAO,MAAM,UAAU,0BAAmC,CAAC;AAE3D,KAAK,KAAK,GAAG;IACX,OAAO,CAAC,EAAE,aAAa,CAAC;IACxB,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAkG3C,CAAC"}
|