-
Notifications
You must be signed in to change notification settings - Fork 172
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 🎸 support umd js bundle * 支持 umd 打包 * feat: 🎸 export load micro app * fix: 🐛 fix lint * feat: 🎸 support name
- Loading branch information
Showing
6 changed files
with
515 additions
and
14 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
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,26 @@ | ||
export interface PathData { | ||
value: string; | ||
exact?: boolean; | ||
strict?: boolean; | ||
sensitive?: boolean; | ||
} | ||
|
||
/** | ||
* util function to covert path to string | ||
* | ||
* @export | ||
* @param {(string | (string | PathData)[])} list | ||
* @returns | ||
*/ | ||
export function converArray2String(list: string | (string | PathData)[]) { | ||
if (Array.isArray(list)) { | ||
return list.map((item) => { | ||
if (Object.prototype.toString.call(item) === '[object Object]') { | ||
return Object.keys(item).map((key) => `${key}:${item[key]}`).join(','); | ||
} | ||
return item; | ||
}).join(','); | ||
} | ||
|
||
return String(list); | ||
} |
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 @@ | ||
import { getCache } from './cache'; | ||
|
||
export default function getMountNode(element?: any): any { | ||
if (getCache('root')) { | ||
return getCache('root'); | ||
} | ||
|
||
if (element) { | ||
// string treated as 'id' | ||
if (typeof element === 'string') { | ||
return document.querySelector(`#${element}`); | ||
} | ||
|
||
// function, return value | ||
if (typeof element === 'function') { | ||
return element(); | ||
} | ||
|
||
return element; | ||
} | ||
const ICE_CONTAINER = document.querySelector('#ice-container'); | ||
if (!ICE_CONTAINER) { | ||
throw new Error('Current page does not exist <div id="ice-container"></div> element.'); | ||
} | ||
|
||
return ICE_CONTAINER; | ||
} |
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,52 @@ | ||
// fork: https://github.com/systemjs/systemjs/blob/master/src/extras/global.js | ||
|
||
// safari unpredictably lists some new globals first or second in object order | ||
let firstGlobalProp; | ||
let secondGlobalProp; | ||
let lastGlobalProp; | ||
const isIE11 = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('Trident') !== -1; | ||
|
||
function shouldSkipProperty(p, globalWindow) { | ||
// eslint-disable-next-line no-prototype-builtins | ||
return !globalWindow.hasOwnProperty(p) | ||
|| !isNaN(p) && p < (globalWindow as any).length | ||
|| isIE11 && globalWindow[p] && typeof window !== 'undefined' && globalWindow[p].parent === window; | ||
} | ||
|
||
export function getGlobalProp (globalWindow) { | ||
let cnt = 0; | ||
let lastProp; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const p in globalWindow) { | ||
// do not check frames cause it could be removed during import | ||
if (shouldSkipProperty(p, globalWindow)) | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
if (cnt === 0 && p !== firstGlobalProp || cnt === 1 && p !== secondGlobalProp) | ||
return p; | ||
cnt++; | ||
lastProp = p; | ||
} | ||
if (lastProp !== lastGlobalProp) | ||
return lastProp; | ||
} | ||
|
||
export function noteGlobalProps (globalWindow) { | ||
// alternatively Object.keys(global).pop() | ||
// but this may be faster (pending benchmarks) | ||
firstGlobalProp = undefined; | ||
secondGlobalProp = undefined; | ||
// eslint-disable-next-line no-restricted-syntax | ||
for (const p in globalWindow) { | ||
// do not check frames cause it could be removed during import | ||
if (shouldSkipProperty(p, globalWindow)) | ||
// eslint-disable-next-line no-continue | ||
continue; | ||
if (!firstGlobalProp) | ||
firstGlobalProp = p; | ||
else if (!secondGlobalProp) | ||
secondGlobalProp = p; | ||
lastGlobalProp = p; | ||
} | ||
return lastGlobalProp; | ||
} |
Oops, something went wrong.