chore: 版本修改

This commit is contained in:
荣彬 2020-11-10 23:25:26 +08:00
commit 20f8a3590c
20 changed files with 115 additions and 38 deletions

View File

@ -17,8 +17,8 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-datasource-types": "^1.0.2", "@ali/lowcode-datasource-types": "^1.0.19",
"@ali/lowcode-types": "^1.0.18", "@ali/lowcode-types": "^1.0.17",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },
"devDependencies": { "devDependencies": {

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-fetch-handler", "name": "@ali/lowcode-datasource-fetch-handler",
"version": "1.0.9", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-jsonp-handler", "name": "@ali/lowcode-datasource-jsonp-handler",
"version": "1.0.6", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",
@ -16,7 +16,7 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-datasource-types": "^1.0.2", "@ali/lowcode-datasource-types": "^1.0.19",
"jsonp": "^0.2.1", "jsonp": "^0.2.1",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-mopen-handler", "name": "@ali/lowcode-datasource-mopen-handler",
"version": "1.0.9", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",
@ -16,7 +16,7 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-datasource-types": "^1.0.2", "@ali/lowcode-datasource-types": "^1.0.19",
"@ali/mirror-io-client-mopen": "1.0.0-beta.16", "@ali/mirror-io-client-mopen": "1.0.0-beta.16",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-mtop-handler", "name": "@ali/lowcode-datasource-mtop-handler",
"version": "1.0.8", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",
@ -16,7 +16,7 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-datasource-types": "^1.0.2", "@ali/lowcode-datasource-types": "^1.0.19",
"@ali/universal-mtop": "^5.1.9", "@ali/universal-mtop": "^5.1.9",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-types", "name": "@ali/lowcode-datasource-types",
"version": "1.0.2", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-universal-mtop-handler", "name": "@ali/lowcode-datasource-universal-mtop-handler",
"version": "1.0.8", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",
@ -16,7 +16,7 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-datasource-types": "^1.0.2", "@ali/lowcode-datasource-types": "^1.0.19",
"@ali/mirror-io-client-universal-mtop": "1.0.0-beta.16", "@ali/mirror-io-client-universal-mtop": "1.0.0-beta.16",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@ -1,6 +1,6 @@
{ {
"name": "@ali/lowcode-datasource-url-params-handler", "name": "@ali/lowcode-datasource-url-params-handler",
"version": "1.0.8", "version": "1.0.19",
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "es/index.js",
"typings": "es/index.d.ts", "typings": "es/index.d.ts",
@ -16,7 +16,7 @@
"prepublishOnly": "npm run build" "prepublishOnly": "npm run build"
}, },
"dependencies": { "dependencies": {
"@ali/lowcode-datasource-types": "^1.0.2", "@ali/lowcode-datasource-types": "^1.0.19",
"query-string": "^6.13.1", "query-string": "^6.13.1",
"typescript": "^3.9.7" "typescript": "^3.9.7"
}, },

View File

@ -11,6 +11,19 @@
"fileName": "test", "fileName": "test",
"dataSource": { "dataSource": {
"list": [ "list": [
{
"type": "fetch",
"id": "请求商家数据,是一个 HTTP 请求,是一个 HTTP 请求,是一个 HTTP 请求",
"isInit": true,
"options": {
"uri": "https://www.taobao.com",
"params": {
"a": 1,
"b": true,
"c": "3"
}
}
}
] ]
}, },
"state": { "state": {

View File

@ -135,6 +135,12 @@ export class BuiltinSimulatorHost implements ISimulatorHost<BuiltinSimulatorProp
return this.get('designMode') || 'design'; return this.get('designMode') || 'design';
} }
@computed get requestHandlersMap(): any {
// renderer 依赖
// TODO: 需要根据 design mode 不同切换鼠标响应情况
return this.get('requestHandlersMap') || null;
}
@computed get componentsAsset(): Asset | undefined { @computed get componentsAsset(): Asset | undefined {
return this.get('componentsAsset'); return this.get('componentsAsset');
} }

View File

@ -15,6 +15,8 @@ interface DesignerPluginState {
renderEnv?: string; renderEnv?: string;
device?: string; device?: string;
simulatorUrl: Asset | null; simulatorUrl: Asset | null;
// @TODO 类型定义
requestHandlersMap: any;
} }
export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> { export default class DesignerPlugin extends PureComponent<PluginProps, DesignerPluginState> {
@ -27,6 +29,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
renderEnv: 'default', renderEnv: 'default',
device: 'default', device: 'default',
simulatorUrl: null, simulatorUrl: null,
requestHandlersMap: null,
}; };
private _mounted = true; private _mounted = true;
@ -43,6 +46,8 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
const renderEnv = await editor.get('renderEnv'); const renderEnv = await editor.get('renderEnv');
const device = await editor.get('device'); const device = await editor.get('device');
const simulatorUrl = await editor.get('simulatorUrl'); const simulatorUrl = await editor.get('simulatorUrl');
// @TODO setupAssets 里设置 requestHandlersMap 不太合适
const requestHandlersMap = await editor.get('requestHandlersMap');
if (!this._mounted) { if (!this._mounted) {
return; return;
} }
@ -54,6 +59,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
renderEnv, renderEnv,
device, device,
simulatorUrl, simulatorUrl,
requestHandlersMap,
}; };
this.setState(state); this.setState(state);
} catch (e) { } catch (e) {
@ -76,7 +82,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
render(): React.ReactNode { render(): React.ReactNode {
const { editor } = this.props; const { editor } = this.props;
const { componentMetadatas, library, extraEnvironment, renderEnv, device, simulatorUrl } = this.state; const { componentMetadatas, library, extraEnvironment, renderEnv, device, simulatorUrl, requestHandlersMap } = this.state;
if (!library || !componentMetadatas) { if (!library || !componentMetadatas) {
// TODO: use a Loading // TODO: use a Loading
return null; return null;
@ -95,6 +101,7 @@ export default class DesignerPlugin extends PureComponent<PluginProps, DesignerP
renderEnv, renderEnv,
device, device,
simulatorUrl, simulatorUrl,
requestHandlersMap,
}} }}
/> />
); );

View File

@ -1,6 +1,7 @@
import { createElement, render } from 'rax'; import { createElement, render } from 'rax';
import UniversalDriver from 'driver-universal'; import UniversalDriver from 'driver-universal';
import { app, Provider } from '@ali/lowcode-runtime'; import { app, Provider } from '@ali/lowcode-runtime';
import { AppHelper } from '@ali/lowcode-utils';
import LazyComponent from './lazy-component'; import LazyComponent from './lazy-component';
import getRouter from './router'; import getRouter from './router';
@ -80,7 +81,12 @@ export default class RaxProvider extends Provider {
history: this.getHistory(), history: this.getHistory(),
routes, routes,
}); });
const RouterView = (props) => createElement(Router, props); const appHelper = new AppHelper({});
appHelper.set('requestHandlersMap', this.getRequestHandlersMap());
const RouterView = (props) => createElement(Router, {
appHelper,
...props,
});
return RouterView; return RouterView;
} }

View File

@ -3,7 +3,7 @@ import { Component, createElement } from 'rax';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Debug from 'debug'; import Debug from 'debug';
import classnames from 'classnames'; import classnames from 'classnames';
import { createInterpret } from '@ali/lowcode-datasource-engine'; import { create as createDataSourceEngine } from '@ali/lowcode-datasource-engine/interpret';
import DataHelper from '../utils/dataHelper'; import DataHelper from '../utils/dataHelper';
import { import {
forEach, forEach,
@ -134,16 +134,16 @@ export default class BaseEngine extends Component {
const schema = props.__schema || {}; const schema = props.__schema || {};
const dataSource = (schema && schema.dataSource) || {}; const dataSource = (schema && schema.dataSource) || {};
// requestHandlersMap 存在才走数据源引擎方案 // requestHandlersMap 存在才走数据源引擎方案
if (props.requestHandlersMap) { if (props?.__appHelper?.requestHandlersMap) {
const { dataSourceMap, reloadDataSource } = createInterpret(dataSource, this, { const { dataSourceMap, reloadDataSource } = createDataSourceEngine(dataSource, this, {
requestHandlersMap: props.requestHandlersMap, requestHandlersMap: props.__appHelper.requestHandlersMap,
}); });
this.dataSourceMap = dataSourceMap; this.dataSourceMap = dataSourceMap;
this.reloadDataSource = () => new Promise((resolve, reject) => { this.reloadDataSource = () => new Promise((resolve, reject) => {
debug('reload data source'); debug('reload data source');
this.__showPlaceholder = true; // this.__showPlaceholder = true;
reloadDataSource().then(() => { reloadDataSource().then(() => {
this.__showPlaceholder = false; // this.__showPlaceholder = false;
// @TODO 是否需要 forceUpate // @TODO 是否需要 forceUpate
resolve(); resolve();
}); });
@ -155,13 +155,13 @@ export default class BaseEngine extends Component {
this.reloadDataSource = () => new Promise((resolve, reject) => { this.reloadDataSource = () => new Promise((resolve, reject) => {
debug('reload data source'); debug('reload data source');
if (!this.__dataHelper) { if (!this.__dataHelper) {
this.__showPlaceholder = false; // this.__showPlaceholder = false;
return resolve(); return resolve();
} }
this.__dataHelper this.__dataHelper
.getInitData() .getInitData()
.then((res) => { .then((res) => {
this.__showPlaceholder = false; // this.__showPlaceholder = false;
if (isEmpty(res)) { if (isEmpty(res)) {
this.forceUpdate(); this.forceUpdate();
return resolve(); return resolve();
@ -178,9 +178,10 @@ export default class BaseEngine extends Component {
}); });
} }
// 设置容器组件占位若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容 // 设置容器组件占位若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容
if (this.__parseData(schema.props && schema.props.autoLoading)) { // @TODO __showPlaceholder 的逻辑一旦开启就关不掉,先注释掉了
/* if (this.__parseData(schema.props && schema.props.autoLoading)) {
this.__showPlaceholder = (dataSource.list || []).some((item) => !!this.__parseData(item.isInit)); this.__showPlaceholder = (dataSource.list || []).some((item) => !!this.__parseData(item.isInit));
} } */
}; };
__render = () => { __render = () => {

View File

@ -113,7 +113,7 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
schema={renderer.schema} schema={renderer.schema}
components={renderer.components} components={renderer.components}
context={renderer.context} context={renderer.context}
requestHandlersMap={host.requestHandlersMap} appHelper={renderer.context}
device={device} device={device}
designMode={renderer.designMode} designMode={renderer.designMode}
suspended={renderer.suspended} suspended={renderer.suspended}

View File

@ -65,6 +65,12 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
return this._designMode; return this._designMode;
} }
@obx.ref private _requestHandlersMap = null;
@computed get requestHandlersMap(): any {
return this._requestHandlersMap;
}
@obx.ref private _componentsMap = {}; @obx.ref private _componentsMap = {};
@computed get componentsMap(): any { @computed get componentsMap(): any {
@ -120,6 +126,9 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
// sync designMode // sync designMode
this._designMode = host.designMode; this._designMode = host.designMode;
// sync requestHandlersMap
this._requestHandlersMap = host.requestHandlersMap;
// sync suspended // sync suspended
// sync scope // sync scope
@ -142,6 +151,7 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
constants: { constants: {
name: 'demo', name: 'demo',
}, },
requestHandlersMap: this._requestHandlersMap,
}; };
}); });
} }

View File

@ -87,6 +87,7 @@ export default class ReactProvider extends Provider {
const appHelper = new AppHelper({}); const appHelper = new AppHelper({});
appHelper.set('utils', this.getUtils()); appHelper.set('utils', this.getUtils());
appHelper.set('constants', this.getConstants()); appHelper.set('constants', this.getConstants());
appHelper.set('requestHandlersMap', this.getRequestHandlersMap());
const self = this; const self = this;
const RouterView = (props: any) => { const RouterView = (props: any) => {
return createElement(Router as any, { return createElement(Router as any, {

View File

@ -2,7 +2,7 @@
import React, { PureComponent } from 'react'; import React, { PureComponent } from 'react';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
import Debug from 'debug'; import Debug from 'debug';
import { createInterpret } from '@ali/lowcode-datasource-engine'; import { create as createDataSourceEngine } from '@ali/lowcode-datasource-engine/interpret';
import Div from '../components/Div'; import Div from '../components/Div';
import VisualDom from '../components/VisualDom'; import VisualDom from '../components/VisualDom';
import AppContext from '../context/appContext'; import AppContext from '../context/appContext';
@ -146,17 +146,18 @@ export default class BaseRender extends PureComponent {
const schema = props.__schema || {}; const schema = props.__schema || {};
const dataSource = (schema && schema.dataSource) || {}; const dataSource = (schema && schema.dataSource) || {};
// requestHandlersMap 存在才走数据源引擎方案 // requestHandlersMap 存在才走数据源引擎方案
if (props.requestHandlersMap) { if (props?.__appHelper?.requestHandlersMap) {
const { dataSourceMap, reloadDataSource } = createInterpret(dataSource, this, { const { dataSourceMap, reloadDataSource } = createDataSourceEngine(dataSource, this, {
requestHandlersMap: props.requestHandlersMap, requestHandlersMap: props.__appHelper.requestHandlersMap,
}); });
this.dataSourceMap = dataSourceMap; this.dataSourceMap = dataSourceMap;
this.reloadDataSource = () => new Promise((resolve) => { this.reloadDataSource = () => new Promise((resolve) => {
debug('reload data source'); debug('reload data source');
this.__showPlaceholder = true; // this.__showPlaceholder = true;
reloadDataSource().then(() => { reloadDataSource().then(() => {
this.__showPlaceholder = false; // this.__showPlaceholder = false;
// @TODO 是否需要 forceUpate // @TODO 是否需要 forceUpate
// this.forceUpdate();
resolve(); resolve();
}); });
}); });
@ -167,13 +168,13 @@ export default class BaseRender extends PureComponent {
this.reloadDataSource = () => new Promise((resolve, reject) => { this.reloadDataSource = () => new Promise((resolve, reject) => {
debug('reload data source'); debug('reload data source');
if (!this.__dataHelper) { if (!this.__dataHelper) {
this.__showPlaceholder = false; // this.__showPlaceholder = false;
return resolve(); return resolve();
} }
this.__dataHelper this.__dataHelper
.getInitData() .getInitData()
.then((res) => { .then((res) => {
this.__showPlaceholder = false; // this.__showPlaceholder = false;
if (isEmpty(res)) { if (isEmpty(res)) {
this.forceUpdate(); this.forceUpdate();
return resolve(); return resolve();
@ -190,9 +191,10 @@ export default class BaseRender extends PureComponent {
}); });
} }
// 设置容器组件占位若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容 // 设置容器组件占位若设置占位则在初始异步请求完成之前用loading占位且不渲染容器组件内部内容
this.__showPlaceholder = this.__parseData(schema.props && schema.props.autoLoading) && (dataSource.list || []).some( // @TODO __showPlaceholder 的逻辑一旦开启就关不掉,先注释掉了
/* this.__showPlaceholder = this.__parseData(schema.props && schema.props.autoLoading) && (dataSource.list || []).some(
(item) => !!this.__parseData(item.isInit), (item) => !!this.__parseData(item.isInit),
); ); */
}; };
__render = () => { __render = () => {
@ -563,6 +565,10 @@ export default class BaseRender extends PureComponent {
return checkProps(props); return checkProps(props);
}; };
get requestHandlersMap() {
return this.appHelper && this.appHelper.requestHandlersMap;
}
get utils() { get utils() {
return this.appHelper && this.appHelper.utils; return this.appHelper && this.appHelper.utils;
} }

View File

@ -105,7 +105,6 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
components={renderer.components} components={renderer.components}
appHelper={renderer.context} appHelper={renderer.context}
// context={renderer.context} // context={renderer.context}
requestHandlersMap={host.requestHandlersMap}
designMode={designMode} designMode={designMode}
device={device} device={device}
suspended={renderer.suspended} suspended={renderer.suspended}

View File

@ -48,6 +48,9 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
// sync designMode // sync designMode
this._designMode = host.designMode; this._designMode = host.designMode;
// sync requestHandlersMap
this._requestHandlersMap = host.requestHandlersMap;
// sync suspended // sync suspended
// sync scope // sync scope
@ -69,6 +72,7 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
constants: { constants: {
name: 'demo', name: 'demo',
}, },
requestHandlersMap: this._requestHandlersMap,
}; };
}); });
} }
@ -114,6 +118,12 @@ export class SimulatorRenderer implements BuiltinSimulatorRenderer {
return this._designMode; return this._designMode;
} }
@obx.ref private _requestHandlersMap = null;
@computed get requestHandlersMap(): any {
return this._requestHandlersMap;
}
@obx.ref private _device = 'default'; @obx.ref private _device = 'default';
@computed get device() { @computed get device() {

View File

@ -35,6 +35,7 @@ export interface IAppData {
containerId?: string; containerId?: string;
components?: IComponents; components?: IComponents;
componentsMap?: IComponentMap[]; componentsMap?: IComponentMap[];
requestHandlersMap?: any;
utils?: IUtils; utils?: IUtils;
constants?: IConstants; constants?: IConstants;
i18n?: I18n; i18n?: I18n;
@ -116,6 +117,9 @@ export default class Provider {
componentsMap: IComponentMap[] = []; componentsMap: IComponentMap[] = [];
// @TODO 类型定义
requestHandlersMap: any = null;
history: HistoryMode = 'hash'; history: HistoryMode = 'hash';
containerId = ''; containerId = '';
@ -147,6 +151,7 @@ export default class Provider {
containerId, containerId,
components, components,
componentsMap, componentsMap,
requestHandlersMap,
utils, utils,
constants, constants,
i18n, i18n,
@ -160,11 +165,13 @@ export default class Provider {
this.registerComponentsMap(componentsMap); this.registerComponentsMap(componentsMap);
this.registerUtils(utils); this.registerUtils(utils);
this.registerContants(constants); this.registerContants(constants);
this.registerRequestHandlersMap(requestHandlersMap);
resolve({ resolve({
history: this.getHistory(), history: this.getHistory(),
components: this.getComponents(), components: this.getComponents(),
utils: this.getUtils(), utils: this.getUtils(),
containerId: this.getContainerId(), containerId: this.getContainerId(),
requestHandlersMap: this.getRequestHandlersMap(),
}); });
} catch (err) { } catch (err) {
reject(err); reject(err);
@ -288,6 +295,13 @@ export default class Provider {
this.constants = constants; this.constants = constants;
} }
registerRequestHandlersMap(requestHandlersMap: any) {
if (!requestHandlersMap) {
return;
}
this.requestHandlersMap = requestHandlersMap;
}
setLayoutConfig(config: ILayoutConfig | undefined) { setLayoutConfig(config: ILayoutConfig | undefined) {
if (!config) { if (!config) {
return; return;
@ -355,6 +369,10 @@ export default class Provider {
return this.constants; return this.constants;
} }
getRequestHandlersMap() {
return this.requestHandlersMap;
}
getComponentsMap() { getComponentsMap() {
return this.componentsMap; return this.componentsMap;
} }