Match-id-7321885d37db6d97de01c5fd56d5acfeb795476f

This commit is contained in:
* 2021-12-25 10:20:45 +08:00 committed by *
parent 90a8629dba
commit 5aa6ebe0c7
17 changed files with 686 additions and 1 deletions

10
.editorconfig Normal file
View File

@ -0,0 +1,10 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
charset = utf-8
indent_size = 2
indent_style = space
trim_trailing_whitespace = true

2
.eslintignore Normal file
View File

@ -0,0 +1,2 @@
**/node_modules
build/

186
.eslintrc.js Normal file
View File

@ -0,0 +1,186 @@
const restrictedGlobals = require('confusing-browser-globals');
const OFF = 0;
const ERROR = 2;
module.exports = {
extends: ['fbjs', 'prettier'],
// Stop ESLint from looking for a configuration file in parent folders
root: true,
plugins: [
'jest',
'no-for-of-loops',
'no-function-declare-after-return',
'react',
],
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
ecmaFeatures: {
experimentalObjectRestSpread: true,
},
},
env: {
'mocha': true,
'node': true,
},
// We're stricter than the default config, mostly. We'll override a few rules
// and then enable some React specific ones.
rules: {
'accessor-pairs': OFF,
'brace-style': [ERROR, '1tbs'],
'consistent-return': OFF,
'dot-location': [ERROR, 'property'],
// We use console['error']() as a signal to not transform it:
'dot-notation': [ERROR, {allowPattern: '^(error|warn)$'}],
'eol-last': ERROR,
eqeqeq: [ERROR, 'allow-null'],
indent: OFF,
'jsx-quotes': [ERROR, 'prefer-double'],
'keyword-spacing': [ERROR, {after: true, before: true}],
'no-bitwise': OFF,
'no-inner-declarations': [ERROR, 'functions'],
'no-multi-spaces': ERROR,
'no-restricted-globals': [ERROR].concat(restrictedGlobals),
'no-restricted-syntax': [ERROR, 'WithStatement'],
'no-shadow': ERROR,
'no-unused-expressions': ERROR,
'no-unused-vars': [ERROR, {args: 'none'}],
'no-use-before-define': OFF,
'no-useless-concat': OFF,
quotes: [ERROR, 'single', {avoidEscape: true, allowTemplateLiterals: true}],
'space-before-blocks': ERROR,
'space-before-function-paren': OFF,
'valid-typeof': [ERROR, {requireStringLiterals: true}],
// We apply these settings to files that should run on Node.
// They can't use JSX or ES6 modules, and must be in strict mode.
// They can, however, use other ES6 features.
// (Note these rules are overridden later for source files.)
'no-var': ERROR,
strict: ERROR,
// Enforced by Prettier
// TODO: Prettier doesn't handle long strings or long comments. Not a big
// deal. But I turned it off because loading the plugin causes some obscure
// syntax error and it didn't seem worth investigating.
'max-len': OFF,
// React & JSX
// Our transforms set this automatically
'react/jsx-boolean-value': [ERROR, 'always'],
'react/jsx-no-undef': ERROR,
// We don't care to do this
'react/jsx-sort-prop-types': OFF,
'react/jsx-space-before-closing': ERROR,
'react/jsx-uses-react': ERROR,
'react/no-is-mounted': OFF,
// This isn't useful in our test code
'react/react-in-jsx-scope': ERROR,
'react/self-closing-comp': ERROR,
// We don't care to do this
'react/jsx-wrap-multilines': [
ERROR,
{declaration: false, assignment: false},
],
// Prevent for...of loops because they require a Symbol polyfill.
// You can disable this rule for code that isn't shipped (e.g. build scripts and tests).
'no-for-of-loops/no-for-of-loops': ERROR,
// Prevent function declarations after return statements
'no-function-declare-after-return/no-function-declare-after-return': ERROR,
},
overrides: [
{
// We apply these settings to the source files that get compiled.
// They can use all features including JSX (but shouldn't use `var`).
files: [
// Internal forwarding modules
'libs/*/*.js',
// Source files
'libs/*/src/**/*.js',
],
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 8,
sourceType: 'module',
},
rules: {
'no-var': ERROR,
'prefer-const': ERROR,
strict: OFF,
},
},
{
files: ['**/__tests__/*.js'],
rules: {
// https://github.com/jest-community/eslint-plugin-jest
'jest/no-focused-tests': ERROR,
'jest/valid-expect': ERROR,
'jest/valid-expect-in-promise': ERROR,
},
},
{
files: [
'**/__tests__/**/*.js',
'scripts/**/*.js',
'libs/*/npm/**/*.js',
'libs/dom-event-testing-library/**/*.js',
'libs/react-devtools*/**/*.js',
],
rules: {
'react-internal/no-production-logging': OFF,
'react-internal/warning-args': OFF,
},
},
{
files: ['libs/react-native-renderer/**/*.js'],
globals: {
nativeFabricUIManager: true,
},
},
{
files: ['libs/react-transport-dom-webpack/**/*.js'],
globals: {
__webpack_chunk_load__: true,
__webpack_require__: true,
},
},
{
files: ['libs/scheduler/**/*.js'],
globals: {
TaskController: true,
},
},
{
files: [
'scripts/e2e-test/**/*.js',
'scripts/e2e-test/**/*.jsx',
],
parserOptions: {
sourceType: 'module',
},
}
],
globals: {
SharedArrayBuffer: true,
spyOnDev: true,
spyOnDevAndProd: true,
spyOnProd: true,
__PROFILE__: true,
__UMD__: true,
__EXPERIMENTAL__: true,
__VARIANT__: true,
gate: true,
trustedTypes: true,
},
};

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
node_modules
build/
.idea
.vscode
package-lock.json

17
.prettierrc.js Normal file
View File

@ -0,0 +1,17 @@
'use strict';
module.exports = {
printWidth: 120, // 一行120字符数如果超过会进行换行
tabWidth: 2, // tab等2个空格
useTabs: false, // 用空格缩进行
semi: true, // 行尾使用分号
singleQuote: true, // 字符串使用单引号
quoteProps: 'as-needed', // 仅在需要时在对象属性添加引号
jsxSingleQuote: false, // 在JSX中使用双引号
trailingComma: 'es5', // 使用尾逗号(对象、数组等)
bracketSpacing: true, // 对象的括号间增加空格
jsxBracketSameLine: false, // 将多行JSX元素的>放在最后一行的末尾
arrowParens: 'avoid', // 在唯一的arrow函数参数周围省略括号
vueIndentScriptAndStyle: false, // 不缩进Vue文件中的<script>和<style>标记内的代码
endOfLine: 'lf', // 仅限换行(\n
};

View File

@ -1 +1,16 @@
#horizon
# horizon
## 工程编译:
1、npm install
2、npm run build
全局单元测试 npm run test
发布包:
npm publish build/horizon --_auth=XXX
XXX是base64编码后的密码值CMO保管。
## 不兼容:
1. input中的defaultValue值不支持改变只有开始设置的值生效。
2. JSX里面不支持<!-- xxx -->注释。

1
app_define.json Normal file
View File

@ -0,0 +1 @@
{"fileVersion":"1","name":"Horizon","serviceId":"067e5bef6cd240ae9460229d107a99a6","description":"","version":"1.0.0","type":"microService","processes":{"Horizon":{"subscribes":[]}}}

32
babel.config.js Normal file
View File

@ -0,0 +1,32 @@
'use strict';
module.exports = {
presets: [
'@babel/preset-typescript',
],
plugins: [
['@babel/plugin-proposal-class-properties', { loose: true }],
'syntax-trailing-function-commas',
[
'@babel/plugin-proposal-object-rest-spread',
{ loose: true, useBuiltIns: true },
],
['@babel/plugin-transform-template-literals', { loose: true }],
'@babel/plugin-transform-literals',
'@babel/plugin-transform-arrow-functions',
'@babel/plugin-transform-block-scoped-functions',
'@babel/plugin-transform-object-super',
'@babel/plugin-transform-shorthand-properties',
'@babel/plugin-transform-computed-properties',
'@babel/plugin-transform-for-of',
['@babel/plugin-transform-spread', { loose: true, useBuiltIns: true }],
'@babel/plugin-transform-parameters',
['@babel/plugin-transform-destructuring', { loose: true, useBuiltIns: true }],
['@babel/plugin-transform-block-scoping', { throwIfClosureRequired: true }],
'@babel/plugin-transform-classes',
'@babel/plugin-transform-runtime',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-optional-chaining',
['@babel/plugin-proposal-private-methods', { 'loose': true }]
],
};

1
libs/README.md Normal file
View File

@ -0,0 +1 @@
# `horizon`

1
libs/index.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare var isDev: any;

7
libs/index.js Normal file
View File

@ -0,0 +1,7 @@
'use strict';
if (process.env.NODE_ENV === 'production') {
module.exports = require('./cjs/horizon.production.js');
} else {
module.exports = require('./cjs/horizon.development.js');
}

100
libs/index.ts Normal file
View File

@ -0,0 +1,100 @@
import {
Children,
createRef,
Component,
PureComponent,
createContext,
forwardRef,
lazy,
memo,
useCallback,
useContext,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
Fragment,
Profiler,
StrictMode,
Suspense,
createElement,
cloneElement,
isValidElement,
} from './horizon/src/external/Horizon';
import {
render,
createPortal,
unstable_batchedUpdates,
findDOMNode,
unmountComponentAtNode,
} from './horizon/src/dom/DOMExternal';
const Horizon = {
Children,
createRef,
Component,
PureComponent,
createContext,
forwardRef,
lazy,
memo,
useCallback,
useContext,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
Fragment,
Profiler,
StrictMode,
Suspense,
createElement,
cloneElement,
isValidElement,
render,
createPortal,
unstable_batchedUpdates,
findDOMNode,
unmountComponentAtNode,
};
export {
Children,
createRef,
Component,
PureComponent,
createContext,
forwardRef,
lazy,
memo,
useCallback,
useContext,
useEffect,
useImperativeHandle,
useLayoutEffect,
useMemo,
useReducer,
useRef,
useState,
Fragment,
Profiler,
StrictMode,
Suspense,
createElement,
cloneElement,
isValidElement,
render,
createPortal,
unstable_batchedUpdates,
findDOMNode,
unmountComponentAtNode,
};
export default Horizon;

16
libs/package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "@cloudsop/horizon",
"description": "Horizon is a JavaScript framework library.",
"keywords": [
"horizon"
],
"version": "1.0.0",
"homepage": "",
"bugs": "",
"main": "index.js",
"repository": {},
"engines": {
"node": ">=0.10.0"
},
"dependencies": {}
}

143
package.json Normal file
View File

@ -0,0 +1,143 @@
{
"private": true,
"workspaces": [
"libs/*"
],
"devDependencies": {
"@babel/cli": "^7.10.5",
"@babel/code-frame": "^7.10.4",
"@babel/core": "^7.11.1",
"@babel/eslint-parser": "^7.11.4",
"@babel/helper-module-imports": "^7.10.4",
"@babel/parser": "^7.11.3",
"@babel/plugin-external-helpers": "^7.10.4",
"@babel/plugin-proposal-class-properties": "^7.14.5",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
"@babel/plugin-proposal-object-rest-spread": "^7.11.0",
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/plugin-syntax-jsx": "^7.10.4",
"@babel/plugin-transform-arrow-functions": "^7.10.4",
"@babel/plugin-transform-async-to-generator": "^7.10.4",
"@babel/plugin-transform-block-scoped-functions": "^7.10.4",
"@babel/plugin-transform-block-scoping": "^7.11.1",
"@babel/plugin-transform-classes": "^7.14.2",
"@babel/plugin-transform-computed-properties": "^7.10.4",
"@babel/plugin-transform-destructuring": "^7.10.4",
"@babel/plugin-transform-for-of": "^7.10.4",
"@babel/plugin-transform-literals": "^7.10.4",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-object-super": "^7.10.4",
"@babel/plugin-transform-parameters": "^7.10.5",
"@babel/plugin-transform-react-jsx-source": "^7.10.5",
"@babel/plugin-transform-runtime": "^7.14.5",
"@babel/plugin-transform-shorthand-properties": "^7.10.4",
"@babel/plugin-transform-spread": "^7.11.0",
"@babel/plugin-transform-template-literals": "^7.10.5",
"@babel/preset-env": "^7.14.7",
"@babel/preset-flow": "^7.10.4",
"@babel/preset-react": "^7.14.5",
"@babel/preset-typescript": "7.8.3",
"@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",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.2.2",
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
"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",
"eslint": "^7.32.0",
"eslint-config-fbjs": "^1.1.1",
"eslint-config-prettier": "^6.9.0",
"eslint-plugin-babel": "^5.3.0",
"eslint-plugin-flowtype": "^2.25.0",
"eslint-plugin-jest": "^22.15.0",
"eslint-plugin-no-for-of-loops": "^1.0.0",
"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.2.7",
"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",
"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"
},
"devEngines": {
"node": "8.x || 9.x || 10.x || 11.x || 12.x || 13.x || 14.x"
},
"jest": {
"testRegex": "/scripts/jest/dont-run-jest-directly\\.js$"
},
"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": "node ./scripts/jest/jest-cli.js",
"watch-test": "yarn test --watch --release-channel=horizon --dev"
},
"dependencies": {
"@elg/speedscope": "^1.9.0-a6f84db",
"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"
}
}

3
path.json Normal file
View File

@ -0,0 +1,3 @@
{
"horizon-test-path": "../horizon-test"
}

39
tsconfig.json Normal file
View File

@ -0,0 +1,39 @@
{
"compilerOptions": {
"outDir": "./build",
"incremental": false,
"sourceMap": false,
"allowJs": true, // allowJs=true => tsc compile js as module, no type check
"checkJs": false, // Disable ts error checking in js
"strict": false, // js-ts mixed setting
"noImplicitReturns": true,
"noUnusedLocals": false, // jsts.
"noUnusedParameters": false,
"noImplicitAny": false,
"noImplicitThis": true,
// "strictNullChecks": true,
"module": "CommonJS",
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"target": "es5",
"jsx": "react",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"allowUnreachableCode": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"downlevelIteration": true,
"types": [], // 使@types/node
"lib": ["dom", "esnext", "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020"],
"baseUrl": ".",
"rootDir": "./libs"
},
"include": [
"./libs/**/src/**/*.ts",
"libs/index.d.ts"
],
"exclude": ["node_modules", "**/*.spec.ts", "dev"]
}

107
tslint.json Normal file
View File

@ -0,0 +1,107 @@
{
"rules": {
"deprecation": true,
"use-isnan": true,
"max-line-length": [
true,
{
"limit": 120,
"ignore-pattern": "^import |^export {(.*?)}",
"check-strings": false,
"check-regex": true
}
],
"member-ordering": [true, { "order": "fields-first" }],
"no-unnecessary-type-assertion": true,
"no-parameter-reassignment": true,
"no-string-throw": true,
"no-unused-expression": true,
"no-duplicate-variable": true,
"no-for-in-array": true,
"no-arg": true,
"no-any": [true, { "ignore-rest-args": true }],
"no-shadowed-variable": [
true,
{
"class": true,
"enum": true,
"function": true,
"interface": false,
"namespace": true,
"typeAlias": false,
"typeParameter": false,
"underscore": false
}
],
"no-sparse-arrays": true,
"no-string-literal": true,
"no-for-in": true,
"no-invalid-this": true,
"no-switch-case-fall-through": true,
"no-inferrable-types": [true, "ignore-params", "ignore-properties"],
"no-non-null-assertion": true,
"no-this-assignment": [
true,
{ "allowed-names": ["^self$"], "allow-destructuring": true }
],
"no-var-keyword": true,
"no-require-imports": true,
"prefer-for-of": true,
"prefer-conditional-expression": [true, "check-else-if"],
"prefer-object-spread": true,
"typeof-compare": true,
"cyclomatic-complexity": [true, 20],
"max-file-line-count": [true, 500],
"prefer-readonly": true,
"prefer-const": true,
"radix": true,
"space-before-function-paren": [
true,
{
"anonymous": "never",
"named": "never",
"asyncArrow": "always",
"method": "never",
"constructor": "never"
}
],
"space-within-parens": 1,
"type-literal-delimiter": true,
"variable-name": {
"options": [
"ban-keywords",
"check-format",
"require-const-for-all-caps",
"allow-pascal-case"
]
},
"curly": true,
"class-name": true,
"one-line": [true, "check-catch", "check-finally", "check-else"],
"arrow-parens": [true, "ban-single-arg-parens"],
"indent": [true, "spaces", 4],
"one-variable-per-declaration": true,
"ban-comma-operator": true,
"function-constructor": true,
"semicolon": [true, "always", "ignore-bound-class-methods"],
"jsdoc-format": [true, "check-multiline-start"],
"no-irregular-whitespace": true,
"no-trailing-whitespace": [
true,
"ignore-comments",
"ignore-jsdoc",
"ignore-template-strings",
"ignore-blank-lines"
],
"triple-equals": true,
"prefer-template": [true, "allow-single-concat"],
"quotemark": [
true,
"single",
"jsx-double",
"avoid-template",
"avoid-escape"
]
},
"defaultSeverity": "warning"
}