Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
timhub66 committed Dec 9, 2024
2 parents 2a20f4e + da00cf7 commit 10a217a
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 11 deletions.
3 changes: 2 additions & 1 deletion Contact.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

欢迎小伙伴们加入micro-app微信群交流^ ^
![image](https://github.com/user-attachments/assets/ec331898-9222-48b9-9fd6-8a58bc9a9bf2)
![image](https://github.com/user-attachments/assets/bc2ed2a1-a5a5-4ad7-8a2f-0f3a58507490)




Expand Down
8 changes: 8 additions & 0 deletions docs/zh-cn/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@
- 修订版本号:每周末会进行日常 bugfix 更新。(如果有紧急的 bugfix,则任何时候都可发布)

---
### 1.0.0-rc.16

`2024-12-09`
- **Bug Fix**
- 🐞 修复 子应用 使用 blob string url 创建 WebWorker 时报错,[issue 1444](https://github.com/micro-zoe/micro-app/issues/1444)
- **Feature**
- 支持 unocss。

### 1.0.0-rc.15

`2024-11-22`
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.15",
"version": "1.0.0-rc.16",
"description": "A lightweight, efficient and powerful micro front-end framework",
"private": false,
"main": "lib/index.min.js",
Expand Down
16 changes: 9 additions & 7 deletions src/proxies/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ interface WorkerOptions {
credentials?: 'omit' | 'same-origin' | 'include';
}

const EXCLUDE_URL_PROTOCOLS = [
'blob:'
]

interface WorkerInstance extends EventTarget {
postMessage(message: any, transfer?: Transferable[]): void;
terminate(): void;
Expand All @@ -20,14 +24,12 @@ interface Worker {
const originalWorker = window.Worker

function isSameOrigin(url: string | URL): boolean {
if (url instanceof URL && url.protocol === 'blob:') {
// 如果 url 是 Blob URL,直接返回 true
return true
}

// 检查 URL 是否与当前页面在同一个源
try {
const parsedUrl = new URL(url as string)
// 检查 URL 是否与当前页面在同一个源
const parsedUrl = url instanceof URL ? url : new URL(url as string)
if (EXCLUDE_URL_PROTOCOLS.includes(parsedUrl.protocol)) {
return true
}
return (
parsedUrl.protocol === window.location.protocol &&
parsedUrl.hostname === window.location.hostname &&
Expand Down
17 changes: 15 additions & 2 deletions src/sandbox/scoped_css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,21 @@ class CSSParser {
* 6. :where(.a, .b, .c) a {}
* should be ==> micro-app[name=xxx] :where(.a, .b, .c) a {}
*/
return m[0].replace(/(^|,[\n\s]*)([^,]+)/g, (_, separator, selector) => {
const attributeValues: {[key: string]: any} = {}
const matchRes = m[0].replace(/\[([^=]+)=?(.+?)\]/g, (match, p1, p2) => {
const mock = `__mock_${p1}Value__`
attributeValues[mock] = p2
return match.replace(p2, mock)
})

return matchRes.replace(/(^|,[\n\s]*)([^,]+)/g, (_, separator, selector) => {
selector = trim(selector)
selector = selector.replace(/\[[^=]+=?(.+?)\]/g, (match:string, p1: string) => {
if (attributeValues[p1]) {
return match.replace(p1, attributeValues[p1])
}
return match
})
if (selector && !(
this.scopecssDisableNextLine ||
(
Expand Down Expand Up @@ -149,7 +162,7 @@ class CSSParser {
!this.scopecssDisableNextLine &&
(!this.scopecssDisable || this.scopecssDisableSelectors.length)
) {
cssValue = cssValue.replace(/url\(["']?([^)"']+)["']?\)/gm, (all, $1) => {
cssValue = cssValue.replace(/url\((["']?)(.*?)\1\)/gm, (all, _, $1) => {
if (/^((data|blob):|#|%23)/.test($1) || /^(https?:)?\/\//.test($1)) {
return all
}
Expand Down

0 comments on commit 10a217a

Please sign in to comment.