bmdl-sdk 1.5.2 → 1.5.3

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/bin/dev.js CHANGED
@@ -1,65 +1,66 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { spawn } from 'child_process'
4
- import { existsSync } from 'fs'
5
- import { dirname, resolve } from 'path'
4
+ import { resolve, dirname } from 'path'
6
5
  import { fileURLToPath } from 'url'
6
+ import { existsSync } from 'fs'
7
7
 
8
- const __dirname = dirname(fileURLToPath(import.meta.url))
8
+ const __filename = fileURLToPath(import.meta.url)
9
+ const __dirname = dirname(__filename)
9
10
  const projectRoot = process.cwd()
11
+ const sdkRoot = resolve(__dirname, '..')
10
12
 
11
13
  console.log('🚀 BMDL SDK Development Server')
12
- console.log('📂 Project:', projectRoot)
14
+ console.log('📂 Project root:', projectRoot)
15
+ console.log('📦 SDK root:', sdkRoot)
13
16
 
14
- // Проверяем наличие необходимых файлов
17
+ // Проверяем наличие необходимых файлов в проекте
15
18
  const requiredFiles = [
16
19
  'src/app/App.tsx',
17
20
  'src/config.ts',
18
21
  'src/dataOptions.ts',
19
- 'src/viewOptions.ts',
22
+ 'src/viewOptions.ts'
20
23
  ]
21
24
 
22
- let hasErrors = false
25
+ let missingFiles = []
23
26
  requiredFiles.forEach(file => {
24
- const fullPath = resolve(projectRoot, file)
25
- if (!existsSync(fullPath)) {
26
- console.log(`⚠️ Missing: ${file}`)
27
- hasErrors = true
27
+ if (!existsSync(resolve(projectRoot, file))) {
28
+ missingFiles.push(file)
28
29
  }
29
30
  })
30
31
 
31
- if (hasErrors) {
32
+ if (missingFiles.length > 0) {
33
+ console.log('⚠️ Missing required files:')
34
+ missingFiles.forEach(file => console.log(` - ${file}`))
32
35
  console.log('')
33
- console.log('💡 Run "npx bmdl-sdk init" to create missing files')
36
+ console.log('💡 Run "npx bmdl-sdk init" to create the missing files')
34
37
  }
35
38
 
36
- // Запускаем Vite из SDK
37
- const sdkRoot = resolve(__dirname, '..')
38
- const viteConfig = resolve(sdkRoot, 'vite.config.ts')
39
-
40
39
  console.log('')
41
- console.log(`🔧 Starting Vite on port 3000...`)
42
- console.log(`📦 Serving from: ${sdkRoot}`)
43
- console.log(`📁 Watching project: ${projectRoot}`)
40
+ console.log('🔧 Starting Vite development server...')
41
+ console.log('🌐 http://localhost:3000')
44
42
 
45
- // Запускаем Vite с передачей корня проекта как переменной окружения
46
- const vite = spawn('npx', ['vite', '--port', '3000', '--config', viteConfig], {
43
+ // Запускаем Vite из SDK с передачей PROJECT_ROOT
44
+ const vite = spawn('npx', [
45
+ 'vite',
46
+ '--port', '3000',
47
+ '--config', resolve(sdkRoot, 'vite.config.ts')
48
+ ], {
47
49
  stdio: 'inherit',
48
50
  shell: true,
49
51
  cwd: sdkRoot,
50
52
  env: {
51
53
  ...process.env,
52
- PROJECT_ROOT: projectRoot,
53
- },
54
+ PROJECT_ROOT: projectRoot
55
+ }
54
56
  })
55
57
 
56
- vite.on('close', code => {
58
+ vite.on('close', (code) => {
57
59
  if (code !== 0) {
58
60
  console.log(`❌ Vite process exited with code ${code}`)
59
61
  }
60
62
  process.exit(code)
61
63
  })
62
64
 
63
- console.log('')
64
- console.log(' Development server running on http://localhost:3000')
65
- console.log('🔄 Hot reload enabled for all source files')
65
+ console.log('✅ Development server is running!')
66
+ console.log('🔄 Hot reload enabled')
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bmdl-sdk",
3
- "version": "1.5.2",
3
+ "version": "1.5.3",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -18,8 +18,11 @@
18
18
  "@types/react": "^19.2.17",
19
19
  "@types/react-dom": "^19.2.3",
20
20
  "@vitejs/plugin-react": "^4.0.0",
21
- "vite": "^4.0.0",
22
21
  "react": "^19.2.7",
23
- "react-dom": "^19.2.7"
22
+ "react-dom": "^19.2.7",
23
+ "vite": "^4.0.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/node": "^26.1.1"
24
27
  }
25
28
  }
package/src/App.tsx CHANGED
@@ -1,19 +1,14 @@
1
- import React, { useState, useEffect } from 'react'
2
- import ReactDOM from 'react-dom/client'
3
-
4
- // Интерфейсы для виджета
5
- interface WidgetProps {
6
- dataOptions?: any
7
- viewOptions?: any
8
- }
1
+ import React, { useEffect, useState } from 'react'
2
+ import { ComponentProps } from '..'
9
3
 
10
4
  // Интерфейс для динамического импорта виджета
11
5
  interface WidgetModule {
12
- default: React.ComponentType<WidgetProps>
6
+ default: React.ComponentType<ComponentProps>
13
7
  }
14
8
 
15
9
  const App: React.FC = () => {
16
- const [WidgetComponent, setWidgetComponent] = useState<React.ComponentType<WidgetProps> | null>(null)
10
+ const [WidgetComponent, setWidgetComponent] =
11
+ useState<React.ComponentType<ComponentProps> | null>(null)
17
12
  const [dataOptions, setDataOptions] = useState<any>(null)
18
13
  const [viewOptions, setViewOptions] = useState<any>(null)
19
14
  const [loading, setLoading] = useState(true)
@@ -24,8 +19,7 @@ const App: React.FC = () => {
24
19
  const loadWidget = async () => {
25
20
  try {
26
21
  // Динамически импортируем компонент из проекта разработчика
27
- const widgetModule = await import('/src/App/App.tsx') as WidgetModule
28
- const configModule = await import('/src/config.ts')
22
+ const widgetModule = (await import('/src/app/App.tsx')) as WidgetModule
29
23
  const dataOptionsModule = await import('/src/dataOptions.ts')
30
24
  const viewOptionsModule = await import('/src/viewOptions.ts')
31
25
 
@@ -45,7 +39,14 @@ const App: React.FC = () => {
45
39
 
46
40
  if (loading) {
47
41
  return (
48
- <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
42
+ <div
43
+ style={{
44
+ display: 'flex',
45
+ justifyContent: 'center',
46
+ alignItems: 'center',
47
+ height: '100vh',
48
+ }}
49
+ >
49
50
  <h2>Loading widget...</h2>
50
51
  </div>
51
52
  )
@@ -53,11 +54,20 @@ const App: React.FC = () => {
53
54
 
54
55
  if (error) {
55
56
  return (
56
- <div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh', flexDirection: 'column' }}>
57
+ <div
58
+ style={{
59
+ display: 'flex',
60
+ justifyContent: 'center',
61
+ alignItems: 'center',
62
+ height: '100vh',
63
+ flexDirection: 'column',
64
+ }}
65
+ >
57
66
  <h2 style={{ color: 'red' }}>Error</h2>
58
67
  <p>{error}</p>
59
68
  <p style={{ fontSize: '14px', color: '#666' }}>
60
- Make sure you have src/App/App.tsx, src/config.ts, src/dataOptions.ts, src/viewOptions.ts
69
+ Make sure you have src/App/App.tsx, src/config.ts, src/dataOptions.ts,
70
+ src/viewOptions.ts
61
71
  </p>
62
72
  </div>
63
73
  )
@@ -68,54 +78,103 @@ const App: React.FC = () => {
68
78
  }
69
79
 
70
80
  return (
71
- <div style={{ display: 'flex', height: '100vh', fontFamily: 'Arial, sans-serif' }}>
81
+ <div
82
+ style={{
83
+ display: 'flex',
84
+ height: '100vh',
85
+ fontFamily: 'Arial, sans-serif',
86
+ }}
87
+ >
72
88
  {/* Левая половина - информация SDK */}
73
- <div style={{
74
- flex: 1,
75
- padding: '20px',
76
- backgroundColor: '#f0f4f8',
77
- borderRight: '2px solid #ddd',
78
- overflow: 'auto'
79
- }}>
89
+ <div
90
+ style={{
91
+ flex: 1,
92
+ padding: '20px',
93
+ backgroundColor: '#f0f4f8',
94
+ borderRight: '2px solid #ddd',
95
+ overflow: 'auto',
96
+ }}
97
+ >
80
98
  <h2 style={{ marginTop: 0 }}>🔧 BMDL SDK Preview</h2>
81
- <div style={{ backgroundColor: 'white', padding: '15px', borderRadius: '8px', marginBottom: '15px' }}>
99
+ <div
100
+ style={{
101
+ backgroundColor: 'white',
102
+ padding: '15px',
103
+ borderRadius: '8px',
104
+ marginBottom: '15px',
105
+ }}
106
+ >
82
107
  <h4>📊 Widget Info</h4>
83
- <div id="widget-info">
108
+ <div id='widget-info'>
84
109
  {/* Информация будет добавлена из config.ts */}
85
110
  </div>
86
111
  </div>
87
- <div style={{ backgroundColor: 'white', padding: '15px', borderRadius: '8px' }}>
112
+ <div
113
+ style={{
114
+ backgroundColor: 'white',
115
+ padding: '15px',
116
+ borderRadius: '8px',
117
+ }}
118
+ >
88
119
  <h4>📦 Data Options</h4>
89
- <pre style={{ background: '#f5f5f5', padding: '10px', borderRadius: '4px', fontSize: '12px' }}>
120
+ <pre
121
+ style={{
122
+ background: '#f5f5f5',
123
+ padding: '10px',
124
+ borderRadius: '4px',
125
+ fontSize: '12px',
126
+ }}
127
+ >
90
128
  {JSON.stringify(dataOptions, null, 2)}
91
129
  </pre>
92
130
  </div>
93
- <div style={{ backgroundColor: 'white', padding: '15px', borderRadius: '8px', marginTop: '15px' }}>
131
+ <div
132
+ style={{
133
+ backgroundColor: 'white',
134
+ padding: '15px',
135
+ borderRadius: '8px',
136
+ marginTop: '15px',
137
+ }}
138
+ >
94
139
  <h4>⚙️ View Options</h4>
95
- <pre style={{ background: '#f5f5f5', padding: '10px', borderRadius: '4px', fontSize: '12px' }}>
140
+ <pre
141
+ style={{
142
+ background: '#f5f5f5',
143
+ padding: '10px',
144
+ borderRadius: '4px',
145
+ fontSize: '12px',
146
+ }}
147
+ >
96
148
  {JSON.stringify(viewOptions, null, 2)}
97
149
  </pre>
98
150
  </div>
99
151
  <div style={{ marginTop: '20px', fontSize: '12px', color: '#666' }}>
100
- <p>💡 Edit src/App/App.tsx, src/dataOptions.ts, or src/viewOptions.ts to see changes</p>
152
+ <p>
153
+ 💡 Edit src/App/App.tsx, src/dataOptions.ts, or src/viewOptions.ts
154
+ to see changes
155
+ </p>
101
156
  </div>
102
157
  </div>
103
158
 
104
159
  {/* Правая половина - виджет разработчика */}
105
- <div style={{
106
- flex: 1,
107
- padding: '20px',
108
- backgroundColor: '#ffffff',
109
- overflow: 'auto'
110
- }}>
111
- <h3 style={{ marginTop: 0 }}>📱 Your Widget</h3>
112
- <div style={{
113
- border: '2px dashed #ccc',
114
- borderRadius: '8px',
160
+ <div
161
+ style={{
162
+ flex: 1,
115
163
  padding: '20px',
116
- minHeight: '400px'
117
- }}>
118
- <WidgetComponent
164
+ backgroundColor: '#ffffff',
165
+ overflow: 'auto',
166
+ }}
167
+ >
168
+ <h3 style={{ marginTop: 0 }}>📱 Your Widget</h3>
169
+ <div
170
+ style={{
171
+ border: '2px dashed #ccc',
172
+ borderRadius: '8px',
173
+ padding: '20px',
174
+ minHeight: '400px',
175
+ }}
176
+ >
177
+ <WidgetComponent
119
178
  dataOptions={dataOptions}
120
179
  viewOptions={viewOptions}
121
180
  />
@@ -125,4 +184,4 @@ const App: React.FC = () => {
125
184
  )
126
185
  }
127
186
 
128
- export default App
187
+ export default App
package/vite.config.ts CHANGED
@@ -1,19 +1,25 @@
1
- import react from '@vitejs/plugin-react'
2
1
  import { defineConfig } from 'vite'
2
+ import react from '@vitejs/plugin-react'
3
+ import { resolve } from 'path'
3
4
 
4
5
  export default defineConfig({
5
6
  plugins: [react()],
6
7
  server: {
7
8
  port: 3000,
8
9
  open: true,
10
+ watch: {
11
+ // Следим за изменениями в проекте разработчика
12
+ ignored: ['!**/node_modules/**']
13
+ }
9
14
  },
10
- root: process.cwd(),
11
15
  resolve: {
12
16
  alias: {
13
- '@': process.cwd(),
14
- },
17
+ // Перенаправляем импорты из /src в проект разработчика
18
+ '/src': resolve(process.env.PROJECT_ROOT || process.cwd(), 'src')
19
+ }
15
20
  },
21
+ root: process.cwd(),
16
22
  optimizeDeps: {
17
- include: ['react', 'react-dom'],
18
- },
19
- })
23
+ include: ['react', 'react-dom']
24
+ }
25
+ })