diff --git a/Contact.md b/Contact.md index 0fb92e33..ed898e50 100644 --- a/Contact.md +++ b/Contact.md @@ -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) + diff --git a/docs/zh-cn/changelog.md b/docs/zh-cn/changelog.md index a2914677..b33c0979 100644 --- a/docs/zh-cn/changelog.md +++ b/docs/zh-cn/changelog.md @@ -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` diff --git a/package.json b/package.json index 1eb93a05..fc096769 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/proxies/worker.ts b/src/proxies/worker.ts index 6152fffa..da30a736 100644 --- a/src/proxies/worker.ts +++ b/src/proxies/worker.ts @@ -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; @@ -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 && diff --git a/src/sandbox/scoped_css.ts b/src/sandbox/scoped_css.ts index 07612754..6856ded0 100644 --- a/src/sandbox/scoped_css.ts +++ b/src/sandbox/scoped_css.ts @@ -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 || ( @@ -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 }