@clikvn/showroom-visualizer 0.3.1 → 0.3.2

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.
@@ -9,11 +9,11 @@ import autoprefixer from 'autoprefixer';
9
9
  // Custom plugin to handle CSS imports as strings (matching Rollup's postcss behavior)
10
10
  const cssAsStringPlugin = (): Plugin => {
11
11
  let postcssProcessor: any;
12
-
12
+
13
13
  return {
14
14
  name: 'css-as-string',
15
15
  enforce: 'pre',
16
-
16
+
17
17
  async configResolved(config) {
18
18
  // Initialize PostCSS processor with Tailwind
19
19
  postcssProcessor = postcss([
@@ -23,55 +23,60 @@ const cssAsStringPlugin = (): Plugin => {
23
23
  autoprefixer(),
24
24
  ]);
25
25
  },
26
-
26
+
27
27
  async resolveId(source, importer) {
28
28
  // Handle CSS imports from the library
29
29
  if (source.endsWith('.css') && importer) {
30
30
  // Check if this is from our library (any src folder) or @clikvn packages
31
- const isLibraryCSS =
32
- importer.includes('/showroom-visualizer/src/') ||
31
+ const isLibraryCSS =
32
+ importer.includes('/showroom-visualizer/src/') ||
33
33
  source.includes('@clikvn/');
34
-
34
+
35
35
  if (isLibraryCSS) {
36
36
  // Resolve the full path
37
37
  let resolvedPath: string;
38
-
38
+
39
39
  if (source.startsWith('.') || source.startsWith('/')) {
40
40
  resolvedPath = path.resolve(path.dirname(importer), source);
41
41
  } else if (source.startsWith('@clikvn/')) {
42
42
  // Handle @clikvn packages - look in parent node_modules
43
- const packagePath = source.replace('@clikvn/', '../node_modules/@clikvn/');
43
+ const packagePath = source.replace(
44
+ '@clikvn/',
45
+ '../node_modules/@clikvn/'
46
+ );
44
47
  resolvedPath = path.resolve(__dirname, packagePath);
45
48
  } else {
46
49
  return null;
47
50
  }
48
-
51
+
49
52
  // Add a virtual marker to bypass Vite's CSS processing
50
53
  return '\0' + resolvedPath + '.string';
51
54
  }
52
55
  }
53
56
  return null;
54
57
  },
55
-
58
+
56
59
  async load(id) {
57
60
  // Handle our virtual CSS string modules
58
61
  if (id.startsWith('\0') && id.endsWith('.css.string')) {
59
62
  const realPath = id.slice(1, -7); // Remove \0 prefix and .string suffix
60
-
63
+
61
64
  try {
62
65
  const content = await fs.promises.readFile(realPath, 'utf-8');
63
-
66
+
64
67
  // Process all CSS through PostCSS/Tailwind to ensure Tailwind utilities work
65
68
  let processedContent = content;
66
69
  try {
67
- const result = await postcssProcessor.process(content, { from: realPath });
70
+ const result = await postcssProcessor.process(content, {
71
+ from: realPath,
72
+ });
68
73
  processedContent = result.css;
69
74
  } catch (error) {
70
75
  console.warn(`PostCSS processing failed for ${realPath}:`, error);
71
76
  // Fall back to original content if processing fails
72
77
  processedContent = content;
73
78
  }
74
-
79
+
75
80
  return {
76
81
  code: `export default ${JSON.stringify(processedContent)};`,
77
82
  map: null,
@@ -95,9 +100,12 @@ export default defineConfig({
95
100
  resolve: {
96
101
  alias: {
97
102
  // Force use of example's React to avoid duplicate instances
98
- 'react': path.resolve(__dirname, 'node_modules/react'),
103
+ react: path.resolve(__dirname, 'node_modules/react'),
99
104
  'react-dom': path.resolve(__dirname, 'node_modules/react-dom'),
100
- 'react/jsx-runtime': path.resolve(__dirname, 'node_modules/react/jsx-runtime'),
105
+ 'react/jsx-runtime': path.resolve(
106
+ __dirname,
107
+ 'node_modules/react/jsx-runtime'
108
+ ),
101
109
  // Alias để import trực tiếp từ source code thay vì build
102
110
  '@clikvn/showroom-visualizer': path.resolve(__dirname, '../src'),
103
111
  // Thư viện sử dụng baseUrl: "./src" nên tất cả imports cần aliases
@@ -116,6 +124,14 @@ export default defineConfig({
116
124
  server: {
117
125
  port: 3001,
118
126
  open: true,
127
+ host: true,
128
+ allowedHosts: [
129
+ 'localhost',
130
+ '.localhost',
131
+ // Cho phép tất cả ngrok-free.app và ngrok.io hosts
132
+ '.ngrok-free.app',
133
+ '.ngrok.io',
134
+ ],
119
135
  },
120
136
  optimizeDeps: {
121
137
  // Force prebundle để tránh conflict React versions
@@ -123,4 +139,4 @@ export default defineConfig({
123
139
  // Ensure all React references use the same instance
124
140
  dedupe: ['react', 'react-dom'],
125
141
  },
126
- });
142
+ });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@clikvn/showroom-visualizer",
3
3
  "description": "Showroom Visualizer",
4
- "version": "0.3.1",
4
+ "version": "0.3.2",
5
5
  "author": "Clik JSC",
6
6
  "license": "ISC",
7
7
  "type": "module",