Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
zizi-2019 committed Sep 10, 2024
2 parents 1d38027 + 34d3517 commit cd25a4d
Show file tree
Hide file tree
Showing 16 changed files with 321 additions and 162 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,6 @@ module.exports = {
'comma-dangle': ['error', 'only-multiline'],
'no-eval': ['error', { allowIndirect: true }],
'no-new-func': 0,
'space-before-function-paren': 0,
}
}
13 changes: 1 addition & 12 deletions Contact.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,7 @@

欢迎小伙伴们加入micro-app微信群交流^ ^

![image](https://github.com/user-attachments/assets/35f37851-32e1-4751-aa80-2cfc28741988)











![IMG_0607](https://github.com/user-attachments/assets/a976245d-2d5e-460e-8bcb-421dbc31e494)



Expand Down
41 changes: 22 additions & 19 deletions dev/children/vite4/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,25 +380,28 @@ if (process.env.NODE_ENV !== 'production') {

/* ---------------------- 插件相关 --------------------- */
// vite环境下无法设置window指向proxyWindow,其值依然是iframeWindow,所以插件无法使用
// window.escapeKey1 = 'escapeKey1' // 无效,只定义在iframeWindow上
// window.escapeKey2 = 'escapeKey2' // 无效,只定义在iframeWindow上
// if (window.__MICRO_APP_ENVIRONMENT__) {
// window.__MICRO_APP_PROXY_WINDOW__.escapeKey3 = 'escapeKey3' // 逃逸到rawWindow上
// window.__MICRO_APP_PROXY_WINDOW__.escapeKey4 = 'escapeKey4' // 逃逸到rawWindow上
// }


// console.log('scopeProperties scopeKeySpe: ', scopeKeySpe)
// console.log('scopeProperties window.scopeKeySpe: ', window.scopeKeySpe)

// console.log('scopeProperties Vue: ', Vue)
// console.log('scopeProperties window.Vue: ', window.Vue)

// window.Vue = Vue ? Vue : 'child Vue'

// console.log('scopeProperties Vue: ', Vue)
// console.log('scopeProperties window.Vue: ', window.Vue)

if (window.__MICRO_APP_ENVIRONMENT__) {
// ----------------------- scope相关---------------------开始
console.assert(window['scopeKey-vite-1'] === undefined, `window['scopeKey-vite-1'] 在主应用上存在,但不会兜底到主应用查找`)
console.assert(('scopeKey-vite-1' in window) === false , 'scopeKey-vite-1 in window 应该为false')
// ----------------------- scope相关---------------------结束


// ----------------------- escape相关--------------------开始
console.assert(window['escapeKey-vite-1'] !== undefined, `window['escapeKey-vite-1'] 兜底到主应用,且在主应用存在`)
console.assert(window['escapeKey-vite-2'] === undefined, `window['escapeKey-vite-2'] 兜底到主应用,但主应用上不存在`)
console.assert(escapeKey1 !== undefined, `escapeKey1 由全局插件配置,兜底到主应用,且在主应用存在`)

window['escapeKey-vite-2'] = 'escapeKey-vite-2 from child'
console.assert(window.rawWindow['escapeKey-vite-2'] === undefined, `window['escapeKey-vite-2']=xxx的设置不会兜底到主应用上`)
console.assert(window['escapeKey-vite-func']() === window.rawWindow, `兜底函数的this指向原生window`)
// ----------------------- escape相关--------------------结束

console.assert(window.Vue === undefined, 'window.Vue 应该为false')
console.assert(('Vue' in window) === false, 'Vue in window 应该为false')
window.Vue = '子应用内部自定义Vue'
console.assert(window.Vue === '子应用内部自定义Vue', 'window.Vue 应该为子应用内部自定义Vue')
}

/* ---------------------- 特殊操作 --------------------- */
// window.document.domain = 'localhost';
11 changes: 11 additions & 0 deletions dev/main-react16/src/global.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ const prefetchConfig = [

// microApp.preFetch(prefetchConfig)

window['escapeKey1'] = 'escapeKey1 from base app by global plugin'
window['escapeKey3'] = 'escapeKey3 from base app'
window['scopeKey-vite-1'] = 'scopeKey-vite-1 from base app'
window['escapeKey-vite-1'] = 'escapeKey-vite-1 from base app'
window['escapeKey-vite-func'] = function () {
console.log('escapeKey-vite-func', this)
return this
}
window.Vue = { tip: 'Vue from base' }

microApp.start({
Expand Down Expand Up @@ -147,6 +154,10 @@ microApp.start({
vite2: [{
escapeProperties: ['escapeKey3', 'escapeKey4'],
}],
vite4: [{
scopeProperties: ['scopeKey-vite-1', 'scopeKey-vite-2'],
escapeProperties: ['escapeKey-vite-1', 'escapeKey-vite-2', 'escapeKey-vite-func'],
}],
}
},
/**
Expand Down
2 changes: 1 addition & 1 deletion dev/main-react16/src/pages/react16/react16.js
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ export default class App extends React.Component {
// fiber
// ssr
// clear-data
// iframe
iframe
>
</micro-app>
)
Expand Down
13 changes: 13 additions & 0 deletions docs/zh-cn/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

---

### 1.0.0-rc.9

`2024-9-10`

- **Feature**
- 支持 cesiumjs及其生态, [issue 1351](https://github.com/micro-zoe/micro-app/issues/1351)
- **Bug Fix**
- 🐞 修复 vite环境下iframe沙箱对于插件系统`escapeProperties`不支持的问题。
- 🐞 修复 iframe沙箱下jquery通过`$('body').append`创建元素逃逸的问题,[issue 1339](https://github.com/micro-zoe/micro-app/issues/1339)
- 🐞 修复 iframe沙箱部分场景下执行`instanceOf`导致死循环的问题,[issue 1341](https://github.com/micro-zoe/micro-app/issues/1341)
- 🐞 修复 子应用css样式缺少闭合标签导致解析失败的问题,[issue 1342](https://github.com/micro-zoe/micro-app/issues/1342)


### 1.0.0-rc.8

`2024-8-20`
Expand Down
20 changes: 16 additions & 4 deletions docs/zh-cn/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ microApp.start({
plugins: {
// 全局插件,作用于所有子应用的js文件
global?: Array<{
// 可选,强隔离的全局变量(默认情况下子应用无法找到的全局变量会兜底到主应用中,scopeProperties可以禁止这种情况)
/**
* 可选,强隔离的全局变量(with沙箱才会生效)
* 默认情况下with沙箱子应用无法找到的全局变量会兜底到主应用中查找,设置scopeProperties后,全局变量只会在子应用内部查找,阻止兜底查找操作
*/
scopeProperties?: string[],
// 可选,可以逃逸到外部的全局变量(escapeProperties中的变量会同时赋值到子应用和外部真实的window上)
/**
* 可选,可以逃逸的全局变量
* 默认情况下iframe沙箱子应用的全局变量只会在内部查找,不会兜底到主应用查找,设置escapeProperties后,无法查找的全局变量会兜底到主应用查找。
*/
escapeProperties?: string[],
// 可选,如果函数返回 `true` 则忽略 script 和 link 标签的创建
excludeChecker?: (url: string) => boolean
Expand All @@ -33,9 +39,15 @@ microApp.start({
modules?: {
// appName为应用的名称,这些插件只会作用于指定的应用
[appName: string]: Array<{
// 可选,强隔离的全局变量(默认情况下子应用无法找到的全局变量会兜底到主应用中,scopeProperties可以禁止这种情况)
/**
* 可选,强隔离的全局变量(with沙箱才会生效)
* 默认情况下with沙箱子应用无法找到的全局变量会兜底到主应用中查找,设置scopeProperties后,全局变量只会在子应用内部查找,阻止兜底查找操作
*/
scopeProperties?: string[],
// 可选,可以逃逸到外部的全局变量(escapeProperties中的变量会同时赋值到子应用和外部真实的window上)
/**
* 可选,可以逃逸的全局变量
* 默认情况下iframe沙箱子应用的全局变量只会在内部查找,不会兜底到主应用查找,设置escapeProperties后,无法查找的全局变量会兜底到主应用查找。
*/
escapeProperties?: string[],
// 可选,如果函数返回 `true` 则忽略 script 和 link 标签的创建
excludeChecker?: (url: string) => boolean
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@micro-zoe/micro-app",
"version": "1.0.0-rc.8",
"version": "1.0.0-rc.9",
"description": "A lightweight, efficient and powerful micro front-end framework",
"private": false,
"main": "lib/index.min.js",
Expand Down
1 change: 1 addition & 0 deletions src/libs/global_env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
import {
updateElementInfo,
} from '../sandbox/adapter'
import '../proxies/worker'

declare global {
interface Node {
Expand Down
Loading

0 comments on commit cd25a4d

Please sign in to comment.