bmdl-sdk 2.0.0 → 2.0.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 CHANGED
@@ -47,21 +47,22 @@ console.log('🔧 Starting Vite development server...')
47
47
  console.log('🌐 http://localhost:3000')
48
48
  console.log('')
49
49
 
50
- // Запускаем Vite - убираем --root, используем только --config
51
50
  const next = spawn(
52
51
  'npx',
53
- ['next', 'dev', '--port', '3000'],
52
+ ['next', 'dev', '--port', '3000', '--experimental-app'],
54
53
  {
55
54
  stdio: 'inherit',
56
55
  shell: true,
57
- cwd: sdkRoot, // Работаем из папки SDK
56
+ cwd: sdkRoot,
58
57
  env: {
59
58
  ...process.env,
60
59
  PROJECT_ROOT: projectRoot,
61
60
  NODE_ENV: 'development',
61
+ NEXT_PUBLIC_PROJECT_ROOT: projectRoot,
62
62
  },
63
- },
64
- )
63
+ }
64
+ );
65
+
65
66
 
66
67
  next.on('close', code => {
67
68
  if (code !== 0) {
Binary file
package/next.config.ts CHANGED
@@ -2,22 +2,30 @@ import type { NextConfig } from 'next'
2
2
  import createNextIntlPlugin from 'next-intl/plugin'
3
3
  import packageJson from './package.json'
4
4
 
5
+ const path = require('path');
6
+
7
+ const projectRoot = process.env.PROJECT_ROOT || process.cwd()
8
+
5
9
  const withNextIntl = createNextIntlPlugin('./src/config/i18n.config.ts')
6
10
 
7
11
  const nextConfig: NextConfig = {
8
12
  reactStrictMode: false,
9
- transpilePackages: ['bmdl-sdk'],
10
13
  webpack: (config, { isServer }) => {
11
- // Добавляем поддержку импорта из проекта разработчика
12
- config.resolve.alias['@project'] = process.env.PROJECT_ROOT
13
- ? `${process.env.PROJECT_ROOT}/src`
14
- : '../line/src'
15
-
16
- return config
14
+ // Разрешаем импорт из проекта пользователя
15
+ config.resolve.modules = [
16
+ path.resolve(process.env.PROJECT_ROOT || process.cwd()),
17
+ 'node_modules',
18
+ ...config.resolve.modules,
19
+ ];
20
+
21
+ // Добавляем поддержку TypeScript из проекта
22
+ config.resolve.extensions = ['.tsx', '.ts', '.jsx', '.js', '.json'];
23
+
24
+ return config;
17
25
  },
18
- // Включаем экспериментальные функции для динамических импортов
19
- experimental: {
20
- esmExternals: true
26
+ // Отключаем строгую проверку для файлов вне SDK
27
+ typescript: {
28
+ ignoreBuildErrors: true,
21
29
  },
22
30
  env: {
23
31
  NEXT_PUBLIC_APP_VERSION: packageJson.version,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bmdl-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,107 +1,9 @@
1
- 'use client'
1
+ import dynamic from 'next/dynamic'
2
2
 
3
- import { useEffect, useState } from 'react'
4
- import { ComponentProps } from '../../../../index'
5
-
6
- // Интерфейс для динамического импорта виджета
7
- interface WidgetModule {
8
- default: React.ComponentType<ComponentProps>
9
- }
10
-
11
- export function ComponentWidget() {
12
- const [WidgetComponent, setWidgetComponent] =
13
- useState<React.ComponentType<ComponentProps> | null>(null)
14
- const [dataOptions, setDataOptions] = useState<any>(null)
15
- const [viewOptions, setViewOptions] = useState<any>(null)
16
- const [loading, setLoading] = useState(true)
17
- const [error, setError] = useState<string | null>(null)
18
-
19
- useEffect(() => {
20
- // Загружаем компонент виджета из проекта
21
- const loadWidget = async () => {
22
- try {
23
- // Динамически импортируем компонент из проекта разработчика
24
- const widgetModule =
25
- (await import('@project/app/App.tsx')) as WidgetModule
26
- const dataOptionsModule = await import('@project/dataOptions.ts')
27
- const viewOptionsModule = await import('@project/viewOptions.ts')
28
-
29
- setWidgetComponent(() => widgetModule.default)
30
- // @ts-ignore
31
- setDataOptions(dataOptionsModule.createDataOptions())
32
- // @ts-ignore
33
- setViewOptions(viewOptionsModule.createViewOptions())
34
- setLoading(false)
35
- } catch (err) {
36
- console.error('Failed to load widget:', err)
37
- setError('Failed to load widget component. Please check your files.')
38
- setLoading(false)
39
- }
40
- }
41
-
42
- loadWidget()
43
- }, [])
44
-
45
- if (loading) {
46
- return (
47
- <div
48
- style={{
49
- display: 'flex',
50
- justifyContent: 'center',
51
- alignItems: 'center',
52
- height: '100vh',
53
- }}
54
- >
55
- <h2>Loading widget...</h2>
56
- </div>
57
- )
3
+ export const ComponentWidget = dynamic(
4
+ () => import(`${process.env.PROJECT_ROOT}/src/app/App.tsx`),
5
+ {
6
+ ssr: false,
7
+ loading: () => <div>Loading...</div>
58
8
  }
59
-
60
- if (error) {
61
- return (
62
- <div
63
- style={{
64
- display: 'flex',
65
- justifyContent: 'center',
66
- alignItems: 'center',
67
- height: '100%',
68
- flexDirection: 'column',
69
- }}
70
- >
71
- <h2 style={{ color: 'red' }}>Error</h2>
72
- <p>{error}</p>
73
- <p style={{ fontSize: '14px', color: '#666' }}>
74
- Make sure you have src/App/App.tsx, src/config.ts, src/dataOptions.ts,
75
- src/viewOptions.ts
76
- </p>
77
- </div>
78
- )
79
- }
80
-
81
- if (!WidgetComponent) {
82
- return null
83
- }
84
-
85
- return (
86
- <div
87
- style={{
88
- flex: 1,
89
- padding: '20px',
90
- backgroundColor: '#ffffff',
91
- overflow: 'auto',
92
- }}
93
- >
94
- <h3 style={{ marginTop: 0 }}>📱 Your Widget</h3>
95
- <div
96
- style={{
97
- border: '2px dashed #ccc',
98
- borderRadius: '8px',
99
- padding: '20px',
100
- minHeight: '100%',
101
- }}
102
- >
103
- <WidgetComponent dataOptions={dataOptions} viewOptions={viewOptions} />
104
- </div>
105
- </div>
106
- )
107
- }
9
+ );
package/templates/App.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { ComponentProps } from '../src/zold/index.d2'
2
+ import { ComponentProps } from '../'
3
3
 
4
4
  const NameComponent: React.FC<ComponentProps> = ({
5
5
  dataOptions,
@@ -1,5 +1,5 @@
1
+ import { Config } from '../'
1
2
  import packageJson from '../package.json'
2
- import { Config } from '../src/zold/index.d2'
3
3
 
4
4
  export const config: Config = {
5
5
  label: {
@@ -1,4 +1,4 @@
1
- import { CreateDataOptions } from '../src/zold/index.d2'
1
+ import { CreateDataOptions } from '../'
2
2
 
3
3
  export const createDataOptions: CreateDataOptions = () => {
4
4
  return []
@@ -1,4 +1,4 @@
1
- import { CreateViewOptions } from '../src/zold/index.d2'
1
+ import { CreateViewOptions } from '../'
2
2
 
3
3
  export const createViewOptions: CreateViewOptions = () => {
4
4
  return []
Binary file