Skip to content

Commit

Permalink
wip: add support for js and add improvements to paging
Browse files Browse the repository at this point in the history
  • Loading branch information
ErrorErrorError committed Nov 13, 2023
1 parent 3da150f commit 0691aaa
Show file tree
Hide file tree
Showing 44 changed files with 2,736 additions and 2,307 deletions.
10 changes: 5 additions & 5 deletions App/iOS/HostingController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import SwiftUI
import UIKit
import ViewComponents

final class HostingController<Content: View>: UIHostingController<Content>, OpaqueController {
final class HostingController<Variant: View>: UIHostingController<Variant>, OpaqueController {
override var prefersHomeIndicatorAutoHidden: Bool { _homeIndicatorAutoHidden }

var _homeIndicatorAutoHidden = false {
Expand All @@ -23,7 +23,7 @@ final class HostingController<Content: View>: UIHostingController<Content>, Opaq

private let box: Box

init<InnerView: View>(rootView: InnerView) where Content == BoxedView<InnerView> {
init<InnerView: View>(rootView: InnerView) where Variant == BoxedView<InnerView> {
self.box = .init()
super.init(rootView: .init(box: box, content: rootView))
box.object = self
Expand All @@ -35,15 +35,15 @@ final class HostingController<Content: View>: UIHostingController<Content>, Opaq
}
}

struct BoxedView<Content: View>: View {
struct BoxedView<Variant: View>: View {
let box: Box

init(box: Box, content: @autoclosure @escaping () -> Content) {
init(box: Box, content: @autoclosure @escaping () -> Variant) {
self.content = content
self.box = box
}

let content: () -> Content
let content: () -> Variant

var body: some View {
content()
Expand Down
80 changes: 58 additions & 22 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ import Foundation
struct LoggerClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
Logging()
}
}
//
Expand Down Expand Up @@ -954,6 +955,32 @@ struct Semver: PackageDependency {
}
}
//
// File.swift
//
//
// Created by ErrorErrorError on 11/9/23.
//
//

struct SwiftLog: PackageDependency {
var name: String { "swift-log" }
var productName: String { "swift-log" }

var dependency: Package.Dependency {
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0")
}
}

struct Logging: _Depending, Dependency {
var targetDepenency: _PackageDescription_TargetDependency {
.product(name: "\(Self.self)", package: SwiftLog().packageName)
}

var dependencies: any Dependencies {
SwiftLog()
}
}
//
// SwiftSoup.swift
//
//
Expand Down Expand Up @@ -982,16 +1009,24 @@ struct SwiftSyntax: PackageDependency {
}
}

struct SwiftSyntaxMacros: Dependency {
struct SwiftSyntaxMacros: _Depending, Dependency {
var targetDepenency: _PackageDescription_TargetDependency {
.product(name: "\(Self.self)", package: SwiftSyntax().packageName)
}

var dependencies: any Dependencies {
SwiftSyntax()
}
}

struct SwiftCompilerPlugin: Dependency {
struct SwiftCompilerPlugin: _Depending, Dependency {
var targetDepenency: _PackageDescription_TargetDependency {
.product(name: "\(Self.self)", package: SwiftSyntax().packageName)
}

var dependencies: any Dependencies {
SwiftSyntax()
}
}

//
Expand Down Expand Up @@ -1023,6 +1058,26 @@ struct Tagged: PackageDependency {
}
}
//
// ContentCore.swift
//
//
// Created by ErrorErrorError on 10/5/23.
//
//

import Foundation

struct ContentCore: _Feature {
var dependencies: any Dependencies {
Architecture()
FoundationHelpers()
ModuleClient()
LoggerClient()
Tagged()
ComposableArchitecture()
}
}
//
// Discover.swift
//
//
Expand Down Expand Up @@ -1273,26 +1328,6 @@ struct Architecture: _Shared {
}
}
//
// ContentCore.swift
//
//
// Created by ErrorErrorError on 10/5/23.
//
//

import Foundation

struct ContentCore: _Shared {
var dependencies: any Dependencies {
Architecture()
FoundationHelpers()
ModuleClient()
LoggerClient()
Tagged()
ComposableArchitecture()
}
}
//
// FoundationHelpers.swift
//
//
Expand Down Expand Up @@ -1338,6 +1373,7 @@ struct SharedModels: _Shared {
Tagged()
ComposableArchitecture()
Semver()
JSValueCoder()
}
}
//
Expand Down
1 change: 1 addition & 0 deletions Package/Sources/Clients/LoggerClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ import Foundation
struct LoggerClient: _Client {
var dependencies: any Dependencies {
ComposableArchitecture()
Logging()
}
}
9 changes: 7 additions & 2 deletions Package/Sources/Dependencies/SwiftLog.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@

struct SwiftLog: PackageDependency {
var name: String { "swift-log" }
var productName: String { "swift-log" }

var dependency: Package.Dependency {
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0")
}
}

struct Logging: Dependency {
struct Logging: _Depending, Dependency {
var targetDepenency: _PackageDescription_TargetDependency {
.product(name: "\(Self.self)", package: SwiftLog().packageName)
}

var dependencies: any Dependencies {
SwiftLog()
}
}
12 changes: 10 additions & 2 deletions Package/Sources/Dependencies/SwiftSyntax.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,23 @@ struct SwiftSyntax: PackageDependency {
}
}

struct SwiftSyntaxMacros: Dependency {
struct SwiftSyntaxMacros: _Depending, Dependency {
var targetDepenency: _PackageDescription_TargetDependency {
.product(name: "\(Self.self)", package: SwiftSyntax().packageName)
}

var dependencies: any Dependencies {
SwiftSyntax()
}
}

struct SwiftCompilerPlugin: Dependency {
struct SwiftCompilerPlugin: _Depending, Dependency {
var targetDepenency: _PackageDescription_TargetDependency {
.product(name: "\(Self.self)", package: SwiftSyntax().packageName)
}

var dependencies: any Dependencies {
SwiftSyntax()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import Foundation

struct ContentCore: _Shared {
struct ContentCore: _Feature {
var dependencies: any Dependencies {
Architecture()
FoundationHelpers()
Expand Down
1 change: 1 addition & 0 deletions Package/Sources/Shared/SharedModels.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ struct SharedModels: _Shared {
Tagged()
ComposableArchitecture()
Semver()
JSValueCoder()
}
}
16 changes: 16 additions & 0 deletions Sources/Clients/DatabaseClient/Models/Extensions/Module+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// Module+.swift
//
//
// Created by ErrorErrorError on 11/12/23.
//
//

import Foundation

public extension Module {
var mainJSFile: URL {
self.directory.appendingPathComponent("main")
.appendingPathExtension("js")
}
}
11 changes: 4 additions & 7 deletions Sources/Clients/DatabaseClient/Models/Module.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,13 @@ import Tagged

@dynamicMemberLookup
public struct Module: Entity, Hashable, Sendable {
// TODO: Rename moduleLocation to moduleDirectory
public var moduleLocation: URL = .init(string: "/").unsafelyUnwrapped
public var directory: URL = .init(string: "/").unsafelyUnwrapped
public var installDate: Date = .init()
public var manifest: Manifest = .init()
public var objectID: ManagedObjectID?

public var moduleDirectory: URL { self.moduleLocation }

public static var properties: Set<Property> = [
.init("moduleLocation", \Self.moduleLocation),
.init("directory", \Self.directory),
.init("installDate", \Self.installDate),
.init("manifest", \Self.manifest)
]
Expand All @@ -43,11 +40,11 @@ extension Module: Identifiable {

public extension Module {
init(
moduleLocation: URL,
directory: URL,
installDate: Date,
manifest: Module.Manifest
) {
self.moduleLocation = moduleLocation
self.directory = directory
self.installDate = installDate
self.manifest = manifest
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="21754" systemVersion="22E252" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="22222" systemVersion="22G120" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Module" representedClassName="Module" syncable="YES">
<attribute name="directory" attributeType="URI"/>
<attribute name="installDate" attributeType="Date" usesScalarValueType="NO"/>
<attribute name="manifest" attributeType="Binary"/>
<attribute name="moduleLocation" attributeType="URI"/>
<relationship name="repo" optional="YES" maxCount="1" deletionRule="Nullify" destinationEntity="Repo" inverseName="modules" inverseEntity="Repo"/>
</entity>
<entity name="Repo" representedClassName="Repo" syncable="YES">
Expand Down
31 changes: 31 additions & 0 deletions Sources/Clients/FileClient/Client+.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Client+.swift
//
//
// Created by ErrorErrorError on 11/12/23.
//
//

import Foundation

public extension FileClient {
func createModuleDirectory(_ url: URL) throws {
try create(
self.url(.documentDirectory, .userDomainMask, nil, true)
.reposDir()
.appendingPathComponent(url.absoluteString)
)
}

func retrieveModuleDirectory(_ url: URL) throws -> URL {
try self.url(.documentDirectory, .userDomainMask, nil, false)
.reposDir()
.appendingPathComponent(url.absoluteString)
}
}

private extension URL {
func reposDir() -> URL {
self.appendingPathComponent("Repos", isDirectory: true)
}
}
12 changes: 8 additions & 4 deletions Sources/Clients/FileClient/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@ import Foundation
// MARK: - FileClient

public struct FileClient {
public let createModuleFolder: @Sendable (String) throws -> URL
public let retrieveModuleFolder: @Sendable (URL) -> URL
public let url: @Sendable (FileManager.SearchPathDirectory, FileManager.SearchPathDomainMask, URL?, Bool) throws -> URL
public let fileExists: @Sendable (String) -> Bool
public let create: @Sendable (URL) throws -> Void
public let remove: @Sendable (URL) throws -> Void
}

// MARK: TestDependencyKey

extension FileClient: TestDependencyKey {
public static var testValue: FileClient = .init(
createModuleFolder: unimplemented(".createModuleFolder"),
retrieveModuleFolder: unimplemented(".retrieveModuleFolder")
url: unimplemented(".url"),
fileExists: unimplemented(".remove"),
create: unimplemented(".create"),
remove: unimplemented(".remove")
)
}

Expand Down
Loading

0 comments on commit 0691aaa

Please sign in to comment.