Compare commits

...

6 Commits

Author SHA1 Message Date
wwsun 05a0f8f490 chore(release): publish
- @music163/tango-context@0.2.12
 - @music163/tango-core@0.2.11
 - @music163/tango-designer@0.5.14
 - @music163/tango-sandbox@0.1.16
 - @music163/tango-setting-form@0.2.16
2023-12-04 18:43:14 +08:00
wwsun c884712331 fix: update FileType 2023-12-04 18:38:38 +08:00
wwsun e35ff792a0 chore(release): publish
- @music163/tango-context@0.2.11
 - @music163/tango-core@0.2.10
 - @music163/tango-designer@0.5.13
 - @music163/tango-sandbox@0.1.15
 - @music163/tango-setting-form@0.2.15
2023-12-04 12:54:30 +08:00
Wells 138cbe9b20 fix: add filesFormatter to sandbox & fix update props with imports (#71)
* fix: update types

* fix: add filesFormatter to sandbox

* fix: update node attributes with imports

---------

Co-authored-by: wwsun <ww.sww@outlook.com>
2023-12-04 12:52:10 +08:00
wwsun 979aa34259 chore(release): publish
- @music163/tango-context@0.2.10
 - @music163/tango-core@0.2.9
 - @music163/tango-designer@0.5.12
 - @music163/tango-sandbox@0.1.14
 - @music163/tango-setting-form@0.2.14
2023-11-30 15:46:50 +08:00
wwsun 76a5a2c659 fix: fix render components tree 2023-11-30 15:44:42 +08:00
17 changed files with 145 additions and 26 deletions
+15
View File
@@ -143,6 +143,8 @@ import {
FormilyForm, FormilyForm,
} from "@music163/antd"; } from "@music163/antd";
import { Space } from '@music163/antd'; import { Space } from '@music163/antd';
import { MyButton } from '../components/button';
class App extends React.Component { class App extends React.Component {
render() { render() {
return ( return (
@@ -151,6 +153,7 @@ class App extends React.Component {
</Section> </Section>
<Section> <Section>
<Space> <Space>
<MyButton />
<Button>button</Button> <Button>button</Button>
<Input /> <Input />
</Space> </Space>
@@ -162,6 +165,16 @@ class App extends React.Component {
export default definePage(App); export default definePage(App);
`; `;
const componentsButtonCode = `
import React from 'react';
export function MyButton() {
return <button>my button</button>
}
`;
const componentsPrototypeCode = ``;
const storeApp = ` const storeApp = `
import { defineStore } from '@music163/tango-boot'; import { defineStore } from '@music163/tango-boot';
@@ -246,6 +259,8 @@ export const sampleFiles = [
{ filename: '/src/style.css', code: cssCode }, { filename: '/src/style.css', code: cssCode },
{ filename: '/src/index.js', code: entryCode }, { filename: '/src/index.js', code: entryCode },
{ filename: '/src/pages/list.js', code: viewHomeCode }, { filename: '/src/pages/list.js', code: viewHomeCode },
{ filename: '/src/components/button.js', code: componentsButtonCode },
{ filename: '/src/components/prototype.js', code: componentsPrototypeCode },
{ filename: '/src/routes.js', code: routesCode }, { filename: '/src/routes.js', code: routesCode },
{ filename: '/src/stores/index.js', code: storeIndexCode }, { filename: '/src/stores/index.js', code: storeIndexCode },
{ filename: '/src/stores/app.js', code: storeApp }, { filename: '/src/stores/app.js', code: storeApp },
+12
View File
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.2.12](https://github.com/netease/tango/compare/@music163/tango-context@0.2.11...@music163/tango-context@0.2.12) (2023-12-04)
**Note:** Version bump only for package @music163/tango-context
## [0.2.11](https://github.com/netease/tango/compare/@music163/tango-context@0.2.10...@music163/tango-context@0.2.11) (2023-12-04)
**Note:** Version bump only for package @music163/tango-context
## [0.2.10](https://github.com/netease/tango/compare/@music163/tango-context@0.2.9...@music163/tango-context@0.2.10) (2023-11-30)
**Note:** Version bump only for package @music163/tango-context
## [0.2.9](https://github.com/netease/tango/compare/@music163/tango-context@0.2.8...@music163/tango-context@0.2.9) (2023-11-29) ## [0.2.9](https://github.com/netease/tango/compare/@music163/tango-context@0.2.8...@music163/tango-context@0.2.9) (2023-11-29)
**Note:** Version bump only for package @music163/tango-context **Note:** Version bump only for package @music163/tango-context
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@music163/tango-context", "name": "@music163/tango-context",
"version": "0.2.9", "version": "0.2.12",
"description": "react context for tango-apps", "description": "react context for tango-apps",
"keywords": [ "keywords": [
"react", "react",
@@ -31,7 +31,7 @@
"react": ">= 16.8" "react": ">= 16.8"
}, },
"dependencies": { "dependencies": {
"@music163/tango-core": "^0.2.8", "@music163/tango-core": "^0.2.11",
"@music163/tango-helpers": "^0.1.8", "@music163/tango-helpers": "^0.1.8",
"mobx-react-lite": "4.0.2" "mobx-react-lite": "4.0.2"
}, },
+18
View File
@@ -3,6 +3,24 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.2.11](https://github.com/netease/tango/compare/@music163/tango-core@0.2.10...@music163/tango-core@0.2.11) (2023-12-04)
### Bug Fixes
- update FileType ([c884712](https://github.com/netease/tango/commit/c8847123312bc47ea06575f4e714dfd596893e39))
## [0.2.10](https://github.com/netease/tango/compare/@music163/tango-core@0.2.9...@music163/tango-core@0.2.10) (2023-12-04)
### Bug Fixes
- add filesFormatter to sandbox & fix update props with imports ([#71](https://github.com/netease/tango/issues/71)) ([138cbe9](https://github.com/netease/tango/commit/138cbe9b203b370aff42c1ae8086d69edacf35e9))
## [0.2.9](https://github.com/netease/tango/compare/@music163/tango-core@0.2.8...@music163/tango-core@0.2.9) (2023-11-30)
### Bug Fixes
- fix render components tree ([76a5a2c](https://github.com/netease/tango/commit/76a5a2c65920bc42b019cd1f32a3cacd0d888638))
## [0.2.8](https://github.com/netease/tango/compare/@music163/tango-core@0.2.7...@music163/tango-core@0.2.8) (2023-11-29) ## [0.2.8](https://github.com/netease/tango/compare/@music163/tango-core@0.2.7...@music163/tango-core@0.2.8) (2023-11-29)
### Bug Fixes ### Bug Fixes
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@music163/tango-core", "name": "@music163/tango-core",
"version": "0.2.8", "version": "0.2.11",
"description": "tango core", "description": "tango core",
"author": "wwsun <ww.sun@outlook.com>", "author": "wwsun <ww.sun@outlook.com>",
"homepage": "", "homepage": "",
+1 -1
View File
@@ -4,5 +4,5 @@ export * from './helpers';
export * from './types'; export * from './types';
export { default as generator } from '@babel/generator'; export { default as generator } from '@babel/generator';
export { default as traverse } from '@babel/types'; export { default as traverse } from '@babel/traverse';
export * from '@babel/parser'; export * from '@babel/parser';
+16 -2
View File
@@ -307,10 +307,24 @@ export class TangoViewModule extends TangoModule implements IViewFile {
updateNodeAttributes(nodeId: string, config: Record<string, any>, relatedImports?: string[]) { updateNodeAttributes(nodeId: string, config: Record<string, any>, relatedImports?: string[]) {
if (relatedImports && relatedImports.length) { if (relatedImports && relatedImports.length) {
// 导入依赖的组件 // 导入依赖的组件
relatedImports.forEach((name: string) => { const newImportData = relatedImports.reduce((prev, name) => {
const proto = this.workspace.getPrototype(name); const proto = this.workspace.getPrototype(name);
const { source, specifiers } = prototype2importDeclarationData(proto, this.filename); const { source, specifiers } = prototype2importDeclarationData(proto, this.filename);
this.addImportSpecifiers(source, specifiers); const existSpecifiers: IImportSpecifierData[] = prev[source];
if (existSpecifiers) {
// merge specifiers
specifiers.forEach((item) => {
if (!existSpecifiers.find((existItem) => existItem.localName === item.localName)) {
existSpecifiers.push(item);
}
});
} else {
prev[source] = specifiers;
}
return prev;
}, {});
Object.keys(newImportData).forEach((source) => {
this.addImportSpecifiers(source, newImportData[source]);
}); });
} }
this.ast = updateJSXAttributes(this.ast, nodeId, config); this.ast = updateJSXAttributes(this.ast, nodeId, config);
+1 -3
View File
@@ -1,7 +1,6 @@
import { action, computed, makeObservable, observable } from 'mobx'; import { action, computed, makeObservable, observable } from 'mobx';
import { JSXElement } from '@babel/types'; import { JSXElement } from '@babel/types';
import { import {
array2object,
ComponentPrototypeType, ComponentPrototypeType,
hasFileExtension, hasFileExtension,
isString, isString,
@@ -16,7 +15,6 @@ import {
getJSXElementChildrenNames, getJSXElementChildrenNames,
namesToImportDeclarations, namesToImportDeclarations,
getBlockNameByFilename, getBlockNameByFilename,
getPrivilegeCode,
prototype2importDeclarationData, prototype2importDeclarationData,
} from '../helpers'; } from '../helpers';
import { DropMethod } from './drop-target'; import { DropMethod } from './drop-target';
@@ -96,7 +94,7 @@ export class Workspace extends EventTarget implements IWorkspace {
/** /**
* 本地区块 { [blockName]: filePath } * 本地区块 { [blockName]: filePath }
* FIXME: 修正类型 Record<string, TangoBlockModule> * TODO: 废弃这个,不再支持
*/ */
localBlocks: Record<string, string>; localBlocks: Record<string, string>;
+10 -1
View File
@@ -10,11 +10,20 @@ export enum FileType {
Module = 'module', Module = 'module',
StoreEntryModule = 'storeEntryModule', StoreEntryModule = 'storeEntryModule',
RouteModule = 'routeModule', RouteModule = 'routeModule',
BlockEntryModule = 'blockEntryModule',
ServiceModule = 'serviceModule', ServiceModule = 'serviceModule',
StoreModule = 'storeModule', StoreModule = 'storeModule',
// 组件配置文件
ComponentPrototypeModule = 'componentPrototypeModule',
// 组件运行调试入口文件,一般为 `/app.js`
ComponentDemoEntryModule = 'componentDemoEntryModule',
// 区块入口文件 FIXME: 是否移除
BlockEntryModule = 'blockEntryModule',
// jsx 类型视图文件
JsxViewModule = 'jsxViewModule', JsxViewModule = 'jsxViewModule',
// json 类型视图文件
JsonViewModule = 'jsonViewModule', JsonViewModule = 'jsonViewModule',
// 非 js 文件 // 非 js 文件
+16
View File
@@ -3,6 +3,22 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.5.14](https://github.com/netease/tango/compare/@music163/tango-designer@0.5.13...@music163/tango-designer@0.5.14) (2023-12-04)
**Note:** Version bump only for package @music163/tango-designer
## [0.5.13](https://github.com/netease/tango/compare/@music163/tango-designer@0.5.12...@music163/tango-designer@0.5.13) (2023-12-04)
### Bug Fixes
- add filesFormatter to sandbox & fix update props with imports ([#71](https://github.com/netease/tango/issues/71)) ([138cbe9](https://github.com/netease/tango/commit/138cbe9b203b370aff42c1ae8086d69edacf35e9))
## [0.5.12](https://github.com/netease/tango/compare/@music163/tango-designer@0.5.11...@music163/tango-designer@0.5.12) (2023-11-30)
### Bug Fixes
- fix render components tree ([76a5a2c](https://github.com/netease/tango/commit/76a5a2c65920bc42b019cd1f32a3cacd0d888638))
## [0.5.11](https://github.com/netease/tango/compare/@music163/tango-designer@0.5.10...@music163/tango-designer@0.5.11) (2023-11-29) ## [0.5.11](https://github.com/netease/tango/compare/@music163/tango-designer@0.5.10...@music163/tango-designer@0.5.11) (2023-11-29)
**Note:** Version bump only for package @music163/tango-designer **Note:** Version bump only for package @music163/tango-designer
+5 -5
View File
@@ -1,6 +1,6 @@
{ {
"name": "@music163/tango-designer", "name": "@music163/tango-designer",
"version": "0.5.11", "version": "0.5.14",
"description": "lowcode designer", "description": "lowcode designer",
"keywords": [ "keywords": [
"react" "react"
@@ -33,11 +33,11 @@
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.8.0", "@ant-design/icons": "^4.8.0",
"@music163/request": "^0.1.2", "@music163/request": "^0.1.2",
"@music163/tango-context": "^0.2.9", "@music163/tango-context": "^0.2.12",
"@music163/tango-core": "^0.2.8", "@music163/tango-core": "^0.2.11",
"@music163/tango-helpers": "^0.1.8", "@music163/tango-helpers": "^0.1.8",
"@music163/tango-sandbox": "^0.1.13", "@music163/tango-sandbox": "^0.1.16",
"@music163/tango-setting-form": "^0.2.13", "@music163/tango-setting-form": "^0.2.16",
"@music163/tango-ui": "^0.1.12", "@music163/tango-ui": "^0.1.12",
"antd": "^4.24.2", "antd": "^4.24.2",
"cash-dom": "^8.1.2", "cash-dom": "^8.1.2",
+13
View File
@@ -23,6 +23,12 @@ export type SandboxProps = Omit<CodeSandboxProps, 'files' | 'eventHandlers' | 'o
* tangoConfigJson 处理器 * tangoConfigJson 处理器
*/ */
configFormatter?: IMergeTangoConfigJsonConfig['formatter']; configFormatter?: IMergeTangoConfigJsonConfig['formatter'];
/**
* 文件格式化器
* @param files 沙箱文件列表
* @returns 修改后的文件列表
*/
filesFormatter?: (files: CodeSandboxProps['files']) => CodeSandboxProps['files'];
sandboxType?: 'design' | 'preview'; sandboxType?: 'design' | 'preview';
mode?: 'single' | 'combined'; mode?: 'single' | 'combined';
injectScript?: string; injectScript?: string;
@@ -41,6 +47,7 @@ const LANDING_PAGE_PATH = '/__background_landing_page__';
function useSandbox({ function useSandbox({
isPreview: isPreviewProp, isPreview: isPreviewProp,
configFormatter, configFormatter,
filesFormatter,
onViewChange, onViewChange,
onMessage: onMessageProp, onMessage: onMessageProp,
onLoad: onLoadProp, onLoad: onLoadProp,
@@ -79,7 +86,12 @@ function useSandbox({
prev[filename] = { code }; prev[filename] = { code };
return prev; return prev;
}, {}); }, {});
files = fixSandboxFiles(files, workspace.entry); files = fixSandboxFiles(files, workspace.entry);
if (filesFormatter) {
// 支持用户对传入的文件进行修改
files = filesFormatter(files);
}
const onMessage = (data: any) => onMessageProp && onMessageProp(data, getSandboxConfig()); const onMessage = (data: any) => onMessageProp && onMessageProp(data, getSandboxConfig());
const onLoad = () => onLoadProp && onLoadProp(getSandboxConfig()); const onLoad = () => onLoadProp && onLoadProp(getSandboxConfig());
@@ -413,6 +425,7 @@ function fixSandboxFiles(files: Record<string, { code: string }>, entry = '/src/
`, `,
}; };
} }
return files; return files;
} }
@@ -148,6 +148,12 @@ export const ComponentsTree: React.FC<ComponentsTreeProps> = observer(
setSelectedKeys(workspace.selectSource.selected.map((item) => item.id)); setSelectedKeys(workspace.selectSource.selected.map((item) => item.id));
}, [workspace.selectSource.selected]); }, [workspace.selectSource.selected]);
useEffect(() => {
setExpandedKeys(getNodeKeys(nodesTree));
// nodeTree 更新后重新计算expandKeys
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [nodesTree?.[0]?.id]);
if (!nodesTree.length) { if (!nodesTree.length) {
return ( return (
<Box> <Box>
@@ -156,12 +162,6 @@ export const ComponentsTree: React.FC<ComponentsTreeProps> = observer(
); );
} }
useEffect(() => {
setExpandedKeys(getNodeKeys(nodesTree));
// nodeTree 更新后重新计算expandKeys
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [nodesTree?.[0]?.id]);
return ( return (
<Box css={outlineStyle}> <Box css={outlineStyle}>
<Tree <Tree
+12
View File
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.1.16](https://github.com/netease/tango/compare/@music163/tango-sandbox@0.1.15...@music163/tango-sandbox@0.1.16) (2023-12-04)
**Note:** Version bump only for package @music163/tango-sandbox
## [0.1.15](https://github.com/netease/tango/compare/@music163/tango-sandbox@0.1.14...@music163/tango-sandbox@0.1.15) (2023-12-04)
**Note:** Version bump only for package @music163/tango-sandbox
## [0.1.14](https://github.com/netease/tango/compare/@music163/tango-sandbox@0.1.13...@music163/tango-sandbox@0.1.14) (2023-11-30)
**Note:** Version bump only for package @music163/tango-sandbox
## [0.1.13](https://github.com/netease/tango/compare/@music163/tango-sandbox@0.1.12...@music163/tango-sandbox@0.1.13) (2023-11-29) ## [0.1.13](https://github.com/netease/tango/compare/@music163/tango-sandbox@0.1.12...@music163/tango-sandbox@0.1.13) (2023-11-29)
**Note:** Version bump only for package @music163/tango-sandbox **Note:** Version bump only for package @music163/tango-sandbox
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@music163/tango-sandbox", "name": "@music163/tango-sandbox",
"version": "0.1.13", "version": "0.1.16",
"description": "sandbox of tango apps", "description": "sandbox of tango apps",
"author": "wwsun <ww.sun@outlook.com>", "author": "wwsun <ww.sun@outlook.com>",
"homepage": "", "homepage": "",
@@ -29,7 +29,7 @@
}, },
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.8.0", "@ant-design/icons": "^4.8.0",
"@music163/tango-core": "^0.2.8", "@music163/tango-core": "^0.2.11",
"@music163/tango-helpers": "^0.1.8", "@music163/tango-helpers": "^0.1.8",
"crypto-js": "^4.1.1", "crypto-js": "^4.1.1",
"lodash.isequal": "4.5.0", "lodash.isequal": "4.5.0",
+12
View File
@@ -3,6 +3,18 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [0.2.16](https://github.com/netease/tango/compare/@music163/tango-setting-form@0.2.15...@music163/tango-setting-form@0.2.16) (2023-12-04)
**Note:** Version bump only for package @music163/tango-setting-form
## [0.2.15](https://github.com/netease/tango/compare/@music163/tango-setting-form@0.2.14...@music163/tango-setting-form@0.2.15) (2023-12-04)
**Note:** Version bump only for package @music163/tango-setting-form
## [0.2.14](https://github.com/netease/tango/compare/@music163/tango-setting-form@0.2.13...@music163/tango-setting-form@0.2.14) (2023-11-30)
**Note:** Version bump only for package @music163/tango-setting-form
## [0.2.13](https://github.com/netease/tango/compare/@music163/tango-setting-form@0.2.12...@music163/tango-setting-form@0.2.13) (2023-11-29) ## [0.2.13](https://github.com/netease/tango/compare/@music163/tango-setting-form@0.2.12...@music163/tango-setting-form@0.2.13) (2023-11-29)
### Bug Fixes ### Bug Fixes
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "@music163/tango-setting-form", "name": "@music163/tango-setting-form",
"version": "0.2.13", "version": "0.2.16",
"description": "setting form of tango-apps", "description": "setting form of tango-apps",
"author": "wwsun <ww.sun@outlook.com>", "author": "wwsun <ww.sun@outlook.com>",
"homepage": "", "homepage": "",
@@ -28,7 +28,7 @@
}, },
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.8.0", "@ant-design/icons": "^4.8.0",
"@music163/tango-core": "^0.2.8", "@music163/tango-core": "^0.2.11",
"@music163/tango-helpers": "^0.1.8", "@music163/tango-helpers": "^0.1.8",
"@music163/tango-ui": "^0.1.12", "@music163/tango-ui": "^0.1.12",
"antd": "^4.24.2", "antd": "^4.24.2",