Match-id-e0d404aeb67f1c331b4caec6e3eac54209d72b00
This commit is contained in:
commit
d090158b1b
|
@ -3,3 +3,4 @@ build/
|
|||
.idea
|
||||
.vscode
|
||||
package-lock.json
|
||||
libs/**/dist
|
||||
|
|
25
README.md
25
README.md
|
@ -1,14 +1,27 @@
|
|||
# horizon
|
||||
|
||||
## 工程编译:
|
||||
1、npm install
|
||||
2、npm run build
|
||||
Horizon采用monorepo方式管理项目,意思是在版本控制系统的单个代码库里包含了许多项目的代码
|
||||
|
||||
全局单元测试 npm run test
|
||||
monorepo工具采用npm workspaces **(npm版本需要大于7.x)**
|
||||
### 工程命令
|
||||
#### 安装
|
||||
```shell
|
||||
npm install
|
||||
```
|
||||
> 需要使用npm7.x以后版本安装,monorepo的依赖才能正确安装到node_modules
|
||||
#### 打包
|
||||
```shell
|
||||
npm run build
|
||||
```
|
||||
#### 全局单元测试
|
||||
```shell
|
||||
npm run test
|
||||
```
|
||||
|
||||
发布包:
|
||||
#### 发布包:
|
||||
```shell
|
||||
npm publish build/horizon --_auth=XXX
|
||||
|
||||
```
|
||||
XXX是base64编码后的密码值,CMO保管。
|
||||
|
||||
## 不兼容:
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
"plugins": [
|
||||
"@babel/plugin-syntax-dynamic-import",
|
||||
"@babel/plugin-syntax-import-meta",
|
||||
"@babel/plugin-proposal-class-properties",
|
||||
"@babel/plugin-proposal-json-strings",
|
||||
[
|
||||
"@babel/plugin-proposal-decorators",
|
||||
{
|
||||
"legacy": true
|
||||
}
|
||||
],
|
||||
"@babel/plugin-proposal-function-sent",
|
||||
"@babel/plugin-proposal-export-namespace-from",
|
||||
"@babel/plugin-proposal-numeric-separator",
|
||||
"@babel/plugin-proposal-throw-expressions"
|
||||
],
|
||||
"env": {
|
||||
"test": {
|
||||
"plugins": [
|
||||
"@babel/plugin-transform-modules-commonjs"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
# horizon jsx babel plugin
|
|
@ -0,0 +1,10 @@
|
|||
/* istanbul ignore next */
|
||||
module.exports = {
|
||||
presets: [
|
||||
'@babel/preset-env',
|
||||
],
|
||||
plugins: [
|
||||
/* eslint-disable-next-line global-require */
|
||||
[require('./dist/index.js')],
|
||||
],
|
||||
};
|
|
@ -0,0 +1,10 @@
|
|||
module.exports = {
|
||||
transform: {
|
||||
'\\.(ts|tsx)$': 'ts-jest',
|
||||
},
|
||||
globals: {
|
||||
'ts-jest': {
|
||||
babelConfig: true,
|
||||
},
|
||||
},
|
||||
};
|
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
"name": "@cloudsop/horizon-jsx-transform-babel-plugin",
|
||||
"version": "0.2.0",
|
||||
"description": "transform jsx for horizon",
|
||||
"main": "./dist/index.js",
|
||||
"scripts": {
|
||||
"build": "rimraf dist && tsc",
|
||||
"test": "rimraf dist && tsc && jest",
|
||||
"jest": "jest",
|
||||
"prepublish": "npm run build"
|
||||
},
|
||||
"files": [
|
||||
"../dist"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/generator": "^7.2.2",
|
||||
"@babel/parser": "^7.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.2.2",
|
||||
"@babel/plugin-proposal-class-properties": "^7.2.1",
|
||||
"@babel/plugin-proposal-decorators": "^7.2.0",
|
||||
"@babel/plugin-proposal-export-namespace-from": "^7.2.0",
|
||||
"@babel/plugin-proposal-function-sent": "^7.2.0",
|
||||
"@babel/plugin-proposal-json-strings": "^7.2.0",
|
||||
"@babel/plugin-proposal-numeric-separator": "^7.2.0",
|
||||
"@babel/plugin-proposal-throw-expressions": "^7.2.0",
|
||||
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
|
||||
"@babel/plugin-syntax-import-meta": "^7.2.0",
|
||||
"@babel/plugin-syntax-jsx": "^7.2.0",
|
||||
"@babel/plugin-transform-modules-commonjs": "^7.2.0",
|
||||
"@babel/preset-env": "^7.16.11",
|
||||
"@babel/types": "^7.0.0",
|
||||
"babel-plugin-tester": "^10.1.0",
|
||||
"ts-jest": "^26.1.3"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
import SyntaxJSX from '@babel/plugin-syntax-jsx';
|
||||
import * as BabelCore from '@babel/core';
|
||||
import * as t from '@babel/types';
|
||||
import {NodePath} from '@babel/traverse';
|
||||
|
||||
export default ({types}: typeof BabelCore) => {
|
||||
return {
|
||||
name: 'horizon-jsx-babel-plugin',
|
||||
inherits: SyntaxJSX,
|
||||
|
||||
visitor: {
|
||||
Program(path: NodePath<t.Program>) {
|
||||
// program = path
|
||||
},
|
||||
|
||||
JSXElement: {
|
||||
exit(path) {
|
||||
|
||||
},
|
||||
},
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
const path = require('path');
|
||||
const pluginTester = require('babel-plugin-tester').default;
|
||||
import plugin from '../src';
|
||||
|
||||
pluginTester({
|
||||
plugin,
|
||||
title: 'horizon jsx plugin',
|
||||
fixtures: path.join(__dirname, '__fixtures__'),
|
||||
snapshot: true
|
||||
});
|
|
@ -23,7 +23,7 @@ import {
|
|||
createElement,
|
||||
cloneElement,
|
||||
isValidElement,
|
||||
} from './horizon/src/external/Horizon';
|
||||
} from './src/external/Horizon';
|
||||
|
||||
import {
|
||||
render,
|
||||
|
@ -31,7 +31,7 @@ import {
|
|||
unstable_batchedUpdates,
|
||||
findDOMNode,
|
||||
unmountComponentAtNode,
|
||||
} from './horizon/src/dom/DOMExternal';
|
||||
} from './src/dom/DOMExternal';
|
||||
|
||||
const Horizon = {
|
||||
Children,
|
|
@ -10,11 +10,14 @@ const uniqueKeyMap = new Map([
|
|||
['Del', 'Delete'],
|
||||
]);
|
||||
|
||||
const noop = () => {};
|
||||
// 创建普通自定义事件对象实例,和原生事件对应
|
||||
export function decorateNativeEvent(customEventName, nativeEvtName, nativeEvent) {
|
||||
|
||||
nativeEvent.isDefaultPrevented = () => nativeEvent.defaultPrevented;
|
||||
nativeEvent.isPropagationStopped = () => nativeEvent.cancelBubble;
|
||||
// 适配老版本事件api
|
||||
nativeEvent.persist = noop;
|
||||
|
||||
// custom事件自定义属性
|
||||
nativeEvent.customEventName = customEventName;
|
||||
|
|
|
@ -30,7 +30,7 @@ function isValidKey(key) {
|
|||
}
|
||||
|
||||
function mergeDefault(sourceObj, defaultObj) {
|
||||
Object.keys(defaultObj).forEach((key) => {
|
||||
Object.keys(defaultObj).forEach(key => {
|
||||
if (sourceObj[key] === undefined) {
|
||||
sourceObj[key] = defaultObj[key];
|
||||
}
|
||||
|
@ -44,10 +44,10 @@ function buildElement(isClone, type, setting, children) {
|
|||
const props = isClone ? { ...type.props } : {};
|
||||
let vNode = isClone ? type.belongClassVNode : getProcessingClassVNode();
|
||||
|
||||
if (setting != null) {
|
||||
if (setting !== null) {
|
||||
const keys = Object.keys(setting);
|
||||
const keyLength = keys.length;
|
||||
for(let i = 0; i < keyLength; i++) {
|
||||
for (let i = 0; i < keyLength; i++) {
|
||||
const k = keys[i];
|
||||
if (isValidKey(k)) {
|
||||
props[k] = setting[k];
|
||||
|
@ -81,5 +81,5 @@ export function cloneElement(element, setting, ...children) {
|
|||
|
||||
// 检测结构体是否为合法的Element
|
||||
export function isValidElement(element) {
|
||||
return !!(element && element.vtype === TYPE_COMMON_ELEMENT);
|
||||
return (element && element.vtype === TYPE_COMMON_ELEMENT);
|
||||
}
|
||||
|
|
75
package.json
75
package.json
|
@ -3,6 +3,14 @@
|
|||
"workspaces": [
|
||||
"libs/*"
|
||||
],
|
||||
"scripts": {
|
||||
"build": " webpack --config ./scripts/webpack/webpack.config.js",
|
||||
"build-3rdLib": "node ./scripts/gen3rdLib.js",
|
||||
"build-3rdLib-dev": "node ./scripts/gen3rdLib.js --dev",
|
||||
"debug-test": "yarn test --debug",
|
||||
"test": "jest --config=jest.config.js",
|
||||
"watch-test": "yarn test --watch --dev"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "^7.10.5",
|
||||
"@babel/code-frame": "^7.10.4",
|
||||
|
@ -40,9 +48,9 @@
|
|||
"@babel/preset-typescript": "^7.16.7",
|
||||
"@babel/register": "^7.14.5",
|
||||
"@babel/traverse": "^7.11.0",
|
||||
"@cloudsop/eview-ui": "^0.1.65",
|
||||
"@mattiasbuelens/web-streams-polyfill": "^0.3.2",
|
||||
"art": "0.10.1",
|
||||
"@types/jest": "^26.0.24",
|
||||
"@types/node": "^17.0.18",
|
||||
"babel-core": "^6.26.3",
|
||||
"babel-eslint": "^10.0.3",
|
||||
"babel-jest": "^27.5.1",
|
||||
|
@ -51,17 +59,9 @@
|
|||
"babel-preset-env": "^1.7.0",
|
||||
"babel-preset-react": "^6.24.1",
|
||||
"chalk": "^3.0.0",
|
||||
"clean-webpack-plugin": "^4.0.0-alpha.0",
|
||||
"cli-table": "^0.3.1",
|
||||
"coffee-script": "^1.12.7",
|
||||
"concurrently": "^6.2.0",
|
||||
"confusing-browser-globals": "^1.0.9",
|
||||
"copy-webpack-plugin": "5.0.4",
|
||||
"core-js": "^3.6.4",
|
||||
"coveralls": "^3.0.9",
|
||||
"create-react-class": "^15.6.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"css-loader": "3.4.2",
|
||||
"danger": "^9.2.10",
|
||||
"ejs": "^3.1.6",
|
||||
"error-stack-parser": "^2.0.6",
|
||||
|
@ -75,72 +75,25 @@
|
|||
"eslint-plugin-no-function-declare-after-return": "^1.0.0",
|
||||
"eslint-plugin-react": "^6.7.1",
|
||||
"eslint-webpack-plugin": "^3.0.1",
|
||||
"express": "^4.17.1",
|
||||
"fbjs-scripts": "1.2.0",
|
||||
"filesize": "^6.0.1",
|
||||
"flow-bin": "0.97",
|
||||
"glob": "^7.1.6",
|
||||
"glob-stream": "^6.1.0",
|
||||
"google-closure-compiler": "^20200517.0.0",
|
||||
"gzip-size": "^5.1.1",
|
||||
"html-webpack-plugin": "4.4.1",
|
||||
"jasmine-check": "^1.0.0-rc.0",
|
||||
"jest": "^25.5.4",
|
||||
"jest-cli": "^25.2.7",
|
||||
"jest-diff": "^25.2.6",
|
||||
"jest-environment-jsdom-sixteen": "^1.0.3",
|
||||
"jest-react": "^0.12.0",
|
||||
"jest-snapshot-serializer-raw": "^1.1.0",
|
||||
"minimatch": "^3.0.4",
|
||||
"minimist": "^1.2.3",
|
||||
"mkdirp": "^0.5.1",
|
||||
"mocha": "^9.0.1",
|
||||
"ncp": "^2.0.0",
|
||||
"object-assign": "^4.1.1",
|
||||
"pacote": "^10.3.0",
|
||||
"power-assert": "^1.6.1",
|
||||
"prettier": "1.19.1",
|
||||
"prop-types": "^15.6.2",
|
||||
"puppeteer-core": "^10.1.0",
|
||||
"random-seed": "^0.3.0",
|
||||
"react-is": "^17.0.2",
|
||||
"react-lifecycles-compat": "^3.0.4",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"regenerator-runtime": "^0.13.9",
|
||||
"resemblejs": "^4.0.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"semver": "^7.1.1",
|
||||
"style-loader": "1.0.0",
|
||||
"targz": "^1.0.1",
|
||||
"through2": "^3.0.1",
|
||||
"tmp": "^0.1.0",
|
||||
"tslint": "^6.0.0",
|
||||
"typescript": "^3.9.7",
|
||||
"url-loader": "^4.1.1",
|
||||
"wait-on": "^6.0.0",
|
||||
"webpack": "^4.46.0",
|
||||
"webpack-cli": "^4.7.2",
|
||||
"yargs": "^15.3.1"
|
||||
"webpack-cli": "^4.7.2"
|
||||
},
|
||||
"devEngines": {
|
||||
"node": "8.x || 9.x || 10.x || 11.x || 12.x || 13.x || 14.x"
|
||||
},
|
||||
"scripts": {
|
||||
"build": " webpack --config ./scripts/webpack/webpack.config.js",
|
||||
"build-3rdLib": "node ./scripts/gen3rdLib.js",
|
||||
"build-3rdLib-dev": "node ./scripts/gen3rdLib.js --dev",
|
||||
"debug-test": "yarn test --debug",
|
||||
"test": "jest --config=jest.config.js",
|
||||
"watch-test": "yarn test --watch --release-channel=horizon --dev"
|
||||
},
|
||||
"dependencies": {
|
||||
"@elg/speedscope": "^1.9.0-a6f84db",
|
||||
"@types/node": "^17.0.18",
|
||||
"babel-code-frame": "^6.26.0",
|
||||
"grunt-cli": "^1.4.3",
|
||||
"react-dom": "^17.0.2",
|
||||
"react-shallow-renderer": "^16.14.1",
|
||||
"rxjs": "^7.1.0",
|
||||
"symlink-dir": "^4.2.0"
|
||||
"engines": {
|
||||
"node": ">=10.x",
|
||||
"npm": ">=7.x"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
|
||||
const libPath = path.join(__dirname, '../../libs');
|
||||
const libPath = path.join(__dirname, '../../libs/horizon');
|
||||
const baseConfig = {
|
||||
entry: path.resolve(libPath, 'index.ts'),
|
||||
module: {
|
||||
|
@ -10,7 +9,7 @@ const baseConfig = {
|
|||
test: /\.(js)|ts$/,
|
||||
exclude: /node_modules/,
|
||||
use: [
|
||||
{
|
||||
{
|
||||
loader: 'babel-loader'
|
||||
}
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue