mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-27 20:30:28 +00:00
feat: 🎸 support parsing fusion source code
This commit is contained in:
parent
d4cc3e5176
commit
5895cf1413
@ -1,48 +0,0 @@
|
||||
import LocalAccesser from './accesser/LocalAccesser';
|
||||
import OnlineAccesser from './accesser/OnlineAccesser';
|
||||
import { IComponentMaterial } from './otter-core';
|
||||
import { IAccesser, IMaterializeOptions } from './types';
|
||||
|
||||
/**
|
||||
* 物料化(将普通组件包装为可接入和可流通的物料组件的过程,称为物料化)运行于 node 端
|
||||
* @class Materialize
|
||||
*/
|
||||
class Materialize {
|
||||
/**
|
||||
* 物料化配置项
|
||||
* @private
|
||||
* @type {IMaterializeOptions}
|
||||
* @memberof Materialize
|
||||
*/
|
||||
private options: IMaterializeOptions;
|
||||
|
||||
/**
|
||||
* 接入器
|
||||
* @private
|
||||
* @type {IAccesser}
|
||||
* @memberof Materialize
|
||||
*/
|
||||
private accesser?: IAccesser;
|
||||
|
||||
constructor(options: IMaterializeOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始物料化
|
||||
*
|
||||
* @returns {Promise<IMaterialinSchema>}
|
||||
* @memberof Materialize
|
||||
*/
|
||||
public async start(): Promise<IComponentMaterial> {
|
||||
// 分发请求到对应接入器
|
||||
if (this.options.accesser === 'local') {
|
||||
this.accesser = new LocalAccesser(this.options);
|
||||
} else {
|
||||
this.accesser = new OnlineAccesser(this.options);
|
||||
}
|
||||
return this.accesser.access();
|
||||
}
|
||||
}
|
||||
|
||||
export default Materialize;
|
||||
@ -1,26 +0,0 @@
|
||||
import { IComponentMaterial } from '../otter-core';
|
||||
import { IAccesser, IMaterializeOptions } from '../types';
|
||||
|
||||
/**
|
||||
* 接入器模板基类
|
||||
* @abstract
|
||||
* @class BaseAccesser
|
||||
* @implements {IAccesser}
|
||||
*/
|
||||
abstract class BaseAccesser implements IAccesser {
|
||||
/**
|
||||
* 物料化配置项
|
||||
* @protected
|
||||
* @type {IMaterializeOptions}
|
||||
* @memberof BaseAccesser
|
||||
*/
|
||||
protected options: IMaterializeOptions;
|
||||
|
||||
constructor(options: IMaterializeOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public abstract access(): Promise<IComponentMaterial>;
|
||||
}
|
||||
|
||||
export default BaseAccesser;
|
||||
@ -1,78 +0,0 @@
|
||||
import Generator from '../generator/Generator';
|
||||
import { debug, IComponentMaterial } from '../otter-core';
|
||||
import BaseParser from '../parser/BaseParser';
|
||||
import ReactParser from '../parser/ReactParser';
|
||||
import Scanner from '../scanner/Scanner';
|
||||
import { IMaterialParsedModel, IMaterialScanModel, IParser } from '../types';
|
||||
import BaseAccesser from './BaseAccesser';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
|
||||
/**
|
||||
* 本地接入器
|
||||
* @class LocalAccesser
|
||||
* @extends {BaseAccesser}
|
||||
*/
|
||||
class LocalAccesser extends BaseAccesser {
|
||||
/**
|
||||
* 扫描器实例
|
||||
* @private
|
||||
* @type {Scanner}
|
||||
* @memberof LocalAccesser
|
||||
*/
|
||||
private scanner!: Scanner;
|
||||
|
||||
/**
|
||||
* 解析器实例
|
||||
* @private
|
||||
* @type {IParser}
|
||||
* @memberof LocalAccesser
|
||||
*/
|
||||
private parser!: IParser;
|
||||
|
||||
/**
|
||||
* 生成器实例
|
||||
* @private
|
||||
* @type {Generator}
|
||||
* @memberof LocalAccesser
|
||||
*/
|
||||
private generator!: Generator;
|
||||
|
||||
public async access(): Promise<IComponentMaterial> {
|
||||
await this.init();
|
||||
// 开始扫描
|
||||
const matScanModel: IMaterialScanModel = await this.scanner.scan();
|
||||
log('matScanModel', matScanModel);
|
||||
// 开始解析
|
||||
const matParsedModels: IMaterialParsedModel[] = await this.parser.parse(
|
||||
matScanModel,
|
||||
);
|
||||
log('matParsedModels', matParsedModels);
|
||||
// 开始生产
|
||||
const material: IComponentMaterial = await this.generator.generate(
|
||||
matScanModel,
|
||||
matParsedModels,
|
||||
);
|
||||
log('material', material);
|
||||
return material;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
* @private
|
||||
* @returns {Promise<void>}
|
||||
* @memberof LocalAccesser
|
||||
*/
|
||||
private async init(): Promise<void> {
|
||||
const options = this.options;
|
||||
this.scanner = new Scanner(options);
|
||||
const ecology = await BaseParser.recognizeEcology(options);
|
||||
if (ecology === 'react') {
|
||||
// debugger;
|
||||
this.parser = new ReactParser(options);
|
||||
this.generator = new Generator(options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default LocalAccesser;
|
||||
@ -1,121 +0,0 @@
|
||||
import spawn from 'cross-spawn-promise';
|
||||
import { ensureDir, ensureFile, writeFile } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import semver from 'semver';
|
||||
import uuid from 'short-uuid';
|
||||
import { debug, IComponentMaterial, OtterError } from '../otter-core';
|
||||
import { IMaterializeOptions } from '../types';
|
||||
import BaseAccesser from './BaseAccesser';
|
||||
import LocalAccesser from './LocalAccesser';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
|
||||
/**
|
||||
* 在线接入
|
||||
* @class OnlineAccesser
|
||||
* @extends {BaseAccesser}
|
||||
*/
|
||||
class OnlineAccesser extends BaseAccesser {
|
||||
/**
|
||||
* 临时目录
|
||||
*
|
||||
* @private
|
||||
* @type {string}
|
||||
* @memberof OnlineAccesser
|
||||
*/
|
||||
private tempDir: string = '';
|
||||
|
||||
public async access(): Promise<IComponentMaterial> {
|
||||
// 创建临时目录
|
||||
this.tempDir = await this.createTempDir();
|
||||
// 创建组件包
|
||||
const { name, version } = this.getPkgNameAndVersion(this.options.entry);
|
||||
await this.createFakePackage({
|
||||
pkgName: name,
|
||||
pkgVersion: version,
|
||||
});
|
||||
// 将问题转化为本地物料化场景
|
||||
const options: IMaterializeOptions = {
|
||||
cwd: this.tempDir,
|
||||
entry: join(this.tempDir, 'node_modules', name),
|
||||
accesser: 'local',
|
||||
isExportedAsMultiple: this.options.isExportedAsMultiple,
|
||||
};
|
||||
const localAccesser = new LocalAccesser(options);
|
||||
return localAccesser.access();
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建组件包
|
||||
*
|
||||
* @private
|
||||
* @param {{
|
||||
* pkgName: string;
|
||||
* pkgVersion: string;
|
||||
* }} params
|
||||
* @returns {Promise<void>}
|
||||
* @memberof OnlineAccesser
|
||||
*/
|
||||
private async createFakePackage(params: {
|
||||
pkgName: string;
|
||||
pkgVersion: string;
|
||||
}): Promise<void> {
|
||||
// 创建临时组件包
|
||||
const tempDir = this.tempDir;
|
||||
const pkgJsonFilePath = join(tempDir, 'package.json');
|
||||
await ensureFile(pkgJsonFilePath);
|
||||
await writeFile(
|
||||
pkgJsonFilePath,
|
||||
JSON.stringify({
|
||||
name: params.pkgName,
|
||||
version: params.pkgVersion,
|
||||
dependencies: {
|
||||
[params.pkgName]: params.pkgVersion,
|
||||
},
|
||||
}),
|
||||
);
|
||||
// 安装依赖
|
||||
const npmClient = this.options.npmClient || 'tnpm';
|
||||
await spawn(npmClient, ['i'], { stdio: 'inherit', cwd: tempDir } as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建临时目录
|
||||
*
|
||||
* @private
|
||||
* @returns {Promise<string>} 返回临时文件夹路径
|
||||
* @memberof LocalGenerator
|
||||
*/
|
||||
private async createTempDir(): Promise<string> {
|
||||
const tempDirName = uuid.generate();
|
||||
const tempDir = join(__dirname, '../../node_modules/.temp/', tempDirName);
|
||||
await ensureDir(tempDir);
|
||||
log('create temp dir successfully', tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分离物料组件名称和版本号
|
||||
*
|
||||
* @private
|
||||
* @param {string} pkgNameWithVersion
|
||||
* @returns {{ [key: string]: any }}
|
||||
* @memberof OnlineAccesser
|
||||
*/
|
||||
private getPkgNameAndVersion(
|
||||
pkgNameWithVersion: string,
|
||||
): { [key: string]: any } {
|
||||
const matches = pkgNameWithVersion.match(/(@\d+\.\d+\.\d+)$/);
|
||||
if (!matches) {
|
||||
throw new OtterError(`Illegal semver version: ${pkgNameWithVersion}`);
|
||||
}
|
||||
const semverObj = semver.coerce(matches[0]);
|
||||
const name = pkgNameWithVersion.replace(matches[0], '');
|
||||
return {
|
||||
version: semverObj && semverObj.version,
|
||||
name,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export default OnlineAccesser;
|
||||
@ -1,37 +0,0 @@
|
||||
import { writeFile } from 'fs-extra';
|
||||
import { IComponentMaterial } from '../otter-core';
|
||||
|
||||
/**
|
||||
* 配置 manifest(物料化场景下可以使用此扩展点)
|
||||
* - 扩展点名称:mat:config:manifest
|
||||
* - 对应 Studio 所处状态:进入 就绪态 前
|
||||
*
|
||||
* @export
|
||||
* @param {{
|
||||
* manifestObj: IComponentMaterial,
|
||||
* manifestFilePath: string,
|
||||
* }} params
|
||||
* @returns {Promise<{
|
||||
* manifestJS: string,
|
||||
* manifestFilePath: string,
|
||||
* manifestObj: IComponentMaterial,
|
||||
* }>}
|
||||
*/
|
||||
export default async function matConfigManifest(params: {
|
||||
manifestObj: IComponentMaterial;
|
||||
manifestFilePath: string;
|
||||
}): Promise<{
|
||||
manifestJSON: string;
|
||||
manifestFilePath: string;
|
||||
manifestObj: IComponentMaterial;
|
||||
}> {
|
||||
const manifestJSON = JSON.stringify(params.manifestObj);
|
||||
|
||||
await writeFile(params.manifestFilePath, manifestJSON);
|
||||
|
||||
return Promise.resolve({
|
||||
manifestJSON,
|
||||
manifestObj: params.manifestObj,
|
||||
manifestFilePath: params.manifestFilePath,
|
||||
});
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
import { ExtensionName } from '../types';
|
||||
import MatConfigManifest from './MatConfigManifest';
|
||||
|
||||
export default {
|
||||
[ExtensionName.CONFIGMANIFEST]: MatConfigManifest,
|
||||
};
|
||||
59
packages/material-parser/src/generate.ts
Normal file
59
packages/material-parser/src/generate.ts
Normal file
@ -0,0 +1,59 @@
|
||||
import { debug, ComponentMeta } from './otter-core';
|
||||
import { IMaterialParsedModel, IMaterialScanModel } from './types';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
|
||||
export default async function(
|
||||
matScanModel: IMaterialScanModel,
|
||||
matParsedModels: IMaterialParsedModel[],
|
||||
): Promise<ComponentMeta[]> {
|
||||
const containerList = [];
|
||||
for (const matParsedModel of matParsedModels) {
|
||||
// TODO 可以开放扩展点让上层使用者指定导出哪些组件或者不导出哪些组件
|
||||
// 默认排除掉 defaultExportName 为空的组件
|
||||
if (!matParsedModel.componentName) {
|
||||
log('skip');
|
||||
continue;
|
||||
}
|
||||
// 组装 manifest
|
||||
const manifest: any = await genManifest(matScanModel, matParsedModel);
|
||||
|
||||
containerList.push(manifest);
|
||||
}
|
||||
|
||||
return containerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 manifest
|
||||
*
|
||||
* @param {IMaterialParsedModel} matParsedModel
|
||||
* @returns {Promise<
|
||||
* manifestObj: ComponentMeta, // 组件描述
|
||||
* >}
|
||||
* @memberof LocalGenerator
|
||||
*/
|
||||
export async function genManifest(
|
||||
matScanModel: IMaterialScanModel,
|
||||
matParsedModel: IMaterialParsedModel,
|
||||
): Promise<ComponentMeta> {
|
||||
const manifestObj: Partial<ComponentMeta> = {
|
||||
componentName: matParsedModel.componentName,
|
||||
title: matScanModel.pkgName,
|
||||
docUrl: '',
|
||||
screenshot: '',
|
||||
npm: {
|
||||
package: matScanModel.pkgName,
|
||||
version: matScanModel.pkgVersion,
|
||||
exportName: matParsedModel.componentName,
|
||||
main: matScanModel.mainEntry,
|
||||
destructuring: false,
|
||||
subName: '',
|
||||
},
|
||||
};
|
||||
|
||||
// 填充 props
|
||||
manifestObj.props = matParsedModel.props;
|
||||
// 执行扩展点
|
||||
return manifestObj as ComponentMeta;
|
||||
}
|
||||
@ -1,175 +0,0 @@
|
||||
import { dirname, join } from 'path';
|
||||
import defaultExtension from '../extensions';
|
||||
import { debug, IComponentMaterial, PropsSection } from '../otter-core';
|
||||
import {
|
||||
IGenerator,
|
||||
IMaterializeOptions,
|
||||
IMaterialParsedModel,
|
||||
IMaterialScanModel,
|
||||
} from '../types';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
|
||||
/**
|
||||
* 用于物料工作台
|
||||
*/
|
||||
class Generator implements IGenerator {
|
||||
/**
|
||||
* 物料化配置项
|
||||
* @protected
|
||||
* @type {IMaterializeOptions}
|
||||
* @memberof BaseGenerator
|
||||
*/
|
||||
/**
|
||||
* 物料化配置项
|
||||
* @protected
|
||||
* @type {IMaterializeOptions}
|
||||
* @memberof BaseGenerator
|
||||
*/
|
||||
protected options!: IMaterializeOptions;
|
||||
|
||||
constructor(options: IMaterializeOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public async generate(
|
||||
matScanModel: IMaterialScanModel,
|
||||
matParsedModels: IMaterialParsedModel[],
|
||||
): Promise<any> {
|
||||
// const model: IMaterialinSchema = {} as any;
|
||||
// 标记协议版本号
|
||||
// model.version = '1.0.0';
|
||||
// 组装 pkgInfo
|
||||
// model.pkgInfo = pkgInfo;
|
||||
const containerList = [];
|
||||
for (const matParsedModel of matParsedModels) {
|
||||
// TODO 可以开放扩展点让上层使用者指定导出哪些组件或者不导出哪些组件
|
||||
// 默认排除掉 defaultExportName 为空的组件
|
||||
if (
|
||||
!matParsedModel.defaultExportName ||
|
||||
!matParsedModel.defaultExportName.length
|
||||
) {
|
||||
log('skip', matParsedModel.filePath);
|
||||
continue;
|
||||
}
|
||||
// 组装 manifest
|
||||
const manifest: any = await this.genManifest(
|
||||
matScanModel,
|
||||
matParsedModel,
|
||||
);
|
||||
|
||||
containerList.push(manifest);
|
||||
}
|
||||
|
||||
// const components: IMaterialinComponent[] = bundle.bundleObj.components;
|
||||
// Object.keys(bundle.bundleObj.Modules).forEach(key => {
|
||||
// const { origin, manifest } = bundle.bundleObj.Modules[key];
|
||||
// const component: IMaterialinComponent = {
|
||||
// componentName: key,
|
||||
// origin,
|
||||
// manifest,
|
||||
// };
|
||||
// components.push(component);
|
||||
// });
|
||||
// model.components = components;
|
||||
// log('materialsModel', JSON.stringify(bundle.bundleObj));
|
||||
|
||||
return containerList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 manifest
|
||||
*
|
||||
* @param {IMaterialParsedModel} matParsedModel
|
||||
* @returns {Promise<{
|
||||
* manifestFilePath: string, // manifest 文件路径
|
||||
* manifestJS: string, // manifest 文件内容
|
||||
* manifestObj: IMaterialinManifest, // manifest 文件对象
|
||||
* }>}
|
||||
* @memberof LocalGenerator
|
||||
*/
|
||||
public async genManifest(
|
||||
matScanModel: IMaterialScanModel,
|
||||
matParsedModel: IMaterialParsedModel,
|
||||
): Promise<{
|
||||
manifestFilePath: string; // manifest 文件路径
|
||||
manifestObj: IComponentMaterial; // manifest 文件对象
|
||||
}> {
|
||||
const manifestObj: Partial<IComponentMaterial> = {
|
||||
// componentName: matParsedModel.defaultExportName,
|
||||
title: matScanModel.pkgName,
|
||||
docUrl: '',
|
||||
screenshot: '',
|
||||
npm: {
|
||||
package: matScanModel.pkgName,
|
||||
version: matScanModel.pkgVersion,
|
||||
exportName: '', // matParsedModel.defaultExportName,
|
||||
main: matScanModel.mainEntry,
|
||||
destructuring: false,
|
||||
subName: '',
|
||||
},
|
||||
};
|
||||
|
||||
const defaultManifestFilePath = join(
|
||||
dirname(matParsedModel.filePath),
|
||||
'./manifest.json',
|
||||
);
|
||||
|
||||
// 填充 props
|
||||
manifestObj.props = matParsedModel.props;
|
||||
// 执行扩展点
|
||||
const manifest: any = await this.executeExtensionPoint(
|
||||
'mat:config:manifest',
|
||||
{
|
||||
manifestObj,
|
||||
manifestFilePath: defaultManifestFilePath,
|
||||
},
|
||||
);
|
||||
return {
|
||||
manifestObj: manifest.manifestObj,
|
||||
manifestFilePath: manifest.manifestFilePath,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 填充 props
|
||||
*
|
||||
* @public
|
||||
* @param {IMaterialParsedModel} matParsedModel
|
||||
* @returns {IMaterialinProp[]}
|
||||
* @memberof BaseGenerator
|
||||
*/
|
||||
public populateProps(
|
||||
matParsedModel: IMaterialParsedModel,
|
||||
): PropsSection['props'] {
|
||||
// @ts-ignore
|
||||
return matParsedModel.props;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行扩展点
|
||||
* @param {string} extName 扩展点名称
|
||||
* @param {...any[]} args 参数
|
||||
* @returns {Promise<any>}
|
||||
* @memberof BaseGenerator
|
||||
*/
|
||||
public async executeExtensionPoint(
|
||||
extName: string,
|
||||
...args: any[]
|
||||
): Promise<any> {
|
||||
const options = this.options;
|
||||
const optionsExtensions: any = options.extensions;
|
||||
const defaultExtensions: any = defaultExtension;
|
||||
|
||||
const ext: any =
|
||||
optionsExtensions && optionsExtensions[extName]
|
||||
? optionsExtensions[extName]
|
||||
: defaultExtensions[extName];
|
||||
if (!ext) {
|
||||
throw new Error(`Unsupported extension point: ${extName}`);
|
||||
}
|
||||
return ext(...args);
|
||||
}
|
||||
}
|
||||
|
||||
export default Generator;
|
||||
@ -1,8 +1,26 @@
|
||||
import Materialize from './Materialize';
|
||||
|
||||
export { default as validate } from './validate';
|
||||
export { default as schema } from './validate/schema.json';
|
||||
|
||||
export * from './types';
|
||||
|
||||
export default Materialize;
|
||||
import { IMaterializeOptions } from './types';
|
||||
import { ComponentMeta } from './otter-core';
|
||||
import scan from './scan';
|
||||
import generate from './generate';
|
||||
import parse from './parse';
|
||||
import localize from './localize';
|
||||
|
||||
export default async function(
|
||||
options: IMaterializeOptions,
|
||||
): Promise<ComponentMeta[]> {
|
||||
const { accesser = 'local' } = options;
|
||||
if (accesser === 'online') {
|
||||
const { entry, cwd } = await localize(options);
|
||||
options.entry = entry;
|
||||
options.cwd = cwd;
|
||||
}
|
||||
const scanedModel = await scan(options);
|
||||
const parsedModel = await parse(scanedModel.modules[0]);
|
||||
const result = await generate(scanedModel, parsedModel);
|
||||
return result;
|
||||
}
|
||||
|
||||
108
packages/material-parser/src/localize.ts
Normal file
108
packages/material-parser/src/localize.ts
Normal file
@ -0,0 +1,108 @@
|
||||
import spawn from 'cross-spawn-promise';
|
||||
import { ensureDir, ensureFile, writeFile } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import semver from 'semver';
|
||||
import uuid from 'short-uuid';
|
||||
import { debug, OtterError } from './otter-core';
|
||||
import { IMaterializeOptions } from './types';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
|
||||
/**
|
||||
* 创建组件包
|
||||
*
|
||||
* @private
|
||||
* @param {{
|
||||
* pkgName: string;
|
||||
* pkgVersion: string;
|
||||
* }} params
|
||||
* @returns {Promise<void>}
|
||||
* @memberof OnlineAccesser
|
||||
*/
|
||||
export async function createFakePackage(params: {
|
||||
tempDir: string;
|
||||
pkgName: string;
|
||||
pkgVersion: string;
|
||||
npmClient?: string;
|
||||
}): Promise<void> {
|
||||
// 创建临时组件包
|
||||
const tempDir = params.tempDir;
|
||||
const pkgJsonFilePath = join(tempDir, 'package.json');
|
||||
await ensureFile(pkgJsonFilePath);
|
||||
await writeFile(
|
||||
pkgJsonFilePath,
|
||||
JSON.stringify({
|
||||
name: params.pkgName,
|
||||
version: params.pkgVersion,
|
||||
dependencies: {
|
||||
[params.pkgName]: params.pkgVersion,
|
||||
},
|
||||
}),
|
||||
);
|
||||
debugger;
|
||||
// 安装依赖
|
||||
const npmClient = params.npmClient || 'tnpm';
|
||||
await spawn(npmClient, ['i'], { stdio: 'inherit', cwd: tempDir } as any);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建临时目录
|
||||
*
|
||||
* @private
|
||||
* @returns {Promise<string>} 返回临时文件夹路径
|
||||
* @memberof LocalGenerator
|
||||
*/
|
||||
export async function createTempDir(): Promise<string> {
|
||||
const tempDirName = uuid.generate();
|
||||
const tempDir = join(__dirname, '../../node_modules/.temp/', tempDirName);
|
||||
await ensureDir(tempDir);
|
||||
log('create temp dir successfully', tempDir);
|
||||
return tempDir;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分离物料组件名称和版本号
|
||||
*
|
||||
* @private
|
||||
* @param {string} pkgNameWithVersion
|
||||
* @returns {{ [key: string]: any }}
|
||||
* @memberof OnlineAccesser
|
||||
*/
|
||||
export function getPkgNameAndVersion(
|
||||
pkgNameWithVersion: string,
|
||||
): { [key: string]: any } {
|
||||
const matches = pkgNameWithVersion.match(/(@\d+\.\d+\.\d+)$/);
|
||||
if (!matches) {
|
||||
throw new OtterError(`Illegal semver version: ${pkgNameWithVersion}`);
|
||||
}
|
||||
const semverObj = semver.coerce(matches[0]);
|
||||
const name = pkgNameWithVersion.replace(matches[0], '');
|
||||
return {
|
||||
version: semverObj && semverObj.version,
|
||||
name,
|
||||
};
|
||||
}
|
||||
|
||||
// 将问题转化为本地物料化场景
|
||||
export default async function localize(
|
||||
options: IMaterializeOptions,
|
||||
): Promise<{
|
||||
cwd: string;
|
||||
entry: string;
|
||||
}> {
|
||||
// 创建临时目录
|
||||
const tempDir = await createTempDir();
|
||||
// 创建组件包
|
||||
const { name, version } = getPkgNameAndVersion(options.entry);
|
||||
await createFakePackage({
|
||||
pkgName: name,
|
||||
pkgVersion: version,
|
||||
tempDir,
|
||||
npmClient: options.npmClient,
|
||||
});
|
||||
|
||||
return {
|
||||
cwd: tempDir,
|
||||
entry: join(tempDir, 'node_modules', name),
|
||||
};
|
||||
}
|
||||
@ -8,10 +8,25 @@
|
||||
/**
|
||||
* json schema for low code component protocol
|
||||
*/
|
||||
export type IComponentMaterial = BasicSection & PropsSection & ConfigureSection;
|
||||
export type ComponentMeta = BasicSection & PropsSection & ConfigureSection;
|
||||
export type PropType = BasicType | RequiredType | ComplexType;
|
||||
export type BasicType = "array" | "bool" | "func" | "number" | "object" | "string" | "node" | "element" | "any";
|
||||
export type ComplexType = OneOf | OneOfType | ArrayOf | ObjectOf | Shape | Exact;
|
||||
export type BasicType =
|
||||
| 'array'
|
||||
| 'bool'
|
||||
| 'func'
|
||||
| 'number'
|
||||
| 'object'
|
||||
| 'string'
|
||||
| 'node'
|
||||
| 'element'
|
||||
| 'any';
|
||||
export type ComplexType =
|
||||
| OneOf
|
||||
| OneOfType
|
||||
| ArrayOf
|
||||
| ObjectOf
|
||||
| Shape
|
||||
| Exact;
|
||||
export type ConfigureProp = {
|
||||
title?: string;
|
||||
extraProps?: {
|
||||
@ -28,7 +43,7 @@ export interface BasicSection {
|
||||
screenshot?: string;
|
||||
icon?: string;
|
||||
tags?: string[];
|
||||
devMode?: "proCode" | "lowCode";
|
||||
devMode?: 'proCode' | 'lowCode';
|
||||
npm: Npm;
|
||||
[k: string]: any;
|
||||
}
|
||||
@ -56,31 +71,31 @@ export interface RequiredType {
|
||||
isRequired?: boolean;
|
||||
}
|
||||
export interface OneOf {
|
||||
type: "oneOf";
|
||||
type: 'oneOf';
|
||||
value: (string | number | boolean)[];
|
||||
isRequired?: boolean;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface OneOfType {
|
||||
type: "oneOfType";
|
||||
type: 'oneOfType';
|
||||
value: PropType[];
|
||||
isRequired?: boolean;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface ArrayOf {
|
||||
type: "arrayOf";
|
||||
type: 'arrayOf';
|
||||
value: PropType;
|
||||
isRequired?: boolean;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface ObjectOf {
|
||||
type: "objectOf";
|
||||
type: 'objectOf';
|
||||
value: PropType;
|
||||
isRequired?: boolean;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface Shape {
|
||||
type: "shape";
|
||||
type: 'shape';
|
||||
value: {
|
||||
name?: string;
|
||||
propType?: PropType;
|
||||
@ -89,7 +104,7 @@ export interface Shape {
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface Exact {
|
||||
type: "exact";
|
||||
type: 'exact';
|
||||
value: {
|
||||
name?: string;
|
||||
propType?: PropType;
|
||||
@ -112,38 +127,38 @@ export interface ConfigureSection {
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface ConfigureFieldProp {
|
||||
type: "field";
|
||||
type: 'field';
|
||||
name?: string;
|
||||
setter?: ConfigureFieldSetter;
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface ConfigureFieldSetter {
|
||||
componentName:
|
||||
| "List"
|
||||
| "Object"
|
||||
| "Function"
|
||||
| "Node"
|
||||
| "Mixin"
|
||||
| "Expression"
|
||||
| "Switch"
|
||||
| "Number"
|
||||
| "Input"
|
||||
| "TextArea"
|
||||
| "Date"
|
||||
| "DateYear"
|
||||
| "DateMonth"
|
||||
| "DateRange"
|
||||
| "ColorPicker"
|
||||
| "CodeEditor"
|
||||
| "Select"
|
||||
| "RadioGroup";
|
||||
| 'List'
|
||||
| 'Object'
|
||||
| 'Function'
|
||||
| 'Node'
|
||||
| 'Mixin'
|
||||
| 'Expression'
|
||||
| 'Switch'
|
||||
| 'Number'
|
||||
| 'Input'
|
||||
| 'TextArea'
|
||||
| 'Date'
|
||||
| 'DateYear'
|
||||
| 'DateMonth'
|
||||
| 'DateRange'
|
||||
| 'ColorPicker'
|
||||
| 'CodeEditor'
|
||||
| 'Select'
|
||||
| 'RadioGroup';
|
||||
props?: {
|
||||
[k: string]: any;
|
||||
};
|
||||
[k: string]: any;
|
||||
}
|
||||
export interface ConfigureGroupProp {
|
||||
type: "group";
|
||||
type: 'group';
|
||||
items: ConfigureProp[];
|
||||
[k: string]: any;
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
const { namedTypes: t, NodePath } = require('ast-types');
|
||||
type NodePathType = typeof NodePath;
|
||||
const {
|
||||
getPropertyName,
|
||||
isReactComponentClass,
|
||||
getMemberValuePath,
|
||||
isReactForwardRefCall,
|
||||
printValue,
|
||||
resolveExportDeclaration,
|
||||
resolveToValue,
|
||||
} = require('react-docgen').utils;
|
||||
const resolveFunctionDefinitionToReturnValue = require('react-docgen/dist/utils/resolveFunctionDefinitionToReturnValue');
|
||||
|
||||
function getDefaultValue(path: NodePathType) {
|
||||
let node = path.node;
|
||||
let defaultValue;
|
||||
if (t.Literal.check(node)) {
|
||||
defaultValue = node.raw;
|
||||
} else {
|
||||
if (t.AssignmentPattern.check(path.node)) {
|
||||
path = resolveToValue(path.get('right'));
|
||||
} else {
|
||||
path = resolveToValue(path);
|
||||
}
|
||||
if (t.ImportDeclaration.check(path.node)) {
|
||||
defaultValue = node.name;
|
||||
} else {
|
||||
node = path.node;
|
||||
try {
|
||||
defaultValue = printValue(path);
|
||||
} catch (e) {}
|
||||
}
|
||||
}
|
||||
if (typeof defaultValue !== 'undefined') {
|
||||
return {
|
||||
value: defaultValue,
|
||||
computed:
|
||||
t.CallExpression.check(node) ||
|
||||
t.MemberExpression.check(node) ||
|
||||
t.Identifier.check(node),
|
||||
};
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function getStatelessPropsPath(componentDefinition: any) {
|
||||
const value = resolveToValue(componentDefinition);
|
||||
if (isReactForwardRefCall(value)) {
|
||||
const inner = resolveToValue(value.get('arguments', 0));
|
||||
return inner.get('params', 0);
|
||||
}
|
||||
return value.get('params', 0);
|
||||
}
|
||||
|
||||
function getDefaultPropsPath(componentDefinition: any) {
|
||||
let defaultPropsPath = getMemberValuePath(
|
||||
componentDefinition,
|
||||
'defaultProps',
|
||||
);
|
||||
if (!defaultPropsPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
defaultPropsPath = resolveToValue(defaultPropsPath);
|
||||
if (!defaultPropsPath) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (t.FunctionExpression.check(defaultPropsPath.node)) {
|
||||
// Find the value that is returned from the function and process it if it is
|
||||
// an object literal.
|
||||
const returnValue = resolveFunctionDefinitionToReturnValue(
|
||||
defaultPropsPath,
|
||||
);
|
||||
if (returnValue && t.ObjectExpression.check(returnValue.node)) {
|
||||
defaultPropsPath = returnValue;
|
||||
}
|
||||
}
|
||||
return defaultPropsPath;
|
||||
}
|
||||
|
||||
function getDefaultValuesFromProps(
|
||||
properties: any[],
|
||||
documentation: any,
|
||||
isStateless: boolean,
|
||||
) {
|
||||
properties
|
||||
// Don't evaluate property if component is functional and the node is not an AssignmentPattern
|
||||
.filter(
|
||||
propertyPath =>
|
||||
!isStateless ||
|
||||
t.AssignmentPattern.check(propertyPath.get('value').node),
|
||||
)
|
||||
.forEach(propertyPath => {
|
||||
if (t.Property.check(propertyPath.node)) {
|
||||
const propName = getPropertyName(propertyPath);
|
||||
if (!propName) return;
|
||||
|
||||
const propDescriptor = documentation.getPropDescriptor(propName);
|
||||
const defaultValue = getDefaultValue(
|
||||
isStateless
|
||||
? propertyPath.get('value', 'right')
|
||||
: propertyPath.get('value'),
|
||||
);
|
||||
if (defaultValue) {
|
||||
propDescriptor.defaultValue = defaultValue;
|
||||
}
|
||||
} else if (t.SpreadElement.check(propertyPath.node)) {
|
||||
const resolvedValuePath = resolveToValue(propertyPath.get('argument'));
|
||||
if (t.ObjectExpression.check(resolvedValuePath.node)) {
|
||||
getDefaultValuesFromProps(
|
||||
resolvedValuePath.get('properties'),
|
||||
documentation,
|
||||
isStateless,
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export default function defaultPropsHandler(
|
||||
documentation: any,
|
||||
componentDefinition: any,
|
||||
) {
|
||||
let statelessProps = null;
|
||||
const defaultPropsPath = getDefaultPropsPath(componentDefinition);
|
||||
/**
|
||||
* function, lazy, memo, forwardRef etc components can resolve default props as well
|
||||
*/
|
||||
if (!isReactComponentClass(componentDefinition)) {
|
||||
statelessProps = getStatelessPropsPath(componentDefinition);
|
||||
}
|
||||
|
||||
// Do both statelessProps and defaultProps if both are available so defaultProps can override
|
||||
if (statelessProps && t.ObjectPattern.check(statelessProps.node)) {
|
||||
getDefaultValuesFromProps(
|
||||
statelessProps.get('properties'),
|
||||
documentation,
|
||||
true,
|
||||
);
|
||||
}
|
||||
if (defaultPropsPath && t.ObjectExpression.check(defaultPropsPath.node)) {
|
||||
getDefaultValuesFromProps(
|
||||
defaultPropsPath.get('properties'),
|
||||
documentation,
|
||||
false,
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,11 @@
|
||||
const { handlers } = require('react-docgen');
|
||||
import {
|
||||
propTypeHandler,
|
||||
contextTypeHandler,
|
||||
childContextTypeHandler,
|
||||
} from './propTypeHandler';
|
||||
import defaultPropsHandler from './defaultPropsHandler';
|
||||
|
||||
const { handlers } = require('react-docgen');
|
||||
|
||||
const defaultHandlers = [
|
||||
propTypeHandler,
|
||||
@ -12,7 +14,7 @@ const defaultHandlers = [
|
||||
handlers.propTypeCompositionHandler,
|
||||
handlers.propDocBlockHandler,
|
||||
handlers.flowTypeHandler,
|
||||
handlers.defaultPropsHandler,
|
||||
defaultPropsHandler,
|
||||
handlers.componentDocblockHandler,
|
||||
handlers.displayNameHandler,
|
||||
handlers.componentMethodsHandler,
|
||||
@ -8,7 +8,7 @@
|
||||
*/
|
||||
|
||||
import { namedTypes as t, visit } from 'ast-types';
|
||||
import { throwStatement } from '@babel/types';
|
||||
|
||||
const {
|
||||
resolveToValue,
|
||||
getPropType,
|
||||
@ -29,7 +29,6 @@ function getRoot(node: any) {
|
||||
}
|
||||
return root;
|
||||
}
|
||||
// import type Documentation from '../Documentation';
|
||||
|
||||
function isPropTypesExpression(path: any) {
|
||||
const moduleName = resolveToModule(path);
|
||||
@ -81,11 +80,12 @@ function amendPropTypes(getDescriptor: any, path: any) {
|
||||
|
||||
function getDefinePropertyValuePath(nodePath: any, propName: string) {
|
||||
const program = getRoot(nodePath);
|
||||
const componentName = nodePath.node.id.name;
|
||||
let resultPath = nodePath;
|
||||
if (!nodePath.node.id) return;
|
||||
const componentName = nodePath.node.id.name;
|
||||
|
||||
visit(program, {
|
||||
visitCallExpression: function(path) {
|
||||
visitCallExpression(path) {
|
||||
const args = path.get('arguments');
|
||||
const argsNodeList = args.value;
|
||||
if (
|
||||
39
packages/material-parser/src/parse/index.ts
Normal file
39
packages/material-parser/src/parse/index.ts
Normal file
@ -0,0 +1,39 @@
|
||||
const reactDocs = require('react-docgen');
|
||||
import { transformItem } from './transform';
|
||||
import { debug } from '../otter-core';
|
||||
import { IMaterialParsedModel, IMaterialScanModel } from '../types';
|
||||
import resolver from './resolver';
|
||||
import handlers from './handlers';
|
||||
|
||||
export default function parse(params: {
|
||||
fileContent: string;
|
||||
filePath: string;
|
||||
}): Promise<IMaterialParsedModel[]> {
|
||||
const { fileContent, filePath } = params;
|
||||
const result = reactDocs.parse(
|
||||
fileContent,
|
||||
(ast: any) => {
|
||||
ast.__path = filePath;
|
||||
return resolver(ast);
|
||||
},
|
||||
handlers,
|
||||
);
|
||||
const coms = result.reduce((res: any[], info: any) => {
|
||||
if (!info || !info.props) return res;
|
||||
const props = Object.keys(info.props).reduce((acc: any[], name) => {
|
||||
try {
|
||||
const item: any = transformItem(name, info.props[name]);
|
||||
acc.push(item);
|
||||
} catch (e) {
|
||||
} finally {
|
||||
return acc;
|
||||
}
|
||||
}, []);
|
||||
res.push({
|
||||
componentName: info.displayName,
|
||||
props,
|
||||
});
|
||||
return res;
|
||||
}, []);
|
||||
return coms;
|
||||
}
|
||||
@ -7,6 +7,12 @@
|
||||
*/
|
||||
|
||||
import { namedTypes as t, visit } from 'ast-types';
|
||||
import checkIsIIFE from './checkIsIIFE';
|
||||
import resolveHOC from './resolveHOC';
|
||||
import resolveIIFE from './resolveIIFE';
|
||||
import resolveImport from './resolveImport';
|
||||
import resolveTranspiledClass from './resolveTranspiledClass';
|
||||
|
||||
const {
|
||||
isExportsOrModuleAssignment,
|
||||
isReactComponentClass,
|
||||
@ -17,13 +23,6 @@ const {
|
||||
resolveExportDeclaration,
|
||||
resolveToValue,
|
||||
} = require('react-docgen').utils;
|
||||
import checkIsIIFE from './checkIsIIFE';
|
||||
import resolveHOC from './resolveHOC';
|
||||
import resolveIIFE from './resolveIIFE';
|
||||
import resolveTranspiledClass from './resolveTranspiledClass';
|
||||
|
||||
const ERROR_MULTIPLE_DEFINITIONS =
|
||||
'Multiple exported component definitions found.';
|
||||
|
||||
function ignore() {
|
||||
return false;
|
||||
@ -57,7 +56,7 @@ function resolveDefinition(definition: any) {
|
||||
return null;
|
||||
}
|
||||
|
||||
function getDefinition(definition: any) {
|
||||
function getDefinition(definition: any): any {
|
||||
if (checkIsIIFE(definition)) {
|
||||
definition = resolveToValue(resolveIIFE(definition));
|
||||
if (!isComponentDefinition(definition)) {
|
||||
@ -70,14 +69,17 @@ function getDefinition(definition: any) {
|
||||
if (!isComponentDefinition(definition)) {
|
||||
definition = resolveTranspiledClass(definition);
|
||||
}
|
||||
} else if (t.SequenceExpression.check(definition.node)) {
|
||||
return getDefinition(
|
||||
resolveToValue(definition.get('expressions').get(0)),
|
||||
);
|
||||
} else {
|
||||
definition = resolveImport(
|
||||
definition,
|
||||
findAllExportedComponentDefinition,
|
||||
);
|
||||
}
|
||||
}
|
||||
// definition = resolveToValue(resolveIIFE(definition));
|
||||
// if (!isComponentDefinition(definition)) {
|
||||
// definition = resolveTranspiledClass(definition);
|
||||
// }
|
||||
// definition = resolveToValue(resolveHOC(definition));
|
||||
|
||||
return definition;
|
||||
}
|
||||
/**
|
||||
@ -95,33 +97,37 @@ function getDefinition(definition: any) {
|
||||
* export default Definition;
|
||||
* export var Definition = ...;
|
||||
*/
|
||||
export default function findExportedComponentDefinition(ast: any) {
|
||||
let foundDefinition: any;
|
||||
export default function findAllExportedComponentDefinition(ast: any) {
|
||||
const components: any[] = [];
|
||||
|
||||
function exportDeclaration(path: any) {
|
||||
const definitions = resolveExportDeclaration(path).reduce(
|
||||
(acc: any, definition: any) => {
|
||||
const definitions = resolveExportDeclaration(path)
|
||||
.reduce((acc: any[], definition: any) => {
|
||||
if (isComponentDefinition(definition)) {
|
||||
acc.push(definition);
|
||||
} else {
|
||||
definition = getDefinition(definition);
|
||||
if (isComponentDefinition(definition)) {
|
||||
acc.push(definition);
|
||||
if (!Array.isArray(definition)) {
|
||||
definition = [definition];
|
||||
}
|
||||
definition.forEach((def: any) => {
|
||||
if (isComponentDefinition(def)) {
|
||||
acc.push(def);
|
||||
}
|
||||
});
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
[],
|
||||
);
|
||||
}, [])
|
||||
.map((definition: any) => resolveDefinition(definition));
|
||||
|
||||
if (definitions.length === 0) {
|
||||
return false;
|
||||
}
|
||||
if (definitions.length > 1 || foundDefinition) {
|
||||
// If a file exports multiple components, ... complain!
|
||||
throw new Error(ERROR_MULTIPLE_DEFINITIONS);
|
||||
}
|
||||
foundDefinition = resolveDefinition(definitions[0]);
|
||||
definitions.forEach((definition: any) => {
|
||||
if (definition && components.indexOf(definition) === -1) {
|
||||
components.push(definition);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -142,6 +148,12 @@ export default function findExportedComponentDefinition(ast: any) {
|
||||
|
||||
visitExportNamedDeclaration: exportDeclaration,
|
||||
visitExportDefaultDeclaration: exportDeclaration,
|
||||
visitExportAllDeclaration: function(path) {
|
||||
components.push(
|
||||
...resolveImport(path, findAllExportedComponentDefinition),
|
||||
);
|
||||
return false;
|
||||
},
|
||||
|
||||
visitAssignmentExpression(path: any) {
|
||||
// Ignore anything that is not `exports.X = ...;` or
|
||||
@ -155,14 +167,14 @@ export default function findExportedComponentDefinition(ast: any) {
|
||||
if (!isComponentDefinition(path)) {
|
||||
path = getDefinition(path);
|
||||
}
|
||||
if (foundDefinition) {
|
||||
// If a file exports multiple components, ... complain!
|
||||
throw new Error(ERROR_MULTIPLE_DEFINITIONS);
|
||||
|
||||
const definition = resolveDefinition(path);
|
||||
if (definition && components.indexOf(definition) === -1) {
|
||||
components.push(definition);
|
||||
}
|
||||
foundDefinition = resolveDefinition(path);
|
||||
return false;
|
||||
},
|
||||
});
|
||||
|
||||
return foundDefinition;
|
||||
return components;
|
||||
}
|
||||
@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
import { namedTypes as t, visit } from 'ast-types';
|
||||
|
||||
const {
|
||||
isReactCreateClassCall,
|
||||
isReactForwardRefCall,
|
||||
@ -1,20 +1,7 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
import checkIsIIFE from './checkIsIIFE';
|
||||
|
||||
// const { namedTypes: t, visit } = require("ast-types");
|
||||
const resolveFunctionDefinitionToReturnValue = require('react-docgen/dist/utils/resolveFunctionDefinitionToReturnValue')
|
||||
.default;
|
||||
// isReactCreateClassCall,
|
||||
// isReactForwardRefCall,
|
||||
// resolveToValue,
|
||||
// resolveHOC
|
||||
|
||||
import checkIsIIFE from './checkIsIIFE';
|
||||
/**
|
||||
* If the path is a call expression, it recursively resolves to the
|
||||
* rightmost argument, stopping if it finds a React.createClass call expression
|
||||
60
packages/material-parser/src/parse/resolver/resolveImport.ts
Normal file
60
packages/material-parser/src/parse/resolver/resolveImport.ts
Normal file
@ -0,0 +1,60 @@
|
||||
import { namedTypes as t } from 'ast-types';
|
||||
import fs from 'fs';
|
||||
import p from 'path';
|
||||
|
||||
function getRoot(node: any) {
|
||||
let root = node.parent;
|
||||
while (root.parent) {
|
||||
root = root.parent;
|
||||
}
|
||||
return root.node;
|
||||
}
|
||||
|
||||
function isImportLike(node: any) {
|
||||
return (
|
||||
t.ImportDeclaration.check(node) ||
|
||||
t.ExportAllDeclaration.check(node) ||
|
||||
t.ExportNamedDeclaration.check(node)
|
||||
);
|
||||
}
|
||||
|
||||
function getPath(path: any, name: any) {
|
||||
const root = getRoot(path);
|
||||
if (!root) return;
|
||||
let { __path } = root;
|
||||
__path = p.dirname(__path);
|
||||
// is directory
|
||||
if (fs.existsSync(p.resolve(__path, name))) {
|
||||
name = name + '/index';
|
||||
}
|
||||
const suffix = suffixes.find(suf => {
|
||||
return fs.existsSync(p.resolve(__path, name + suf));
|
||||
});
|
||||
if (!suffix) return;
|
||||
return p.resolve(__path, name + suffix);
|
||||
}
|
||||
|
||||
const buildParser = require('react-docgen/dist/babelParser').default;
|
||||
const parser = buildParser();
|
||||
const suffixes = ['.js', '.jsx', '.ts', '.tsx'];
|
||||
|
||||
export default function resolveImport(path: any, callback: any) {
|
||||
let name;
|
||||
if (path.name === 'local') {
|
||||
name = path.parentPath.parentPath.parentPath.node.source.value;
|
||||
} else if (!isImportLike(path.node)) {
|
||||
return path;
|
||||
} else {
|
||||
name = path.node.source.value;
|
||||
}
|
||||
if (name) {
|
||||
const __path = getPath(path, name);
|
||||
if (!__path) return path;
|
||||
const fileContent = fs.readFileSync(__path, 'utf8');
|
||||
const ast = parser.parse(fileContent);
|
||||
ast.__src = fileContent;
|
||||
ast.__path = __path;
|
||||
return callback(ast);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
@ -1,11 +1,3 @@
|
||||
/**
|
||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
*/
|
||||
|
||||
import { builders, namedTypes as t, NodePath, visit } from 'ast-types';
|
||||
/**
|
||||
* If the path is a call expression, it recursively resolves to the
|
||||
@ -19,7 +11,7 @@ export default function resolveTranspiledClass(path: any) {
|
||||
visitFunctionDeclaration(arg) {
|
||||
classPath = new NodePath(
|
||||
builders.functionDeclaration(
|
||||
arg.node.id,
|
||||
arg.node.id || 'Default',
|
||||
[],
|
||||
builders.blockStatement([
|
||||
builders.returnStatement(
|
||||
138
packages/material-parser/src/parse/transform.ts
Normal file
138
packages/material-parser/src/parse/transform.ts
Normal file
@ -0,0 +1,138 @@
|
||||
export function transformType(type: any) {
|
||||
if (typeof type === 'string') return type;
|
||||
const { name, elements, value = elements, computed, required } = type;
|
||||
if (!value && !required) {
|
||||
return name;
|
||||
}
|
||||
if (computed !== undefined && value) {
|
||||
return eval(value);
|
||||
}
|
||||
const result: any = {
|
||||
type: name,
|
||||
};
|
||||
if (required) {
|
||||
result.isRequired = required;
|
||||
}
|
||||
switch (name) {
|
||||
case 'number':
|
||||
case 'string':
|
||||
case 'bool':
|
||||
case 'any':
|
||||
case 'func':
|
||||
case 'symbol':
|
||||
case 'object':
|
||||
break;
|
||||
case 'literal':
|
||||
return eval(value);
|
||||
case 'enum':
|
||||
case 'tuple':
|
||||
result.type = 'oneOf';
|
||||
result.value = value.map(transformType);
|
||||
break;
|
||||
case 'union':
|
||||
result.type = 'oneOfType';
|
||||
result.value = value.map(transformType);
|
||||
break;
|
||||
case 'boolean':
|
||||
result.type = 'bool';
|
||||
break;
|
||||
case 'Array': {
|
||||
result.type = 'arrayOf';
|
||||
const v = transformType(value[0]);
|
||||
if (typeof v.type === 'string') result.value = v.type;
|
||||
break;
|
||||
}
|
||||
case 'signature': {
|
||||
result.type = 'shape';
|
||||
const {
|
||||
signature: { properties },
|
||||
} = type;
|
||||
if (properties.length === 0) {
|
||||
result.type = 'object';
|
||||
} else if (
|
||||
properties.length === 1 &&
|
||||
typeof properties[0].key === 'object'
|
||||
) {
|
||||
result.type = 'objectOf';
|
||||
const v = transformType(properties[0].value);
|
||||
if (typeof v.type === 'string') result.value = v.type;
|
||||
} else {
|
||||
result.value = properties
|
||||
.filter((item: any) => typeof item.key !== 'object')
|
||||
.map((prop: any) => {
|
||||
const {
|
||||
key,
|
||||
value: { name, ...others },
|
||||
} = prop;
|
||||
return transformItem(key, {
|
||||
...others,
|
||||
type: {
|
||||
name,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'objectOf':
|
||||
case 'arrayOf':
|
||||
case 'instanceOf':
|
||||
result.value = transformType(value);
|
||||
break;
|
||||
case 'exact':
|
||||
case 'shape':
|
||||
result.value = Object.keys(value).map(n => {
|
||||
// tslint:disable-next-line:variable-name
|
||||
const { name: _name, ...others } = value[n];
|
||||
return transformItem(n, {
|
||||
...others,
|
||||
type: {
|
||||
name: _name,
|
||||
},
|
||||
});
|
||||
});
|
||||
break;
|
||||
case (name.match('ReactNode$') || {}).input:
|
||||
result.type = 'node';
|
||||
break;
|
||||
case (name.match('Element$') || {}).input:
|
||||
result.type = 'element';
|
||||
break;
|
||||
case (name.match('ElementType$') || {}).input:
|
||||
result.type = 'elementType';
|
||||
break;
|
||||
default:
|
||||
result.type = 'instanceOf';
|
||||
result.value = name;
|
||||
break;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
export function transformItem(name: string, item: any) {
|
||||
const {
|
||||
description,
|
||||
flowType,
|
||||
type = flowType,
|
||||
required,
|
||||
defaultValue,
|
||||
} = item;
|
||||
const result: any = {
|
||||
name,
|
||||
propType: transformType({
|
||||
...type,
|
||||
required: !!required,
|
||||
}),
|
||||
};
|
||||
if (description) {
|
||||
result.description = description;
|
||||
}
|
||||
if (defaultValue) {
|
||||
try {
|
||||
const value = eval(defaultValue.value);
|
||||
result.defaultValue = value;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -1,76 +0,0 @@
|
||||
import { OtterError } from '../otter-core';
|
||||
import {
|
||||
EcologyType,
|
||||
IMaterializeOptions,
|
||||
IMaterialParsedModel,
|
||||
IMaterialScanModel,
|
||||
IParser,
|
||||
SourceType,
|
||||
} from '../types';
|
||||
|
||||
/**
|
||||
* 解析器基类
|
||||
* @abstract
|
||||
* @class BaseParser
|
||||
* @implements {IParser}
|
||||
*/
|
||||
abstract class BaseParser implements IParser {
|
||||
/**
|
||||
* 识别语法生态,判断是 react、vue、rax
|
||||
* @static
|
||||
* @param {IMaterializeOptions} options
|
||||
* @returns {Promise<EcologyType>}
|
||||
* @memberof BaseParser
|
||||
*/
|
||||
public static recognizeEcology(
|
||||
options: IMaterializeOptions,
|
||||
): Promise<EcologyType> {
|
||||
// TODO 识别物料组件生态
|
||||
return Promise.resolve(EcologyType.REACT);
|
||||
}
|
||||
|
||||
private options: IMaterializeOptions;
|
||||
|
||||
constructor(options: IMaterializeOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public async parse(
|
||||
model: IMaterialScanModel,
|
||||
): Promise<IMaterialParsedModel[]> {
|
||||
const results: IMaterialParsedModel[] = [];
|
||||
switch (model.sourceType) {
|
||||
case SourceType.MODULE: {
|
||||
for (const item of model.modules) {
|
||||
const parsedModel: IMaterialParsedModel = await this.parseES6({
|
||||
model,
|
||||
filePath: item.filePath,
|
||||
fileContent: item.fileContent,
|
||||
});
|
||||
results.push(parsedModel);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SourceType.MAIN: {
|
||||
this.parseES5(model);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
throw new OtterError(`Unsupported SourceType [${model.sourceType}]`);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public abstract parseES5(
|
||||
model: IMaterialScanModel,
|
||||
): Promise<IMaterialParsedModel>;
|
||||
|
||||
public abstract parseES6(params: {
|
||||
model: IMaterialScanModel;
|
||||
filePath: string;
|
||||
fileContent: string;
|
||||
}): Promise<IMaterialParsedModel>;
|
||||
}
|
||||
|
||||
export default BaseParser;
|
||||
@ -1,704 +0,0 @@
|
||||
import { CodeGenerator } from '@babel/generator';
|
||||
// import { parse } from '@babel/parser';
|
||||
const buildParser = require('react-docgen/dist/babelParser').default;
|
||||
const reactDocs = require('react-docgen');
|
||||
import traverse from '@babel/traverse';
|
||||
import * as t from '@babel/types';
|
||||
const { utils: ReactDocUtils } = require('react-docgen');
|
||||
import { debug } from '../otter-core';
|
||||
import {
|
||||
IMaterialParsedModel,
|
||||
IMaterialScanModel,
|
||||
IPropType,
|
||||
IPropTypes,
|
||||
SourceType,
|
||||
} from '../types';
|
||||
import BaseParser from './BaseParser';
|
||||
import resolver from './resolver';
|
||||
import handlers from './handlers';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
const parser = buildParser();
|
||||
|
||||
function transformType(type: any): any {
|
||||
const { name, value, computed, required } = type;
|
||||
if (!value && !required) {
|
||||
return name;
|
||||
}
|
||||
if (computed !== undefined && value) {
|
||||
// tslint:disable-next-line:no-eval
|
||||
return eval(value);
|
||||
}
|
||||
const result: any = {
|
||||
type: name,
|
||||
};
|
||||
if (required) {
|
||||
result.isRequired = required;
|
||||
}
|
||||
if (Array.isArray(value)) {
|
||||
if (name === 'enum') {
|
||||
result.type = 'oneOf';
|
||||
} else if (name === 'union') {
|
||||
result.type = 'oneOfType';
|
||||
}
|
||||
result.value = value.map(transformType);
|
||||
} else if (typeof value === 'object') {
|
||||
if (name === 'objectOf' || name === 'arrayOf' || name === 'instanceOf') {
|
||||
result.value = transformType(value);
|
||||
} else {
|
||||
result.value = Object.keys(value).map((n: string) => {
|
||||
// tslint:disable-next-line:variable-name
|
||||
const { name: _name, ...others } = value[n];
|
||||
return transformItem(n, {
|
||||
...others,
|
||||
type: {
|
||||
name: _name,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
} else if (value !== undefined) {
|
||||
result.value = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function transformItem(name: string, item: any): any {
|
||||
const { description, type, required, defaultValue } = item;
|
||||
const result: any = {
|
||||
name,
|
||||
propType: transformType({
|
||||
...type,
|
||||
required: !!required,
|
||||
}),
|
||||
};
|
||||
if (description) {
|
||||
result.description = description;
|
||||
}
|
||||
if (defaultValue) {
|
||||
try {
|
||||
const value = eval(defaultValue.value);
|
||||
result.defaultValue = value;
|
||||
} catch (e) {}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/**
|
||||
* 解析 react 生态下的组件
|
||||
*
|
||||
* @class ReactParser
|
||||
* @extends {BaseParser}
|
||||
*/
|
||||
class ReactParser extends BaseParser {
|
||||
/**
|
||||
* 解析 ExportStatement
|
||||
* @static
|
||||
* @returns {Promise<any>}
|
||||
* @memberof ReactParser
|
||||
*/
|
||||
public static async parseExportedStatement(
|
||||
fileContent: string,
|
||||
sourceType: string,
|
||||
): Promise<
|
||||
Array<{
|
||||
localName: string;
|
||||
exportedName: string;
|
||||
source: string;
|
||||
}>
|
||||
> {
|
||||
const ast = parser.parse(fileContent);
|
||||
|
||||
// @ts-ignore
|
||||
ast.__src = fileContent;
|
||||
|
||||
const specifiers: any = [];
|
||||
|
||||
// 组装 localName 和 exportedName
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (t.isExportNamedDeclaration(path.node)) {
|
||||
path.node.specifiers.forEach(spec => {
|
||||
if (t.isExportSpecifier(spec)) {
|
||||
const source = (path.node as t.ExportNamedDeclaration).source;
|
||||
specifiers.push({
|
||||
localName: spec.local.name,
|
||||
exportedName: spec.exported.name,
|
||||
source: t.isLiteral(source) ? (source as any).value : '',
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
// 组装 source
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (t.isImportDeclaration(path.node)) {
|
||||
const source = path.node.source;
|
||||
path.node.specifiers.forEach(spec => {
|
||||
if (t.isImportDefaultSpecifier(spec)) {
|
||||
const target = specifiers.find(
|
||||
(inner: any) => inner.localName === spec.local.name,
|
||||
);
|
||||
if (target) {
|
||||
target.source = source.value;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
debug('specifiers', specifiers);
|
||||
return specifiers;
|
||||
}
|
||||
public static parseProperties(objectPath: any): IPropTypes {
|
||||
const results: IPropTypes = objectPath
|
||||
.get('properties')
|
||||
.map((p: any) =>
|
||||
transformItem(
|
||||
p.get('key').node.name,
|
||||
ReactDocUtils.getPropType(p.get('value')),
|
||||
),
|
||||
);
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public async parseES5(
|
||||
model: IMaterialScanModel,
|
||||
): Promise<IMaterialParsedModel> {
|
||||
const parsedModel: IMaterialParsedModel = {
|
||||
filePath: '',
|
||||
defaultExportName: '',
|
||||
componentNames: [],
|
||||
importModules: [],
|
||||
exportModules: [],
|
||||
subModules: [],
|
||||
propsTypes: [],
|
||||
propsDefaults: [],
|
||||
};
|
||||
|
||||
const mainEntryItem: any = model.modules.find(
|
||||
item => item.filePath === model.mainEntry,
|
||||
);
|
||||
|
||||
const result = reactDocs.parse(
|
||||
mainEntryItem.fileContent,
|
||||
resolver,
|
||||
handlers,
|
||||
);
|
||||
const props = Object.keys(result.props || {}).map(name => {
|
||||
return transformItem(name, result.props[name]);
|
||||
});
|
||||
|
||||
return {
|
||||
filePath: mainEntryItem.filePath,
|
||||
// defaultExportName,
|
||||
// subModules,
|
||||
// propsTypes,
|
||||
props,
|
||||
} as any;
|
||||
|
||||
// log('mainEntryItem', mainEntryItem);
|
||||
// const ast = parser.parse(mainEntryItem.file);
|
||||
|
||||
// @ts-ignore
|
||||
// ast.__src = mainEntryItem.file;
|
||||
|
||||
// // 获取 defaultExportName
|
||||
// traverse(ast, {
|
||||
// enter(path) {
|
||||
// if (t.isExpressionStatement(path.node)) {
|
||||
// if (
|
||||
// t.isAssignmentExpression(path.node.expression) &&
|
||||
// t.isMemberExpression(path.node.expression.left) &&
|
||||
// t.isIdentifier(path.node.expression.left.object) &&
|
||||
// t.isIdentifier(path.node.expression.right) &&
|
||||
// path.node.expression.left.object.name === 'exports' &&
|
||||
// (path.node.expression.left.property.name === 'default' ||
|
||||
// path.node.expression.left.property.value === 'default')
|
||||
// ) {
|
||||
// // 支持 export default Demo 写法
|
||||
// const tempVarName = path.node.expression.right.name;
|
||||
// let defaultExportName = '';
|
||||
// traverse(ast, {
|
||||
// enter(innerPath) {
|
||||
// if (
|
||||
// t.isVariableDeclaration(innerPath.node) &&
|
||||
// Array.isArray(innerPath.node.declarations) &&
|
||||
// innerPath.node.declarations.length &&
|
||||
// t.isVariableDeclarator(innerPath.node.declarations[0]) &&
|
||||
// t.isIdentifier(innerPath.node.declarations[0].id) &&
|
||||
// innerPath.node.declarations[0].id.name === tempVarName &&
|
||||
// t.isIdentifier(innerPath.node.declarations[0].init)
|
||||
// ) {
|
||||
// defaultExportName = innerPath.node.declarations[0].init.name;
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
// parsedModel.defaultExportName = defaultExportName;
|
||||
// log('isIdentifier defaultExportName', defaultExportName);
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
|
||||
// traverse(ast, {
|
||||
// enter(path) {
|
||||
// // 获取 componentNames
|
||||
// if (t.isVariableDeclaration(path.node)) {
|
||||
// if (
|
||||
// t.isVariableDeclarator(path.node.declarations) &&
|
||||
// t.isIdentifier(path.node.declarations.init) &&
|
||||
// t.isIdentifier(path.node.declarations.id)
|
||||
// ) {
|
||||
// const exportedName = path.node.declarations.init.name;
|
||||
// const localName = path.node.declarations.id.name;
|
||||
// log('isIdentifier componentNames', exportedName);
|
||||
// parsedModel.componentNames.push({
|
||||
// exportedName,
|
||||
// localName,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// // 获取 exportModules
|
||||
// if (t.isExpressionStatement(path.node)) {
|
||||
// // 对应 export function DemoFunc() {} 或 export { DemoFunc } 写法
|
||||
// if (
|
||||
// t.isAssignmentExpression(path.node.expression) &&
|
||||
// t.isMemberExpression(path.node.expression.left) &&
|
||||
// t.isIdentifier(path.node.expression.left.object) &&
|
||||
// t.isIdentifier(path.node.expression.left.property) &&
|
||||
// t.isIdentifier(path.node.expression.right) &&
|
||||
// path.node.expression.left.object.name === 'exports'
|
||||
// ) {
|
||||
// const exportedName = path.node.expression.left.property.name;
|
||||
// const localName = path.node.expression.right.name;
|
||||
// parsedModel.exportModules.push({
|
||||
// exportedName:
|
||||
// exportedName === 'default'
|
||||
// ? parsedModel.defaultExportName
|
||||
// : exportedName,
|
||||
// localName:
|
||||
// exportedName === 'default'
|
||||
// ? parsedModel.defaultExportName
|
||||
// : localName,
|
||||
// });
|
||||
// }
|
||||
// // 支持 export { default as DemoFunc } from './DemoFunc' 写法
|
||||
// if (
|
||||
// t.isCallExpression(path.node.expression) &&
|
||||
// t.isMemberExpression(path.node.expression.callee) &&
|
||||
// t.isIdentifier(path.node.expression.callee.object) &&
|
||||
// t.isIdentifier(path.node.expression.callee.property) &&
|
||||
// path.node.expression.callee.object.name === 'Object' &&
|
||||
// path.node.expression.callee.property.name === 'defineProperty' &&
|
||||
// Array.isArray(path.node.expression.arguments) &&
|
||||
// t.isIdentifier(path.node.expression.arguments[0]) &&
|
||||
// (path.node.expression.arguments[0] as t.Identifier).name ===
|
||||
// 'exports' &&
|
||||
// t.isLiteral(path.node.expression.arguments[1])
|
||||
// ) {
|
||||
// // 对应 export function DemoFunc() {} 或 export { DemoFunc } 写法
|
||||
// const args = path.node.expression.arguments as any;
|
||||
// const funcName = args[1].value;
|
||||
// if (funcName !== '__esModule') {
|
||||
// parsedModel.exportModules.push({
|
||||
// exportedName: funcName,
|
||||
// localName: funcName,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// // 获取 importModules
|
||||
// if (
|
||||
// t.isVariableDeclaration(path.node) &&
|
||||
// Array.isArray(path.node.declarations) &&
|
||||
// path.node.declarations.length
|
||||
// ) {
|
||||
// path.node.declarations.forEach(dec => {
|
||||
// // 支持 import Demo from './demo' 写法
|
||||
// if (
|
||||
// t.isVariableDeclarator(dec) &&
|
||||
// t.isIdentifier(dec.id) &&
|
||||
// t.isCallExpression(dec.init) &&
|
||||
// t.isIdentifier(dec.init.callee) &&
|
||||
// ['_interopRequireWildcard', '_interopRequireDefault'].includes(
|
||||
// dec.init.callee.name,
|
||||
// ) &&
|
||||
// // dec.init.callee.name === '_interopRequireWildcard' &&
|
||||
// Array.isArray(dec.init.arguments) &&
|
||||
// t.isCallExpression(dec.init.arguments[0]) &&
|
||||
// t.isIdentifier(
|
||||
// (dec.init.arguments[0] as t.CallExpression).callee,
|
||||
// ) &&
|
||||
// ((dec.init.arguments[0] as t.CallExpression)
|
||||
// .callee as t.Identifier).name === 'require'
|
||||
// ) {
|
||||
// const localName = dec.id.name;
|
||||
// const args = (dec.init.arguments[0] as t.CallExpression)
|
||||
// .arguments as any;
|
||||
// const source = args[0].value;
|
||||
// parsedModel.importModules.push({
|
||||
// importDefaultName: localName,
|
||||
// localName,
|
||||
// source,
|
||||
// });
|
||||
// }
|
||||
|
||||
// // 支持 import { Demo as Demo2 } from './demo' 写法
|
||||
// if (
|
||||
// t.isVariableDeclarator(dec) &&
|
||||
// t.isIdentifier(dec.id) &&
|
||||
// t.isCallExpression(dec.init) &&
|
||||
// t.isIdentifier(dec.init.callee) &&
|
||||
// dec.init.callee.name === 'require' &&
|
||||
// Array.isArray(dec.init.arguments) &&
|
||||
// t.isLiteral(dec.init.arguments[0])
|
||||
// ) {
|
||||
// const args = dec.init.arguments as any;
|
||||
// const source = args[0].value;
|
||||
// const importName = dec.id.name;
|
||||
// const localName = dec.id.name;
|
||||
// // 遍历查找出 importName 和 localName
|
||||
// // ES5 本身并不支持按需加载,故 import 都是全量导入
|
||||
// // 但如果使用了诸如:babel-plugin-import 等插件,会自动更改编译之后的 ES5 代码
|
||||
// parsedModel.importModules.push({
|
||||
// importName,
|
||||
// localName,
|
||||
// source,
|
||||
// });
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// // 获取 subModules
|
||||
// if (
|
||||
// t.isExpressionStatement(path.node) &&
|
||||
// t.isAssignmentExpression(path.node.expression) &&
|
||||
// t.isMemberExpression(path.node.expression.left)
|
||||
// ) {
|
||||
// if (
|
||||
// t.isIdentifier(path.node.expression.left.object) &&
|
||||
// path.node.expression.left.object.name ===
|
||||
// parsedModel.defaultExportName
|
||||
// ) {
|
||||
// // 支持 SFC.SubDemo1 = SubDemo1; 写法
|
||||
// if (t.isIdentifier(path.node.expression.right)) {
|
||||
// parsedModel.subModules.push({
|
||||
// objectName: [path.node.expression.left.object.name],
|
||||
// propertyName: path.node.expression.left.property.name,
|
||||
// isValueAnonymousFunc: false,
|
||||
// value: path.node.expression.right.name,
|
||||
// });
|
||||
// }
|
||||
|
||||
// // 支持 SFC.SubDemo2 = function() {}; 写法
|
||||
// if (t.isFunctionExpression(path.node.expression.right)) {
|
||||
// const rightID = path.node.expression.right.id as any;
|
||||
// parsedModel.subModules.push({
|
||||
// objectName: [path.node.expression.left.object.name],
|
||||
// propertyName: path.node.expression.left.property.name,
|
||||
// isValueAnonymousFunc: !rightID,
|
||||
// value: rightID ? rightID.name : undefined,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// if (t.isMemberExpression(path.node.expression.left.object)) {
|
||||
// if (t.isIdentifier(path.node.expression.right)) {
|
||||
// // 支持 DemoFunc4.Test.Obj2 = Obj3; 写法
|
||||
// const tempLeftObject = path.node.expression.left.object as any;
|
||||
// parsedModel.subModules.push({
|
||||
// objectName: [
|
||||
// tempLeftObject.object.name,
|
||||
// tempLeftObject.property.name,
|
||||
// ],
|
||||
// propertyName: path.node.expression.left.property.name,
|
||||
// isValueAnonymousFunc: false,
|
||||
// value: path.node.expression.right.name,
|
||||
// });
|
||||
// }
|
||||
// if (t.isFunctionExpression(path.node.expression.right)) {
|
||||
// // 支持 DemoFunc4.Test.Obj2 = function() {}; 写法
|
||||
// const rightID = path.node.expression.right.id as any;
|
||||
// const tempLeftObject = path.node.expression.left.object as any;
|
||||
// parsedModel.subModules.push({
|
||||
// objectName: [
|
||||
// tempLeftObject.object.name,
|
||||
// tempLeftObject.property.name,
|
||||
// ],
|
||||
// propertyName: path.node.expression.left.property.name,
|
||||
// isValueAnonymousFunc: !rightID,
|
||||
// value: rightID ? rightID.name : undefined,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// // 获取 propsTypes 和 defaultProps
|
||||
// if (
|
||||
// t.isExpressionStatement(path.node) &&
|
||||
// t.isAssignmentExpression(path.node.expression) &&
|
||||
// t.isMemberExpression(path.node.expression.left) &&
|
||||
// t.isObjectExpression(path.node.expression.right) &&
|
||||
// t.isIdentifier(path.node.expression.left.object) &&
|
||||
// t.isIdentifier(path.node.expression.left.property) &&
|
||||
// path.node.expression.left.object.name ===
|
||||
// parsedModel.defaultExportName &&
|
||||
// ['propTypes', 'defaultProps'].includes(
|
||||
// path.node.expression.left.property.name,
|
||||
// )
|
||||
// ) {
|
||||
// // 处理 propTypes
|
||||
// if (path.node.expression.left.property.name === 'propTypes') {
|
||||
// path.node.expression.right.properties.forEach(prop => {
|
||||
// if (t.isProperty(prop)) {
|
||||
// if (t.isMemberExpression(prop.value)) {
|
||||
// if (t.isIdentifier(prop.value.object)) {
|
||||
// // 支持 optionalArray: PropTypes.array 写法
|
||||
// parsedModel.propsTypes.push({
|
||||
// name: prop.key.name,
|
||||
// type: prop.value.property.name,
|
||||
// required: false,
|
||||
// });
|
||||
// }
|
||||
// if (t.isMemberExpression(prop.value.object)) {
|
||||
// // 支持 optionalArray: PropTypes.array.isRequired 写法
|
||||
// parsedModel.propsTypes.push({
|
||||
// name: prop.key.name,
|
||||
// type: prop.value.object.property.name,
|
||||
// required:
|
||||
// prop.value.object.property.name === 'isRequired',
|
||||
// });
|
||||
// }
|
||||
// if (
|
||||
// t.isCallExpression(prop.value.object) &&
|
||||
// t.isMemberExpression(prop.value.object.callee)
|
||||
// ) {
|
||||
// // 支持 optionalArray: PropTypes.shape().isRequired 写法
|
||||
// parsedModel.propsTypes.push({
|
||||
// name: prop.key.name,
|
||||
// type: prop.value.object.callee.property.name,
|
||||
// required: prop.value.property.name === 'isRequired',
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// if (
|
||||
// t.isCallExpression(prop.value) &&
|
||||
// t.isMemberExpression(prop.value.callee)
|
||||
// ) {
|
||||
// // 支持 optionalArray: PropTypes.shape() 写法
|
||||
// parsedModel.propsTypes.push({
|
||||
// name: prop.key.name,
|
||||
// type: prop.value.callee.property.name,
|
||||
// required: false,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// // 处理 defaultProps
|
||||
// if (path.node.expression.left.property.name === 'defaultProps') {
|
||||
// path.node.expression.right.properties.forEach(prop => {
|
||||
// if (t.isProperty(prop)) {
|
||||
// if (t.isObjectExpression(prop.value)) {
|
||||
// const defaultValue = new CodeGenerator(
|
||||
// t.objectExpression(prop.value.properties),
|
||||
// ).generate().code;
|
||||
// parsedModel.propsDefaults.push({
|
||||
// name: prop.key.name,
|
||||
// defaultValue,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// },
|
||||
// });
|
||||
|
||||
// log('traverse done.');
|
||||
// log('parsedModel.defaultExportName', parsedModel.defaultExportName);
|
||||
// log('parsedModel.componentNames', parsedModel.componentNames);
|
||||
// log('parsedModel.importModules', parsedModel.importModules);
|
||||
// log('parsedModel.exportModules', parsedModel.exportModules);
|
||||
// log('parsedModel.subModules', parsedModel.subModules);
|
||||
// log('parsedModel.propsTypes', parsedModel.propsTypes);
|
||||
// log('parsedModel.propsDefaults', parsedModel.propsDefaults);
|
||||
// log('parsedModel', parsedModel);
|
||||
// return parsedModel;
|
||||
}
|
||||
|
||||
public async parseES6(params: {
|
||||
model: IMaterialScanModel;
|
||||
filePath: string;
|
||||
fileContent: string;
|
||||
}): Promise<IMaterialParsedModel> {
|
||||
const ast = parser.parse(params.fileContent);
|
||||
const result = reactDocs.parse(params.fileContent, resolver, handlers);
|
||||
const props = Object.keys(result.props || {}).map(name => {
|
||||
return transformItem(name, result.props[name]);
|
||||
});
|
||||
const defaultExportName = await this.parseDefaultExportNameES6(ast);
|
||||
// const subModules = await this.parseSubModulesES6(ast);
|
||||
|
||||
return {
|
||||
filePath: params.filePath,
|
||||
defaultExportName,
|
||||
// subModules,
|
||||
props,
|
||||
} as any;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 AST 获取 defaultExportName
|
||||
* 支持的写法:
|
||||
* - export default Demo
|
||||
* - export default function Demo() {}
|
||||
* - export default class Demo {}
|
||||
*
|
||||
* @private
|
||||
* @param {*} ast
|
||||
* @memberof ReactParser
|
||||
*/
|
||||
private async parseDefaultExportNameES6(ast: any): Promise<string> {
|
||||
let defaultExportName = '';
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
// 获取 defaultExportName
|
||||
if (t.isExportDefaultDeclaration(path.node)) {
|
||||
if (t.isIdentifier(path.node.declaration)) {
|
||||
// 支持 export default Demo 写法
|
||||
defaultExportName = path.node.declaration.name;
|
||||
log('isIdentifier defaultExportName', defaultExportName);
|
||||
}
|
||||
if (t.isFunctionDeclaration(path.node.declaration)) {
|
||||
if (t.isIdentifier(path.node.declaration.id)) {
|
||||
// 支持 export default function Demo() {} 写法
|
||||
defaultExportName = path.node.declaration.id.name;
|
||||
log('isFunctionDeclaration defaultExportName', defaultExportName);
|
||||
}
|
||||
}
|
||||
if (t.isClassDeclaration(path.node.declaration)) {
|
||||
if (t.isIdentifier(path.node.declaration.id)) {
|
||||
// 支持 export default class Demo {} 写法
|
||||
defaultExportName = path.node.declaration.id.name;
|
||||
log('isClassDeclaration defaultExportName', defaultExportName);
|
||||
}
|
||||
}
|
||||
if (t.isCallExpression(path.node.declaration)) {
|
||||
const traverseCallExp: any = (args: any[]) => {
|
||||
const arg = args[0];
|
||||
if (t.isIdentifier(arg)) {
|
||||
return arg.name;
|
||||
}
|
||||
return traverseCallExp(arg.arguments);
|
||||
};
|
||||
defaultExportName = traverseCallExp(
|
||||
path.node.declaration.arguments,
|
||||
);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
return defaultExportName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 AST 获取 subModules
|
||||
* 支持的写法:
|
||||
* - DemoFunc4.Test = Test;
|
||||
* - DemoFunc4.Test = function() {};
|
||||
* - DemoFunc4.Test.Obj2 = Obj3;
|
||||
* - DemoFunc4.Test.Obj2 = function() {};
|
||||
*
|
||||
* @private
|
||||
* @param {*} ast
|
||||
* @returns {Promise<Array<{
|
||||
* objectName: string[],
|
||||
* propertyName: string,
|
||||
* value?: string,
|
||||
* isValueAnonymousFunc: boolean,
|
||||
* }>>}
|
||||
* @memberof ReactParser
|
||||
*/
|
||||
private async parseSubModulesES6(
|
||||
ast: any,
|
||||
): Promise<
|
||||
Array<{
|
||||
objectName: string[];
|
||||
propertyName: string;
|
||||
value?: string;
|
||||
isValueAnonymousFunc: boolean;
|
||||
}>
|
||||
> {
|
||||
const results: any[] = [];
|
||||
traverse(ast, {
|
||||
enter(path) {
|
||||
if (t.isExpressionStatement(path.node)) {
|
||||
if (t.isAssignmentExpression(path.node.expression)) {
|
||||
if (t.isMemberExpression(path.node.expression.left)) {
|
||||
if (t.isIdentifier(path.node.expression.left.object)) {
|
||||
if (t.isIdentifier(path.node.expression.right)) {
|
||||
// 支持 DemoFunc4.Test = Test; 写法
|
||||
results.push({
|
||||
objectName: [path.node.expression.left.object.name],
|
||||
propertyName: path.node.expression.left.property.name,
|
||||
isValueAnonymousFunc: false,
|
||||
value: path.node.expression.right.name,
|
||||
});
|
||||
}
|
||||
if (t.isFunctionExpression(path.node.expression.right)) {
|
||||
// 支持 DemoFunc4.Test = function() {}; 写法
|
||||
const rightID = !path.node.expression.right.id as any;
|
||||
results.push({
|
||||
objectName: [path.node.expression.left.object.name],
|
||||
propertyName: path.node.expression.left.property.name,
|
||||
isValueAnonymousFunc: !!rightID,
|
||||
value: rightID ? rightID.name : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
if (t.isMemberExpression(path.node.expression.left.object)) {
|
||||
if (t.isIdentifier(path.node.expression.right)) {
|
||||
// 支持 DemoFunc4.Test.Obj2 = Obj3; 写法
|
||||
const tempLeftObject = path.node.expression.left
|
||||
.object as any;
|
||||
results.push({
|
||||
objectName: [
|
||||
tempLeftObject.object.name,
|
||||
tempLeftObject.property.name,
|
||||
],
|
||||
propertyName: path.node.expression.left.property.name,
|
||||
isValueAnonymousFunc: false,
|
||||
value: path.node.expression.right.name,
|
||||
});
|
||||
}
|
||||
if (t.isFunctionExpression(path.node.expression.right)) {
|
||||
// 支持 DemoFunc4.Test.Obj2 = function() {}; 写法
|
||||
const rightID = !path.node.expression.right.id as any;
|
||||
const tempLeftObject = path.node.expression.left
|
||||
.object as any;
|
||||
results.push({
|
||||
objectName: [
|
||||
tempLeftObject.object.name,
|
||||
tempLeftObject.property.name,
|
||||
],
|
||||
propertyName: path.node.expression.left.property.name,
|
||||
isValueAnonymousFunc: !!rightID,
|
||||
value: rightID ? rightID.name : undefined,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
export default ReactParser;
|
||||
74
packages/material-parser/src/scan.ts
Normal file
74
packages/material-parser/src/scan.ts
Normal file
@ -0,0 +1,74 @@
|
||||
import { IMaterializeOptions, IMaterialScanModel, SourceType } from './types';
|
||||
import { pathExists, readFile } from 'fs-extra';
|
||||
import { join } from 'path';
|
||||
import { debug } from './otter-core';
|
||||
const log = debug.extend('mat');
|
||||
|
||||
export default async function scan(
|
||||
options: IMaterializeOptions,
|
||||
): Promise<IMaterialScanModel> {
|
||||
const model: IMaterialScanModel = {
|
||||
pkgName: '',
|
||||
pkgVersion: '',
|
||||
mainEntry: '',
|
||||
sourceType: SourceType.MODULE,
|
||||
modules: [],
|
||||
};
|
||||
log('options', options);
|
||||
// 入口文件路径
|
||||
let entryFilePath = null;
|
||||
const cwd = options.cwd ? options.cwd : '';
|
||||
const entry = options.entry;
|
||||
const isDepsMode = cwd !== entry;
|
||||
const pkgJsonPath = join(cwd, 'package.json');
|
||||
// 判断是否存在 package.json
|
||||
if (!(await pathExists(pkgJsonPath))) {
|
||||
throw new Error(`Cannot find package.json. ${pkgJsonPath}`);
|
||||
}
|
||||
// 读取 package.json
|
||||
let pkgJson = await resolvePkgJson(pkgJsonPath);
|
||||
model.pkgName = pkgJson.name;
|
||||
model.pkgVersion = pkgJson.version;
|
||||
if (isDepsMode) {
|
||||
pkgJson = await resolvePkgJson(join(entry, 'package.json'));
|
||||
}
|
||||
if (pkgJson.module) {
|
||||
// 支持 es module
|
||||
model.sourceType = SourceType.MODULE;
|
||||
entryFilePath = pkgJson.module;
|
||||
} else if (pkgJson.main) {
|
||||
// 支持 commonjs
|
||||
model.sourceType = SourceType.MAIN;
|
||||
entryFilePath = pkgJson.main;
|
||||
} else {
|
||||
entryFilePath = './index.js';
|
||||
}
|
||||
entryFilePath = join(isDepsMode ? entry : cwd, entryFilePath);
|
||||
log('entryFilePath', entryFilePath);
|
||||
const entryFile = await loadFile(entryFilePath);
|
||||
log('entryFile', entryFile);
|
||||
model.mainEntry = entryFilePath;
|
||||
// 记录入口文件
|
||||
model.modules.push({
|
||||
filePath: entryFilePath,
|
||||
fileContent: entryFile,
|
||||
});
|
||||
log('model', model);
|
||||
return model;
|
||||
}
|
||||
|
||||
export async function loadFile(filePath: string): Promise<string> {
|
||||
const content: string | Buffer = await readFile(filePath);
|
||||
if (typeof content === 'string') {
|
||||
return content;
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
export async function resolvePkgJson(
|
||||
pkgJsonPath: string,
|
||||
): Promise<{ [k: string]: any }> {
|
||||
const content = await loadFile(pkgJsonPath);
|
||||
const json = JSON.parse(content);
|
||||
return json;
|
||||
}
|
||||
@ -1,170 +0,0 @@
|
||||
import { pathExists, readFile, statSync } from 'fs-extra';
|
||||
import { dirname, join } from 'path';
|
||||
import { debug } from '../otter-core';
|
||||
import BaseParser from '../parser/BaseParser';
|
||||
import ReactParser from '../parser/ReactParser';
|
||||
import {
|
||||
IMaterializeOptions,
|
||||
IMaterialScanModel,
|
||||
IScanner,
|
||||
SourceType,
|
||||
} from '../types';
|
||||
|
||||
const log = debug.extend('mat');
|
||||
|
||||
/**
|
||||
* 文件扫描器
|
||||
*
|
||||
* @class Scanner
|
||||
* @implements {IScanner}
|
||||
*/
|
||||
class Scanner implements IScanner {
|
||||
public options: IMaterializeOptions;
|
||||
|
||||
constructor(options: IMaterializeOptions) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public async scan(): Promise<IMaterialScanModel> {
|
||||
const model: IMaterialScanModel = {
|
||||
pkgName: '',
|
||||
pkgVersion: '',
|
||||
mainEntry: '',
|
||||
sourceType: SourceType.MODULE,
|
||||
modules: [],
|
||||
};
|
||||
const options = this.options;
|
||||
log('options', options);
|
||||
// 入口文件路径
|
||||
let entryFilePath = null;
|
||||
const cwd = options.cwd ? options.cwd : '';
|
||||
const entry = options.entry;
|
||||
const isDepsMode = cwd !== entry;
|
||||
const pkgJsonPath = join(cwd, 'package.json');
|
||||
// 判断是否存在 package.json
|
||||
// if (!(await pathExists(pkgJsonPath))) {
|
||||
// throw new Error(`Cannot find package.json. ${pkgJsonPath}`);
|
||||
// }
|
||||
// 读取 package.json
|
||||
let pkgJson = await this.resolvePkgJson(pkgJsonPath);
|
||||
model.pkgName = pkgJson.name;
|
||||
model.pkgVersion = pkgJson.version;
|
||||
if (isDepsMode) {
|
||||
pkgJson = await this.resolvePkgJson(join(entry, 'package.json'));
|
||||
}
|
||||
if (pkgJson.module) {
|
||||
// 支持 es module
|
||||
model.sourceType = SourceType.MODULE;
|
||||
entryFilePath = pkgJson.module;
|
||||
} else if (pkgJson.main) {
|
||||
// 支持 commonjs
|
||||
model.sourceType = SourceType.MAIN;
|
||||
entryFilePath = pkgJson.main;
|
||||
} else {
|
||||
entryFilePath = './index.js';
|
||||
}
|
||||
entryFilePath = join(isDepsMode ? entry : cwd, entryFilePath);
|
||||
log('entryFilePath', entryFilePath);
|
||||
const entryFile = await this.loadFile(entryFilePath);
|
||||
log('entryFile', entryFile);
|
||||
model.mainEntry = entryFilePath;
|
||||
// 记录入口文件
|
||||
model.modules.push({
|
||||
filePath: entryFilePath,
|
||||
fileContent: entryFile,
|
||||
});
|
||||
log('model', model);
|
||||
// debugger;
|
||||
if (options.isExportedAsMultiple) {
|
||||
// 解析 entryFile,提取出 export 语句
|
||||
const modules = await this.parseEntryFile({
|
||||
entryFile,
|
||||
entryFilePath,
|
||||
sourceType: model.sourceType,
|
||||
});
|
||||
model.modules = [...modules];
|
||||
}
|
||||
log('model', model);
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否为文件夹
|
||||
* @param {string} filePath 文件路径
|
||||
* @returns {Promise<boolean>}
|
||||
* @memberof LocalScanner
|
||||
*/
|
||||
public async isDirectory(filePath: string): Promise<boolean> {
|
||||
log('materialIn', 'isDirectory - filePath', filePath);
|
||||
const stats = statSync(filePath);
|
||||
return stats.isDirectory();
|
||||
}
|
||||
|
||||
public async loadFile(filePath: string): Promise<string> {
|
||||
const content: string | Buffer = await readFile(filePath);
|
||||
if (typeof content === 'string') {
|
||||
return content;
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
public async resolvePkgJson(
|
||||
pkgJsonPath: string,
|
||||
): Promise<{ [k: string]: any }> {
|
||||
const content = await this.loadFile(pkgJsonPath);
|
||||
const json = JSON.parse(content);
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析入口文件,获取要导出的模块内容
|
||||
* @private
|
||||
* @param {{
|
||||
* entryFile: string;
|
||||
* entryFilePath: string;
|
||||
* sourceType: string;
|
||||
* }} params
|
||||
* @returns {Promise<any>}
|
||||
* @memberof LocalScanner
|
||||
*/
|
||||
private async parseEntryFile(params: {
|
||||
entryFile: string;
|
||||
entryFilePath: string;
|
||||
sourceType: string;
|
||||
}): Promise<any> {
|
||||
const modules: any = [];
|
||||
const entryFileDirName = dirname(params.entryFilePath);
|
||||
const ecology = await BaseParser.recognizeEcology(this.options);
|
||||
if (ecology === 'react') {
|
||||
const exportedList = await ReactParser.parseExportedStatement(
|
||||
params.entryFile,
|
||||
params.sourceType,
|
||||
);
|
||||
if (Array.isArray(exportedList)) {
|
||||
for (const item of exportedList) {
|
||||
if (item.source && item.source.length) {
|
||||
try {
|
||||
let filePath = join(entryFileDirName, item.source);
|
||||
if (await this.isDirectory(filePath)) {
|
||||
filePath = join(filePath, 'index.js');
|
||||
} else {
|
||||
filePath = join(filePath, '.js');
|
||||
}
|
||||
debug('filePath', filePath);
|
||||
modules.push({
|
||||
filePath,
|
||||
fileContent: await this.loadFile(filePath),
|
||||
});
|
||||
} catch (e) {
|
||||
debug('error', 'parseEntryFile', e.message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
debug('modules', modules);
|
||||
return modules;
|
||||
}
|
||||
}
|
||||
|
||||
export default Scanner;
|
||||
@ -1,4 +1,4 @@
|
||||
import { IComponentMaterial } from '../otter-core';
|
||||
import { ComponentMeta } from '../otter-core';
|
||||
|
||||
/**
|
||||
* 接入器接口(用于定义物料化组件的接入渠道)
|
||||
@ -10,7 +10,7 @@ interface IAccesser {
|
||||
* @returns {Promise<IMaterialinSchema>}
|
||||
* @memberof IAccesser
|
||||
*/
|
||||
access(): Promise<IComponentMaterial>;
|
||||
access(): Promise<ComponentMeta[]>;
|
||||
}
|
||||
|
||||
export default IAccesser;
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
import { IComponentMaterial } from '../otter-core';
|
||||
import { ComponentMeta } from '../otter-core';
|
||||
/**
|
||||
* 扩展点:配置 manifest
|
||||
* (物料化场景)
|
||||
*/
|
||||
type IExtensionConfigManifest = (params: {
|
||||
manifestObj: IComponentMaterial; // manifest 配置对象
|
||||
manifestObj: ComponentMeta; // manifest 配置对象
|
||||
manifestFilePath: string; // manifest 文件默认路径
|
||||
}) => Promise<{
|
||||
manifestJSON: string; // manifest 文件内容
|
||||
manifestFilePath: string; // manifest 文件路径
|
||||
manifestObj: IComponentMaterial; // manifest 文件对象
|
||||
manifestObj: ComponentMeta; // manifest 文件对象
|
||||
}>;
|
||||
|
||||
export default IExtensionConfigManifest;
|
||||
|
||||
@ -1,20 +0,0 @@
|
||||
import { IComponentMaterial } from '../otter-core';
|
||||
import { IMaterialParsedModel } from './IMaterialParsedModel';
|
||||
import IMaterialScanModel from './IMaterialScanModel';
|
||||
|
||||
/**
|
||||
* 生成器
|
||||
*/
|
||||
export default interface IGenerator {
|
||||
/**
|
||||
* 根据前面两阶段的产物生成最终编排引擎需要的物料
|
||||
* @param {IMaterialScanModel} matScanModel 对应扫描阶段产物
|
||||
* @param {IMaterialParsedModel[]} matParsedModels 对应解析阶段产物
|
||||
* @returns {Promise<IMaterialinSchema>}
|
||||
* @memberof IGenerator
|
||||
*/
|
||||
generate(
|
||||
matScanModel: IMaterialScanModel,
|
||||
matParsedModels: IMaterialParsedModel[],
|
||||
): Promise<IComponentMaterial>;
|
||||
}
|
||||
@ -12,38 +12,38 @@ export interface IPropType {
|
||||
export type IPropTypes = IPropType[];
|
||||
|
||||
export interface IMaterialParsedModel {
|
||||
filePath: string;
|
||||
defaultExportName: string;
|
||||
// filePath: string;
|
||||
componentName: string;
|
||||
props?: PropsSection['props'];
|
||||
componentNames: Array<{
|
||||
exportedName: string;
|
||||
localName: string;
|
||||
source?: string;
|
||||
}>;
|
||||
importModules: Array<{
|
||||
importDefaultName?: string;
|
||||
importName?: string;
|
||||
localName?: string;
|
||||
source: string;
|
||||
}>;
|
||||
exportModules: Array<{
|
||||
exportedName: string;
|
||||
localName: string;
|
||||
source?: string;
|
||||
}>;
|
||||
/**
|
||||
* 子模块,形如:Demo.SubModule = value; 或者 Demo.SubModule.Sub = subValue;
|
||||
*/
|
||||
subModules: Array<{
|
||||
objectName: string[];
|
||||
propertyName: string;
|
||||
value?: string;
|
||||
// value 是否对应匿名函数
|
||||
isValueAnonymousFunc: boolean;
|
||||
}>;
|
||||
propsTypes: IPropTypes;
|
||||
propsDefaults: Array<{
|
||||
name: string;
|
||||
defaultValue: any;
|
||||
}>;
|
||||
// componentNames: {
|
||||
// exportedName: string;
|
||||
// localName: string;
|
||||
// source?: string;
|
||||
// }[];
|
||||
// importModules: {
|
||||
// importDefaultName?: string;
|
||||
// importName?: string;
|
||||
// localName?: string;
|
||||
// source: string;
|
||||
// }[];
|
||||
// exportModules: {
|
||||
// exportedName: string;
|
||||
// localName: string;
|
||||
// source?: string;
|
||||
// }[];
|
||||
// /**
|
||||
// * 子模块,形如:Demo.SubModule = value; 或者 Demo.SubModule.Sub = subValue;
|
||||
// */
|
||||
// subModules: {
|
||||
// objectName: string[];
|
||||
// propertyName: string;
|
||||
// value?: string;
|
||||
// // value 是否对应匿名函数
|
||||
// isValueAnonymousFunc: boolean;
|
||||
// }[];
|
||||
// propsTypes: IPropTypes;
|
||||
// propsDefaults: {
|
||||
// name: string;
|
||||
// defaultValue: any;
|
||||
// }[];
|
||||
}
|
||||
|
||||
@ -7,10 +7,10 @@ interface IMaterialScanModel {
|
||||
/** 标记物料组件包所使用的模块规范 */
|
||||
sourceType: 'module' | 'main';
|
||||
/** 每个文件对应的文件内容 */
|
||||
modules: Array<{
|
||||
modules: {
|
||||
filePath: string;
|
||||
fileContent: string;
|
||||
}>;
|
||||
}[];
|
||||
/** 当前包名 */
|
||||
pkgName: string;
|
||||
/** 当前包版本 */
|
||||
|
||||
@ -22,14 +22,6 @@ interface IMaterializeOptions {
|
||||
*/
|
||||
accesser: 'local' | 'online';
|
||||
|
||||
/**
|
||||
* 是否为多组件透出场景
|
||||
* (true:表示多组件透出场景,false:表示单组件透出场景)
|
||||
* @type {boolean}
|
||||
* @memberof IMaterializeOptions
|
||||
*/
|
||||
isExportedAsMultiple: boolean;
|
||||
|
||||
/**
|
||||
* 当 accesser=local 时,需要通过此配置项指定当前工作目录,形如:/usr/.../demo-project
|
||||
* @type {string}
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
import { IMaterialParsedModel } from './IMaterialParsedModel';
|
||||
import IMaterialScanModel from './IMaterialScanModel';
|
||||
|
||||
/**
|
||||
* 解析器
|
||||
* @interface IParser
|
||||
*/
|
||||
interface IParser {
|
||||
/**
|
||||
* 根据 IScanner 阶段的产出结果,解析对文件内容进行 AST 解析
|
||||
* @param {IMaterialScanModel} model IScanner 阶段的产出结果
|
||||
* @returns {Promise<IMaterialParsedModel[]>}
|
||||
* @memberof IParser
|
||||
*/
|
||||
parse(model: IMaterialScanModel): Promise<IMaterialParsedModel[]>;
|
||||
|
||||
/**
|
||||
* 解析 ES5 语法
|
||||
* @param {IMaterialScanModel} model
|
||||
* @returns {Promise<IMaterialParsedModel>}
|
||||
* @memberof IParser
|
||||
*/
|
||||
parseES5(model: IMaterialScanModel): Promise<IMaterialParsedModel>;
|
||||
|
||||
/**
|
||||
* 解析 ESM 语法
|
||||
* @param {{
|
||||
* model: IMaterialScanModel,
|
||||
* filePath: string, // 要解析的文件路径
|
||||
* fileContent: string // 要解析的文件内容
|
||||
* }} params
|
||||
* @returns {Promise<IMaterialParsedModel>}
|
||||
* @memberof IParser
|
||||
*/
|
||||
parseES6(params: {
|
||||
model: IMaterialScanModel;
|
||||
filePath: string;
|
||||
fileContent: string;
|
||||
}): Promise<IMaterialParsedModel>;
|
||||
}
|
||||
|
||||
export default IParser;
|
||||
@ -1,32 +0,0 @@
|
||||
import IMaterialScanModel from './IMaterialScanModel';
|
||||
|
||||
/**
|
||||
* 扫描器接口
|
||||
* @interface IScanner
|
||||
*/
|
||||
interface IScanner {
|
||||
/**
|
||||
* 扫描
|
||||
* @returns {Promise<IMaterialScanModel>} 扫描产物
|
||||
* @memberof IScanner
|
||||
*/
|
||||
scan(): Promise<IMaterialScanModel>;
|
||||
|
||||
/**
|
||||
* 加载文件
|
||||
* @param {string} filePath 文件地址
|
||||
* @returns {Promise<string>} 返回文件内容
|
||||
* @memberof IScanner
|
||||
*/
|
||||
loadFile(filePath: string): Promise<string>;
|
||||
|
||||
/**
|
||||
* 解析 package.json 文件
|
||||
* @param {string} pkgJsonPath 文件路径
|
||||
* @returns {Promise<{ [k: string]: any }>} package 文件信息
|
||||
* @memberof IScanner
|
||||
*/
|
||||
resolvePkgJson(pkgJsonPath: string): Promise<{ [k: string]: any }>;
|
||||
}
|
||||
|
||||
export default IScanner;
|
||||
@ -6,12 +6,13 @@ import ICompiler from './ICompiler';
|
||||
import IExtensionConfigManifest from './IExtensionConfigManifest';
|
||||
import IGenerator from './IGenerator';
|
||||
import IMaterializeOptions from './IMaterializeOptions';
|
||||
export * from './IMaterialParsedModel';
|
||||
import IMaterialScanModel from './IMaterialScanModel';
|
||||
import IParser from './IParser';
|
||||
import IScanner from './IScanner';
|
||||
import SourceType from './SourceType';
|
||||
|
||||
export * from './IMaterialParsedModel';
|
||||
|
||||
export {
|
||||
IGenerator,
|
||||
IParser,
|
||||
|
||||
@ -1,63 +0,0 @@
|
||||
import test from 'ava';
|
||||
import Materialize from '../src/Materialize';
|
||||
import { IMaterializeOptions } from '../src/types';
|
||||
import { getFromFixtures } from './helpers';
|
||||
|
||||
const multiExportedComptPath = getFromFixtures('multiple-exported-component');
|
||||
const singleExportedComptPath = getFromFixtures('single-exported-component');
|
||||
const singleExportedComponent = '@ali/demo-biz-test090702@0.0.2';
|
||||
const multipleExportedComponent = '@ali/aimake-basic@0.1.0';
|
||||
|
||||
test('materialize single exported component by local', async t => {
|
||||
const options: IMaterializeOptions = {
|
||||
cwd: singleExportedComptPath,
|
||||
entry: singleExportedComptPath,
|
||||
accesser: 'local',
|
||||
isExportedAsMultiple: false,
|
||||
};
|
||||
|
||||
const instance = new Materialize(options);
|
||||
const actual = await instance.start();
|
||||
|
||||
t.snapshot(actual);
|
||||
});
|
||||
|
||||
// test('materialize multiple exported component by local', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// cwd: multiExportedComptPath,
|
||||
// entry: multiExportedComptPath,
|
||||
// accesser: 'local',
|
||||
// isExportedAsMultiple: true,
|
||||
// };
|
||||
|
||||
// const instance = new Materialize(options);
|
||||
// const actual = await instance.start();
|
||||
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
|
||||
// test('materialize single exported component by online', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// entry: singleExportedComponent,
|
||||
// accesser: 'online',
|
||||
// isExportedAsMultiple: false,
|
||||
// };
|
||||
|
||||
// const instance = new Materialize(options);
|
||||
// const actual = await instance.start();
|
||||
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
|
||||
// test('materialize multiple exported component by online', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// entry: multipleExportedComponent,
|
||||
// accesser: 'online',
|
||||
// isExportedAsMultiple: false,
|
||||
// };
|
||||
|
||||
// const instance = new Materialize(options);
|
||||
// const actual = await instance.start();
|
||||
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
@ -1,29 +0,0 @@
|
||||
import test from 'ava';
|
||||
import LocalAccesser from '../../src/accesser/LocalAccesser';
|
||||
import { IMaterializeOptions } from '../../src/types';
|
||||
import { getFromFixtures } from '../helpers';
|
||||
|
||||
const multiExportedComptPath = getFromFixtures('multiple-exported-component');
|
||||
const singleExportedComptPath = getFromFixtures('single-exported-component');
|
||||
|
||||
test.serial('access single exported component by local', async t => {
|
||||
const options: IMaterializeOptions = {
|
||||
entry: singleExportedComptPath,
|
||||
accesser: 'local',
|
||||
isExportedAsMultiple: false,
|
||||
};
|
||||
const accesser = new LocalAccesser(options);
|
||||
const actual = await accesser.access();
|
||||
t.snapshot(actual);
|
||||
});
|
||||
|
||||
// test.serial('access multiple exported component by local', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// entry: multiExportedComptPath,
|
||||
// accesser: 'local',
|
||||
// isExportedAsMultiple: true,
|
||||
// };
|
||||
// const accesser = new LocalAccesser(options);
|
||||
// const actual = await accesser.access();
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
@ -1,42 +0,0 @@
|
||||
import test from 'ava';
|
||||
import OnlineAccesser from '../../src/accesser/OnlineAccesser';
|
||||
import { IMaterializeOptions } from '../../src/types';
|
||||
|
||||
const singleExportedComponent = '@ali/demo-biz-test090702@0.0.2';
|
||||
const multipleExportedComponent = '@ali/aimake-basic@0.1.0';
|
||||
|
||||
test.serial('online accesser', t => {
|
||||
t.pass();
|
||||
})
|
||||
// test.serial('access single exported component by online', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// entry: singleExportedComponent,
|
||||
// accesser: 'online',
|
||||
// isExportedAsMultiple: false,
|
||||
// };
|
||||
// const accesser = new OnlineAccesser(options);
|
||||
// const actual = await accesser.access();
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
|
||||
// test.serial('access multiple exported component by online', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// entry: multipleExportedComponent,
|
||||
// accesser: 'online',
|
||||
// isExportedAsMultiple: true,
|
||||
// };
|
||||
// const accesser = new OnlineAccesser(options);
|
||||
// const actual = await accesser.access();
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
|
||||
// test.serial('access @alifd/next@1.17.12 by online', async t => {
|
||||
// const options: IMaterializeOptions = {
|
||||
// entry: '@alifd/next@1.17.12',
|
||||
// accesser: 'online',
|
||||
// isExportedAsMultiple: true,
|
||||
// };
|
||||
// const accesser = new OnlineAccesser(options);
|
||||
// const actual = await accesser.access();
|
||||
// t.snapshot(actual);
|
||||
// });
|
||||
@ -1,529 +0,0 @@
|
||||
# Snapshot report for `test/accesser/LocalAccesser.ts`
|
||||
|
||||
The actual snapshot is saved in `LocalAccesser.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://ava.li).
|
||||
|
||||
## access multiple exported component by local
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeBlank/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeBlank","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"styleFlexLayout","label":"styleFlexLayout","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"},{"name":"id","label":"id","renderer":""}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeBlank',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleFlexLayout',
|
||||
name: 'styleFlexLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'id',
|
||||
name: 'id',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeIcon/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeIcon","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"className","label":"className","renderer":""},{"name":"iconClassName","label":"iconClassName","renderer":""},{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleText","label":"styleText","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeIcon',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'className',
|
||||
name: 'className',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'iconClassName',
|
||||
name: 'iconClassName',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleText',
|
||||
name: 'styleText',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeImage/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeImage","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeImage',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeLink/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeLink","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleText","label":"styleText","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeLink',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleText',
|
||||
name: 'styleText',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakePlaceholder/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakePlaceholder","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakePlaceholder',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeText/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeText","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"type","label":"type","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleText","label":"styleText","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeText',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'type',
|
||||
name: 'type',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleText',
|
||||
name: 'styleText',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/Root/manifest.js',
|
||||
manifestJS: 'export default {"name":"Root","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"style","label":"style","renderer":"","defaultValue":"{\\n padding: 0,\\n backgroundColor: \'#f0f2f5\',\\n minHeight: \'100%\'\\n}"},{"name":"children","label":"children","renderer":""}]}}',
|
||||
manifestObj: {
|
||||
name: 'Root',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: `{␊
|
||||
padding: 0,␊
|
||||
backgroundColor: '#f0f2f5',␊
|
||||
minHeight: '100%'␊
|
||||
}`,
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
## access single exported component by local
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/manifest.js',
|
||||
manifestJS: 'export default {"name":"Demo","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"optionalArray","label":"optionalArray","renderer":""},{"name":"optionalBool","label":"optionalBool","renderer":""},{"name":"optionalFunc","label":"optionalFunc","renderer":""},{"name":"optionalNumber","label":"optionalNumber","renderer":""},{"name":"optionalObject","label":"optionalObject","renderer":""},{"name":"optionalString","label":"optionalString","renderer":""},{"name":"optionalSymbol","label":"optionalSymbol","renderer":""},{"name":"optionalNode","label":"optionalNode","renderer":""},{"name":"optionalElement","label":"optionalElement","renderer":""},{"name":"optionalElementType","label":"optionalElementType","renderer":""},{"name":"optionalMessage","label":"optionalMessage","renderer":""},{"name":"optionalEnum","label":"optionalEnum","renderer":""},{"name":"optionalUnion","label":"optionalUnion","renderer":""},{"name":"optionalArrayOf","label":"optionalArrayOf","renderer":""},{"name":"optionalObjectOf","label":"optionalObjectOf","renderer":""},{"name":"optionalObjectWithShape","label":"optionalObjectWithShape","renderer":""},{"name":"optionalObjectWithShape2","label":"optionalObjectWithShape2","renderer":""},{"name":"optionalObjectWithStrictShape","label":"optionalObjectWithStrictShape","renderer":""},{"name":"requiredFunc","label":"requiredFunc","renderer":""},{"name":"requiredAny","label":"requiredAny","renderer":""}]}}',
|
||||
manifestObj: {
|
||||
name: 'Demo',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalArray',
|
||||
name: 'optionalArray',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalBool',
|
||||
name: 'optionalBool',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalFunc',
|
||||
name: 'optionalFunc',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalNumber',
|
||||
name: 'optionalNumber',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalObject',
|
||||
name: 'optionalObject',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalString',
|
||||
name: 'optionalString',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalSymbol',
|
||||
name: 'optionalSymbol',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalNode',
|
||||
name: 'optionalNode',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalElement',
|
||||
name: 'optionalElement',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalElementType',
|
||||
name: 'optionalElementType',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalMessage',
|
||||
name: 'optionalMessage',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalEnum',
|
||||
name: 'optionalEnum',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalUnion',
|
||||
name: 'optionalUnion',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalArrayOf',
|
||||
name: 'optionalArrayOf',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalObjectOf',
|
||||
name: 'optionalObjectOf',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalObjectWithShape',
|
||||
name: 'optionalObjectWithShape',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalObjectWithShape2',
|
||||
name: 'optionalObjectWithShape2',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'optionalObjectWithStrictShape',
|
||||
name: 'optionalObjectWithStrictShape',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'requiredFunc',
|
||||
name: 'requiredFunc',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'requiredAny',
|
||||
name: 'requiredAny',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,408 +0,0 @@
|
||||
# Snapshot report for `test/accesser/OnlineAccesser.ts`
|
||||
|
||||
The actual snapshot is saved in `OnlineAccesser.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://ava.li).
|
||||
|
||||
## access multiple exported component by online
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/AIMakeBlank/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeBlank","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"styleFlexLayout","label":"styleFlexLayout","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"},{"name":"id","label":"id","renderer":""}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeBlank',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleFlexLayout',
|
||||
name: 'styleFlexLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'id',
|
||||
name: 'id',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/AIMakeIcon/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeIcon","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"className","label":"className","renderer":""},{"name":"iconClassName","label":"iconClassName","renderer":""},{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleText","label":"styleText","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeIcon',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'className',
|
||||
name: 'className',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'iconClassName',
|
||||
name: 'iconClassName',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleText',
|
||||
name: 'styleText',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/AIMakeImage/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeImage","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeImage',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/AIMakeLink/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeLink","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleText","label":"styleText","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeLink',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleText',
|
||||
name: 'styleText',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/AIMakePlaceholder/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakePlaceholder","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakePlaceholder',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/AIMakeText/manifest.js',
|
||||
manifestJS: 'export default {"name":"AIMakeText","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"children","label":"children","renderer":""},{"name":"type","label":"type","renderer":""},{"name":"styleBoxModel","label":"styleBoxModel","renderer":""},{"name":"styleText","label":"styleText","renderer":""},{"name":"styleLayout","label":"styleLayout","renderer":""},{"name":"styleBackground","label":"styleBackground","renderer":""},{"name":"style","label":"style","renderer":"","defaultValue":"{}"}]}}',
|
||||
manifestObj: {
|
||||
name: 'AIMakeText',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'type',
|
||||
name: 'type',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBoxModel',
|
||||
name: 'styleBoxModel',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleText',
|
||||
name: 'styleText',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleLayout',
|
||||
name: 'styleLayout',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'styleBackground',
|
||||
name: 'styleBackground',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: '{}',
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/kDKCQ3wGKzpHh6KU5ExdE1/node_modules/@ali/aimake-basic/es/basic/Root/manifest.js',
|
||||
manifestJS: 'export default {"name":"Root","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[{"name":"style","label":"style","renderer":"","defaultValue":"{\\n padding: 0,\\n backgroundColor: \'#f0f2f5\',\\n minHeight: \'100%\'\\n}"},{"name":"children","label":"children","renderer":""}]}}',
|
||||
manifestObj: {
|
||||
name: 'Root',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [
|
||||
{
|
||||
defaultValue: `{␊
|
||||
padding: 0,␊
|
||||
backgroundColor: '#f0f2f5',␊
|
||||
minHeight: '100%'␊
|
||||
}`,
|
||||
label: 'style',
|
||||
name: 'style',
|
||||
renderer: '',
|
||||
},
|
||||
{
|
||||
defaultValue: undefined,
|
||||
label: 'children',
|
||||
name: 'children',
|
||||
renderer: '',
|
||||
},
|
||||
],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
## access single exported component by online
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/node_modules/.temp/todtaTTK9KxDGepu5Kbb9G/node_modules/@ali/demo-biz-test090702/es/manifest.js',
|
||||
manifestJS: 'export default {"name":"Demo","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}',
|
||||
manifestObj: {
|
||||
name: 'Demo',
|
||||
settings: {
|
||||
handles: [
|
||||
'cut',
|
||||
'copy',
|
||||
'duplicate',
|
||||
'delete',
|
||||
'paste',
|
||||
],
|
||||
insertionModes: 'tbrl',
|
||||
props: [],
|
||||
shouldActive: true,
|
||||
shouldDrag: true,
|
||||
type: 'element_inline',
|
||||
},
|
||||
},
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,188 +0,0 @@
|
||||
# Snapshot report for `test/Materialize.ts`
|
||||
|
||||
The actual snapshot is saved in `Materialize.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## materialize single exported component by local
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/manifest.json',
|
||||
manifestObj: {
|
||||
docUrl: '',
|
||||
npm: {
|
||||
destructuring: false,
|
||||
exportName: '',
|
||||
main: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
package: 'single-exported-component',
|
||||
subName: '',
|
||||
version: '1.0.0',
|
||||
},
|
||||
props: [
|
||||
{
|
||||
name: 'optionalArray',
|
||||
propType: 'array',
|
||||
},
|
||||
{
|
||||
name: 'optionalBool',
|
||||
propType: 'bool',
|
||||
},
|
||||
{
|
||||
name: 'optionalFunc',
|
||||
propType: 'func',
|
||||
},
|
||||
{
|
||||
defaultValue: 123,
|
||||
name: 'optionalNumber',
|
||||
propType: 'number',
|
||||
},
|
||||
{
|
||||
name: 'optionalObject',
|
||||
propType: 'object',
|
||||
},
|
||||
{
|
||||
name: 'optionalString',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'optionalSymbol',
|
||||
propType: 'symbol',
|
||||
},
|
||||
{
|
||||
name: 'optionalNode',
|
||||
propType: 'node',
|
||||
},
|
||||
{
|
||||
name: 'optionalElement',
|
||||
propType: 'element',
|
||||
},
|
||||
{
|
||||
name: 'optionalElementType',
|
||||
propType: 'elementType',
|
||||
},
|
||||
{
|
||||
name: 'optionalMessage',
|
||||
propType: {
|
||||
type: 'instanceOf',
|
||||
value: 'Demo',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalEnum',
|
||||
propType: {
|
||||
type: 'oneOf',
|
||||
value: [
|
||||
'News',
|
||||
'Photos',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalUnion',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
'string',
|
||||
'number',
|
||||
{
|
||||
type: 'instanceOf',
|
||||
value: 'Demo',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalArrayOf',
|
||||
propType: {
|
||||
type: 'arrayOf',
|
||||
value: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectOf',
|
||||
propType: {
|
||||
type: 'objectOf',
|
||||
value: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithShape',
|
||||
propType: {
|
||||
type: 'shape',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithShape2',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'shape',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithStrictShape',
|
||||
propType: {
|
||||
type: 'exact',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'requiredFunc',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'func',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'requiredAny',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'any',
|
||||
},
|
||||
},
|
||||
],
|
||||
screenshot: '',
|
||||
title: 'single-exported-component',
|
||||
},
|
||||
},
|
||||
]
|
||||
Binary file not shown.
@ -1,188 +0,0 @@
|
||||
# Snapshot report for `test/accesser/LocalAccesser.ts`
|
||||
|
||||
The actual snapshot is saved in `LocalAccesser.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## access single exported component by local
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
manifestFilePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/manifest.json',
|
||||
manifestObj: {
|
||||
docUrl: '',
|
||||
npm: {
|
||||
destructuring: false,
|
||||
exportName: '',
|
||||
main: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
package: '@ali/lowcode-engine-material-parser',
|
||||
subName: '',
|
||||
version: '0.1.0',
|
||||
},
|
||||
props: [
|
||||
{
|
||||
name: 'optionalArray',
|
||||
propType: 'array',
|
||||
},
|
||||
{
|
||||
name: 'optionalBool',
|
||||
propType: 'bool',
|
||||
},
|
||||
{
|
||||
name: 'optionalFunc',
|
||||
propType: 'func',
|
||||
},
|
||||
{
|
||||
defaultValue: 123,
|
||||
name: 'optionalNumber',
|
||||
propType: 'number',
|
||||
},
|
||||
{
|
||||
name: 'optionalObject',
|
||||
propType: 'object',
|
||||
},
|
||||
{
|
||||
name: 'optionalString',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'optionalSymbol',
|
||||
propType: 'symbol',
|
||||
},
|
||||
{
|
||||
name: 'optionalNode',
|
||||
propType: 'node',
|
||||
},
|
||||
{
|
||||
name: 'optionalElement',
|
||||
propType: 'element',
|
||||
},
|
||||
{
|
||||
name: 'optionalElementType',
|
||||
propType: 'elementType',
|
||||
},
|
||||
{
|
||||
name: 'optionalMessage',
|
||||
propType: {
|
||||
type: 'instanceOf',
|
||||
value: 'Demo',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalEnum',
|
||||
propType: {
|
||||
type: 'oneOf',
|
||||
value: [
|
||||
'News',
|
||||
'Photos',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalUnion',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
'string',
|
||||
'number',
|
||||
{
|
||||
type: 'instanceOf',
|
||||
value: 'Demo',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalArrayOf',
|
||||
propType: {
|
||||
type: 'arrayOf',
|
||||
value: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectOf',
|
||||
propType: {
|
||||
type: 'objectOf',
|
||||
value: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithShape',
|
||||
propType: {
|
||||
type: 'shape',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithShape2',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'shape',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithStrictShape',
|
||||
propType: {
|
||||
type: 'exact',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'requiredFunc',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'func',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'requiredAny',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'any',
|
||||
},
|
||||
},
|
||||
],
|
||||
screenshot: '',
|
||||
title: '@ali/lowcode-engine-material-parser',
|
||||
},
|
||||
},
|
||||
]
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
1074
packages/material-parser/test/fixtures/__snapshots__/test/index.ts.md
vendored
Normal file
1074
packages/material-parser/test/fixtures/__snapshots__/test/index.ts.md
vendored
Normal file
File diff suppressed because it is too large
Load Diff
BIN
packages/material-parser/test/fixtures/__snapshots__/test/index.ts.snap
vendored
Normal file
BIN
packages/material-parser/test/fixtures/__snapshots__/test/index.ts.snap
vendored
Normal file
Binary file not shown.
@ -1,474 +0,0 @@
|
||||
# Snapshot report for `test/parser/ReactParser.ts`
|
||||
|
||||
The actual snapshot is saved in `ReactParser.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## parse es6 multiple exported component by local
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
defaultExportName: 'AIMakeBlank',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeBlank/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'children',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
{
|
||||
type: 'arrayOf',
|
||||
value: 'node',
|
||||
},
|
||||
'node',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBoxModel',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleLayout',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBackground',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleFlexLayout',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
{
|
||||
name: 'id',
|
||||
propType: 'string',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultExportName: 'AIMakeIcon',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeIcon/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'className',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'iconClassName',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'children',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
{
|
||||
type: 'arrayOf',
|
||||
value: 'node',
|
||||
},
|
||||
'node',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBoxModel',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleText',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBackground',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultExportName: 'AIMakeImage',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeImage/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'styleBoxModel',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultExportName: 'AIMakeLink',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeLink/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'children',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
{
|
||||
type: 'arrayOf',
|
||||
value: 'node',
|
||||
},
|
||||
'node',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBoxModel',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleText',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleLayout',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBackground',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultExportName: 'AIMakePlaceholder',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakePlaceholder/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'children',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
{
|
||||
type: 'arrayOf',
|
||||
value: 'node',
|
||||
},
|
||||
'node',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBoxModel',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleLayout',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultExportName: 'AIMakeText',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeText/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'children',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
{
|
||||
type: 'arrayOf',
|
||||
value: 'node',
|
||||
},
|
||||
'node',
|
||||
'string',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'type',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'styleBoxModel',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleText',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleLayout',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'styleBackground',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'object',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
defaultExportName: 'Root',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/Root/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'style',
|
||||
propType: 'object',
|
||||
},
|
||||
{
|
||||
name: 'children',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
'element',
|
||||
{
|
||||
type: 'arrayOf',
|
||||
value: 'element',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
|
||||
## parse es6 single exported component by local
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
[
|
||||
{
|
||||
defaultExportName: 'Demo',
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
props: [
|
||||
{
|
||||
name: 'optionalArray',
|
||||
propType: 'array',
|
||||
},
|
||||
{
|
||||
name: 'optionalBool',
|
||||
propType: 'bool',
|
||||
},
|
||||
{
|
||||
name: 'optionalFunc',
|
||||
propType: 'func',
|
||||
},
|
||||
{
|
||||
defaultValue: 123,
|
||||
name: 'optionalNumber',
|
||||
propType: 'number',
|
||||
},
|
||||
{
|
||||
name: 'optionalObject',
|
||||
propType: 'object',
|
||||
},
|
||||
{
|
||||
name: 'optionalString',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'optionalSymbol',
|
||||
propType: 'symbol',
|
||||
},
|
||||
{
|
||||
name: 'optionalNode',
|
||||
propType: 'node',
|
||||
},
|
||||
{
|
||||
name: 'optionalElement',
|
||||
propType: 'element',
|
||||
},
|
||||
{
|
||||
name: 'optionalElementType',
|
||||
propType: 'elementType',
|
||||
},
|
||||
{
|
||||
name: 'optionalMessage',
|
||||
propType: {
|
||||
type: 'instanceOf',
|
||||
value: 'Demo',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalEnum',
|
||||
propType: {
|
||||
type: 'oneOf',
|
||||
value: [
|
||||
'News',
|
||||
'Photos',
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalUnion',
|
||||
propType: {
|
||||
type: 'oneOfType',
|
||||
value: [
|
||||
'string',
|
||||
'number',
|
||||
{
|
||||
type: 'instanceOf',
|
||||
value: 'Demo',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalArrayOf',
|
||||
propType: {
|
||||
type: 'arrayOf',
|
||||
value: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectOf',
|
||||
propType: {
|
||||
type: 'objectOf',
|
||||
value: 'number',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithShape',
|
||||
propType: {
|
||||
type: 'shape',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithShape2',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'shape',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'optionalObjectWithStrictShape',
|
||||
propType: {
|
||||
type: 'exact',
|
||||
value: [
|
||||
{
|
||||
name: 'optionalProperty',
|
||||
propType: 'string',
|
||||
},
|
||||
{
|
||||
name: 'requiredProperty',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'number',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'requiredFunc',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'func',
|
||||
},
|
||||
},
|
||||
{
|
||||
name: 'requiredAny',
|
||||
propType: {
|
||||
isRequired: true,
|
||||
type: 'any',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
]
|
||||
Binary file not shown.
132
packages/material-parser/test/fixtures/__snapshots__/test/scan.ts.md
vendored
Normal file
132
packages/material-parser/test/fixtures/__snapshots__/test/scan.ts.md
vendored
Normal file
@ -0,0 +1,132 @@
|
||||
# Snapshot report for `test/scan.ts`
|
||||
|
||||
The actual snapshot is saved in `scan.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## scan multiple exported component
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
mainEntry: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/index.js',
|
||||
modules: [
|
||||
{
|
||||
fileContent: `import AIMakeBlank from './basic/AIMakeBlank';␊
|
||||
import AIMakeIcon from './basic/AIMakeIcon';␊
|
||||
import AIMakeImage from './basic/AIMakeImage';␊
|
||||
import AIMakeLink from './basic/AIMakeLink';␊
|
||||
import AIMakePlaceholder from './basic/AIMakePlaceholder';␊
|
||||
import AIMakeText from './basic/AIMakeText';␊
|
||||
import Root from './basic/Root';␊
|
||||
␊
|
||||
export { AIMakeBlank, AIMakeIcon, AIMakeImage, AIMakeLink, AIMakePlaceholder, AIMakeText, Root };␊
|
||||
`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/index.js',
|
||||
},
|
||||
],
|
||||
pkgName: 'multiple-exported-component',
|
||||
pkgVersion: '1.0.0',
|
||||
sourceType: 'module',
|
||||
}
|
||||
|
||||
## scan single exported component
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
mainEntry: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
modules: [
|
||||
{
|
||||
fileContent: `import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
␊
|
||||
/* eslint-disable react/no-unused-prop-types */␊
|
||||
␊
|
||||
/* eslint-disable react/require-default-props */␊
|
||||
import React from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import "./main.css";␊
|
||||
␊
|
||||
const Demo =␊
|
||||
/* #__PURE__ */␊
|
||||
function (_React$Component) {␊
|
||||
_inherits(Demo, _React$Component);␊
|
||||
␊
|
||||
function Demo() {␊
|
||||
_classCallCheck(this, Demo);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(Demo).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(Demo, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
return React.createElement("div", null, " Test ");␊
|
||||
},␊
|
||||
}]);␊
|
||||
␊
|
||||
return Demo;␊
|
||||
}(React.Component);␊
|
||||
␊
|
||||
Demo.propTypes = {␊
|
||||
optionalArray: PropTypes.array,␊
|
||||
optionalBool: PropTypes.bool,␊
|
||||
optionalFunc: PropTypes.func,␊
|
||||
optionalNumber: PropTypes.number,␊
|
||||
optionalObject: PropTypes.object,␊
|
||||
optionalString: PropTypes.string,␊
|
||||
optionalSymbol: PropTypes.symbol,␊
|
||||
// Anything that can be rendered: numbers, strings, elements or an array␊
|
||||
// (or fragment) containing these types.␊
|
||||
optionalNode: PropTypes.node,␊
|
||||
// A React element (ie. <MyComponent />).␊
|
||||
optionalElement: PropTypes.element,␊
|
||||
// A React element type (ie. MyComponent).␊
|
||||
optionalElementType: PropTypes.elementType,␊
|
||||
// You can also declare that a prop is an instance of a class. This uses␊
|
||||
// JS's instanceof operator.␊
|
||||
optionalMessage: PropTypes.instanceOf(Demo),␊
|
||||
// You can ensure that your prop is limited to specific values by treating␊
|
||||
// it as an enum.␊
|
||||
optionalEnum: PropTypes.oneOf(['News', 'Photos']),␊
|
||||
// An object that could be one of many types␊
|
||||
optionalUnion: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Demo)]),␊
|
||||
// An array of a certain type␊
|
||||
optionalArrayOf: PropTypes.arrayOf(PropTypes.number),␊
|
||||
// An object with property values of a certain type␊
|
||||
optionalObjectOf: PropTypes.objectOf(PropTypes.number),␊
|
||||
// You can chain any of the above with `isRequired` to make sure a warning␊
|
||||
// is shown if the prop isn't provided.␊
|
||||
// An object taking on a particular shape␊
|
||||
optionalObjectWithShape: PropTypes.shape({␊
|
||||
optionalProperty: PropTypes.string,␊
|
||||
requiredProperty: PropTypes.number.isRequired,␊
|
||||
}),␊
|
||||
optionalObjectWithShape2: PropTypes.shape({␊
|
||||
optionalProperty: PropTypes.string,␊
|
||||
requiredProperty: PropTypes.number.isRequired,␊
|
||||
}).isRequired,␊
|
||||
// An object with warnings on extra properties␊
|
||||
optionalObjectWithStrictShape: PropTypes.exact({␊
|
||||
optionalProperty: PropTypes.string,␊
|
||||
requiredProperty: PropTypes.number.isRequired,␊
|
||||
}),␊
|
||||
requiredFunc: PropTypes.func.isRequired,␊
|
||||
// A value of any data type␊
|
||||
requiredAny: PropTypes.any.isRequired,␊
|
||||
};␊
|
||||
Demo.defaultProps = {␊
|
||||
optionalNumber: 123,␊
|
||||
};␊
|
||||
export default Demo;`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
},
|
||||
],
|
||||
pkgName: 'single-exported-component',
|
||||
pkgVersion: '1.0.0',
|
||||
sourceType: 'module',
|
||||
}
|
||||
BIN
packages/material-parser/test/fixtures/__snapshots__/test/scan.ts.snap
vendored
Normal file
BIN
packages/material-parser/test/fixtures/__snapshots__/test/scan.ts.snap
vendored
Normal file
Binary file not shown.
@ -1,623 +0,0 @@
|
||||
# Snapshot report for `test/scanner/Scanner.ts`
|
||||
|
||||
The actual snapshot is saved in `Scanner.ts.snap`.
|
||||
|
||||
Generated by [AVA](https://avajs.dev).
|
||||
|
||||
## scan multiple exported component
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
mainEntry: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/index.js',
|
||||
modules: [
|
||||
{
|
||||
fileContent: `import _extends from "@babel/runtime/helpers/extends";␊
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React, { Component } from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import HOCBoxModelProps from '../utils/HOCBoxModelProps';␊
|
||||
import HOCLayoutProps from '../utils/HOCLayoutProps';␊
|
||||
import HOCBackgroundProps from '../utils/HOCBackgroundProps';␊
|
||||
import HOCFlexLayoutProps from '../utils/HOCFlexLayoutProps';␊
|
||||
␊
|
||||
var AIMakeBlank =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_Component) {␊
|
||||
_inherits(AIMakeBlank, _Component);␊
|
||||
␊
|
||||
function AIMakeBlank() {␊
|
||||
_classCallCheck(this, AIMakeBlank);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(AIMakeBlank).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(AIMakeBlank, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var merged = {};␊
|
||||
var _this$props = this.props,␊
|
||||
children = _this$props.children,␊
|
||||
styleBoxModel = _this$props.styleBoxModel,␊
|
||||
styleLayout = _this$props.styleLayout,␊
|
||||
styleBackground = _this$props.styleBackground,␊
|
||||
styleFlexLayout = _this$props.styleFlexLayout,␊
|
||||
style = _this$props.style,␊
|
||||
id = _this$props.id;␊
|
||||
var styles = { ...styleBoxModel,␊
|
||||
...styleLayout,␊
|
||||
...styleBackground,␊
|
||||
...styleFlexLayout,␊
|
||||
...style␊
|
||||
};␊
|
||||
␊
|
||||
if (id) {␊
|
||||
merged.id = id;␊
|
||||
}␊
|
||||
␊
|
||||
return React.createElement("div", _extends({␊
|
||||
style: styles␊
|
||||
}, merged), children);␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return AIMakeBlank;␊
|
||||
}(Component);␊
|
||||
␊
|
||||
_defineProperty(AIMakeBlank, "propTypes", {␊
|
||||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),␊
|
||||
styleBoxModel: PropTypes.object.isRequired,␊
|
||||
styleLayout: PropTypes.object.isRequired,␊
|
||||
styleBackground: PropTypes.object.isRequired,␊
|
||||
styleFlexLayout: PropTypes.object.isRequired,␊
|
||||
style: PropTypes.object,␊
|
||||
id: PropTypes.string␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(AIMakeBlank, "defaultProps", {␊
|
||||
children: [],␊
|
||||
style: {},␊
|
||||
id: ''␊
|
||||
});␊
|
||||
␊
|
||||
export default HOCBoxModelProps(HOCLayoutProps(HOCBackgroundProps(HOCFlexLayoutProps(AIMakeBlank))));`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeBlank/index.js',
|
||||
},
|
||||
{
|
||||
fileContent: `import _extends from "@babel/runtime/helpers/extends";␊
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";␊
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React, { Component } from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import classNames from 'classnames';␊
|
||||
import createFromIconfont from './IconFont';␊
|
||||
␊
|
||||
var AIMakeIcon =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_Component) {␊
|
||||
_inherits(AIMakeIcon, _Component);␊
|
||||
␊
|
||||
function AIMakeIcon() {␊
|
||||
_classCallCheck(this, AIMakeIcon);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(AIMakeIcon).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(AIMakeIcon, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var _this$props = this.props,␊
|
||||
className = _this$props.className,␊
|
||||
iconClassName = _this$props.iconClassName,␊
|
||||
children = _this$props.children,␊
|
||||
styleBoxModel = _this$props.styleBoxModel,␊
|
||||
styleText = _this$props.styleText,␊
|
||||
styleBackground = _this$props.styleBackground,␊
|
||||
style = _this$props.style,␊
|
||||
otherProps = _objectWithoutProperties(_this$props, ["className", "iconClassName", "children", "styleBoxModel", "styleText", "styleBackground", "style"]);␊
|
||||
␊
|
||||
var styles = { ...styleBoxModel,␊
|
||||
...styleText,␊
|
||||
...styleBackground,␊
|
||||
...style␊
|
||||
};␊
|
||||
return React.createElement("i", _extends({}, otherProps, {␊
|
||||
className: classNames(className, iconClassName),␊
|
||||
style: styles␊
|
||||
}), children);␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return AIMakeIcon;␊
|
||||
}(Component);␊
|
||||
␊
|
||||
_defineProperty(AIMakeIcon, "propTypes", {␊
|
||||
className: PropTypes.string,␊
|
||||
iconClassName: PropTypes.string,␊
|
||||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),␊
|
||||
styleBoxModel: PropTypes.object.isRequired,␊
|
||||
styleText: PropTypes.object.isRequired,␊
|
||||
styleBackground: PropTypes.object.isRequired,␊
|
||||
style: PropTypes.object␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(AIMakeIcon, "defaultProps", {␊
|
||||
className: '',␊
|
||||
iconClassName: 'iconfont',␊
|
||||
children: '',␊
|
||||
style: {}␊
|
||||
});␊
|
||||
␊
|
||||
AIMakeIcon.createFromIconfont = createFromIconfont;␊
|
||||
export default AIMakeIcon;`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeIcon/index.js',
|
||||
},
|
||||
{
|
||||
fileContent: `import _extends from "@babel/runtime/helpers/extends";␊
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";␊
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React, { Component } from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import HOCBoxModelProps from '../utils/HOCBoxModelProps';␊
|
||||
␊
|
||||
var AIMakeImage =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_Component) {␊
|
||||
_inherits(AIMakeImage, _Component);␊
|
||||
␊
|
||||
function AIMakeImage() {␊
|
||||
_classCallCheck(this, AIMakeImage);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(AIMakeImage).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(AIMakeImage, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var _this$props = this.props,␊
|
||||
styleBoxModel = _this$props.styleBoxModel,␊
|
||||
style = _this$props.style,␊
|
||||
otherProps = _objectWithoutProperties(_this$props, ["styleBoxModel", "style"]);␊
|
||||
␊
|
||||
var styles = { ...styleBoxModel,␊
|
||||
...style␊
|
||||
};␊
|
||||
return React.createElement("img", _extends({}, otherProps, {␊
|
||||
style: styles,␊
|
||||
alt: "AIMakeImage"␊
|
||||
}));␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return AIMakeImage;␊
|
||||
}(Component);␊
|
||||
␊
|
||||
_defineProperty(AIMakeImage, "propTypes", {␊
|
||||
styleBoxModel: PropTypes.object.isRequired,␊
|
||||
style: PropTypes.object␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(AIMakeImage, "defaultProps", {␊
|
||||
style: {}␊
|
||||
});␊
|
||||
␊
|
||||
export default HOCBoxModelProps(AIMakeImage);`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeImage/index.js',
|
||||
},
|
||||
{
|
||||
fileContent: `import _extends from "@babel/runtime/helpers/extends";␊
|
||||
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";␊
|
||||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React, { Component } from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import HOCBoxModelProps from '../utils/HOCBoxModelProps';␊
|
||||
import HOCTextProps from '../utils/HOCTextProps';␊
|
||||
import HOCLayoutProps from '../utils/HOCLayoutProps';␊
|
||||
import HOCBackgroundProps from '../utils/HOCBackgroundProps';␊
|
||||
␊
|
||||
var AIMakeLink =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_Component) {␊
|
||||
_inherits(AIMakeLink, _Component);␊
|
||||
␊
|
||||
function AIMakeLink() {␊
|
||||
_classCallCheck(this, AIMakeLink);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(AIMakeLink).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(AIMakeLink, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var _this$props = this.props,␊
|
||||
children = _this$props.children,␊
|
||||
styleBoxModel = _this$props.styleBoxModel,␊
|
||||
styleText = _this$props.styleText,␊
|
||||
styleLayout = _this$props.styleLayout,␊
|
||||
styleBackground = _this$props.styleBackground,␊
|
||||
style = _this$props.style,␊
|
||||
otherProps = _objectWithoutProperties(_this$props, ["children", "styleBoxModel", "styleText", "styleLayout", "styleBackground", "style"]);␊
|
||||
␊
|
||||
var styles = { ...styleBoxModel,␊
|
||||
...styleText,␊
|
||||
...styleLayout,␊
|
||||
...styleBackground,␊
|
||||
...style␊
|
||||
};␊
|
||||
␊
|
||||
if (typeof children !== 'string') {␊
|
||||
styles.display = 'inline-block';␊
|
||||
}␊
|
||||
␊
|
||||
return React.createElement("a", _extends({}, otherProps, {␊
|
||||
style: styles␊
|
||||
}), [children]);␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return AIMakeLink;␊
|
||||
}(Component);␊
|
||||
␊
|
||||
_defineProperty(AIMakeLink, "propTypes", {␊
|
||||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),␊
|
||||
styleBoxModel: PropTypes.object.isRequired,␊
|
||||
styleText: PropTypes.object.isRequired,␊
|
||||
styleLayout: PropTypes.object.isRequired,␊
|
||||
styleBackground: PropTypes.object.isRequired,␊
|
||||
style: PropTypes.object␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(AIMakeLink, "defaultProps", {␊
|
||||
children: '',␊
|
||||
style: {}␊
|
||||
});␊
|
||||
␊
|
||||
export default HOCBoxModelProps(HOCTextProps(HOCLayoutProps(HOCBackgroundProps(AIMakeLink))));`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeLink/index.js',
|
||||
},
|
||||
{
|
||||
fileContent: `import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React, { Component } from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import HOCBoxModelProps from '../utils/HOCBoxModelProps';␊
|
||||
import HOCLayoutProps from '../utils/HOCLayoutProps';␊
|
||||
␊
|
||||
var AIMakePlaceholder =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_Component) {␊
|
||||
_inherits(AIMakePlaceholder, _Component);␊
|
||||
␊
|
||||
function AIMakePlaceholder() {␊
|
||||
_classCallCheck(this, AIMakePlaceholder);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(AIMakePlaceholder).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(AIMakePlaceholder, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var _this$props = this.props,␊
|
||||
children = _this$props.children,␊
|
||||
styleBoxModel = _this$props.styleBoxModel,␊
|
||||
styleLayout = _this$props.styleLayout,␊
|
||||
style = _this$props.style;␊
|
||||
var styles = { ...styleBoxModel,␊
|
||||
...styleLayout,␊
|
||||
...style␊
|
||||
};␊
|
||||
var placeholderStyle = {␊
|
||||
display: 'inline-block',␊
|
||||
border: '1px dashed #aaa',␊
|
||||
lineHeight: styles.height,␊
|
||||
backgroundColor: '#F5E075',␊
|
||||
overflow: 'hidden',␊
|
||||
textAlign: 'center',␊
|
||||
...styles␊
|
||||
};␊
|
||||
return React.createElement("div", {␊
|
||||
style: placeholderStyle␊
|
||||
}, children);␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return AIMakePlaceholder;␊
|
||||
}(Component);␊
|
||||
␊
|
||||
_defineProperty(AIMakePlaceholder, "propTypes", {␊
|
||||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node]),␊
|
||||
styleBoxModel: PropTypes.object.isRequired,␊
|
||||
styleLayout: PropTypes.object.isRequired,␊
|
||||
style: PropTypes.object␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(AIMakePlaceholder, "defaultProps", {␊
|
||||
children: '',␊
|
||||
style: {}␊
|
||||
});␊
|
||||
␊
|
||||
export default HOCBoxModelProps(HOCLayoutProps(AIMakePlaceholder));`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakePlaceholder/index.js',
|
||||
},
|
||||
{
|
||||
fileContent: `import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React, { Component } from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import HOCBoxModelProps from '../utils/HOCBoxModelProps';␊
|
||||
import HOCTextProps from '../utils/HOCTextProps';␊
|
||||
import HOCLayoutProps from '../utils/HOCLayoutProps';␊
|
||||
import HOCBackgroundProps from '../utils/HOCBackgroundProps';␊
|
||||
␊
|
||||
var AIMakeText =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_Component) {␊
|
||||
_inherits(AIMakeText, _Component);␊
|
||||
␊
|
||||
function AIMakeText() {␊
|
||||
var _this;␊
|
||||
␊
|
||||
_classCallCheck(this, AIMakeText);␊
|
||||
␊
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {␊
|
||||
args[_key] = arguments[_key];␊
|
||||
}␊
|
||||
␊
|
||||
_this = _possibleConstructorReturn(this, _getPrototypeOf(AIMakeText).call(this, ...args));␊
|
||||
␊
|
||||
_defineProperty(_assertThisInitialized(_this), "generateComponentType", function (componentType) {␊
|
||||
var componentNameMap = {␊
|
||||
h1: 'h1',␊
|
||||
h2: 'h2',␊
|
||||
h3: 'h3',␊
|
||||
h4: 'h4',␊
|
||||
h5: 'h5',␊
|
||||
paragraph: 'p',␊
|
||||
label: 'label'␊
|
||||
};␊
|
||||
return componentNameMap[componentType] || 'div';␊
|
||||
});␊
|
||||
␊
|
||||
return _this;␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(AIMakeText, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var _this$props = this.props,␊
|
||||
children = _this$props.children,␊
|
||||
type = _this$props.type,␊
|
||||
styleBoxModel = _this$props.styleBoxModel,␊
|
||||
styleText = _this$props.styleText,␊
|
||||
styleLayout = _this$props.styleLayout,␊
|
||||
styleBackground = _this$props.styleBackground,␊
|
||||
style = _this$props.style;␊
|
||||
var styles = { ...styleBoxModel,␊
|
||||
...styleText,␊
|
||||
...styleLayout,␊
|
||||
...styleBackground,␊
|
||||
...style␊
|
||||
};␊
|
||||
var Comp = this.generateComponentType(type);␊
|
||||
var labelStyle = Comp === 'label' ? {␊
|
||||
display: 'inline-block'␊
|
||||
} : {};␊
|
||||
return React.createElement(Comp, {␊
|
||||
className: "AIMakeText",␊
|
||||
style: Object.assign(labelStyle, styles)␊
|
||||
}, [children]);␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return AIMakeText;␊
|
||||
}(Component);␊
|
||||
␊
|
||||
_defineProperty(AIMakeText, "propTypes", {␊
|
||||
children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.node), PropTypes.node, PropTypes.string]),␊
|
||||
type: PropTypes.string,␊
|
||||
styleBoxModel: PropTypes.object.isRequired,␊
|
||||
styleText: PropTypes.object.isRequired,␊
|
||||
styleLayout: PropTypes.object.isRequired,␊
|
||||
styleBackground: PropTypes.object.isRequired,␊
|
||||
style: PropTypes.object␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(AIMakeText, "defaultProps", {␊
|
||||
children: '',␊
|
||||
type: '',␊
|
||||
// paragraph || label␊
|
||||
style: {}␊
|
||||
});␊
|
||||
␊
|
||||
export default HOCBoxModelProps(HOCTextProps(HOCLayoutProps(HOCBackgroundProps(AIMakeText))));`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/AIMakeText/index.js',
|
||||
},
|
||||
{
|
||||
fileContent: `import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
import _defineProperty from "@babel/runtime/helpers/defineProperty";␊
|
||||
import React from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
␊
|
||||
var Root =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_React$Component) {␊
|
||||
_inherits(Root, _React$Component);␊
|
||||
␊
|
||||
function Root() {␊
|
||||
_classCallCheck(this, Root);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(Root).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(Root, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
var _this$props = this.props,␊
|
||||
style = _this$props.style,␊
|
||||
children = _this$props.children;␊
|
||||
var newStyle = Object.assign({}, Root.defaultProps.style, style);␊
|
||||
return React.createElement("div", {␊
|
||||
style: newStyle␊
|
||||
}, children);␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return Root;␊
|
||||
}(React.Component);␊
|
||||
␊
|
||||
_defineProperty(Root, "propTypes", {␊
|
||||
style: PropTypes.object,␊
|
||||
children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)])␊
|
||||
});␊
|
||||
␊
|
||||
_defineProperty(Root, "defaultProps", {␊
|
||||
style: {␊
|
||||
padding: 0,␊
|
||||
backgroundColor: '#f0f2f5',␊
|
||||
minHeight: '100%'␊
|
||||
},␊
|
||||
children: null␊
|
||||
});␊
|
||||
␊
|
||||
export default Root;`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/multiple-exported-component/es/basic/Root/index.js',
|
||||
},
|
||||
],
|
||||
pkgName: 'multiple-exported-component',
|
||||
pkgVersion: '1.0.0',
|
||||
sourceType: 'module',
|
||||
}
|
||||
|
||||
## scan single exported component
|
||||
|
||||
> Snapshot 1
|
||||
|
||||
{
|
||||
mainEntry: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
modules: [
|
||||
{
|
||||
fileContent: `import _classCallCheck from "@babel/runtime/helpers/classCallCheck";␊
|
||||
import _createClass from "@babel/runtime/helpers/createClass";␊
|
||||
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";␊
|
||||
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";␊
|
||||
import _inherits from "@babel/runtime/helpers/inherits";␊
|
||||
␊
|
||||
/* eslint-disable react/no-unused-prop-types */␊
|
||||
␊
|
||||
/* eslint-disable react/require-default-props */␊
|
||||
import React from 'react';␊
|
||||
import PropTypes from 'prop-types';␊
|
||||
import "./main.css";␊
|
||||
␊
|
||||
var Demo =␊
|
||||
/*#__PURE__*/␊
|
||||
function (_React$Component) {␊
|
||||
_inherits(Demo, _React$Component);␊
|
||||
␊
|
||||
function Demo() {␊
|
||||
_classCallCheck(this, Demo);␊
|
||||
␊
|
||||
return _possibleConstructorReturn(this, _getPrototypeOf(Demo).apply(this, arguments));␊
|
||||
}␊
|
||||
␊
|
||||
_createClass(Demo, [{␊
|
||||
key: "render",␊
|
||||
value: function render() {␊
|
||||
return React.createElement("div", null, " Test ");␊
|
||||
}␊
|
||||
}]);␊
|
||||
␊
|
||||
return Demo;␊
|
||||
}(React.Component);␊
|
||||
␊
|
||||
Demo.propTypes = {␊
|
||||
optionalArray: PropTypes.array,␊
|
||||
optionalBool: PropTypes.bool,␊
|
||||
optionalFunc: PropTypes.func,␊
|
||||
optionalNumber: PropTypes.number,␊
|
||||
optionalObject: PropTypes.object,␊
|
||||
optionalString: PropTypes.string,␊
|
||||
optionalSymbol: PropTypes.symbol,␊
|
||||
// Anything that can be rendered: numbers, strings, elements or an array␊
|
||||
// (or fragment) containing these types.␊
|
||||
optionalNode: PropTypes.node,␊
|
||||
// A React element (ie. <MyComponent />).␊
|
||||
optionalElement: PropTypes.element,␊
|
||||
// A React element type (ie. MyComponent).␊
|
||||
optionalElementType: PropTypes.elementType,␊
|
||||
// You can also declare that a prop is an instance of a class. This uses␊
|
||||
// JS's instanceof operator.␊
|
||||
optionalMessage: PropTypes.instanceOf(Demo),␊
|
||||
// You can ensure that your prop is limited to specific values by treating␊
|
||||
// it as an enum.␊
|
||||
optionalEnum: PropTypes.oneOf(['News', 'Photos']),␊
|
||||
// An object that could be one of many types␊
|
||||
optionalUnion: PropTypes.oneOfType([PropTypes.string, PropTypes.number, PropTypes.instanceOf(Demo)]),␊
|
||||
// An array of a certain type␊
|
||||
optionalArrayOf: PropTypes.arrayOf(PropTypes.number),␊
|
||||
// An object with property values of a certain type␊
|
||||
optionalObjectOf: PropTypes.objectOf(PropTypes.number),␊
|
||||
// You can chain any of the above with `isRequired` to make sure a warning␊
|
||||
// is shown if the prop isn't provided.␊
|
||||
// An object taking on a particular shape␊
|
||||
optionalObjectWithShape: PropTypes.shape({␊
|
||||
optionalProperty: PropTypes.string,␊
|
||||
requiredProperty: PropTypes.number.isRequired␊
|
||||
}),␊
|
||||
optionalObjectWithShape2: PropTypes.shape({␊
|
||||
optionalProperty: PropTypes.string,␊
|
||||
requiredProperty: PropTypes.number.isRequired␊
|
||||
}).isRequired,␊
|
||||
// An object with warnings on extra properties␊
|
||||
optionalObjectWithStrictShape: PropTypes.exact({␊
|
||||
optionalProperty: PropTypes.string,␊
|
||||
requiredProperty: PropTypes.number.isRequired␊
|
||||
}),␊
|
||||
requiredFunc: PropTypes.func.isRequired,␊
|
||||
// A value of any data type␊
|
||||
requiredAny: PropTypes.any.isRequired␊
|
||||
};␊
|
||||
Demo.defaultProps = {␊
|
||||
optionalNumber: 123␊
|
||||
};␊
|
||||
export default Demo;`,
|
||||
filePath: '/Users/gengyang/code/frontend/low-code/ali-lowcode-engine/packages/material-parser/test/fixtures/single-exported-component/es/index.js',
|
||||
},
|
||||
],
|
||||
pkgName: 'single-exported-component',
|
||||
pkgVersion: '1.0.0',
|
||||
sourceType: 'module',
|
||||
}
|
||||
Binary file not shown.
@ -1,14 +1,11 @@
|
||||
{
|
||||
"name": "fusion-next-component",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@alife/next": "^1.17.12"
|
||||
"name": "@alifd/next",
|
||||
"version": "1.19.18",
|
||||
"description": "A configurable component library for web built on React.",
|
||||
"main": "src/index.js",
|
||||
"typings": "types/index.d.ts",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/alibaba-fusion/next.git"
|
||||
}
|
||||
}
|
||||
|
||||
22
packages/material-parser/test/fixtures/fusion-next-component/src/.editorconfig
vendored
Normal file
22
packages/material-parser/test/fixtures/fusion-next-component/src/.editorconfig
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# EditorConfig helps developers define and maintain consistent
|
||||
# coding styles between different editors and IDEs
|
||||
# editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
# Apply for all files
|
||||
[*]
|
||||
|
||||
charset = utf-8
|
||||
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
# package.json
|
||||
[package.json]
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
5
packages/material-parser/test/fixtures/fusion-next-component/src/.eslintrc
vendored
Normal file
5
packages/material-parser/test/fixtures/fusion-next-component/src/.eslintrc
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"rules": {
|
||||
"react/prefer-stateless-function": "off"
|
||||
}
|
||||
}
|
||||
17
packages/material-parser/test/fixtures/fusion-next-component/src/.stylelintrc
vendored
Normal file
17
packages/material-parser/test/fixtures/fusion-next-component/src/.stylelintrc
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"extends": [
|
||||
"@alifd/stylelint-config-next"
|
||||
],
|
||||
"ignoreFiles": [
|
||||
"**/*.js",
|
||||
"**/*.jsx"
|
||||
],
|
||||
"rules": {
|
||||
"max-nesting-depth": 4,
|
||||
"max-empty-lines": 3,
|
||||
"no-duplicate-selectors": null,
|
||||
"no-descending-specificity": null,
|
||||
"font-family-no-missing-generic-family-keyword": null,
|
||||
"no-empty-source": null
|
||||
}
|
||||
}
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Affix from './../../../../node_modules/@alife/next/es/affix/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Affix, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Affix","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Animate from './../../../../node_modules/@alife/next/es/animate/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Animate, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Animate","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Badge from './../../../../node_modules/@alife/next/es/badge/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Badge, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Badge","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Balloon from './../../../../node_modules/@alife/next/es/balloon/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Balloon, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Balloon","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Breadcrumb from './../../../../node_modules/@alife/next/es/breadcrumb/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Breadcrumb, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Breadcrumb","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Button from './../../../../node_modules/@alife/next/es/button/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Button, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Button","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Calendar from './../../../../node_modules/@alife/next/es/calendar/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Calendar, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Calendar","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Card from './../../../../node_modules/@alife/next/es/card/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Card, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Card","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import CascaderSelect from './../../../../node_modules/@alife/next/es/cascader-select/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: CascaderSelect, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"CascaderSelect","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Cascader from './../../../../node_modules/@alife/next/es/cascader/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Cascader, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Cascader","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Checkbox from './../../../../node_modules/@alife/next/es/checkbox/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Checkbox, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Checkbox","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Collapse from './../../../../node_modules/@alife/next/es/collapse/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Collapse, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Collapse","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import ConfigProvider from './../../../../node_modules/@alife/next/es/config-provider/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: ConfigProvider, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"ConfigProvider","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import DatePicker from './../../../../node_modules/@alife/next/es/date-picker/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: DatePicker, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"DatePicker","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Dialog from './../../../../node_modules/@alife/next/es/dialog/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Dialog, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Dialog","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Drawer from './../../../../node_modules/@alife/next/es/drawer/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Drawer, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Drawer","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Dropdown from './../../../../node_modules/@alife/next/es/dropdown/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Dropdown, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Dropdown","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Field from './../../../../node_modules/@alife/next/es/field/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Field, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Field","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Form from './../../../../node_modules/@alife/next/es/form/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Form, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Form","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
@ -1,5 +0,0 @@
|
||||
|
||||
import Grid from './../../../../node_modules/@alife/next/es/grid/index.js';
|
||||
import manifest from './manifest.js';
|
||||
export default { origin: Grid, manifest };
|
||||
|
||||
@ -1 +0,0 @@
|
||||
const manifest = {"name":"Grid","settings":{"type":"element_inline","insertionModes":"tbrl","handles":["cut","copy","duplicate","delete","paste"],"shouldActive":true,"shouldDrag":true,"props":[]}}; export default manifest;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user