Skip to content

Commit

Permalink
Merge branch 'refactor/develop' of https://github.com/opentiny/tiny-e…
Browse files Browse the repository at this point in the history
…ngine into refactor/develop
  • Loading branch information
wenmine committed Jun 21, 2024
2 parents ed9afe0 + 54b8353 commit 4a3ae23
Show file tree
Hide file tree
Showing 95 changed files with 407 additions and 658 deletions.
24 changes: 1 addition & 23 deletions designer-demo/registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,15 @@ import {
Layout,
Canvas,
EditorInfoService,
HelpService,
AppService,
BlockService,
BreadcrumbService,
DataSourceService,
PageService,
ResourceService,
PropertiesService,
PropertyService,
SaveLocalService,
TranslateService,
HistoryService,
} from '@opentiny/tiny-engine'

export default {
root: {
id: 'engine.root',
metas: [
EditorInfoService,
HelpService,
AppService,
BreadcrumbService,
BlockService,
DataSourceService,
PageService,
ResourceService,
PropertiesService,
PropertyService,
SaveLocalService,
TranslateService,
HistoryService,
AppService
]
},
config: {
Expand Down
7 changes: 1 addition & 6 deletions designer-demo/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,8 @@
// 导入@opentiny/tiny-engine时,内部的依赖包也会逐个导入,可能会执行useComplie,此时需要templateHashMap。所以需要先执行一次defineEntry
import { registry } from './defineEntry.js'
import { init } from '@opentiny/tiny-engine'
import { initHook, HOOK_NAME } from '@opentiny/tiny-engine'
import { configurators } from './configurators/'
import 'virtual:svg-icons-register'
import '@opentiny/tiny-engine-theme'

const beforeAppCreate = () => {
initHook(HOOK_NAME.useEnv, import.meta.env)
}

init({ registry, configurators, lifeCycles: { beforeAppCreate } })
init({ registry, configurators })
2 changes: 0 additions & 2 deletions designer-demo/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ export default defineConfig((options) => {
'@opentiny/tiny-engine-controller/js': path.resolve(__dirname, '../packages/controller/js'),
'@opentiny/tiny-engine-common/component': path.resolve(__dirname, '../packages/common/component'),
'@opentiny/tiny-engine-common': path.resolve(__dirname, '../packages/common/index.js'),
'@opentiny/tiny-engine-controller/utils': path.resolve(__dirname, '../packages/controller/utils.js'),
'@opentiny/tiny-engine-controller/adapter': path.resolve(__dirname, '../packages/controller/adapter.js'),
'@opentiny/tiny-engine-controller': path.resolve(__dirname, '../packages/controller/src/index.js'),
'@opentiny/tiny-engine-plugin-materials': path.resolve(__dirname, '../packages/plugins/materials/index.js'),
'@opentiny/tiny-engine-plugin-block': path.resolve(__dirname, '../packages/plugins/block/index.js'),
Expand Down
9 changes: 8 additions & 1 deletion packages/canvas/breadcrumb/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { HOOK_NAME } from '@opentiny/tiny-engine-entry'
import CanvasBreadcrumb from './src/CanvasFooter.vue'
import metaData from './meta'
import useBreadcrumb from './src/useBreadcrumb'

export default {
...metaData,
entry: CanvasBreadcrumb
apis: useBreadcrumb(),
entry: CanvasBreadcrumb,
composable: {
name: HOOK_NAME.useBreadcrumb
}
}
2 changes: 2 additions & 0 deletions packages/canvas/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"@opentiny/tiny-engine-i18n-host": "workspace:*",
"@opentiny/tiny-engine-utils": "workspace:*",
"@opentiny/tiny-engine-webcomponent-core": "workspace:*",
"@opentiny/tiny-engine-plugin-materials": "workspace:*",
"@opentiny/tiny-engine-http": "workspace:*",
"@vue/babel-plugin-jsx": "1.1.1",
"@vue/shared": "^3.3.4",
"@vueuse/core": "^9.6.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/canvas/render/src/RenderMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
import { h, provide, inject, nextTick, shallowReactive, reactive, ref, watch, watchEffect } from 'vue'
import { I18nInjectionKey } from 'vue-i18n'
import { useBroadcastChannel } from '@vueuse/core'
import { constants } from '@opentiny/tiny-engine-utils'
import { generateFunction } from '@opentiny/tiny-engine-controller/utils'
import { constants, utils as commonUtils } from '@opentiny/tiny-engine-utils'
import renderer, { parseData, setConfigure, setController, globalNotify, isStateAccessor } from './render'
import { getNode as getNodeById, clearNodes, getRoot, setContext, getContext, setCondition, context } from './context'
import CanvasEmpty from './CanvasEmpty.vue'

const { BROADCAST_CHANNEL } = constants
const { parseFunction: generateFunction } = commonUtils

const reset = (obj) => {
Object.keys(obj).forEach((key) => delete obj[key])
Expand Down
2 changes: 1 addition & 1 deletion packages/common/component/BindI18n.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<script>
import { reactive, ref, watchEffect } from 'vue'
import { useLayout, useTranslate } from '@opentiny/tiny-engine-controller'
import { PROP_DATA_TYPE } from '@opentiny/tiny-engine-controller/utils'
import { PROP_DATA_TYPE } from '@opentiny/tiny-engine-controller/js/constants'
import { utils } from '@opentiny/tiny-engine-utils'
import { Select, Option, Button, Input } from '@opentiny/vue'
import { iconPlus } from '@opentiny/vue-icon'
Expand Down
2 changes: 1 addition & 1 deletion packages/common/component/BlockDeployDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ import {
Popover as TinyPopover,
FormItem as TinyFormItem
} from '@opentiny/vue'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import { theme } from '@opentiny/tiny-engine-controller/js/monaco'
import { useLayout, useNotify, useCanvas } from '@opentiny/tiny-engine-controller'
import { constants } from '@opentiny/tiny-engine-utils'
import VueMonaco from './VueMonaco.vue'
Expand Down
4 changes: 3 additions & 1 deletion packages/common/component/ConfigItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,11 @@ import i18n from '@opentiny/tiny-engine-controller/js/i18n'
import { CodeConfigurator, VariableConfigurator } from '@opentiny/tiny-engine-configurator'
import MultiTypeSelector from './MultiTypeSelector.vue'
import { useHistory, useProperties, useResource, useLayout, useCanvas } from '@opentiny/tiny-engine-controller'
import { generateFunction } from '@opentiny/tiny-engine-controller/utils'
import { SCHEMA_DATA_TYPE, PAGE_STATUS, TYPES } from '@opentiny/tiny-engine-controller/js/constants'
import { getConfigurator } from '@opentiny/tiny-engine-entry'
import { utils } from '@opentiny/tiny-engine-utils'
const { parseFunction: generateFunction } = utils
const hasRule = (required, rules) => {
if (required) {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/component/LifeCycles.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ import { reactive, ref, watchEffect, onBeforeUnmount } from 'vue'
import { Button, DialogBox, Popover, Search, Alert } from '@opentiny/vue'
import { useModal, usePage, useNotify, useCanvas } from '@opentiny/tiny-engine-controller'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import { theme } from '@opentiny/tiny-engine-controller/js/monaco'
import MetaListItems from './MetaListItems.vue'
import { iconYes } from '@opentiny/vue-icon'
import VueMonaco from './VueMonaco.vue'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ const confirm = ({ title, status, message, exec, cancel, showFooter = true }) =>
message: () => {
return (
<div class="modal-content">
<div class="wrap">
{typeof message === 'string' ? message : <message />}
</div>
<div class="wrap">{typeof message === 'string' ? message : <message />}</div>
</div>
)
}
Expand All @@ -32,11 +30,9 @@ const message = ({ title, status, message, exec, width = '400' }) => {
width: width,
message() {
return (
<div div class="modal-content" >
<div class="wrap">
{typeof message === 'string' ? message : <message />}
</div>
</div >
<div div class="modal-content">
<div class="wrap">{typeof message === 'string' ? message : <message />}</div>
</div>
)
}
}).then(() => {
Expand Down Expand Up @@ -67,10 +63,8 @@ const topbox = (options) => {
window.topbox = topbox
window.message = message

export default () => {
return {
confirm,
message,
topbox
}
export default {
confirm,
message,
topbox
}
2 changes: 1 addition & 1 deletion packages/common/component/MonacoEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

<script>
import { computed, ref, onActivated, onDeactivated } from 'vue'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import { theme } from '@opentiny/tiny-engine-controller/js/monaco'
import { Tooltip } from '@opentiny/vue'
import PublicIcon from './PublicIcon.vue'
import VueMonaco from './VueMonaco.vue'
Expand Down
File renamed without changes.
3 changes: 3 additions & 0 deletions packages/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,6 @@ export {
MetaTableColumns,
SearchEmpty
}

export { default as Modal } from './component/Modal'
export { default as Notify } from './component/Notify'
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
import { getCurrentInstance, reactive, ref, watchEffect } from 'vue'
import { Button, Tabs, TabItem, Input, ButtonGroup, Switch, Select } from '@opentiny/vue'
import { IconClose } from '@opentiny/vue-icon'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import { theme } from '@opentiny/tiny-engine-controller/js/monaco'
import { VueMonaco } from '../components'
export default {
Expand Down
2 changes: 1 addition & 1 deletion packages/configurator/src/components/BindI18n.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<script>
import { reactive, ref, watchEffect } from 'vue'
import { useLayout, useTranslate } from '@opentiny/tiny-engine-controller'
import { PROP_DATA_TYPE } from '@opentiny/tiny-engine-controller/utils'
import { PROP_DATA_TYPE } from '@opentiny/tiny-engine-controller/js/constants'
import { utils } from '@opentiny/tiny-engine-utils'
import { Select, Option, Button, Input } from '@opentiny/vue'
import { iconPlus } from '@opentiny/vue-icon'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@

<script>
import { VueMonaco as MonacoEditor, SvgButton } from '../components' // TODO 等 common 包移除了 configurator 依赖后再更换成 @opentiny/tiny-engine-common
import { useApp, useCanvas, useData, useLayout, useProperties, useResource } from '@opentiny/tiny-engine-controller'
import { theme } from '@opentiny/tiny-engine-controller/adapter'
import { useApp, useCanvas, useLayout, useProperties, useResource } from '@opentiny/tiny-engine-controller'
import { getCommentByKey } from '@opentiny/tiny-engine-controller/js/comment'
import { theme } from '@opentiny/tiny-engine-controller/js/monaco'
import { formatString, generate, parse, traverse } from '@opentiny/tiny-engine-controller/js/ast'
import { DEFAULT_LOOP_NAME } from '@opentiny/tiny-engine-controller/js/constants'
import { useHttp } from '@opentiny/tiny-engine-http'
Expand Down Expand Up @@ -318,7 +319,6 @@ export default {
const genRemoteMethodToLifeSetup = (variableName, sourceRef, pageSchema) => {
if (sourceRef?.data?.data) {
const setupFn = pageSchema.lifeCycles?.setup?.value
const { getCommentByKey } = useData()
const { start, end } = getCommentByKey(variableName)
const intervalId = `${CONSTANTS.INTERVALID}${capitalize(camelize(sourceRef.name))}`
const isPoll = state.isPoll && state.pollInterval !== undefined
Expand Down
16 changes: 16 additions & 0 deletions packages/controller/js/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2023 - present TinyEngine Authors.
* Copyright (c) 2023 - present Huawei Cloud Computing Technologies Co., Ltd.
*
* Use of this source code is governed by an MIT-style license.
*
* THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL,
* BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR
* A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
*
*/

export const getCommentByKey = (key) => ({
start: `start-${key} 设计器生成的代码,为了避免出现问题,请勿修改`,
end: `end-${key}`
})
21 changes: 20 additions & 1 deletion packages/controller/js/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,27 @@ export const HOST_TYPE = {
Block: 'block'
}

// 转化国际化的映射关系表
export const i18nKeyMaps = {
zhCN: 'zh_CN',
enUS: 'en_US'
}

export const MATERIAL_TYPE = {
Component: 'component',
Block: 'block'
}

export const NODE_INSERT_TYPE = {
Inside: 'inside',
After: 'after',
Before: 'before',
Replace: 'replace'
}

export const PROP_DATA_TYPE = {
I18N: 'i18n',
VARIABLE: 'variable',
JSEXPRESSION: 'JSExpression',
JSRESOURCE: 'JSResource',
JSSLOT: 'JSSlot'
}
4 changes: 3 additions & 1 deletion packages/controller/js/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
*/

import * as cssTree from 'css-tree'
import { hyphenate } from '../utils'
import { utils } from '@opentiny/tiny-engine-utils'

const { hyphenate } = utils

/**
* 传入 css 字符串,得到以选择器为 Key,css 规则为 value 的 object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ const exampleMap = {
}
] `
}
export default (name) => {

export const getExample = (name) => {
const resetName = `${name || ''}`.toLocaleLowerCase()
return exampleMap[resetName]
}
3 changes: 1 addition & 2 deletions packages/controller/js/http.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
*/

import { useHttp } from '@opentiny/tiny-engine-http'
import useNotify from '../src/components/useNotify'
import { isVsCodeEnv } from './environments'
import { generateRouter, generatePage } from './vscodeGenerateFile'
import { usePage, useCanvas } from '@opentiny/tiny-engine-entry'
import { usePage, useCanvas, useNotify } from '@opentiny/tiny-engine-entry'

const http = useHttp()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,13 @@
*
*/

import { toRaw } from 'vue'
import { getMergeMeta } from '@opentiny/tiny-engine-entry'

/**
* 将画布pageSchema对象转换成编辑器中的string
*
* @param {*} obj
* @returns
*/
export const obj2String = (obj) => {
let out = null

try {
out = JSON.stringify(toRaw(obj), null, 2)
} catch (error) {
// do nothing
}

return out
}

/**
* 将编辑器中的string转换成画布识别的pageSchema对象
* @param {*} string
* @returns
*/

export const string2Obj = (string) => {
let obj = null

try {
obj = JSON.parse(string)
} catch (error) {
// do nothing
}

return obj
}

/**
* 判断 Monaco 编辑器背景色的主题
* @returns
*/

// TODO: 后续放入Monaco组件中,由组件提供API设置主题
export const theme = () => {
const theme = getMergeMeta('engine.config').theme?.includes('dark') ? 'vs-dark' : 'vs'

Expand Down
3 changes: 0 additions & 3 deletions packages/controller/meta.js

This file was deleted.

3 changes: 1 addition & 2 deletions packages/controller/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@
"exports": {
".": "./dist/index.js",
"./js/": "./dist/js/",
"./utils": "./dist/utils.js",
"./adapter": "./dist/adapter.js"
"./utils": "./dist/utils.js"
},
"repository": {
"type": "git",
Expand Down
Loading

0 comments on commit 4a3ae23

Please sign in to comment.