bmdl-sdk 1.4.0 → 1.5.1
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 +51 -8
- package/bin/init.js +1 -1
- package/bmdl-sdk-1.5.1.tgz +0 -0
- package/index.html +23 -0
- package/package.json +11 -6
- package/src/App.tsx +128 -0
- package/src/main.tsx +9 -0
- package/vite.config.ts +8 -14
- package/bmdl-sdk-1.3.12.tgz +0 -0
- package/bmdl-sdk-1.4.0.tgz +0 -0
package/bin/dev.js
CHANGED
|
@@ -1,22 +1,65 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
import { spawn } from 'child_process'
|
|
4
|
-
import {
|
|
4
|
+
import { existsSync } from 'fs'
|
|
5
|
+
import { dirname, resolve } from 'path'
|
|
5
6
|
import { fileURLToPath } from 'url'
|
|
6
|
-
import { dirname } from 'path'
|
|
7
7
|
|
|
8
8
|
const __dirname = dirname(fileURLToPath(import.meta.url))
|
|
9
|
+
const projectRoot = process.cwd()
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
console.log('🚀 BMDL SDK Development Server')
|
|
12
|
+
console.log('📂 Project:', projectRoot)
|
|
13
|
+
|
|
14
|
+
// Проверяем наличие необходимых файлов
|
|
15
|
+
const requiredFiles = [
|
|
16
|
+
'src/app/App.tsx',
|
|
17
|
+
'src/config.ts',
|
|
18
|
+
'src/dataOptions.ts',
|
|
19
|
+
'src/viewOptions.ts',
|
|
20
|
+
]
|
|
21
|
+
|
|
22
|
+
let hasErrors = false
|
|
23
|
+
requiredFiles.forEach(file => {
|
|
24
|
+
const fullPath = resolve(projectRoot, file)
|
|
25
|
+
if (!existsSync(fullPath)) {
|
|
26
|
+
console.log(`⚠️ Missing: ${file}`)
|
|
27
|
+
hasErrors = true
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
if (hasErrors) {
|
|
32
|
+
console.log('')
|
|
33
|
+
console.log('💡 Run "npx bmdl-sdk init" to create missing files')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Запускаем Vite из SDK
|
|
37
|
+
const sdkRoot = resolve(__dirname, '..')
|
|
38
|
+
const viteConfig = resolve(sdkRoot, 'vite.config.ts')
|
|
39
|
+
|
|
40
|
+
console.log('')
|
|
41
|
+
console.log(`🔧 Starting Vite on port 3000...`)
|
|
42
|
+
console.log(`📦 Serving from: ${sdkRoot}`)
|
|
43
|
+
console.log(`📁 Watching project: ${projectRoot}`)
|
|
44
|
+
|
|
45
|
+
// Запускаем Vite с передачей корня проекта как переменной окружения
|
|
46
|
+
const vite = spawn('npx', ['vite', '--port', '3000', '--config', viteConfig], {
|
|
12
47
|
stdio: 'inherit',
|
|
13
48
|
shell: true,
|
|
14
|
-
cwd:
|
|
49
|
+
cwd: sdkRoot,
|
|
50
|
+
env: {
|
|
51
|
+
...process.env,
|
|
52
|
+
PROJECT_ROOT: projectRoot,
|
|
53
|
+
},
|
|
15
54
|
})
|
|
16
55
|
|
|
17
|
-
vite.on('close',
|
|
56
|
+
vite.on('close', code => {
|
|
57
|
+
if (code !== 0) {
|
|
58
|
+
console.log(`❌ Vite process exited with code ${code}`)
|
|
59
|
+
}
|
|
18
60
|
process.exit(code)
|
|
19
61
|
})
|
|
20
62
|
|
|
21
|
-
console.log('
|
|
22
|
-
console.log('
|
|
63
|
+
console.log('')
|
|
64
|
+
console.log('✅ Development server running on http://localhost:3000')
|
|
65
|
+
console.log('🔄 Hot reload enabled for all source files')
|
package/bin/init.js
CHANGED
|
Binary file
|
package/index.html
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
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>BMDL SDK - Widget Development</title>
|
|
7
|
+
<style>
|
|
8
|
+
* {
|
|
9
|
+
margin: 0;
|
|
10
|
+
padding: 0;
|
|
11
|
+
box-sizing: border-box;
|
|
12
|
+
}
|
|
13
|
+
body {
|
|
14
|
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
|
|
15
|
+
background: #fff;
|
|
16
|
+
}
|
|
17
|
+
</style>
|
|
18
|
+
</head>
|
|
19
|
+
<body>
|
|
20
|
+
<div id="root"></div>
|
|
21
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
22
|
+
</body>
|
|
23
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bmdl-sdk",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"
|
|
3
|
+
"version": "1.5.1",
|
|
4
|
+
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"bmdl-sdk": "./bin/cli.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"
|
|
10
|
+
"dev": "vite --port 3000",
|
|
11
|
+
"build": "vite build",
|
|
12
|
+
"preview": "vite preview"
|
|
11
13
|
},
|
|
12
14
|
"keywords": [],
|
|
13
15
|
"author": "",
|
|
@@ -15,9 +17,12 @@
|
|
|
15
17
|
"dependencies": {
|
|
16
18
|
"@types/react": "^19.2.17",
|
|
17
19
|
"@types/react-dom": "^19.2.3",
|
|
18
|
-
"@vitejs/plugin-react": "^6.0.3",
|
|
19
20
|
"react": "^19.2.7",
|
|
20
|
-
"react-dom": "^19.2.7"
|
|
21
|
-
|
|
21
|
+
"react-dom": "^19.2.7"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@vitejs/plugin-react": "^4.0.0",
|
|
25
|
+
"typescript": "^5.0.0",
|
|
26
|
+
"vite": "^4.0.0"
|
|
22
27
|
}
|
|
23
28
|
}
|
package/src/App.tsx
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
}
|
|
9
|
+
|
|
10
|
+
// Интерфейс для динамического импорта виджета
|
|
11
|
+
interface WidgetModule {
|
|
12
|
+
default: React.ComponentType<WidgetProps>
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const App: React.FC = () => {
|
|
16
|
+
const [WidgetComponent, setWidgetComponent] = useState<React.ComponentType<WidgetProps> | null>(null)
|
|
17
|
+
const [dataOptions, setDataOptions] = useState<any>(null)
|
|
18
|
+
const [viewOptions, setViewOptions] = useState<any>(null)
|
|
19
|
+
const [loading, setLoading] = useState(true)
|
|
20
|
+
const [error, setError] = useState<string | null>(null)
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
// Загружаем компонент виджета из проекта
|
|
24
|
+
const loadWidget = async () => {
|
|
25
|
+
try {
|
|
26
|
+
// Динамически импортируем компонент из проекта разработчика
|
|
27
|
+
const widgetModule = await import('/src/App/App.tsx') as WidgetModule
|
|
28
|
+
const configModule = await import('/src/config.ts')
|
|
29
|
+
const dataOptionsModule = await import('/src/dataOptions.ts')
|
|
30
|
+
const viewOptionsModule = await import('/src/viewOptions.ts')
|
|
31
|
+
|
|
32
|
+
setWidgetComponent(() => widgetModule.default)
|
|
33
|
+
setDataOptions(dataOptionsModule.createDataOptions())
|
|
34
|
+
setViewOptions(viewOptionsModule.createViewOptions())
|
|
35
|
+
setLoading(false)
|
|
36
|
+
} catch (err) {
|
|
37
|
+
console.error('Failed to load widget:', err)
|
|
38
|
+
setError('Failed to load widget component. Please check your files.')
|
|
39
|
+
setLoading(false)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
loadWidget()
|
|
44
|
+
}, [])
|
|
45
|
+
|
|
46
|
+
if (loading) {
|
|
47
|
+
return (
|
|
48
|
+
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh' }}>
|
|
49
|
+
<h2>Loading widget...</h2>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (error) {
|
|
55
|
+
return (
|
|
56
|
+
<div style={{ display: 'flex', justifyContent: 'center', alignItems: 'center', height: '100vh', flexDirection: 'column' }}>
|
|
57
|
+
<h2 style={{ color: 'red' }}>Error</h2>
|
|
58
|
+
<p>{error}</p>
|
|
59
|
+
<p style={{ fontSize: '14px', color: '#666' }}>
|
|
60
|
+
Make sure you have src/App/App.tsx, src/config.ts, src/dataOptions.ts, src/viewOptions.ts
|
|
61
|
+
</p>
|
|
62
|
+
</div>
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!WidgetComponent) {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div style={{ display: 'flex', height: '100vh', fontFamily: 'Arial, sans-serif' }}>
|
|
72
|
+
{/* Левая половина - информация SDK */}
|
|
73
|
+
<div style={{
|
|
74
|
+
flex: 1,
|
|
75
|
+
padding: '20px',
|
|
76
|
+
backgroundColor: '#f0f4f8',
|
|
77
|
+
borderRight: '2px solid #ddd',
|
|
78
|
+
overflow: 'auto'
|
|
79
|
+
}}>
|
|
80
|
+
<h2 style={{ marginTop: 0 }}>🔧 BMDL SDK Preview</h2>
|
|
81
|
+
<div style={{ backgroundColor: 'white', padding: '15px', borderRadius: '8px', marginBottom: '15px' }}>
|
|
82
|
+
<h4>📊 Widget Info</h4>
|
|
83
|
+
<div id="widget-info">
|
|
84
|
+
{/* Информация будет добавлена из config.ts */}
|
|
85
|
+
</div>
|
|
86
|
+
</div>
|
|
87
|
+
<div style={{ backgroundColor: 'white', padding: '15px', borderRadius: '8px' }}>
|
|
88
|
+
<h4>📦 Data Options</h4>
|
|
89
|
+
<pre style={{ background: '#f5f5f5', padding: '10px', borderRadius: '4px', fontSize: '12px' }}>
|
|
90
|
+
{JSON.stringify(dataOptions, null, 2)}
|
|
91
|
+
</pre>
|
|
92
|
+
</div>
|
|
93
|
+
<div style={{ backgroundColor: 'white', padding: '15px', borderRadius: '8px', marginTop: '15px' }}>
|
|
94
|
+
<h4>⚙️ View Options</h4>
|
|
95
|
+
<pre style={{ background: '#f5f5f5', padding: '10px', borderRadius: '4px', fontSize: '12px' }}>
|
|
96
|
+
{JSON.stringify(viewOptions, null, 2)}
|
|
97
|
+
</pre>
|
|
98
|
+
</div>
|
|
99
|
+
<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>
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
{/* Правая половина - виджет разработчика */}
|
|
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',
|
|
115
|
+
padding: '20px',
|
|
116
|
+
minHeight: '400px'
|
|
117
|
+
}}>
|
|
118
|
+
<WidgetComponent
|
|
119
|
+
dataOptions={dataOptions}
|
|
120
|
+
viewOptions={viewOptions}
|
|
121
|
+
/>
|
|
122
|
+
</div>
|
|
123
|
+
</div>
|
|
124
|
+
</div>
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default App
|
package/src/main.tsx
ADDED
package/vite.config.ts
CHANGED
|
@@ -5,21 +5,15 @@ export default defineConfig({
|
|
|
5
5
|
plugins: [react()],
|
|
6
6
|
server: {
|
|
7
7
|
port: 3000,
|
|
8
|
+
open: true,
|
|
8
9
|
},
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
formats: ['es'],
|
|
14
|
-
},
|
|
15
|
-
rollupOptions: {
|
|
16
|
-
external: ['react', 'react-dom'],
|
|
17
|
-
output: {
|
|
18
|
-
globals: {
|
|
19
|
-
react: 'React',
|
|
20
|
-
'react-dom': 'ReactDOM',
|
|
21
|
-
},
|
|
22
|
-
},
|
|
10
|
+
root: process.cwd(),
|
|
11
|
+
resolve: {
|
|
12
|
+
alias: {
|
|
13
|
+
'@': process.cwd(),
|
|
23
14
|
},
|
|
24
15
|
},
|
|
16
|
+
optimizeDeps: {
|
|
17
|
+
include: ['react', 'react-dom'],
|
|
18
|
+
},
|
|
25
19
|
})
|
package/bmdl-sdk-1.3.12.tgz
DELETED
|
Binary file
|
package/bmdl-sdk-1.4.0.tgz
DELETED
|
Binary file
|