This file contains hidden or 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
/** | |
* MacEditorTextView | |
* Copyright (c) Thiago Holanda 2020-2021 | |
* https://twitter.com/tholanda | |
* | |
* MIT license | |
* Modified by https://github.com/cjwcommuny for TextKit 2 | |
*/ | |
import Combine |
This file contains hidden or 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
struct UserDefaultsKey<T: Codable> { | |
var name: String | |
var `default`: T | |
} | |
extension UserDefaults { | |
func get<T>(_ key: UserDefaultsKey<T>) -> T { | |
guard | |
let data = data(forKey: key.name), | |
let box = try? JSONDecoder().decode(Box<T>.self, from: data) |
This file contains hidden or 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
extension Sequence { | |
func asyncMap<T>(_ transform: @escaping (Element) async -> T) async -> [T] { | |
return await withTaskGroup(of: T.self) { group in | |
var transformedElements = [T]() | |
for element in self { | |
group.addTask { | |
return await transform(element) | |
} | |
} |
This file contains hidden or 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
// | |
// Watchdog.swift | |
// | |
// The MIT License (MIT) | |
// Copyright © 2023 Front Pocket Software LLC | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | |
// documentation files (the “Software”), to deal in the Software without restriction, including without limitation the | |
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | |
// permit persons to whom the Software is furnished to do so, subject to the following conditions: |
This file contains hidden or 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
import SwiftUI | |
enum OSDocumentError: Error { | |
case unknownFileFormat | |
} | |
#if canImport(UIKit) | |
import UIKit |
This file contains hidden or 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
import SwiftUI | |
import Observation | |
@propertyWrapper | |
struct EnvironmentObservable<Value: AnyObject & Observable>: DynamicProperty { | |
@Environment var wrappedValue: Value | |
public init(_ objectType: Value.Type) { | |
_wrappedValue = .init(objectType) |
OlderNewer