mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-07 01:53:45 +00:00
Compare commits
2 Commits
06-18-feat
...
lakr/affin
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
486e047b6d | ||
|
|
a7db5c5027 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1669,7 +1669,7 @@ dependencies = [
|
||||
"js-sys",
|
||||
"log",
|
||||
"wasm-bindgen",
|
||||
"windows-core 0.57.0",
|
||||
"windows-core 0.58.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
"kind" : "remoteSourceControl",
|
||||
"location" : "https://github.com/apollographql/apollo-ios.git",
|
||||
"state" : {
|
||||
"revision" : "4d0845f9f2901ed657d680c874ffc68d12704cd4",
|
||||
"version" : "1.19.0"
|
||||
"revision" : "9aa748d6f0526a744d49d59a2383dc7fdf9d645b",
|
||||
"version" : "1.18.0"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
@@ -17,6 +17,27 @@ extension AFFiNEViewController: IntelligentsButtonDelegate, IntelligentsFocusApe
|
||||
}
|
||||
|
||||
button.beginProgress()
|
||||
|
||||
// associate current view controller to callbacks
|
||||
Intelligents.Delegates.createNewDocument = { title, content in
|
||||
print("[*] creating new document \(title) \(content)")
|
||||
webView.evaluateScript(
|
||||
.createNewDocument,
|
||||
arguments: [content, title]
|
||||
) { _ in }
|
||||
}
|
||||
Intelligents.Delegates.dismissAll = { [weak self] in
|
||||
guard let self else { return }
|
||||
if self.presentedViewController != nil {
|
||||
self.dismiss(animated: true)
|
||||
}
|
||||
if let focusView = self.focusView {
|
||||
focusView.executeAnimationDismiss() {
|
||||
focusView.removeFromSuperview()
|
||||
}
|
||||
}
|
||||
self.focusView = nil
|
||||
}
|
||||
|
||||
let group = DispatchGroup()
|
||||
|
||||
@@ -67,6 +88,7 @@ extension AFFiNEViewController: IntelligentsButtonDelegate, IntelligentsFocusApe
|
||||
webView?.scrollView.contentOffset = contentOffset
|
||||
}
|
||||
let focus = IntelligentsFocusApertureView()
|
||||
self.focusView = focus
|
||||
focus.prepareAnimationWith(
|
||||
capturingTargetContentView: webView ?? .init(),
|
||||
coveringRootViewController: self
|
||||
|
||||
@@ -2,6 +2,7 @@ import Capacitor
|
||||
import Intelligents
|
||||
import UIKit
|
||||
|
||||
@objc(AFFiNEViewController)
|
||||
class AFFiNEViewController: CAPBridgeViewController {
|
||||
var baseUrl: String? {
|
||||
didSet { Intelligents.setUpstreamEndpoint(baseUrl ?? "") }
|
||||
@@ -9,6 +10,7 @@ class AFFiNEViewController: CAPBridgeViewController {
|
||||
var documentID: String?
|
||||
var workspaceID: String?
|
||||
var documentContent: String?
|
||||
var focusView: IntelligentsFocusApertureView?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
@@ -6,7 +6,6 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||
var window: UIWindow?
|
||||
|
||||
func application(_: UIApplication, didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
|
||||
// Override point for customization after application launch.
|
||||
true
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,11 @@ import Foundation
|
||||
import WebKit
|
||||
|
||||
enum ApplicationBridgedWindowScript: String {
|
||||
case getCurrentDocContentInMarkdown = "return await window.getCurrentDocContentInMarkdown();"
|
||||
case getCurrentServerBaseUrl = "window.getCurrentServerBaseUrl()"
|
||||
case getCurrentWorkspaceId = "window.getCurrentWorkspaceId();"
|
||||
case getCurrentDocId = "window.getCurrentDocId();"
|
||||
case getCurrentDocContentInMarkdown = ###"return await window.getCurrentDocContentInMarkdown();"###
|
||||
case getCurrentServerBaseUrl = ###"window.getCurrentServerBaseUrl()"###
|
||||
case getCurrentWorkspaceId = ###"window.getCurrentWorkspaceId();"###
|
||||
case getCurrentDocId = ###"window.getCurrentDocId();"###
|
||||
case createNewDocument = ###"window.createNewDocByMarkdownInCurrentWorkspace($ARG_1$, $ARG_2$)"###
|
||||
|
||||
var requiresAsyncContext: Bool {
|
||||
switch self {
|
||||
@@ -23,10 +24,24 @@ enum ApplicationBridgedWindowScript: String {
|
||||
}
|
||||
|
||||
extension WKWebView {
|
||||
func evaluateScript(_ script: ApplicationBridgedWindowScript, callback: @escaping (Any?) -> ()) {
|
||||
func evaluateScript(_ script: ApplicationBridgedWindowScript, arguments: [String] = [], callback: @escaping (Any?) -> ()) {
|
||||
let escapedArguments = arguments.map { arg in
|
||||
let encoded = arg.data(using: .utf8)?.base64EncodedString() ?? ""
|
||||
return "atob('\(encoded)')"
|
||||
}
|
||||
var sourceCode = script.rawValue
|
||||
for (idx, argument) in escapedArguments.enumerated() {
|
||||
sourceCode = sourceCode.replacingOccurrences(
|
||||
of: "$ARG_\(idx + 1)$",
|
||||
with: argument
|
||||
)
|
||||
}
|
||||
#if DEBUG
|
||||
print("[*] evaluating script: \(sourceCode)")
|
||||
#endif
|
||||
if script.requiresAsyncContext {
|
||||
callAsyncJavaScript(
|
||||
script.rawValue,
|
||||
sourceCode,
|
||||
arguments: [:],
|
||||
in: nil,
|
||||
in: .page
|
||||
@@ -39,7 +54,9 @@ extension WKWebView {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
evaluateJavaScript(script.rawValue) { output, _ in callback(output) }
|
||||
evaluateJavaScript(sourceCode) { output, _ in
|
||||
callback(output)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
@_exported import ApolloAPI
|
||||
|
||||
public class RetryAudioTranscriptionMutation: GraphQLMutation {
|
||||
public static let operationName: String = "retryAudioTranscription"
|
||||
public static let operationDocument: ApolloAPI.OperationDocument = .init(
|
||||
definition: .init(
|
||||
#"mutation retryAudioTranscription($workspaceId: String!, $jobId: String!) { retryAudioTranscription(workspaceId: $workspaceId, jobId: $jobId) { __typename id status } }"#
|
||||
))
|
||||
|
||||
public var workspaceId: String
|
||||
public var jobId: String
|
||||
|
||||
public init(
|
||||
workspaceId: String,
|
||||
jobId: String
|
||||
) {
|
||||
self.workspaceId = workspaceId
|
||||
self.jobId = jobId
|
||||
}
|
||||
|
||||
public var __variables: Variables? { [
|
||||
"workspaceId": workspaceId,
|
||||
"jobId": jobId
|
||||
] }
|
||||
|
||||
public struct Data: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.Mutation }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("retryAudioTranscription", RetryAudioTranscription?.self, arguments: [
|
||||
"workspaceId": .variable("workspaceId"),
|
||||
"jobId": .variable("jobId")
|
||||
]),
|
||||
] }
|
||||
|
||||
public var retryAudioTranscription: RetryAudioTranscription? { __data["retryAudioTranscription"] }
|
||||
|
||||
/// RetryAudioTranscription
|
||||
///
|
||||
/// Parent Type: `TranscriptionResultType`
|
||||
public struct RetryAudioTranscription: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.TranscriptionResultType }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("__typename", String.self),
|
||||
.field("id", AffineGraphQL.ID.self),
|
||||
.field("status", GraphQLEnum<AffineGraphQL.AiJobStatus>.self),
|
||||
] }
|
||||
|
||||
public var id: AffineGraphQL.ID { __data["id"] }
|
||||
public var status: GraphQLEnum<AffineGraphQL.AiJobStatus> { __data["status"] }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// @generated
|
||||
// This file was automatically generated and should not be edited.
|
||||
|
||||
@_exported import ApolloAPI
|
||||
|
||||
public class SendTestEmailMutation: GraphQLMutation {
|
||||
public static let operationName: String = "sendTestEmail"
|
||||
public static let operationDocument: ApolloAPI.OperationDocument = .init(
|
||||
definition: .init(
|
||||
#"mutation sendTestEmail($host: String!, $port: Int!, $sender: String!, $username: String!, $password: String!, $ignoreTLS: Boolean!) { sendTestEmail( config: { host: $host port: $port sender: $sender username: $username password: $password ignoreTLS: $ignoreTLS } ) }"#
|
||||
))
|
||||
|
||||
public var host: String
|
||||
public var port: Int
|
||||
public var sender: String
|
||||
public var username: String
|
||||
public var password: String
|
||||
public var ignoreTLS: Bool
|
||||
|
||||
public init(
|
||||
host: String,
|
||||
port: Int,
|
||||
sender: String,
|
||||
username: String,
|
||||
password: String,
|
||||
ignoreTLS: Bool
|
||||
) {
|
||||
self.host = host
|
||||
self.port = port
|
||||
self.sender = sender
|
||||
self.username = username
|
||||
self.password = password
|
||||
self.ignoreTLS = ignoreTLS
|
||||
}
|
||||
|
||||
public var __variables: Variables? { [
|
||||
"host": host,
|
||||
"port": port,
|
||||
"sender": sender,
|
||||
"username": username,
|
||||
"password": password,
|
||||
"ignoreTLS": ignoreTLS
|
||||
] }
|
||||
|
||||
public struct Data: AffineGraphQL.SelectionSet {
|
||||
public let __data: DataDict
|
||||
public init(_dataDict: DataDict) { __data = _dataDict }
|
||||
|
||||
public static var __parentType: any ApolloAPI.ParentType { AffineGraphQL.Objects.Mutation }
|
||||
public static var __selections: [ApolloAPI.Selection] { [
|
||||
.field("sendTestEmail", Bool.self, arguments: ["config": [
|
||||
"host": .variable("host"),
|
||||
"port": .variable("port"),
|
||||
"sender": .variable("sender"),
|
||||
"username": .variable("username"),
|
||||
"password": .variable("password"),
|
||||
"ignoreTLS": .variable("ignoreTLS")
|
||||
]]),
|
||||
] }
|
||||
|
||||
public var sendTestEmail: Bool { __data["sendTestEmail"] }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//
|
||||
// File.swift
|
||||
// Intelligents
|
||||
//
|
||||
// Created by 秋星桥 on 4/4/25.
|
||||
//
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public extension Intelligents {
|
||||
enum Delegates {
|
||||
public static var createNewDocument: ((_ title: String, _ content: String) -> Void) = { _, _ in }
|
||||
public static var dismissAll: (() -> Void) = { }
|
||||
}
|
||||
}
|
||||
@@ -131,6 +131,10 @@ public class IntelligentsEphemeralActionController: UIViewController {
|
||||
guard let self else { return }
|
||||
continueToChat()
|
||||
}
|
||||
actionBar.createNewDoc.action = { [weak self] in
|
||||
guard let self else { return }
|
||||
createNewDoc()
|
||||
}
|
||||
}
|
||||
|
||||
func setupContentViews() {
|
||||
@@ -294,4 +298,10 @@ extension IntelligentsEphemeralActionController {
|
||||
chatController.metadata[.content] = documentContent
|
||||
navigationController?.pushViewController(chatController, animated: true)
|
||||
}
|
||||
|
||||
func createNewDoc() {
|
||||
let content = copilotDocumentStorage
|
||||
Intelligents.Delegates.createNewDocument("New Document", content)
|
||||
Intelligents.Delegates.dismissAll()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,12 @@ EXTERNAL SOURCES:
|
||||
:path: "../../../../../node_modules/@capacitor/keyboard"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Capacitor: 106e7a4205f4618d582b886a975657c61179138d
|
||||
CapacitorApp: d63334c052278caf5d81585d80b21905c6f93f39
|
||||
CapacitorBrowser: 081852cf532acf77b9d2953f3a88fe5b9711fb06
|
||||
Capacitor: 03bc7cbdde6a629a8b910a9d7d78c3cc7ed09ea7
|
||||
CapacitorApp: febecbb9582cb353aed037e18ec765141f880fe9
|
||||
CapacitorBrowser: 6299776d496e968505464884d565992faa20444a
|
||||
CapacitorCordova: 5967b9ba03915ef1d585469d6e31f31dc49be96f
|
||||
CapacitorHaptics: 70e47470fa1a6bd6338cd102552e3846b7f9a1b3
|
||||
CapacitorKeyboard: 969647d0ca2e5c737d7300088e2517aa832434e2
|
||||
CapacitorHaptics: 1f1e17041f435d8ead9ff2a34edd592c6aa6a8d6
|
||||
CapacitorKeyboard: 09fd91dcde4f8a37313e7f11bde553ad1ed52036
|
||||
CryptoSwift: 967f37cea5a3294d9cce358f78861652155be483
|
||||
|
||||
PODFILE CHECKSUM: bd61c17ff51f31ae55ec8dc579da83fda7bb51cb
|
||||
|
||||
@@ -11,7 +11,7 @@ console.log('[*] PackageRoot', PackageRoot);
|
||||
|
||||
console.log('[*] graphql...');
|
||||
execSync(
|
||||
`${PackageRoot}/App/Packages/AffineGraphQL/apollo-ios-cli generate --path ${PackageRoot}/apollo-codegen-config.json`,
|
||||
`${PackageRoot}/App/Packages/AffineGraphQL/apollo-ios-cli generate --path ${PackageRoot}/apollo-codegen-config.json --ignore-version-mismatch`,
|
||||
{ stdio: 'inherit' }
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user