Workaround for broken dynamic imports on Safari 17.2

This commit is contained in:
Foxster
2023-12-14 19:33:38 -08:00
parent 097ffb0dfe
commit e0116394d4
3 changed files with 73 additions and 60 deletions

View File

@@ -13,117 +13,127 @@ export const sourceURL = urlSearchParams.get('source')?.replaceAll("+", "%2B");
// https://stackoverflow.com/a/8943487 // https://stackoverflow.com/a/8943487
export const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; export const urlRegex = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
export const sources = [
"https://therealfoxster.github.io/altsource/apps.json",
"https://qnblackcat.github.io/AltStore/apps.json",
"https://quarksources.github.io/dist/quantumsource.min.json",
"https://quarksources.github.io/dist/quantumsource%2B%2B.min.json",
"https://alt.getutm.app",
"https://flyinghead.github.io/flycast-builds/altstore.json",
"https://provenance-emu.com/apps.json"
];
export const entitlements = { export const entitlements = {
"com.apple.security.application-groups": { "com.apple.security.application-groups": {
name: "App Groups", "name": "App Groups",
description: "Allow app to share files with other apps and app extensions in the same App Group.", "description": "Allow app to share files with other apps and app extensions in the same App Group.",
icon: "columns-gap" "icon": "columns-gap"
}, },
"com.apple.developer.associated-domains": { "com.apple.developer.associated-domains": {
name: "Associated Domains", "name": "Associated Domains",
description: "The associated domains for specific services, such as shared web credentials, universal links, and App Clips.", "description": "The associated domains for specific services, such as shared web credentials, universal links, and App Clips.",
icon: "globe2" "icon": "globe2"
}, },
"com.apple.developer.carplay-audio": { "com.apple.developer.carplay-audio": {
name: "CarPlay Audio", "name": "CarPlay Audio",
description: "Allows the app the provide audio content for CarPlay.", "description": "Allows the app the provide audio content for CarPlay.",
icon: "car-front-fill" "icon": "car-front-fill"
}, },
"get-task-allow": { "get-task-allow": {
name: "Debuggable", "name": "Debuggable",
description: "Allow developers to attach a debugger to this app. This permission is required for JIT to work.", "description": "Allow developers to attach a debugger to this app. This permission is required for JIT to work.",
icon: "tools" "icon": "tools"
}, },
"com.apple.developer.device-information.user-assigned-device-name": { "com.apple.developer.device-information.user-assigned-device-name": {
name: "Device Name", "name": "Device Name",
description: "Grants access to the user-assigned device name instead of a generic device name.", "description": "Grants access to the user-assigned device name instead of a generic device name.",
icon: "phone-fill" "icon": "phone-fill"
}, },
"keychain-access-groups": { "keychain-access-groups": {
name: "Keychain", "name": "Keychain",
description: "Allows app to read and write secure data to the system's keychain.", "description": "Allows app to read and write secure data to the system's keychain.",
icon: "key-fill" "icon": "key-fill"
}, },
"com.apple.developer.networking.multicast": { "com.apple.developer.networking.multicast": {
name: "Multicast", "name": "Multicast",
description: "App can send or receive IP multicast traffic.", "description": "App can send or receive IP multicast traffic.",
icon: "globe2" "icon": "globe2"
}, },
"aps-environment": { "aps-environment": {
name: "Push Notifications", "name": "Push Notifications",
description: "App can send push notifications.", "description": "App can send push notifications.",
icon: "app-indicator" "icon": "app-indicator"
}, },
"com.apple.developer.applesignin": { "com.apple.developer.applesignin": {
name: "Sign in with Apple", "name": "Sign in with Apple",
description: "Allows sign in with Apple.", "description": "Allows sign in with Apple.",
icon: "apple" "icon": "apple"
}, },
"com.apple.developer.siri": { "com.apple.developer.siri": {
name: "Siri", "name": "Siri",
description: "Allows app to handle Siri requests.", "description": "Allows app to handle Siri requests.",
icon: "mic-fill" "icon": "mic-fill"
}, },
"com.apple.developer.networking.wifi-info": { "com.apple.developer.networking.wifi-info": {
name: "Wi-Fi Information Access", "name": "Wi-Fi Information Access",
description: "Allows app to access information about the connected Wi-Fi network.", "description": "Allows app to access information about the connected Wi-Fi network.",
icon: "wifi" "icon": "wifi"
} }
}; };
export const privacy = { export const privacy = {
"AppleMusic": { "AppleMusic": {
icon: "music-note-beamed" "icon": "music-note-beamed"
}, },
"BluetoothAlways": { "BluetoothAlways": {
name: "Bluetooth", "name": "Bluetooth",
icon: "bluetooth" "icon": "bluetooth"
}, },
"BluetoothPeripheral": { "BluetoothPeripheral": {
name: "Bluetooth (Peripherals)", "name": "Bluetooth (Peripherals)",
icon: "bluetooth" "icon": "bluetooth"
}, },
"Contacts": { "Contacts": {
icon: "person-circle" "icon": "person-circle"
}, },
"Camera": { "Camera": {
icon: "camera-fill" "icon": "camera-fill"
}, },
"FaceID": { "FaceID": {
name: "Face ID", "name": "Face ID",
icon: "person-bounding-box" "icon": "person-bounding-box"
}, },
"LocalNetwork": { "LocalNetwork": {
icon: "globe2" "icon": "globe2"
}, },
"LocationWhenInUse": { "LocationWhenInUse": {
name: "Location (When Using)", "name": "Location (When Using)",
icon: "cursor-fill" "icon": "cursor-fill"
}, },
"Microphone": { "Microphone": {
icon: "mic-fill" "icon": "mic-fill"
}, },
"PhotoLibrary": { "PhotoLibrary": {
name: "Photos", "name": "Photos",
icon: "images" "icon": "images"
}, },
"PhotoLibraryAdd": { "PhotoLibraryAdd": {
name: "Photos (Add)", "name": "Photos (Add)",
icon: "image" "icon": "image"
}, },
"UserTracking": { "UserTracking": {
icon: "person-vcard-fill" "icon": "person-vcard-fill"
}, }
}; };
export const legacyPermissions = { export const legacyPermissions = {
"background-audio": { "background-audio": {
icon: "volume-up-fill" "icon": "volume-up-fill"
}, },
"background-fetch": { "background-fetch": {
icon: "arrow-repeat" "icon": "arrow-repeat"
}, },
"photos": { "photos": {
icon: "images" "icon": "images"
} }
}; };

View File

@@ -8,7 +8,9 @@
import { urlSearchParams, sourceURL } from "./common/modules/constants.js"; import { urlSearchParams, sourceURL } from "./common/modules/constants.js";
import { isValidHTTPURL, open } from "./common/modules/utilities.js"; import { isValidHTTPURL, open } from "./common/modules/utilities.js";
const { default: sources } = await import("./common/assets/sources.json", { assert: { type: "json" } }); // import sources from "./common/assets/sources.json" assert { type: "json" }; // Doesn't work in Safari
// const { default: sources } = await import("./common/assets/sources.json", {assert: { type: "json" } }); // Broken on Safari 17.2
import { sources } from "./common/modules/constants.js";
(function main() { (function main() {
for (const url of sources) for (const url of sources)

View File

@@ -10,12 +10,13 @@ import { urlSearchParams, sourceURL } from "../../common/modules/constants.js";
import { formatString, insertSpaceInCamelString, insertSpaceInSnakeString, formatVersionDate, open } from "../../common/modules/utilities.js"; import { formatString, insertSpaceInCamelString, insertSpaceInSnakeString, formatVersionDate, open } from "../../common/modules/utilities.js";
import { main } from "../../common/modules/main.js"; import { main } from "../../common/modules/main.js";
import { AppPermissionItem } from "../../common/components/AppPermissionItem.js"; import { AppPermissionItem } from "../../common/components/AppPermissionItem.js";
// import { privacy, entitlements, legacyPermissions } from "../../modules/constants.js"; import { privacy, entitlements, legacyPermissions } from "../../common/modules/constants.js";
// Dynamic imports (https://stackoverflow.com/a/76845572/19227228) // Dynamic imports (https://stackoverflow.com/a/76845572/19227228)
const { default: privacy } = await import("../../common/assets/privacy.json", { assert: { type: "json" } }) // Broken on Safari 17.2
const { default: entitlements } = await import("../../common/assets/entitlements.json", { assert: { type: "json" } }) // const { default: privacy } = await import("../../common/assets/privacy.json", { assert: { type: "json" } })
const { default: legacyPermissions } = await import("../../common/assets/legacy-permissions.json", { assert: { type: "json" } }) // const { default: entitlements } = await import("../../common/assets/entitlements.json", { assert: { type: "json" } })
// const { default: legacyPermissions } = await import("../../common/assets/legacy-permissions.json", { assert: { type: "json" } })
const fallbackURL = `../?source=${sourceURL}`; const fallbackURL = `../?source=${sourceURL}`;