Skip to content

Commit

Permalink
Merge branch 'lerna/pub'
Browse files Browse the repository at this point in the history
  • Loading branch information
justnewbee committed Dec 2, 2020
2 parents 51b5586 + 37bcac8 commit f4d2f2e
Show file tree
Hide file tree
Showing 1,443 changed files with 41,454 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# common

.*/

# generated

**/build/*
**/coverage/*
3 changes: 3 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "@alicloud/eslint-config/tsx"
}
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# common
.*
!.*ignore
!.*rc
!.*rc.*
*.log*

# dev

**/node_modules

# generated

**/*.lock
**/build/
**/coverage/
**/*-lock.json
7 changes: 7 additions & 0 deletions .ncurc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
upgrade: true
dep: dev,prod
reject:
- 'react' # 暂时不要 17...
- 'react-dom' # 暂时不要 17...
- '@types/react' # 暂时不要 17...
- '@types/react-dom' # 暂时不要 17...
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
ConsoleBase
===

> ConsoleBase === 阿里云控制台的基座
<a href="https://www.alibabacloud.com">
<img src="https://aliyunsdk-pages.alicdn.com/icons/AlibabaCloud.svg" alt="Alibaba Cloud" />
</a>

此为 mono-repo
11 changes: 11 additions & 0 deletions __legacy-of-widget/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# common

.*/

# generated

**/archive/*
**/dist/*
**/es/*
**/build/*
**/coverage/*
27 changes: 27 additions & 0 deletions __legacy-of-widget/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = {
env: {
browser: true,
es6: true,
jest: true,
node: true,
},
extends: ['eslint:recommended', 'plugin:react/recommended', 'prettier'],
plugins: ['react-hooks', 'prettier'],
parserOptions: {
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
settings: {
react: {
version: '16.x',
},
},
rules: {
'react-hooks/rules-of-hooks': 'error', // Checks rules of Hooks
'react-hooks/exhaustive-deps': 'warn', // Checks effect dependencies
'prettier/prettier': 'error',
},
}
24 changes: 24 additions & 0 deletions __legacy-of-widget/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# common

.*
!.*ignore
!.*rc
!.*rc.js

# dev

node_modules/
packages/*/node_modules/
packages/*/lib/

# generated
*.tgz*
*.log*
build/
dist/
coverage/

# misc

*.cache
/.eslintcache
1 change: 1 addition & 0 deletions __legacy-of-widget/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
5 changes: 5 additions & 0 deletions __legacy-of-widget/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
tabWidth: 2,
semi: false,
singleQuote: true,
}
21 changes: 21 additions & 0 deletions __legacy-of-widget/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2019 Alibaba Cloud

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
10 changes: 10 additions & 0 deletions __legacy-of-widget/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# alibabacloud-console-widget

A lightweight approach to achieve micro frontends. It's dead simple!

## Development

1. Jest, eslint and their related packages are installed in the root directory.
2. Npm scripts like `npm test` and `npm run lint` can be found in root's package.json.
3. All packages should be transpiled by babel before publication.
4. A shell script `init-package.sh` can be used to initialize a package, run `npm run add-package`, it will setup a basic configuration for you.
35 changes: 35 additions & 0 deletions __legacy-of-widget/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
presets: [
[
'@babel/preset-env',
{
modules: false,
},
],
],
plugins: [
[
'@babel/plugin-transform-runtime',
{
// Since Webpack know how to deal with the ES6 modules,
// we don't transform it.
useESModules: true,
},
],
],
env: {
test: {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
],
plugins: ['@babel/plugin-transform-modules-commonjs'],
},
},
}
2 changes: 2 additions & 0 deletions __legacy-of-widget/browsing-context/.browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>0.2%
not dead
7 changes: 7 additions & 0 deletions __legacy-of-widget/browsing-context/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.*
!.*ignore
node_modules/
src/
test/
babel.config.js
*lock.json
1 change: 1 addition & 0 deletions __legacy-of-widget/browsing-context/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
registry=https://registry.npmjs.org/
5 changes: 5 additions & 0 deletions __legacy-of-widget/browsing-context/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
Empty file.
8 changes: 8 additions & 0 deletions __legacy-of-widget/browsing-context/opts.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "id for the iframe element",
"dangerouslyPermittedAccess": [],
"rootClassName": "class name for the root element",
"rootId": "id for the dom root element",
"body": "root element",
"logLevel": "none or verbose"
}
27 changes: 27 additions & 0 deletions __legacy-of-widget/browsing-context/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "@alicloud/browsing-context",
"version": "0.1.1",
"description": "",
"main": "lib/index.js",
"directories": {
"test": "test"
},
"scripts": {
"compile": "babel src -d lib --root-mode upward",
"prepare": "npm run compile"
},
"author": "woota<[email protected]>",
"license": "MIT",
"devDependencies": {
"@babel/cli": "^7.10.4",
"@babel/core": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.10.4",
"@babel/preset-env": "^7.10.4"
},
"dependencies": {
"@babel/runtime": "^7.10.4"
},
"publishConfig": {
"access": "public"
}
}
121 changes: 121 additions & 0 deletions __legacy-of-widget/browsing-context/src/Context.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
import Window from './Window'
import Document from './Document'
import Location from './Location'
import History from './History'
import hijackElement from './hijackElement'
import injectStyle from './utils/injectStyle'

/**
* Context class
* It uses iframe to create nesting browsing contexts under the top one
*/
class Context {
constructor(opts, frame) {
this.accessRecords = []

// hack frame.contentWindow.Element.prototype
// Since different browsing context have total different globals,
// so it won't have any global influences to the top context.
hijackElement(opts, frame.contentWindow.Element, this)

// proxy globals
this.window = new Window(opts, this, frame)
this.document = new Document(opts, this, frame)
this.location = new Location(opts, this, frame)
this.history = new History(opts, this, frame)
this.self = this.window

// expose the underlying iframe element
this.frame = frame

// expose a style injection util
this.injectStyleToHostDocument = (cssText) => injectStyle(cssText, opts)
}

remove() {
this.document.removeEventListeners()

if (this.frame) {
if (this.frame.parentNode) {
this.frame.parentNode.removeChild(this.frame)
}
}
}

addAccessRecord(record) {
this.accessRecords = [
...this.accessRecords,
{
...record,
time: Date.now(),
},
]
}

addGetRecord(record) {
this.addAccessRecord({
type: 'get',
...record,
})
}

addSetRecord(record) {
this.addAccessRecord({
type: 'set',
...record,
})
}

getAccessRecords() {
return this.accessRecords
}

getWindowAccessRecords() {
return this.accessRecords.filter((r) => r.targetName === 'window')
}

getDocumentAccessRecords() {
return this.accessRecords.filter((r) => r.targetName === 'document')
}

getLocationAccessRecords() {
return this.accessRecords.filter((r) => r.targetName === 'location')
}

getHistoryAccessRecords() {
return this.accessRecords.filter((r) => r.targetName === 'history')
}

getReadAccessRecords() {
return this.accessRecords.filter((r) => r.type === 'get')
}

getWriteAccessRecords() {
return this.accessRecords.filter((r) => r.type === 'set')
}

getDangerousAccessRecords() {
return this.accessRecords.filter((r) => r.danger === true)
}

static create(opts) {
const iframe = document.createElement('iframe')
// use "about:blank" may trigger cross origin problems
iframe.src = 'about:blank'
iframe.style.cssText = 'display:none'

if (opts.id) {
iframe.id = opts.id
}

document.appendChild(iframe)

return new this(opts, iframe)
}

static remove(ctx) {
ctx.remove && ctx.remove()
}
}

export default Context
Loading

0 comments on commit f4d2f2e

Please sign in to comment.