Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgv authored Nov 10, 2023
2 parents 1d38d10 + 8dc9191 commit c23a077
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 8 deletions.
3 changes: 2 additions & 1 deletion api/messaging/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
],
"repository": {
"type": "git",
"url": "https://github.com/PlasmoHQ/plasmo.git"
"url": "https://github.com/PlasmoHQ/plasmo.git",
"directory": "api/messaging"
},
"license": "MIT",
"keywords": [
Expand Down
6 changes: 5 additions & 1 deletion api/messaging/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ export const sendToBackground: PlasmoMessaging.SendFx<MessageName> = async (
*/
export const sendToContentScript: PlasmoMessaging.SendFx = async (req) => {
const tabId =
typeof req.tabId === "number" ? req.tabId : (await getActiveTab()).id
typeof req.tabId === "number" ? req.tabId : (await getActiveTab())?.id

if (!tabId) {
throw new Error("No active tab found to send message to.")
}

return getExtTabs().sendMessage(tabId, req)
}
Expand Down
2 changes: 1 addition & 1 deletion api/messaging/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const getActiveTab = async () => {
active: true,
currentWindow: true
})
return tab
return tab as chrome.tabs.Tab | undefined
}

export const isSameOrigin = (
Expand Down
3 changes: 2 additions & 1 deletion api/persistent/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
],
"repository": {
"type": "git",
"url": "https://github.com/PlasmoHQ/plasmo.git"
"url": "https://github.com/PlasmoHQ/plasmo.git",
"directory": "api/persistent"
},
"license": "MIT",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion api/selector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
],
"repository": {
"type": "git",
"url": "https://github.com/PlasmoHQ/plasmo.git"
"url": "https://github.com/PlasmoHQ/plasmo.git",
"directory": "api/selector"
},
"license": "MIT",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion cli/create-plasmo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
"homepage": "https://docs.plasmo.com/",
"repository": {
"type": "git",
"url": "https://github.com/PlasmoHQ/plasmo.git"
"url": "https://github.com/PlasmoHQ/plasmo.git",
"directory": "cli/create-plasmo"
},
"license": "MIT",
"keywords": [
Expand Down
3 changes: 2 additions & 1 deletion cli/plasmo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
"homepage": "https://docs.plasmo.com/",
"repository": {
"type": "git",
"url": "https://github.com/PlasmoHQ/plasmo.git"
"url": "https://github.com/PlasmoHQ/plasmo.git",
"directory": "cli/plasmo"
},
"license": "MIT",
"keywords": [
Expand Down
9 changes: 8 additions & 1 deletion core/parcel-runtime/src/utils/loading-indicator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

const LOADING_ID = "__plasmo-loading__"

const trustedPolicy = typeof trustedTypes !== "undefined"
? trustedTypes
.createPolicy(`trusted-html-${LOADING_ID}`, { createHTML: str => str })
: undefined

function getLoader() {
return document.getElementById(LOADING_ID)
}
Expand All @@ -22,7 +27,7 @@ function createLoader() {
const loadingEl = document.createElement("div")
loadingEl.id = LOADING_ID

loadingEl.innerHTML = `
const htmlText = `
<style>
#${LOADING_ID} {
background: #f3f3f3;
Expand Down Expand Up @@ -72,6 +77,8 @@ function createLoader() {
<span class="hidden">Context Invalidated, Press to Reload</span>
`

loadingEl.innerHTML = trustedPolicy ? trustedPolicy.createHTML(htmlText) : htmlText

loadingEl.style.pointerEvents = "none"

loadingEl.style.position = "fixed"
Expand Down

0 comments on commit c23a077

Please sign in to comment.