-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@lexical/devtools): Added full Safari support
- Loading branch information
Showing
34 changed files
with
1,214 additions
and
44 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
xcuserdata/ | ||
*.xcworkspace | ||
build/ | ||
fastlane/report.xml | ||
fastlane/Preview.html | ||
fastlane/screenshots/**/*.png | ||
fastlane/test_output |
13 changes: 13 additions & 0 deletions
13
...evtools/safari-xcode/Lexical Developer Tools/Lexical Developer Tools Extension/Info.plist
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,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>NSExtension</key> | ||
<dict> | ||
<key>NSExtensionPointIdentifier</key> | ||
<string>com.apple.Safari.web-extension</string> | ||
<key>NSExtensionPrincipalClass</key> | ||
<string>$(PRODUCT_MODULE_NAME).SafariWebExtensionHandler</string> | ||
</dict> | ||
</dict> | ||
</plist> |
10 changes: 10 additions & 0 deletions
10
...er Tools/Lexical Developer Tools Extension/Lexical_Developer_Tools_Extension.entitlements
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,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>com.apple.security.app-sandbox</key> | ||
<true/> | ||
<key>com.apple.security.files.user-selected.read-only</key> | ||
<true/> | ||
</dict> | ||
</plist> |
38 changes: 38 additions & 0 deletions
38
...Lexical Developer Tools/Lexical Developer Tools Extension/SafariWebExtensionHandler.swift
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,38 @@ | ||
// | ||
// SafariWebExtensionHandler.swift | ||
// Lexical Developer Tools Extension | ||
// | ||
// Created by Vladlen Fedosov on 5/14/24. | ||
// | ||
|
||
import SafariServices | ||
import os.log | ||
|
||
class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling { | ||
|
||
func beginRequest(with context: NSExtensionContext) { | ||
let request = context.inputItems.first as? NSExtensionItem | ||
|
||
let profile: UUID? | ||
if #available(iOS 17.0, macOS 14.0, *) { | ||
profile = request?.userInfo?[SFExtensionProfileKey] as? UUID | ||
} else { | ||
profile = request?.userInfo?["profile"] as? UUID | ||
} | ||
|
||
let message: Any? | ||
if #available(iOS 17.0, macOS 14.0, *) { | ||
message = request?.userInfo?[SFExtensionMessageKey] | ||
} else { | ||
message = request?.userInfo?["message"] | ||
} | ||
|
||
os_log(.default, "Received message from browser.runtime.sendNativeMessage: %@ (profile: %@)", String(describing: message), profile?.uuidString ?? "none") | ||
|
||
let response = NSExtensionItem() | ||
response.userInfo = [ SFExtensionMessageKey: [ "echo": message ] ] | ||
|
||
context.completeRequest(returningItems: [ response ], completionHandler: nil) | ||
} | ||
|
||
} |
Oops, something went wrong.