Skip to content

Commit

Permalink
🆕 Feature: New swift package
Browse files Browse the repository at this point in the history
  • Loading branch information
nookery committed Jan 17, 2025
1 parent 26a9ddd commit e6dd954
Show file tree
Hide file tree
Showing 24 changed files with 2,129 additions and 8 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ node_modules
/dist
/public/draw
dist-ssr
/dist-demo
coverage
*.local

.build/
.swiftpm/
Sources/JuiceEditorKit/WebApp/

/cypress/videos/
/cypress/screenshots/

Expand All @@ -26,4 +31,4 @@ coverage
*.ntvs*
*.njsproj
*.sln
*.sw?
*.sw?
230 changes: 230 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
{
"pins" : [
{
"identity" : "async-http-client",
"kind" : "remoteSourceControl",
"location" : "https://github.com/swift-server/async-http-client.git",
"state" : {
"revision" : "0a9b72369b9d87ab155ef585ef50700a34abf070",
"version" : "1.23.1"
}
},
{
"identity" : "async-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/async-kit.git",
"state" : {
"revision" : "e048c8ee94967e8d8a1c2ec0e1156d6f7fa34d31",
"version" : "1.20.0"
}
},
{
"identity" : "console-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/console-kit.git",
"state" : {
"revision" : "78c0dd739df8cb9ee14a8bbbf770facc4fc3402a",
"version" : "4.15.0"
}
},
{
"identity" : "id3tageditor",
"kind" : "remoteSourceControl",
"location" : "https://github.com/chicio/ID3TagEditor",
"state" : {
"revision" : "3ccc31eafae0ded1fea8c9acd5e7ef7dfdbf1e8e",
"version" : "4.6.0"
}
},
{
"identity" : "magickit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/CofficLab/MagicKit.git",
"state" : {
"branch" : "dev",
"revision" : "5fe2985e11d23a76d9fd9598a52bd169a0dfe07f"
}
},
{
"identity" : "multipart-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/multipart-kit.git",
"state" : {
"revision" : "a31236f24bfd2ea2f520a74575881f6731d7ae68",
"version" : "4.7.0"
}
},
{
"identity" : "routing-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/routing-kit.git",
"state" : {
"revision" : "8c9a227476555c55837e569be71944e02a056b72",
"version" : "4.9.1"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms.git",
"state" : {
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
"version" : "1.2.0"
}
},
{
"identity" : "swift-asn1",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-asn1.git",
"state" : {
"revision" : "7faebca1ea4f9aaf0cda1cef7c43aecd2311ddf6",
"version" : "1.3.0"
}
},
{
"identity" : "swift-async-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-async-algorithms",
"state" : {
"revision" : "9cfed92b026c524674ed869a4ff2dcfdeedf8a2a",
"version" : "0.1.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections.git",
"state" : {
"revision" : "671108c96644956dddcd89dd59c203dcdb36cec7",
"version" : "1.1.4"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "21f7878f2b39d46fd8ba2b06459ccb431cdf876c",
"version" : "3.8.1"
}
},
{
"identity" : "swift-http-types",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-http-types",
"state" : {
"revision" : "ae67c8178eb46944fd85e4dc6dd970e1f3ed6ccd",
"version" : "1.3.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "9cb486020ebf03bfa5b5df985387a14a98744537",
"version" : "1.6.1"
}
},
{
"identity" : "swift-metrics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "e0165b53d49b413dd987526b641e05e246782685",
"version" : "2.5.0"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "f7dc3f527576c398709b017584392fb58592e7f5",
"version" : "2.75.0"
}
},
{
"identity" : "swift-nio-extras",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-extras.git",
"state" : {
"revision" : "2e9746cfc57554f70b650b021b6ae4738abef3e6",
"version" : "1.24.1"
}
},
{
"identity" : "swift-nio-http2",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-http2.git",
"state" : {
"revision" : "eaa71bb6ae082eee5a07407b1ad0cbd8f48f9dca",
"version" : "1.34.1"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "d7ceaf0e4d8001cd35cdc12e42cdd281e9e564e8",
"version" : "2.28.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "dbace16f126fdcd80d58dc54526c561ca17327d7",
"version" : "1.22.0"
}
},
{
"identity" : "swift-numerics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics.git",
"state" : {
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "c8a44d836fe7913603e246acab7c528c2e780168",
"version" : "1.4.0"
}
},
{
"identity" : "vapor",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/vapor.git",
"state" : {
"revision" : "1466c50e4ad39072143e2fcdf13b4ba11be375a0",
"version" : "4.106.0"
}
},
{
"identity" : "websocket-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/websocket-kit.git",
"state" : {
"revision" : "4232d34efa49f633ba61afde365d3896fc7f8740",
"version" : "2.15.0"
}
}
],
"version" : 2
}
39 changes: 39 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// swift-tools-version: 5.9
import PackageDescription

let package = Package(
name: "JuiceEditorKit",
platforms: [
.macOS(.v14)
],
products: [
.library(
name: "JuiceEditorKit",
targets: ["JuiceEditorKit"]),
.executable(
name: "JuiceEditorTestApp",
targets: ["JuiceEditorTestApp"])
],
dependencies: [
.package(url: "https://github.com/vapor/vapor.git", from: "4.0.0"),
.package(url: "https://github.com/CofficLab/MagicKit.git", branch: "dev")
],
targets: [
.target(
name: "JuiceEditorKit",
dependencies: [
.product(name: "Vapor", package: "vapor"),
.product(name: "MagicKit", package: "MagicKit")
],
resources: [
.copy("./WebApp")
]),
.executableTarget(
name: "JuiceEditorTestApp",
dependencies: ["JuiceEditorKit"],
path: "Sources/JuiceEditorTestApp"),
.testTarget(
name: "JuiceEditorKitTests",
dependencies: ["JuiceEditorKit"]),
]
)
99 changes: 99 additions & 0 deletions Sources/JuiceEditorKit/Config.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import CloudKit
import OSLog
import SwiftData
import SwiftUI
import WebKit
import Foundation

struct Config {
static var rootEmoji = "🖼️"

static var publicDir = Bundle.main.url(forResource: "dist", withExtension: nil)

private var fileManager = FileManager.default

var sandboxPrivateKeyURL: URL {
getRunnerDir().appending(component: "private_key")
}

func getDocumentsURL() -> URL {
fileManager
.urls(for: .documentDirectory, in: .userDomainMask)
.first!
}

func getKnownHostsURL() -> URL {
getRunnerDir().appending(component: "known_hosts")
}

func getAppDir() -> URL {
var isDir: ObjCBool = true
let url = getDocumentsURL().appendingPathComponent(
"Kuaiyizhi",
isDirectory: true
)

if !fileManager.fileExists(atPath: url.path, isDirectory: &isDir) {
do {
try fileManager.createDirectory(
at: url,
withIntermediateDirectories: true
)
} catch (let error) {
fatalError("创建 APP 目录失败:\(error.localizedDescription)")
}
}

return url
}

func getTempDir() -> URL {
var isDir: ObjCBool = true
let url = getAppDir()
.appendingPathComponent("temp", isDirectory: true)

if !fileManager.fileExists(atPath: url.path, isDirectory: &isDir) {
do {
try fileManager.createDirectory(
at: url,
withIntermediateDirectories: true
)
} catch (let error) {
fatalError("创建 TEMP 目录失败:\(error.localizedDescription)")
}
}

return url
}

func getRunnerDir() -> URL {
var isDir: ObjCBool = true
let url = getAppDir()
.appendingPathComponent("runner", isDirectory: true)

if !fileManager.fileExists(atPath: url.path, isDirectory: &isDir) {
do {
try fileManager.createDirectory(
at: url,
withIntermediateDirectories: true
)
} catch (let error) {
fatalError("创建 Runner 目录失败:\(error.localizedDescription)")
}
}

return url
}

static var currentDirectoryPath = FileManager.default.currentDirectoryPath

static var webAppPath: String = {
let settingsURL = Bundle.module.url(forResource: "WebApp", withExtension: nil)

if let settingsURL = settingsURL {
return settingsURL.path(percentEncoded: false)
}

fatalError("WebApp directory not found")
}()
}
Loading

0 comments on commit e6dd954

Please sign in to comment.