Skip to content

Commit 4d5eac3

Browse files
committed
feat: default export all plugins (#1286)
* feat: default export all plugins * fix: async import init func * fix: del LayoutHash file
1 parent f7a4bc4 commit 4d5eac3

File tree

34 files changed

+553
-659
lines changed

34 files changed

+553
-659
lines changed

designer-demo/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
},
1313
"dependencies": {
1414
"@opentiny/tiny-engine": "workspace:^",
15+
"@opentiny/tiny-engine-meta-register": "^2.3.0",
1516
"@opentiny/tiny-engine-utils": "workspace:*",
1617
"@opentiny/vue": "~3.20.0",
1718
"@opentiny/vue-design-smb": "~3.20.0",

designer-demo/registry.js

Lines changed: 16 additions & 105 deletions
Original file line numberDiff line numberDiff line change
@@ -9,116 +9,27 @@
99
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
1010
*
1111
*/
12-
13-
import {
14-
Breadcrumb,
15-
Fullscreen,
16-
Lang,
17-
ViewSetting,
18-
Logo,
19-
Lock,
20-
Media,
21-
Redoundo,
22-
Save,
23-
Clean,
24-
ThemeSwitch,
25-
Preview,
26-
GenerateCode,
27-
Refresh,
28-
Collaboration,
29-
Materials,
30-
State,
31-
Script,
32-
Tree,
33-
Help,
34-
Schema,
35-
Page,
36-
I18n,
37-
Bridge,
38-
Block,
39-
Datasource,
40-
Robot,
41-
Props,
42-
Events,
43-
Styles,
44-
Layout,
45-
Canvas,
46-
GenerateCodeService,
47-
GlobalService,
48-
ThemeSwitchService
49-
} from '@opentiny/tiny-engine'
12+
import { META_SERVICE } from '@opentiny/tiny-engine'
5013
import engineConfig from './engine.config'
5114
import { HttpService } from './src/composable'
5215

5316
export default {
54-
root: {
55-
id: 'engine.root',
56-
metas: [HttpService, GenerateCodeService, GlobalService, ThemeSwitchService] // GlobalService 依赖 HttpService,HttpService需要在前面处理
17+
[META_SERVICE.Http]: HttpService,
18+
'engine.config': {
19+
...engineConfig,
5720
},
58-
config: engineConfig,
59-
layout: {
60-
...Layout,
61-
options: {
62-
...Layout.options,
63-
isShowLine: true,
64-
isShowCollapse: true,
65-
toolbars: {
66-
left: ['engine.toolbars.breadcrumb', 'engine.toolbars.lock', 'engine.toolbars.logo'],
67-
center: ['engine.toolbars.media'],
68-
right: [
69-
['engine.toolbars.themeSwitch', 'engine.toolbars.redoundo', 'engine.toolbars.clean'],
70-
['engine.toolbars.preview'],
71-
['engine.toolbars.generate-code', 'engine.toolbars.save']
72-
],
73-
collapse: [
74-
['engine.toolbars.collaboration'],
75-
['engine.toolbars.refresh', 'engine.toolbars.fullscreen'],
76-
['engine.toolbars.lang'],
77-
['engine.toolbars.viewSetting']
78-
]
21+
'engine.plugins.i18n': {
22+
overwrite: {
23+
lifeCycles: {
24+
'': {
25+
onMounted: [
26+
(ctx) => () => {
27+
console.log('overWrite i18n onMounted', ctx.i18nSearchTypes, ctx.currentSearchType.value)
28+
ctx.currentSearchType.value = ctx.i18nSearchTypes[0].value
29+
}
30+
]
31+
}
7932
}
8033
}
81-
},
82-
themes: [
83-
{
84-
id: 'engine.theme.light'
85-
},
86-
{
87-
id: 'engine.theme.dark'
88-
}
89-
],
90-
toolbars: [
91-
ThemeSwitch,
92-
Logo,
93-
Breadcrumb,
94-
Lock,
95-
Media,
96-
Redoundo,
97-
Collaboration,
98-
Clean,
99-
Preview,
100-
Refresh,
101-
GenerateCode,
102-
Save,
103-
Fullscreen,
104-
Lang,
105-
ViewSetting
106-
],
107-
plugins: [
108-
Materials,
109-
Tree,
110-
Page,
111-
[Block, { options: { ...Block.options, mergeCategoriesAndGroups: true } }],
112-
Datasource,
113-
Bridge,
114-
I18n,
115-
Script,
116-
State,
117-
Schema,
118-
Help,
119-
Robot
120-
],
121-
dsls: [{ id: 'engine.dsls.dslvue' }],
122-
settings: [Props, Styles, Events],
123-
canvas: Canvas
34+
}
12435
}

designer-demo/src/defineEntry.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

designer-demo/src/main.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,21 @@
99
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
1010
*
1111
*/
12-
13-
// 导入@opentiny/tiny-engine时,内部的依赖包也会逐个导入,可能会执行useComplie,此时需要templateHashMap。所以需要先执行一次defineEntry
14-
import { registry } from './defineEntry.js'
15-
import { init } from '@opentiny/tiny-engine'
12+
import { defineEntry } from '@opentiny/tiny-engine-meta-register'
1613
import { configurators } from './configurators/'
14+
import registry from '../registry'
1715
import 'virtual:svg-icons-register'
1816

19-
init({
20-
registry,
21-
configurators,
22-
createAppSignal: ['global_service_init_finish']
23-
})
17+
async function startApp() {
18+
const { init } = await import('@opentiny/tiny-engine')
19+
// 导入@opentiny/tiny-engine时,内部的依赖包也会逐个导入,可能会执行useComplie,此时需要templateHashMap。所以需要先执行一次defineEntry
20+
defineEntry(registry)
21+
22+
init({
23+
registry,
24+
configurators,
25+
createAppSignal: ['global_service_init_finish']
26+
})
27+
}
28+
29+
startApp()

designer-demo/src/preview.js

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,34 @@
99
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
1010
*
1111
*/
12-
13-
import { initHook, HOOK_NAME, GenerateCodeService, Breadcrumb, Media, Lang } from '@opentiny/tiny-engine'
14-
import { initPreview } from '@opentiny/tiny-engine'
12+
import { defineEntry } from '@opentiny/tiny-engine-meta-register'
1513
import 'virtual:svg-icons-register'
1614
import { HttpService } from './composable'
1715

18-
const beforeAppCreate = () => {
19-
initHook(HOOK_NAME.useEnv, import.meta.env)
20-
}
16+
async function startApp () {
17+
const { initHook, HOOK_NAME, META_SERVICE, initPreview } = await import('@opentiny/tiny-engine')
18+
19+
const beforeAppCreate = () => {
20+
initHook(HOOK_NAME.useEnv, import.meta.env)
21+
}
2122

22-
initPreview({
23-
registry: {
24-
root: {
25-
id: 'engine.root',
26-
metas: [HttpService, GenerateCodeService]
27-
},
28-
config: {
23+
const registry = {
24+
[META_SERVICE.Http]: HttpService,
25+
'engine.config': {
2926
id: 'engine.config',
3027
theme: 'light',
31-
material: ['/mock/bundle.json'],
32-
},
33-
toolbars: [Breadcrumb, Media, Lang]
34-
},
35-
lifeCycles: {
36-
beforeAppCreate
28+
material: ['/mock/bundle.json']
29+
}
3730
}
38-
})
31+
32+
defineEntry(registry)
33+
34+
initPreview({
35+
registry,
36+
lifeCycles: {
37+
beforeAppCreate
38+
}
39+
})
40+
}
41+
42+
startApp()

packages/canvas/DesignCanvas/src/DesignCanvas.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
useModal,
3333
usePage,
3434
useMessage,
35-
getMergeRegistry,
3635
getMergeMeta,
3736
getOptions,
3837
getMetaApi,
@@ -56,7 +55,7 @@ const componentType = {
5655
5756
export default {
5857
setup() {
59-
const registry = getMergeRegistry('canvas')
58+
const registry = getMergeMeta('engine.canvas')
6059
const materialsPanel = getMergeMeta('engine.plugins.materials')?.entry
6160
const { CanvasRouteBar, CanvasBreadcrumb } = registry.components
6261
const CanvasLayout = registry.layout.entry

packages/design-core/index.js

Lines changed: 1 addition & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,3 @@
11
export { init } from './src/init'
22

3-
// reexport all plugin, user can import ondemand
4-
export { default as Breadcrumb, BreadcrumbService } from '@opentiny/tiny-engine-toolbar-breadcrumb'
5-
export { default as Fullscreen } from '@opentiny/tiny-engine-toolbar-fullscreen'
6-
export { default as Lang } from '@opentiny/tiny-engine-toolbar-lang'
7-
export { default as ViewSetting } from '@opentiny/tiny-engine-toolbar-view-setting'
8-
export { default as Logo } from '@opentiny/tiny-engine-toolbar-logo'
9-
export { default as Lock } from '@opentiny/tiny-engine-toolbar-lock'
10-
export { default as Media } from '@opentiny/tiny-engine-toolbar-media'
11-
export { default as Redoundo, HistoryService } from '@opentiny/tiny-engine-toolbar-redoundo'
12-
export { default as Save } from '@opentiny/tiny-engine-toolbar-save'
13-
export { default as Clean } from '@opentiny/tiny-engine-toolbar-clean'
14-
export { default as ThemeSwitch, ThemeSwitchService } from '@opentiny/tiny-engine-toolbar-theme-switch'
15-
export { default as Preview } from '@opentiny/tiny-engine-toolbar-preview'
16-
export { default as GenerateCode, SaveLocalService } from '@opentiny/tiny-engine-toolbar-generate-code'
17-
export { default as Refresh } from '@opentiny/tiny-engine-toolbar-refresh'
18-
export { default as Collaboration } from '@opentiny/tiny-engine-toolbar-collaboration'
19-
export { default as Setting } from '@opentiny/tiny-engine-toolbar-setting'
20-
export { default as Materials, ResourceService, MaterialService } from '@opentiny/tiny-engine-plugin-materials'
21-
export { default as State } from '@opentiny/tiny-engine-plugin-state'
22-
export { default as Script } from '@opentiny/tiny-engine-plugin-script'
23-
export { default as Tree } from '@opentiny/tiny-engine-plugin-tree'
24-
export { default as Help, HelpService } from '@opentiny/tiny-engine-plugin-help'
25-
export { default as Schema } from '@opentiny/tiny-engine-plugin-schema'
26-
export { default as Page, PageService } from '@opentiny/tiny-engine-plugin-page'
27-
export { default as I18n, TranslateService } from '@opentiny/tiny-engine-plugin-i18n'
28-
export { default as Bridge } from '@opentiny/tiny-engine-plugin-bridge'
29-
export { default as Block, BlockService } from '@opentiny/tiny-engine-plugin-block'
30-
export { default as Datasource, DataSourceService } from '@opentiny/tiny-engine-plugin-datasource'
31-
export { default as Robot } from '@opentiny/tiny-engine-plugin-robot'
32-
export { default as Props, PropertiesService, PropertyService } from '@opentiny/tiny-engine-setting-props'
33-
export { default as Events } from '@opentiny/tiny-engine-setting-events'
34-
export { default as Styles } from '@opentiny/tiny-engine-setting-styles'
35-
export { default as Layout, LayoutService } from '@opentiny/tiny-engine-layout'
36-
export { default as Canvas } from '@opentiny/tiny-engine-canvas'
37-
export { initPreview } from './src/preview/src/main'
38-
export {
39-
GenerateCodeService,
40-
PluginPanel,
41-
PluginSetting,
42-
ToolbarBase,
43-
GlobalService,
44-
HttpService
45-
} from '@opentiny/tiny-engine-common'
46-
47-
export { default as defaultRegistry } from './registry'
48-
49-
export * from '@opentiny/tiny-engine-meta-register'
3+
export * from './re-export'

packages/design-core/re-export.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// reexport all plugin, user can import ondemand
2+
export { default as Breadcrumb, BreadcrumbService } from '@opentiny/tiny-engine-toolbar-breadcrumb'
3+
export { default as Fullscreen } from '@opentiny/tiny-engine-toolbar-fullscreen'
4+
export { default as Lang } from '@opentiny/tiny-engine-toolbar-lang'
5+
export { default as ViewSetting } from '@opentiny/tiny-engine-toolbar-view-setting'
6+
export { default as Logo } from '@opentiny/tiny-engine-toolbar-logo'
7+
export { default as Lock } from '@opentiny/tiny-engine-toolbar-lock'
8+
export { default as Media } from '@opentiny/tiny-engine-toolbar-media'
9+
export { default as Redoundo, HistoryService } from '@opentiny/tiny-engine-toolbar-redoundo'
10+
export { default as Save } from '@opentiny/tiny-engine-toolbar-save'
11+
export { default as Clean } from '@opentiny/tiny-engine-toolbar-clean'
12+
export { default as ThemeSwitch, ThemeSwitchService } from '@opentiny/tiny-engine-toolbar-theme-switch'
13+
export { default as Preview } from '@opentiny/tiny-engine-toolbar-preview'
14+
export { default as GenerateCode, SaveLocalService } from '@opentiny/tiny-engine-toolbar-generate-code'
15+
export { default as Refresh } from '@opentiny/tiny-engine-toolbar-refresh'
16+
export { default as Collaboration } from '@opentiny/tiny-engine-toolbar-collaboration'
17+
export { default as Setting } from '@opentiny/tiny-engine-toolbar-setting'
18+
export { default as Materials, ResourceService, MaterialService } from '@opentiny/tiny-engine-plugin-materials'
19+
export { default as State } from '@opentiny/tiny-engine-plugin-state'
20+
export { default as Script } from '@opentiny/tiny-engine-plugin-script'
21+
export { default as Tree } from '@opentiny/tiny-engine-plugin-tree'
22+
export { default as Help, HelpService } from '@opentiny/tiny-engine-plugin-help'
23+
export { default as Schema } from '@opentiny/tiny-engine-plugin-schema'
24+
export { default as Page, PageService } from '@opentiny/tiny-engine-plugin-page'
25+
export { default as I18n, TranslateService } from '@opentiny/tiny-engine-plugin-i18n'
26+
export { default as Bridge } from '@opentiny/tiny-engine-plugin-bridge'
27+
export { default as Block, BlockService } from '@opentiny/tiny-engine-plugin-block'
28+
export { default as Datasource, DataSourceService } from '@opentiny/tiny-engine-plugin-datasource'
29+
export { default as Robot } from '@opentiny/tiny-engine-plugin-robot'
30+
export { default as Props, PropertiesService, PropertyService } from '@opentiny/tiny-engine-setting-props'
31+
export { default as Events } from '@opentiny/tiny-engine-setting-events'
32+
export { default as Styles } from '@opentiny/tiny-engine-setting-styles'
33+
export { default as Layout, LayoutService } from '@opentiny/tiny-engine-layout'
34+
export { default as Canvas } from '@opentiny/tiny-engine-canvas'
35+
export { initPreview } from './src/preview/src/main'
36+
export {
37+
GenerateCodeService,
38+
PluginPanel,
39+
PluginSetting,
40+
ToolbarBase,
41+
GlobalService,
42+
HttpService
43+
} from '@opentiny/tiny-engine-common'
44+
45+
export { default as defaultRegistry } from './registry'
46+
47+
export * from '@opentiny/tiny-engine-meta-register'

0 commit comments

Comments
 (0)