fix(packages): delete types and utils buildscripts

This commit is contained in:
1ncounter 2024-03-23 14:05:25 +08:00
parent 3592356c90
commit 62c535bf2a
62 changed files with 372 additions and 581 deletions

View File

@ -1,13 +0,0 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
quote_type = single
[*.md]
trim_trailing_whitespace = false

11
TODOS.md Normal file
View File

@ -0,0 +1,11 @@
## project
### docs for contributing:
1. init
2. develop
3. debug
4. build
5. test
6. publish
7. github workflows

View File

@ -1,6 +0,0 @@
module.exports = {
plugins: [
['@babel/plugin-proposal-decorators', { legacy: true }],
[require.resolve('@babel/plugin-proposal-class-properties'), { loose: true }],
],
};

View File

@ -1,37 +0,0 @@
{
"lerna": "4.0.0",
"version": "1.3.2",
"npmClient": "yarn",
"useWorkspaces": true,
"packages": [
"packages/*",
"runtime/*"
],
"command": {
"bootstrap": {
"npmClientArgs": [
"--no-package-lock"
]
},
"version": {
"allowBranch": [
"master",
"main",
"release/*",
"daily/*",
"refactor/*"
]
},
"publish": {
"npmClient": "npm",
"verifyRegistry": false,
"verifyAccess": false,
"ignoreChanges": [
"**/*.md",
"**/test/**"
],
"message": "chore(release): publish %v",
"conventionalCommits": true
}
}
}

View File

@ -1,19 +1,7 @@
{ {
"private": true, "private": true,
"workspaces": {
"packages": [
"packages/*",
"runtime/*",
"examples/*"
],
"nohoist": [
"**/css-modules-typescript-loader",
"**/@alifc/theme-lowcode-*",
"**/jest"
]
},
"scripts": { "scripts": {
"dev": "pnpm --filter playground dev", "playground": "pnpm --filter playground dev",
"build": "./scripts/build.sh", "build": "./scripts/build.sh",
"build:npm": "lerna run build --stream", "build:npm": "lerna run build --stream",
"build:umd": "lerna run build:umd --stream", "build:umd": "lerna run build:umd --stream",
@ -30,13 +18,9 @@
"pub:preminor": "npm run watchdog:build && lerna publish preminor --force-publish --exact --dist-tag beta --preid beta --no-changelog", "pub:preminor": "npm run watchdog:build && lerna publish preminor --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prepatch": "npm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog", "pub:prepatch": "npm run watchdog:build && lerna publish prepatch --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"pub:prerelease": "npm run watchdog:build && lerna publish prerelease --yes --force-publish --exact --dist-tag beta --preid beta --no-changelog", "pub:prerelease": "npm run watchdog:build && lerna publish prerelease --yes --force-publish --exact --dist-tag beta --preid beta --no-changelog",
"setup": "node ./scripts/setup.js",
"setup:test": "./scripts/setup-for-test.sh",
"setup:skip-build": "./scripts/setup-skip-build.sh", "setup:skip-build": "./scripts/setup-skip-build.sh",
"start": "node ./scripts/start.js",
"test": "lerna run test --stream", "test": "lerna run test --stream",
"test:snapshot": "lerna run test:snapshot", "test:snapshot": "lerna run test:snapshot",
"watchdog:build": "node ./scripts/watchdog.js",
"sync": "./scripts/sync.sh", "sync": "./scripts/sync.sh",
"syncOss": "node ./scripts/sync-oss.js" "syncOss": "node ./scripts/sync-oss.js"
}, },

View File

@ -1,6 +1,5 @@
const { execSync } = require('child_process'); const { execSync } = require('child_process');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin'); const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const fse = require('fs-extra');
// get version from git branch name, // get version from git branch name,
// e.g. release/1.0.7 => 1.0.7 // e.g. release/1.0.7 => 1.0.7
@ -25,16 +24,16 @@ const releaseVersion = getVersion();
module.exports = ({ context, onGetWebpackConfig }) => { module.exports = ({ context, onGetWebpackConfig }) => {
onGetWebpackConfig((config) => { onGetWebpackConfig((config) => {
config.resolve config.resolve.plugin('tsconfigpaths').use(TsconfigPathsPlugin, [
.plugin('tsconfigpaths') {
.use(TsconfigPathsPlugin, [{
configFile: './tsconfig.json', configFile: './tsconfig.json',
}]); },
config ]);
.plugin('define') config.plugin('define').use(context.webpack.DefinePlugin, [
.use(context.webpack.DefinePlugin, [{ {
VERSION_PLACEHOLDER: JSON.stringify(releaseVersion), VERSION_PLACEHOLDER: JSON.stringify(releaseVersion),
}]); },
]);
config.plugins.delete('hot'); config.plugins.delete('hot');
config.devServer.hot(false); config.devServer.hot(false);
}); });

View File

@ -1,3 +0,0 @@
lib
es
node_modules

View File

@ -1,6 +0,0 @@
module.exports = {
printWidth: 80,
singleQuote: true,
trailingComma: 'all',
tabSize: 2,
};

View File

@ -1,5 +0,0 @@
{
"plugins": [
"@alilc/build-plugin-lce"
]
}

View File

@ -1,25 +1,28 @@
{ {
"name": "@alilc/lowcode-types", "name": "@alilc/lowcode-types",
"version": "1.3.3", "version": "2.0.0-beta.0",
"description": "Types for Ali lowCode engine", "description": "Types for Ali lowCode engine",
"files": [ "files": [
"es", "es",
"lib" "lib"
], ],
"main": "lib/index.js", "main": "dist/index.js",
"module": "es/index.js", "module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": { "scripts": {
"build": "build-scripts build" "build": "tsc"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-datasource-types": "^1.0.0", "@alilc/lowcode-datasource-types": "^1.0.0",
"react": "^16.9", "@alifd/next": "^1.27.8",
"react": "^18.2.0",
"strict-event-emitter-types": "^2.0.0" "strict-event-emitter-types": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18", "@types/react": "^18"
"@types/node": "^13.7.1", },
"@types/react": "^16" "peerDependencies": {
"react": "^18.2.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",

View File

@ -1,18 +0,0 @@
export * from './isActionContentObject';
export * from './isCustomView';
export * from './isDOMText';
export * from './isDynamicSetter';
export * from './isI18nData';
export * from './isJSBlock';
export * from './isJSExpression';
export * from './isJSFunction';
export * from './isJSSlot';
export * from './isLowCodeComponentType';
export * from './isNodeSchema';
export * from './isPlainObject';
export * from './isProCodeComponentType';
export * from './isProjectSchema';
export * from './isReactClass';
export * from './isReactComponent';
export * from './isSetterConfig';
export * from './isTitleConfig';

View File

@ -1,8 +0,0 @@
import { IPublicTypeActionContentObject } from '../shell';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isActionContentObject(obj: any): obj is IPublicTypeActionContentObject {
return obj && typeof obj === 'object';
}

View File

@ -1,10 +0,0 @@
import { isValidElement } from 'react';
import { isReactComponent } from './isReactComponent';
import { IPublicTypeCustomView } from '../shell/type/custom-view';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isCustomView(obj: any): obj is IPublicTypeCustomView {
return obj && (isValidElement(obj) || isReactComponent(obj));
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeDOMText } from '../shell/type/dom-text';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isDOMText(data: any): data is IPublicTypeDOMText {
return typeof data === 'string';
}

View File

@ -1,9 +0,0 @@
import { isReactClass } from './isReactClass';
import { IPublicTypeDynamicSetter } from '../shell/type/dynamic-setter';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isDynamicSetter(obj: any): obj is IPublicTypeDynamicSetter {
return obj && typeof obj === 'function' && !isReactClass(obj);
}

View File

@ -1,7 +0,0 @@
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isI18nData(obj: any): boolean {
return obj && obj.type === 'i18n';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSBlock } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSBlock(data: any): data is IPublicTypeJSBlock {
return data && data.type === 'JSBlock';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSExpression } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSExpression(data: any): data is IPublicTypeJSExpression {
return data && data.type === 'JSExpression' && data.extType !== 'function';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSFunction } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSFunction(x: any): x is IPublicTypeJSFunction {
return typeof x === 'object' && x && x.type === 'JSFunction';
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeJSSlot } from '../shell/type/value-type';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isJSSlot(data: any): data is IPublicTypeJSSlot {
return data && data.type === 'JSSlot';
}

View File

@ -1,9 +0,0 @@
import { isProCodeComponentType } from './isProCodeComponentType';
import { IPublicTypeComponentMap, IPublicTypeLowCodeComponent } from '../shell/type/npm';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isLowCodeComponentType(desc: IPublicTypeComponentMap): desc is IPublicTypeLowCodeComponent {
return !isProCodeComponentType(desc);
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeNodeSchema } from '../shell';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isNodeSchema(data: any): data is IPublicTypeNodeSchema {
return data && data.componentName;
}

View File

@ -1,10 +0,0 @@
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isPlainObject(value: any): value is Record<string, unknown> {
if (typeof value !== 'object') {
return false;
}
const proto = Object.getPrototypeOf(value);
return proto === Object.prototype || proto === null || Object.getPrototypeOf(proto) === null;
}

View File

@ -1,8 +0,0 @@
import { IPublicTypeComponentMap, IPublicTypeProCodeComponent } from '../shell/type/npm';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isProCodeComponentType(desc: IPublicTypeComponentMap): desc is IPublicTypeProCodeComponent {
return 'package' in desc;
}

View File

@ -1,6 +0,0 @@
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isProjectSchema(data: any): boolean {
return data && data.componentsTree;
}

View File

@ -1,8 +0,0 @@
import { ComponentClass, Component } from 'react';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isReactClass(obj: any): obj is ComponentClass<any> {
return obj && obj.prototype && (obj.prototype.isReactComponent || obj.prototype instanceof Component);
}

View File

@ -1,9 +0,0 @@
import { ComponentType } from 'react';
import { isReactClass } from './isReactClass';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isReactComponent(obj: any): obj is ComponentType<any> {
return obj && (isReactClass(obj) || typeof obj === 'function');
}

View File

@ -1,9 +0,0 @@
import { IPublicTypeSetterConfig } from '../shell/type/setter-config';
import { isCustomView } from './isCustomView';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isSetterConfig(obj: any): obj is IPublicTypeSetterConfig {
return obj && typeof obj === 'object' && 'componentName' in obj && !isCustomView(obj);
}

View File

@ -1,10 +0,0 @@
import { isI18nData } from './isI18nData';
import { isPlainObject } from './isPlainObject';
import { IPublicTypeTitleConfig } from '../shell/type/title-config';
/**
* @deprecated use same function from '@alilc/lowcode-utils' instead
*/
export function isTitleConfig(obj: any): obj is IPublicTypeTitleConfig {
return isPlainObject(obj) && !isI18nData(obj);
}

View File

@ -1,7 +1,6 @@
import * as Node from './node'; import * as Node from './node';
export interface EventConfig { export interface EventConfig {
[Node.Prop.Change]: (options: Node.Prop.ChangeOptions) => any;
[Node.Prop.InnerChange]: (options: Node.Prop.ChangeOptions) => any; [Node.Prop.InnerChange]: (options: Node.Prop.ChangeOptions) => any;
[Node.Rerender]: (options: Node.RerenderOptions) => void; [Node.Rerender]: (options: Node.RerenderOptions) => void;
[eventName: string]: any; [eventName: string]: any;

View File

@ -6,11 +6,5 @@ export interface ChangeOptions {
oldValue: any; oldValue: any;
} }
/**
* Node Prop
* @Deprecated Please Replace With InnerPropChange
*/
export const Change = 'node.prop.change';
/** Node Prop 变化事件 */ /** Node Prop 变化事件 */
export const InnerChange = 'node.innerProp.change'; export const InnerChange = 'node.innerProp.change';

View File

@ -7,5 +7,3 @@ export * from './assets';
export * as GlobalEvent from './event'; export * as GlobalEvent from './event';
export * from './shell'; export * from './shell';
export * from './shell-model-factory'; export * from './shell-model-factory';
// TODO: remove this in future versions
export * from './deprecated';

View File

@ -1,7 +1,41 @@
import React, { ReactElement } from 'react'; import React, { ReactElement, ComponentProps } from 'react';
import { IPublicTypeContextMenuAction, IPublicTypeHelpTipConfig, IPublicTypeTipConfig, IPublicTypeTitleContent } from '../type'; import {
import { Balloon, Breadcrumb, Button, Card, Checkbox, DatePicker, Dialog, Dropdown, Form, Icon, Input, Loading, Message, Overlay, Pagination, Radio, Search, Select, SplitButton, Step, Switch, Tab, Table, Tree, TreeSelect, Upload, Divider } from '@alifd/next'; IPublicTypeContextMenuAction,
import { IconProps } from '@alifd/next/types/icon'; IPublicTypeHelpTipConfig,
IPublicTypeTipConfig,
IPublicTypeTitleContent,
} from '../type';
import {
Balloon,
Breadcrumb,
Button,
Card,
Checkbox,
DatePicker,
Dialog,
Dropdown,
Form,
Icon,
Input,
Loading,
Message,
Overlay,
Pagination,
Radio,
Search,
Select,
SplitButton,
Step,
Switch,
Tab,
Table,
Tree,
TreeSelect,
Upload,
Divider,
} from '@alifd/next';
type IconProps = ComponentProps<typeof Icon>;
export interface IPublicApiCommonUI { export interface IPublicApiCommonUI {
Balloon: typeof Balloon; Balloon: typeof Balloon;

View File

@ -1,5 +1,10 @@
import { ReactElement, ReactNode } from 'react'; import type { ReactElement, ReactNode } from 'react';
import { IPublicTypeI18nData, IPublicTypeTitleConfig } from './'; import type { IPublicTypeI18nData, IPublicTypeTitleConfig } from './';
// eslint-disable-next-line max-len // eslint-disable-next-line max-len
export type IPublicTypeTitleContent = string | IPublicTypeI18nData | ReactElement | ReactNode | IPublicTypeTitleConfig; export type IPublicTypeTitleContent =
| string
| IPublicTypeI18nData
| ReactElement
| ReactNode
| IPublicTypeTitleConfig;

View File

@ -1,5 +1,11 @@
import { ReactElement, ComponentType } from 'react'; import type { ReactElement, ComponentType } from 'react';
import { IPublicTypeI18nData, IPublicTypeIconType, IPublicTypeTitleContent, IPublicTypeWidgetConfigArea, TipContent } from './'; import type {
IPublicTypeI18nData,
IPublicTypeIconType,
IPublicTypeTitleContent,
IPublicTypeWidgetConfigArea,
TipContent,
} from './';
export type IPublicTypeHelpTipConfig = string | { url?: string; content?: string | ReactElement }; export type IPublicTypeHelpTipConfig = string | { url?: string; content?: string | ReactElement };
@ -36,7 +42,12 @@ export interface IPublicTypeWidgetBaseConfig {
*/ */
area?: IPublicTypeWidgetConfigArea; area?: IPublicTypeWidgetConfigArea;
props?: Record<string, any>; props?: Record<string, any>;
content?: string | ReactElement | ComponentType<any> | IPublicTypePanelConfig[] | IPublicTypePanelConfig; content?:
| string
| ReactElement
| ComponentType<any>
| IPublicTypePanelConfig[]
| IPublicTypePanelConfig;
contentProps?: Record<string, any>; contentProps?: Record<string, any>;
/** /**

View File

@ -1,9 +1,7 @@
{ {
"extends": "../../tsconfig.json", "extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "lib" "outDir": "dist"
}, },
"include": [ "include": ["src"]
"./src/"
]
} }

View File

@ -1,5 +0,0 @@
{
"plugins": [
"@alilc/build-plugin-lce"
]
}

View File

@ -1,6 +0,0 @@
{
"plugins": [
"@alilc/build-plugin-lce",
"@alilc/lowcode-test-mate/plugin/index.ts"
]
}

View File

@ -1,21 +0,0 @@
const fs = require('fs');
const { join } = require('path');
const pkgNames = fs.readdirSync(join('..')).filter(pkgName => !pkgName.startsWith('.'));
const jestConfig = {
moduleFileExtensions: ['ts', 'tsx', 'js', 'json'],
collectCoverage: false,
collectCoverageFrom: [
'src/**/*.ts',
'!src/**/*.d.ts',
'!**/node_modules/**',
'!**/vendor/**',
],
setupFilesAfterEnv: ['./jest.setup.js'],
};
// 只对本仓库内的 pkg 做 mapping
jestConfig.moduleNameMapper = {};
jestConfig.moduleNameMapper[`^@alilc/lowcode\\-(${pkgNames.join('|')})$`] = '<rootDir>/../$1/src';
module.exports = jestConfig;

View File

@ -1 +0,0 @@
import '@testing-library/jest-dom';

View File

@ -1,32 +1,36 @@
{ {
"name": "@alilc/lowcode-utils", "name": "@alilc/lowcode-utils",
"version": "1.3.2", "version": "2.0.0-beta.0",
"description": "Utils for Ali lowCode engine", "description": "Utils for Ali lowCode engine",
"files": [ "files": [
"lib", "lib",
"es" "es"
], ],
"main": "lib/index.js", "main": "lib/index.js",
"module": "es/index.js", "module": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": { "scripts": {
"test": "build-scripts test --config build.test.json --jest-coverage", "build": "tsc"
"build": "build-scripts build"
}, },
"dependencies": { "dependencies": {
"@alifd/next": "^1.19.16", "@alifd/next": "^1.27.8",
"@alilc/lowcode-types": "1.3.2", "@alilc/lowcode-types": "workspace:*",
"lodash": "^4.17.21", "classnames": "^2.5.1",
"mobx": "^6.3.0", "lodash-es": "^4.17.21",
"mobx": "^6.12.1",
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"react": "^16" "react": "^18.2.0",
"react-is": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@alib/build-scripts": "^0.1.18", "@testing-library/react": "^14.2.2",
"@testing-library/jest-dom": "^6.1.4", "@types/lodash-es": "^4.17.12",
"@testing-library/react": "^11.2.7", "@types/react": "^18.2.67",
"@types/node": "^13.7.1", "@types/react-is": "^18.2.4",
"@types/react": "^16", "@types/prop-types": "^15.7.12"
"react-dom": "^16.14.0" },
"peerDependencies": {
"react": "^18.2.0"
}, },
"publishConfig": { "publishConfig": {
"access": "public", "access": "public",

View File

@ -1,12 +1,24 @@
import { AssetType, AssetLevels, AssetLevel } from '@alilc/lowcode-types'; import { AssetType, AssetLevels, AssetLevel } from '@alilc/lowcode-types';
import type { AssetItem, Asset, AssetList, AssetBundle, IPublicTypeAssetsJson } from '@alilc/lowcode-types'; import type {
AssetItem,
Asset,
AssetList,
AssetBundle,
IPublicTypeAssetsJson,
} from '@alilc/lowcode-types';
import { isCSSUrl } from './is-css-url'; import { isCSSUrl } from './is-css-url';
import { createDefer } from './create-defer'; import { createDefer } from './create-defer';
import { load, evaluate } from './script'; import { load, evaluate } from './script';
// API 向下兼容 // API 向下兼容
export { AssetType, AssetLevels, AssetLevel } from '@alilc/lowcode-types'; export { AssetType, AssetLevels, AssetLevel } from '@alilc/lowcode-types';
export type { AssetItem, Asset, AssetList, AssetBundle, IPublicTypeAssetsJson } from '@alilc/lowcode-types'; export type {
AssetItem,
Asset,
AssetList,
AssetBundle,
IPublicTypeAssetsJson,
} from '@alilc/lowcode-types';
export function isAssetItem(obj: any): obj is AssetItem { export function isAssetItem(obj: any): obj is AssetItem {
return obj && obj.type; return obj && obj.type;
@ -38,7 +50,12 @@ urls: [
"view1.js mobile|pc", "view1.js mobile|pc",
"view2.js <device selector>" "view2.js <device selector>"
] */ ] */
export function assetItem(type: AssetType, content?: string | null, level?: AssetLevel, id?: string): AssetItem | null { export function assetItem(
type: AssetType,
content?: string | null,
level?: AssetLevel,
id?: string,
): AssetItem | null {
if (!content) { if (!content) {
return null; return null;
} }
@ -50,7 +67,10 @@ export function assetItem(type: AssetType, content?: string | null, level?: Asse
}; };
} }
export function mergeAssets(assets: IPublicTypeAssetsJson, incrementalAssets: IPublicTypeAssetsJson): IPublicTypeAssetsJson { export function mergeAssets(
assets: IPublicTypeAssetsJson,
incrementalAssets: IPublicTypeAssetsJson,
): IPublicTypeAssetsJson {
if (incrementalAssets.packages) { if (incrementalAssets.packages) {
assets.packages = [...(assets.packages || []), ...incrementalAssets.packages]; assets.packages = [...(assets.packages || []), ...incrementalAssets.packages];
} }
@ -65,7 +85,11 @@ export function mergeAssets(assets: IPublicTypeAssetsJson, incrementalAssets: IP
return assets; return assets;
} }
function mergeAssetsComponentList(assets: IPublicTypeAssetsJson, incrementalAssets: IPublicTypeAssetsJson, listName: keyof IPublicTypeAssetsJson): void { function mergeAssetsComponentList(
assets: IPublicTypeAssetsJson,
incrementalAssets: IPublicTypeAssetsJson,
listName: keyof Omit<IPublicTypeAssetsJson, 'version' | 'sort'>,
): void {
if (incrementalAssets[listName]) { if (incrementalAssets[listName]) {
if (assets[listName]) { if (assets[listName]) {
// 根据title进行合并 // 根据title进行合并
@ -131,7 +155,10 @@ export class StylePoint {
element.setAttribute('data-id', this.id); element.setAttribute('data-id', this.id);
} }
element.appendChild(document.createTextNode(content)); element.appendChild(document.createTextNode(content));
document.head.insertBefore(element, this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null); document.head.insertBefore(
element,
this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null,
);
document.head.removeChild(this.placeholder); document.head.removeChild(this.placeholder);
this.placeholder = element; this.placeholder = element;
} }
@ -162,7 +189,10 @@ export class StylePoint {
if (this.id) { if (this.id) {
element.setAttribute('data-id', this.id); element.setAttribute('data-id', this.id);
} }
document.head.insertBefore(element, this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null); document.head.insertBefore(
element,
this.placeholder.parentNode === document.head ? this.placeholder.nextSibling : null,
);
document.head.removeChild(this.placeholder); document.head.removeChild(this.placeholder);
this.placeholder = element; this.placeholder = element;
return i.promise(); return i.promise();
@ -175,7 +205,12 @@ function parseAssetList(scripts: any, styles: any, assets: AssetList, level?: As
} }
} }
function parseAsset(scripts: any, styles: any, asset: Asset | undefined | null, level?: AssetLevel) { function parseAsset(
scripts: any,
styles: any,
asset: Asset | undefined | null,
level?: AssetLevel,
) {
if (!asset) { if (!asset) {
return; return;
} }
@ -219,7 +254,7 @@ export class AssetLoader {
async load(asset: Asset) { async load(asset: Asset) {
const styles: any = {}; const styles: any = {};
const scripts: any = {}; const scripts: any = {};
AssetLevels.forEach(lv => { AssetLevels.forEach((lv) => {
styles[lv] = []; styles[lv] = [];
scripts[lv] = []; scripts[lv] = [];
}); });
@ -237,12 +272,23 @@ export class AssetLoader {
scripts[AssetLevel.App], scripts[AssetLevel.App],
); );
await Promise.all( await Promise.all(
styleQueue.map(({ content, level, type, id }) => this.loadStyle(content, level!, type === AssetType.CSSUrl, id)), styleQueue.map(({ content, level, type, id }) =>
this.loadStyle(content, level!, type === AssetType.CSSUrl, id),
),
);
await Promise.all(
scriptQueue.map(({ content, type, scriptType }) =>
this.loadScript(content, type === AssetType.JSUrl, scriptType),
),
); );
await Promise.all(scriptQueue.map(({ content, type, scriptType }) => this.loadScript(content, type === AssetType.JSUrl, scriptType)));
} }
private loadStyle(content: string | undefined | null, level: AssetLevel, isUrl?: boolean, id?: string) { private loadStyle(
content: string | undefined | null,
level: AssetLevel,
isUrl?: boolean,
id?: string,
) {
if (!content) { if (!content) {
return; return;
} }

View File

@ -1,5 +1,9 @@
import { ComponentType, forwardRef, createElement, FunctionComponent } from 'react'; import { ComponentType, forwardRef, createElement, FunctionComponent } from 'react';
import { IPublicTypeNpmInfo, IPublicTypeComponentSchema, IPublicTypeProjectSchema } from '@alilc/lowcode-types'; import {
IPublicTypeNpmInfo,
IPublicTypeComponentSchema,
IPublicTypeProjectSchema,
} from '@alilc/lowcode-types';
import { isESModule } from './is-es-module'; import { isESModule } from './is-es-module';
import { isReactComponent, acceptsRef, wrapReactClass } from './is-react'; import { isReactComponent, acceptsRef, wrapReactClass } from './is-react';
import { isObject } from './is-object'; import { isObject } from './is-object';
@ -19,9 +23,9 @@ export function accessLibrary(library: string | Record<string, unknown>) {
return (window as any)[library] || generateHtmlComp(library); return (window as any)[library] || generateHtmlComp(library);
} }
export function generateHtmlComp(library: string) { export function generateHtmlComp(library: string): any {
if (['a', 'img', 'div', 'span', 'svg'].includes(library)) { if (['a', 'img', 'div', 'span', 'svg'].includes(library)) {
return forwardRef((props, ref) => { return forwardRef((props: any, ref) => {
return createElement(library, { ref, ...props }, props.children); return createElement(library, { ref, ...props }, props.children);
}); });
} }
@ -92,12 +96,20 @@ function isMixinComponent(components: any) {
return false; return false;
} }
return Object.keys(components).some(componentName => isReactComponent(components[componentName])); return Object.keys(components).some((componentName) =>
isReactComponent(components[componentName]),
);
} }
export function buildComponents(libraryMap: LibraryMap, export function buildComponents(
componentsMap: { [componentName: string]: IPublicTypeNpmInfo | ComponentType<any> | IPublicTypeComponentSchema }, libraryMap: LibraryMap,
createComponent: (schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>) => Component | null) { componentsMap: {
[componentName: string]: IPublicTypeNpmInfo | ComponentType<any> | IPublicTypeComponentSchema;
},
createComponent: (
schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>,
) => Component | null,
) {
const components: any = {}; const components: any = {};
Object.keys(componentsMap).forEach((componentName) => { Object.keys(componentsMap).forEach((componentName) => {
let component = componentsMap[componentName]; let component = componentsMap[componentName];
@ -150,14 +162,17 @@ interface LibrayMap {
interface ProjectUtils { interface ProjectUtils {
[packageName: string]: any; [packageName: string]: any;
} }
export function getProjectUtils(librayMap: LibrayMap, utilsMetadata: UtilsMetadata[]): ProjectUtils { export function getProjectUtils(
librayMap: LibrayMap,
utilsMetadata: UtilsMetadata[],
): ProjectUtils {
const projectUtils: ProjectUtils = {}; const projectUtils: ProjectUtils = {};
if (utilsMetadata) { if (utilsMetadata) {
utilsMetadata.forEach(meta => { utilsMetadata.forEach((meta) => {
if (librayMap[meta?.npm?.package]) { if (librayMap[meta?.npm?.package]) {
const lib = accessLibrary(librayMap[meta?.npm.package]); const lib = accessLibrary(librayMap[meta?.npm.package]);
if (lib?.destructuring) { if (lib?.destructuring) {
Object.keys(lib).forEach(name => { Object.keys(lib).forEach((name) => {
if (name === 'destructuring') return; if (name === 'destructuring') return;
projectUtils[name] = lib[name]; projectUtils[name] = lib[name];
}); });

View File

@ -1,5 +1,7 @@
import * as ReactIs from 'react-is'; import * as ReactIs from 'react-is';
// @ts-expect-error
import { default as ReactPropTypesSecret } from 'prop-types/lib/ReactPropTypesSecret'; import { default as ReactPropTypesSecret } from 'prop-types/lib/ReactPropTypesSecret';
// @ts-expect-error
import { default as factoryWithTypeCheckers } from 'prop-types/factoryWithTypeCheckers'; import { default as factoryWithTypeCheckers } from 'prop-types/factoryWithTypeCheckers';
import { IPublicTypePropType } from '@alilc/lowcode-types'; import { IPublicTypePropType } from '@alilc/lowcode-types';
import { isRequiredPropType } from './check-types/is-required-prop-type'; import { isRequiredPropType } from './check-types/is-required-prop-type';
@ -41,15 +43,24 @@ export function transformPropTypesRuleToString(rule: IPublicTypePropType | strin
return 'PropTypes.any'; return 'PropTypes.any';
} }
export function checkPropTypes(value: any, name: string, rule: any, componentName: string): boolean { export function checkPropTypes(
value: any,
name: string,
rule: any,
componentName: string,
): boolean {
let ruleFunction = rule; let ruleFunction = rule;
if (typeof rule === 'object') { if (typeof rule === 'object') {
// eslint-disable-next-line no-new-func // eslint-disable-next-line no-new-func
ruleFunction = new Function(`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`)(PropTypes2); ruleFunction = new Function(
`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`,
)(PropTypes2);
} }
if (typeof rule === 'string') { if (typeof rule === 'string') {
// eslint-disable-next-line no-new-func // eslint-disable-next-line no-new-func
ruleFunction = new Function(`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`)(PropTypes2); ruleFunction = new Function(
`"use strict"; const PropTypes = arguments[0]; return ${transformPropTypesRuleToString(rule)}`,
)(PropTypes2);
} }
if (!ruleFunction || typeof ruleFunction !== 'function') { if (!ruleFunction || typeof ruleFunction !== 'function') {
logger.warn('checkPropTypes should have a function type rule argument'); logger.warn('checkPropTypes should have a function type rule argument');

View File

@ -1,8 +1,15 @@
import { Menu, Icon } from '@alifd/next'; import { Menu, Icon } from '@alifd/next';
import { IPublicEnumContextMenuType, IPublicModelNode, IPublicModelPluginContext, IPublicTypeContextMenuAction, IPublicTypeContextMenuItem } from '@alilc/lowcode-types'; import {
import { Logger } from '@alilc/lowcode-utils'; IPublicEnumContextMenuType,
IPublicModelNode,
IPublicModelPluginContext,
IPublicTypeContextMenuAction,
IPublicTypeContextMenuItem,
} from '@alilc/lowcode-types';
import { Logger } from './logger';
import classNames from 'classnames'; import classNames from 'classnames';
import React from 'react'; import React from 'react';
import './context-menu.scss'; import './context-menu.scss';
const logger = new Logger({ level: 'warn', bizName: 'utils' }); const logger = new Logger({ level: 'warn', bizName: 'utils' });
@ -24,9 +31,7 @@ const Tree = (props: {
const { node } = props; const { node } = props;
if (!node) { if (!node) {
return ( return <div className="engine-context-menu-tree-wrap">{props.children}</div>;
<div className="engine-context-menu-tree-wrap">{ props.children }</div>
);
} }
const { common } = props.options.pluginContext || {}; const { common } = props.options.pluginContext || {};
@ -49,21 +54,22 @@ const Tree = (props: {
}} }}
style={style} style={style}
> >
{props.options.nodes?.[0].id === node.id ? (<Icon className="engine-context-menu-tree-selecte-icon" size="small" type="success" />) : null} {props.options.nodes?.[0].id === node.id ? (
<Icon className="engine-context-menu-tree-selecte-icon" size="small" type="success" />
) : null}
{intl(node.title)} {intl(node.title)}
</div> </div>
<div <div className="engine-context-menu-tree-children">{props.children}</div>
className="engine-context-menu-tree-children"
>
{ props.children }
</div>
</Tree> </Tree>
); );
}; };
let destroyFn: Function | undefined; let destroyFn: Function | undefined;
export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[], options: IOptions): React.ReactNode[] { export function parseContextMenuAsReactNode(
menus: IPublicTypeContextMenuItem[],
options: IOptions,
): React.ReactNode[] {
const { common, commonUI } = options.pluginContext || {}; const { common, commonUI } = options.pluginContext || {};
const { intl = (title: any) => title } = common?.utils || {}; const { intl = (title: any) => title } = common?.utils || {};
const { HelpTip } = commonUI || {}; const { HelpTip } = commonUI || {};
@ -77,7 +83,7 @@ export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[],
if (menu.type === IPublicEnumContextMenuType.MENU_ITEM) { if (menu.type === IPublicEnumContextMenuType.MENU_ITEM) {
if (menu.items && menu.items.length) { if (menu.items && menu.items.length) {
children.push(( children.push(
<PopupItem <PopupItem
className={classNames('engine-context-menu-item', { className={classNames('engine-context-menu-item', {
disabled: menu.disabled, disabled: menu.disabled,
@ -88,10 +94,10 @@ export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[],
<Menu className="next-context engine-context-menu"> <Menu className="next-context engine-context-menu">
{parseContextMenuAsReactNode(menu.items, options)} {parseContextMenuAsReactNode(menu.items, options)}
</Menu> </Menu>
</PopupItem> </PopupItem>,
)); );
} else { } else {
children.push(( children.push(
<Item <Item
className={classNames('engine-context-menu-item', { className={classNames('engine-context-menu-item', {
disabled: menu.disabled, disabled: menu.disabled,
@ -106,24 +112,26 @@ export function parseContextMenuAsReactNode(menus: IPublicTypeContextMenuItem[],
{menu.title ? intl(menu.title) : null} {menu.title ? intl(menu.title) : null}
{menu.help ? <HelpTip size="xs" help={menu.help} direction="right" /> : null} {menu.help ? <HelpTip size="xs" help={menu.help} direction="right" /> : null}
</div> </div>
</Item> </Item>,
)); );
} }
} }
if (menu.type === IPublicEnumContextMenuType.NODE_TREE) { if (menu.type === IPublicEnumContextMenuType.NODE_TREE) {
children.push(( children.push(<Tree node={options.nodes?.[0]} options={options} />);
<Tree node={options.nodes?.[0]} options={options} />
));
} }
}); });
return children; return children;
} }
export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction | Omit<IPublicTypeContextMenuAction, 'items'>)[], options: IOptions & { export function parseContextMenuProperties(
menus: (IPublicTypeContextMenuAction | Omit<IPublicTypeContextMenuAction, 'items'>)[],
options: IOptions & {
event?: MouseEvent; event?: MouseEvent;
}, level = 1): IPublicTypeContextMenuItem[] { },
level = 1,
): IPublicTypeContextMenuItem[] {
destroyFn?.(); destroyFn?.();
const { nodes, destroy } = options; const { nodes, destroy } = options;
@ -133,14 +141,9 @@ export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction
} }
return menus return menus
.filter(menu => !menu.condition || (menu.condition && menu.condition(nodes || []))) .filter((menu) => !menu.condition || (menu.condition && menu.condition(nodes || [])))
.map((menu) => { .map((menu) => {
const { const { name, title, type = IPublicEnumContextMenuType.MENU_ITEM, help } = menu;
name,
title,
type = IPublicEnumContextMenuType.MENU_ITEM,
help,
} = menu;
const result: IPublicTypeContextMenuItem = { const result: IPublicTypeContextMenuItem = {
name, name,
@ -151,7 +154,7 @@ export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction
destroy?.(); destroy?.();
menu.action?.(nodes || [], options.event); menu.action?.(nodes || [], options.event);
}, },
disabled: menu.disabled && menu.disabled(nodes || []) || false, disabled: (menu.disabled && menu.disabled(nodes || [])) || false,
}; };
if ('items' in menu && menu.items) { if ('items' in menu && menu.items) {
@ -169,7 +172,7 @@ export function parseContextMenuProperties(menus: (IPublicTypeContextMenuAction
return menus.concat([currentMenu]); return menus.concat([currentMenu]);
} }
const index = menus.find(item => item.name === currentMenu.name); const index = menus.find((item) => item.name === currentMenu.name);
if (!index) { if (!index) {
return menus.concat([currentMenu]); return menus.concat([currentMenu]);
} else { } else {
@ -192,20 +195,29 @@ function getMenuItemHeight() {
return menuItemHeight; return menuItemHeight;
} }
export function createContextMenu(children: React.ReactNode[], { export function createContextMenu(
children: React.ReactNode[],
{
event, event,
offset = [0, 0], offset = [0, 0],
}: { }: {
event: MouseEvent | React.MouseEvent; event: MouseEvent | React.MouseEvent;
offset?: [number, number]; offset?: [number, number];
}) { },
) {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
const viewportWidth = window.innerWidth; const viewportWidth = window.innerWidth;
const viewportHeight = window.innerHeight; const viewportHeight = window.innerHeight;
const dividerCount = React.Children.count(children.filter(child => React.isValidElement(child) && child.type === Divider)); const dividerCount = React.Children.count(
const popupItemCount = React.Children.count(children.filter(child => React.isValidElement(child) && (child.type === PopupItem || child.type === Item))); children.filter((child) => React.isValidElement(child) && child.type === Divider),
);
const popupItemCount = React.Children.count(
children.filter(
(child) => React.isValidElement(child) && (child.type === PopupItem || child.type === Item),
),
);
const menuHeight = popupItemCount * parseInt(getMenuItemHeight(), 10) + dividerCount * 8 + 16; const menuHeight = popupItemCount * parseInt(getMenuItemHeight(), 10) + dividerCount * 8 + 16;
const menuWidthLimit = 200; const menuWidthLimit = 200;
let x = event.clientX + offset[0]; let x = event.clientX + offset[0];

View File

@ -36,5 +36,5 @@ export function createIcon(
}); });
} }
return <Icon {...icon} {...props} />; return <Icon {...(icon as any)} {...props} />;
} }

View File

@ -4,7 +4,7 @@
*/ */
// 需要通过 Env 来判断是否需要 // 需要通过 Env 来判断是否需要
import { some } from 'lodash'; import { some } from 'lodash-es';
const pseudoMap = ['hover', 'focus', 'active', 'visited']; const pseudoMap = ['hover', 'focus', 'active', 'visited'];
@ -37,7 +37,7 @@ function isString(str: any): str is string {
} }
function hyphenate(str: string): string { function hyphenate(str: string): string {
return str.replace(RE_CAMEL, w => `-${w}`).toLowerCase(); return str.replace(RE_CAMEL, (w) => `-${w}`).toLowerCase();
} }
function camelize(str: string): string { function camelize(str: string): string {
@ -63,30 +63,30 @@ function toNativeStyle(runtime: Record<string, string> | undefined) {
return {}; return {};
} }
if (runtime.default) { if (runtime.default) {
const normalized: Record<string, string> = {}; const normalized: any = {};
Object.keys(runtime).forEach((pseudo) => { Object.keys(runtime).forEach((pseudo) => {
if (pseudo === 'extra') { if (pseudo === 'extra') {
normalized[pseudo] = runtime[pseudo]; normalized[pseudo] = runtime[pseudo];
return; return;
} }
normalized[pseudo] = toNativeStyle(runtime[pseudo]); normalized[pseudo] = toNativeStyle(runtime[pseudo] as any);
}); });
return normalized; return normalized;
} }
const normalized = {}; const normalized: any = {};
Object.keys(runtime).forEach((key) => { Object.keys(runtime).forEach((key) => {
normalized[camelize(key)] = runtime[key]; normalized[camelize(key)] = runtime[key];
}); });
return normalized; return normalized;
} }
function normalizeStyle(style) { function normalizeStyle(style: any): any {
if (!style) { if (!style) {
return {}; return {};
} }
if (style.default) { if (style.default) {
const normalized = {}; const normalized: Record<string, string> = {};
Object.keys(style).forEach((pseudo) => { Object.keys(style).forEach((pseudo) => {
if (pseudo === 'extra') { if (pseudo === 'extra') {
normalized[pseudo] = style[pseudo]; normalized[pseudo] = style[pseudo];
@ -104,12 +104,11 @@ function normalizeStyle(style) {
return normalized; return normalized;
} }
function toCss(runtime) { function toCss(runtime: Record<string, string>) {
if (!runtime) { if (!runtime) {
return ( return `:root {
`:root {
}`); }`;
} }
if (runtime.default) { if (runtime.default) {
@ -130,12 +129,10 @@ ${runtimeToCss(normalizeStyle(runtime[pseudo]))}
return css.join('\n'); return css.join('\n');
} }
return ( return `:root {
`:root {
${runtimeToCss(normalizeStyle(runtime))} ${runtimeToCss(normalizeStyle(runtime))}
} }
` `;
);
} }
function cssToRuntime(css: string) { function cssToRuntime(css: string) {
@ -152,25 +149,28 @@ function cssToRuntime(css: string) {
runtime.extra = runtime.extra || []; runtime.extra = runtime.extra || [];
runtime.extra.push(cssItem.trim()); runtime.extra.push(cssItem.trim());
} else { } else {
const res = /:root:?(.*)?{(.*)/ig.exec(cssItem.replace(/[\r\n]+/ig, '').trim()); const res = /:root:?(.*)?{(.*)/gi.exec(cssItem.replace(/[\r\n]+/gi, '').trim());
if (res) { if (res) {
let pseudo: string | undefined; let pseudo: string | undefined;
if (res[1] && res[1].trim() && some(pseudoMap, pse => res[1].indexOf(pse) === 0)) { if (res[1] && res[1].trim() && some(pseudoMap, (pse) => res[1].indexOf(pse) === 0)) {
pseudo = res[1].trim(); pseudo = res[1].trim();
} else if (res[1] && res[1].trim()) { } else if (res[1] && res[1].trim()) {
pseudo = res[1]; pseudo = res[1];
} }
const s: Record<string, string> = {}; const s: Record<string, string> = {};
res[2].split(';').reduce<string[]>((prev, next) => { res[2]
.split(';')
.reduce<string[]>((prev, next) => {
if (next.indexOf('base64') > -1) { if (next.indexOf('base64') > -1) {
prev[prev.length - 1] += `;${next}`; prev[prev.length - 1] += `;${next}`;
} else { } else {
prev.push(next); prev.push(next);
} }
return prev; return prev;
}, []).forEach((item) => { }, [])
.forEach((item) => {
if (item) { if (item) {
if (PROPS_REG.test(item)) { if (PROPS_REG.test(item)) {
const props = item.match(PROPS_REG); const props = item.match(PROPS_REG);
@ -183,14 +183,14 @@ function cssToRuntime(css: string) {
} }
}); });
runtime[pseudo || 'default'] = s; (runtime as any)[pseudo || 'default'] = s;
} }
} }
}); });
return runtime; return runtime;
} }
function cssToStyle(css) { function cssToStyle(css: any) {
try { try {
if (isString(css)) { if (isString(css)) {
return toNativeStyle(cssToRuntime(css).default); return toNativeStyle(cssToRuntime(css).default);
@ -205,12 +205,4 @@ function cssToStyle(css) {
return {}; return {};
} }
export { export { hyphenate, camelize, toNativeStyle, normalizeStyle, toCss, cssToRuntime, cssToStyle };
hyphenate,
camelize,
toNativeStyle,
normalizeStyle,
toCss,
cssToRuntime,
cssToStyle,
};

View File

@ -1,6 +1,6 @@
import { isObject } from './is-object'; import { isObject } from './is-object';
export function isPlainObject<T extends object = object>(value: any): value is T { export function isPlainObject<T extends object = Record<PropertyKey, any>>(value: any): value is T {
if (!isObject(value)) { if (!isObject(value)) {
return false; return false;
} }

View File

@ -57,11 +57,13 @@ export function isReactComponent(obj: any): obj is ComponentType<any> {
return false; return false;
} }
return Boolean(isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj) || isMemoType(obj)); return Boolean(
isReactClass(obj) || typeof obj === 'function' || isForwardRefType(obj) || isMemoType(obj),
);
} }
export function wrapReactClass(view: FunctionComponent) { export function wrapReactClass(view: FunctionComponent) {
let ViewComponentClass = class extends Component { let ViewComponentClass = class extends Component<any, any> {
render() { render() {
const { children, ...other } = this.props; const { children, ...other } = this.props;
return createElement(view, other, children); return createElement(view, other, children);

View File

@ -1,6 +1,5 @@
import { isI18NObject } from './is-object'; import { isI18NObject } from './is-object';
import { get } from 'lodash'; import { get } from 'lodash-es';
import { IPublicEnumTransformStage, IPublicModelComponentMeta } from '@alilc/lowcode-types'; import { IPublicEnumTransformStage, IPublicModelComponentMeta } from '@alilc/lowcode-types';
import { Logger } from './logger'; import { Logger } from './logger';
@ -22,7 +21,7 @@ export function isVariable(obj: any): obj is Variable {
export function isUseI18NSetter(prototype: any, propName: string) { export function isUseI18NSetter(prototype: any, propName: string) {
const configure = prototype?.options?.configure; const configure = prototype?.options?.configure;
if (Array.isArray(configure)) { if (Array.isArray(configure)) {
return configure.some(c => { return configure.some((c) => {
return c.name === propName && c?.setter?.type?.displayName === 'I18nSetter'; return c.name === propName && c?.setter?.type?.displayName === 'I18nSetter';
}); });
} }
@ -64,7 +63,7 @@ export function waitForThing(obj: any, path: string): Promise<any> {
export function arrShallowEquals(arr1: any[], arr2: any[]): boolean { export function arrShallowEquals(arr1: any[], arr2: any[]): boolean {
if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false; if (!Array.isArray(arr1) || !Array.isArray(arr2)) return false;
if (arr1.length !== arr2.length) return false; if (arr1.length !== arr2.length) return false;
return arr1.every(item => arr2.includes(item)); return arr1.every((item) => arr2.includes(item));
} }
/** /**
@ -79,14 +78,7 @@ export function executePendingFn(fn: () => void, timeout: number = 2000) {
return setTimeout(fn, timeout); return setTimeout(fn, timeout);
} }
const stageList = [ const stageList = ['render', 'serilize', 'save', 'clone', 'init', 'upgrade'];
'render',
'serilize',
'save',
'clone',
'init',
'upgrade',
];
/** /**
* *
@ -95,7 +87,9 @@ const stageList = [
*/ */
export function compatStage(stage: IPublicEnumTransformStage | number): IPublicEnumTransformStage { export function compatStage(stage: IPublicEnumTransformStage | number): IPublicEnumTransformStage {
if (typeof stage === 'number') { if (typeof stage === 'number') {
console.warn('stage 直接指定为数字的使用方式已经过时,将在下一版本移除,请直接使用 IPublicEnumTransformStage.Render|Serilize|Save|Clone|Init|Upgrade'); console.warn(
'stage 直接指定为数字的使用方式已经过时,将在下一版本移除,请直接使用 IPublicEnumTransformStage.Render|Serilize|Save|Clone|Init|Upgrade',
);
return stageList[stage - 1] as IPublicEnumTransformStage; return stageList[stage - 1] as IPublicEnumTransformStage;
} }
return stage as IPublicEnumTransformStage; return stage as IPublicEnumTransformStage;

View File

@ -23,7 +23,7 @@ export function compatibleLegaoSchema(props: any): any {
} }
if (Array.isArray(props)) { if (Array.isArray(props)) {
return props.map(k => compatibleLegaoSchema(k)); return props.map((k) => compatibleLegaoSchema(k));
} }
if (!isPlainObject(props)) { if (!isPlainObject(props)) {
@ -78,7 +78,10 @@ export function compatibleLegaoSchema(props: any): any {
return newProps; return newProps;
} }
export function getNodeSchemaById(schema: IPublicTypeNodeSchema, nodeId: string): IPublicTypeNodeSchema | undefined { export function getNodeSchemaById(
schema: IPublicTypeNodeSchema,
nodeId: string,
): IPublicTypeNodeSchema | undefined {
let found: IPublicTypeNodeSchema | undefined; let found: IPublicTypeNodeSchema | undefined;
if (schema.id === nodeId) { if (schema.id === nodeId) {
return schema; return schema;
@ -123,7 +126,10 @@ function getNodeSchemaFromPropsById(props: any, nodeId: string): IPublicTypeNode
* TODO: not sure if this is used anywhere * TODO: not sure if this is used anywhere
* @deprecated * @deprecated
*/ */
export function applyActivities(pivotSchema: IPublicTypeRootSchema, activities: any): IPublicTypeRootSchema { export function applyActivities(
pivotSchema: IPublicTypeRootSchema,
activities: any,
): IPublicTypeRootSchema {
let schema = { ...pivotSchema }; let schema = { ...pivotSchema };
if (!Array.isArray(activities)) { if (!Array.isArray(activities)) {
activities = [activities]; activities = [activities];

View File

@ -1,9 +1,10 @@
{ {
"extends": "../../tsconfig.json", "extends": "../../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "lib" "outDir": "dist",
}, "paths": {
"include": [ "@alilc/lowcode-*": ["packages/*"]
"./src/" }
] },
"include": ["src"]
} }

8
playground/tsconfig.json Normal file
View File

@ -0,0 +1,8 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"paths": {
"@alilc/renderer-react": ["runtime/renderer-react"]
}
}
}

View File

@ -1,4 +1,6 @@
packages: packages:
- 'runtime/*' - 'runtime/*'
- 'packages/types'
- 'packages/utils'
- 'playground' - 'playground'
- 'docs' - 'docs'

View File

@ -14,10 +14,13 @@
"test:watch": "vitest" "test:watch": "vitest"
}, },
"dependencies": { "dependencies": {
"@alilc/lowcode-types": "1.3.2",
"lodash-es": "^4.17.21" "lodash-es": "^4.17.21"
}, },
"devDependencies": { "devDependencies": {
"@types/lodash-es": "^4.17.12" "@types/lodash-es": "^4.17.12"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
} }
} }

View File

@ -13,8 +13,9 @@
"test": "vitest" "test": "vitest"
}, },
"dependencies": { "dependencies": {
"@alilc/renderer-core": "workspace:*",
"@alilc/runtime-router": "workspace:*",
"@vue/reactivity": "^3.4.21", "@vue/reactivity": "^3.4.21",
"@alilc/renderer-core": "^2.0.0-beta.0",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"hoist-non-react-statics": "^3.3.2", "hoist-non-react-statics": "^3.3.2",
"use-sync-external-store": "^1.2.0", "use-sync-external-store": "^1.2.0",
@ -22,7 +23,6 @@
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
}, },
"devDependencies": { "devDependencies": {
"@alilc/runtime-router": "1.0.0-beta.0",
"@testing-library/react": "^14.2.0", "@testing-library/react": "^14.2.0",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/hoist-non-react-statics": "^3.3.5", "@types/hoist-non-react-statics": "^3.3.5",
@ -34,5 +34,9 @@
"peerDependencies": { "peerDependencies": {
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0" "react-dom": "^18.2.0"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
} }
} }

View File

@ -13,7 +13,7 @@
"test": "vitest" "test": "vitest"
}, },
"dependencies": { "dependencies": {
"@alilc/renderer-core": "^2.0.0-beta.0", "@alilc/renderer-core": "workspace:*",
"lodash-es": "^4.17.21", "lodash-es": "^4.17.21",
"path-to-regexp": "^6.2.1", "path-to-regexp": "^6.2.1",
"qs": "^6.12.0" "qs": "^6.12.0"
@ -21,5 +21,9 @@
"devDependencies": { "devDependencies": {
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/qs": "^6.9.13" "@types/qs": "^6.9.13"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
} }
} }

View File

@ -1,13 +0,0 @@
#!/usr/bin/env bash
rm -rf node_modules package-lock.json yarn.lock
lerna clean -y
find ./packages -type f -name "package-lock.json" -exec rm -f {} \;
lerna bootstrap
lerna exec --stream \
--scope @alilc/lowcode-editor-core \
--scope @alilc/lowcode-types \
--scope @alilc/lowcode-utils \
-- npm run build

View File

@ -1,26 +0,0 @@
#!/usr/bin/env node
const os = require('os');
const del = require('del');
const gulp = require('gulp');
const execa = require('execa');
async function deleteRootDirLockFile() {
await del('package-lock.json');
await del('yarn.lock');
}
async function clean() {
await execa.command('lerna clean -y', { stdio: 'inherit', encoding: 'utf-8' });
}
async function deletePackagesDirLockFile() {
await del('packages/**/package-lock.json');
}
async function bootstrap() {
await execa.command('lerna bootstrap --force-local', { stdio: 'inherit', encoding: 'utf-8' });
}
const setup = gulp.series(deleteRootDirLockFile, clean, deletePackagesDirLockFile, bootstrap);
os.type() === 'Windows_NT' ? setup() : execa.command('scripts/setup.sh', { stdio: 'inherit', encoding: 'utf-8' });

View File

@ -1,10 +0,0 @@
#!/usr/bin/env node
const os = require('os');
const execa = require('execa');
async function start() {
const [, , pkgName = '@alilc/lowcode-ignitor'] = process.argv;
await execa.command(`lerna exec --scope ${pkgName} -- npm start`, { stdio: 'inherit', encoding: 'utf-8' });
}
os.type() === 'Windows_NT' ? start() : execa.command('scripts/start.sh', { stdio: 'inherit', encoding: 'utf-8' });

View File

@ -1,24 +0,0 @@
#!/usr/bin/env node
const fs = require('fs');
const { join } = require('path');
const packagesDir = join(__dirname, '../packages');
const blacklistPkgNames = ['code-generator', 'material-parser'];
const dirs = fs.readdirSync(packagesDir);
dirs
.filter(dir => {
return !dir.startsWith('.') && !blacklistPkgNames.includes(dir);
})
.forEach(dir => {
const pkgDir = join(packagesDir, dir);
const pkg = JSON.parse(fs.readFileSync(join(pkgDir, 'package.json'), 'utf-8'));
if (pkg.private) return;
const { files } = pkg;
files.forEach(file => {
const fileDir = join(pkgDir, file);
if (!fs.existsSync(fileDir)) {
throw new Error(`${fileDir} does not exist, plz run build`);
}
});
});

View File

@ -31,11 +31,7 @@
// skip type checking of declaration files // skip type checking of declaration files
"skipLibCheck": true, "skipLibCheck": true,
"baseUrl": "./packages", "baseUrl": "./packages",
"useDefineForClassFields": true, "useDefineForClassFields": true
"paths": {
"@alilc/lowcode-*": ["./*/src"]
},
"outDir": "lib"
}, },
"exclude": ["**/tests/*", "**/*.test.ts", "**/lib", "**/es", "node_modules"] "exclude": ["**/tests/*", "**/*.test.ts", "**/lib", "**/es", "node_modules"]
} }