-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚡ Optimize package size: Avoid bundling chrome-driver and chrome-head…
…less-shell (#1698)
- Loading branch information
1 parent
3c8079e
commit 09aaa82
Showing
32 changed files
with
936 additions
and
431 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
const fs = require('fs'); | ||
const axios = require('axios'); | ||
|
||
function convertUrl(url) { | ||
const match = url.match(/\/(\d+\.\d+\.\d+\.\d+)\/(.+)\/(.+\.zip)/); | ||
if (match) { | ||
const [, version, platform, filename] = match; | ||
return `https://cdn.npmmirror.com/binaries/chrome-for-testing/${version}/${platform}/${filename}`; | ||
} | ||
return url; | ||
} | ||
|
||
function processJson(inputJson) { | ||
const processedJson = JSON.parse(JSON.stringify(inputJson)); | ||
|
||
processedJson.versions.forEach(version => { | ||
if (version.downloads && version.downloads.chromedriver) { | ||
version.downloads.chromedriver.forEach(item => { | ||
item.url = convertUrl(item.url); | ||
}); | ||
} | ||
if (version.downloads) { | ||
version.downloads = { chromedriver: version.downloads.chromedriver || [] }; | ||
} | ||
}); | ||
|
||
return processedJson; | ||
} | ||
|
||
async function fetchAndProcessJson() { | ||
const url = "https://raw.githubusercontent.com/GoogleChromeLabs/chrome-for-testing/main/data/known-good-versions-with-downloads.json"; | ||
|
||
try { | ||
console.log(`Fetching JSON from: ${url}`); | ||
const response = await axios.get(url, { timeout: 10000 }); | ||
console.log(`Status Code: ${response.status}`); | ||
|
||
const inputJson = response.data; | ||
const processedJson = processJson(inputJson); | ||
|
||
fs.writeFileSync('known-good-versions-with-downloads.json', JSON.stringify(processedJson, null, 2)); | ||
console.log("JSON processing complete. Output saved to known-good-versions-with-downloads.json"); | ||
} catch (error) { | ||
if (error.response) { | ||
// The request was made and the server responded with a status code that falls out of the range of 2xx | ||
console.error(`HTTP error! status: ${error.response.status}`); | ||
} else if (error.request) { | ||
// The request was made but no response was received | ||
console.error('No response received:', error.message); | ||
} else { | ||
// Something happened in setting up the request that triggered an Error | ||
console.error('Error:', error.message); | ||
} | ||
throw error; | ||
} | ||
} | ||
|
||
// If the script is run directly, execute the processing | ||
if (require.main === module) { | ||
fetchAndProcessJson().catch(error => { | ||
console.error("Script failed:", error); | ||
process.exit(1); | ||
}); | ||
} | ||
|
||
module.exports = { processJson, fetchAndProcessJson }; |
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
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 |
---|---|---|
|
@@ -5,6 +5,7 @@ enum class AppFileType { | |
USER, | ||
LOG, | ||
ENCRYPT, | ||
MODULE, | ||
DATA, | ||
HTML, | ||
ICON, // use for app icon | ||
|
4 changes: 3 additions & 1 deletion
4
...lin/com/crosspaste/paste/ChromeService.kt → ...tlin/com/crosspaste/html/ChromeService.kt
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
12 changes: 4 additions & 8 deletions
12
composeApp/src/commonMain/kotlin/com/crosspaste/image/ImageLoader.kt
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
Oops, something went wrong.