-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1,443 changed files
with
41,454 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# common | ||
|
||
.*/ | ||
|
||
# generated | ||
|
||
**/build/* | ||
**/coverage/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@alicloud/eslint-config/tsx" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# common | ||
|
||
.*/ | ||
|
||
# generated | ||
|
||
**/archive/* | ||
**/dist/* | ||
**/es/* | ||
**/build/* | ||
**/coverage/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
tabWidth: 2, | ||
semi: false, | ||
singleQuote: true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'], | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
>0.2% | ||
not dead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.* | ||
!.*ignore | ||
node_modules/ | ||
src/ | ||
test/ | ||
babel.config.js | ||
*lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
registry=https://registry.npmjs.org/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.