chore: Move everything into package/ (#1745)

* Move everything into package

* Remove .DS_Store

* Move scripts and eslintrc to package

* Create CODE_OF_CONDUCT.md

* fix some links

* Update all links (I think)

* Update generated docs

* Update notice-yarn-changes.yml

* Update validate-android.yml

* Update validate-cpp.yml

* Delete notice-yarn-changes.yml

* Update validate-cpp.yml

* Update validate-cpp.yml

* Update validate-js.yml

* Update validate-cpp.yml

* Update validate-cpp.yml

* wrong c++ style

* Revert "wrong c++ style"

This reverts commit 55a3575589c6f13f8b05134d83384f55e0601ab2.
This commit is contained in:
Marc Rousavy
2023-09-01 18:15:28 +02:00
committed by GitHub
parent 2a5c33323b
commit 036856aed5
347 changed files with 3088 additions and 154 deletions

View File

@@ -0,0 +1,28 @@
//
// AVAssetWriter.Status+descriptor.swift
// VisionCamera
//
// Created by Marc Rousavy on 01.05.21.
// Copyright © 2021 mrousavy. All rights reserved.
//
import AVFoundation
extension AVAssetWriter.Status {
var descriptor: String {
switch self {
case .cancelled:
return "cancelled"
case .completed:
return "completed"
case .failed:
return "failed"
case .unknown:
return "unknown"
case .writing:
return "writing"
@unknown default:
fatalError("Unknown AVAssetWriter.Status value! \(rawValue)")
}
}
}

View File

@@ -0,0 +1,26 @@
//
// AVAuthorizationStatus+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 29.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
extension AVAuthorizationStatus {
var descriptor: String {
switch self {
case .authorized:
return "granted"
case .denied:
return "denied"
case .notDetermined:
return "not-determined"
case .restricted:
return "restricted"
@unknown default:
fatalError("AVAuthorizationStatus has unknown state.")
}
}
}

View File

@@ -0,0 +1,38 @@
//
// AVCaptureDevice.DeviceType+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 15.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
import Foundation
extension AVCaptureDevice.DeviceType {
var descriptor: String {
if #available(iOS 13.0, *) {
switch self {
case .builtInDualWideCamera:
return "dual-wide-camera"
case .builtInTripleCamera:
return "triple-camera"
case .builtInUltraWideCamera:
return "ultra-wide-angle-camera"
default:
break
}
}
switch self {
case .builtInDualCamera:
return "dual-camera"
case .builtInTelephotoCamera:
return "telephoto-camera"
case .builtInWideAngleCamera:
return "wide-angle-camera"
default:
// e.g. `.builtInTrueDepthCamera`
fatalError("AVCaptureDevice.Position has unknown state.")
}
}
}

View File

@@ -0,0 +1,27 @@
//
// AVCaptureDevice.FlashMode+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 15.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
extension AVCaptureDevice.FlashMode {
init?(withString string: String) {
switch string {
case "on":
self = .on
return
case "off":
self = .off
return
case "auto":
self = .auto
return
default:
return nil
}
}
}

View File

@@ -0,0 +1,40 @@
//
// AVCaptureDevice.Format.AutoFocusSystem+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 29.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
extension AVCaptureDevice.Format.AutoFocusSystem {
init(withString string: String) throws {
switch string {
case "contrast-detection":
self = .contrastDetection
return
case "phase-detection":
self = .phaseDetection
return
case "none":
self = .none
return
default:
throw EnumParserError.invalidValue
}
}
var descriptor: String {
switch self {
case .contrastDetection:
return "contrast-detection"
case .phaseDetection:
return "phase-detection"
case .none:
return "none"
@unknown default:
fatalError("AVCaptureDevice.Format has unknown state.")
}
}
}

View File

@@ -0,0 +1,25 @@
//
// AVCaptureDevice.Position+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 15.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
import Foundation
extension AVCaptureDevice.Position {
var descriptor: String {
switch self {
case .back:
return "back"
case .front:
return "front"
case .unspecified:
return "unspecified"
@unknown default:
fatalError("AVCaptureDevice.Position has unknown state.")
}
}
}

View File

@@ -0,0 +1,27 @@
//
// AVCaptureDevice.TorchMode+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 18.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
extension AVCaptureDevice.TorchMode {
init?(withString string: String) {
switch string {
case "on":
self = .on
return
case "off":
self = .off
return
case "auto":
self = .auto
return
default:
return nil
}
}
}

View File

@@ -0,0 +1,29 @@
//
// AVCapturePhotoOutput.QualityPrioritization+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 15.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
import Foundation
@available(iOS 13.0, *)
extension AVCapturePhotoOutput.QualityPrioritization {
init?(withString string: String) {
switch string {
case "speed":
self = .speed
return
case "quality":
self = .quality
return
case "balanced":
self = .balanced
return
default:
return nil
}
}
}

View File

@@ -0,0 +1,61 @@
//
// AVCaptureVideoStabilizationMode+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 29.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
extension AVCaptureVideoStabilizationMode {
init(withString string: String) throws {
switch string {
case "auto":
self = .auto
return
case "cinematic":
self = .cinematic
return
case "cinematic-extended":
if #available(iOS 13.0, *) {
self = .cinematicExtended
return
} else {
throw EnumParserError.unsupportedOS(supportedOnOS: "iOS 13.0")
}
case "off":
self = .off
return
case "standard":
self = .standard
return
default:
throw EnumParserError.invalidValue
}
}
var descriptor: String {
if #available(iOS 13.0, *) {
switch self {
case .cinematicExtended:
return "cinematic-extended"
default:
break
}
}
switch self {
case .auto:
return "auto"
case .cinematic:
return "cinematic"
case .off:
return "off"
case .standard:
return "standard"
default:
fatalError("AVCaptureVideoStabilizationMode has unknown state.")
}
}
}

View File

@@ -0,0 +1,42 @@
//
// AVFileType+descriptor.swift
// VisionCamera
//
// Created by Marc Rousavy on 01.05.21.
// Copyright © 2021 mrousavy. All rights reserved.
//
import AVFoundation
import Foundation
extension AVFileType {
init(withString string: String) throws {
switch string {
case "mov":
self = .mov
case "mp4":
self = .mp4
case "avci":
self = .avci
case "m4v":
self = .m4v
default:
throw EnumParserError.invalidValue
}
}
var descriptor: String? {
switch self {
case .mov:
return "mov"
case .mp4:
return "mp4"
case .avci:
return "avci"
case .m4v:
return "m4v"
default:
return nil
}
}
}

View File

@@ -0,0 +1,25 @@
//
// AVVideoCodecType+descriptor.swift
// mrousavy
//
// Created by Marc Rousavy on 15.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import AVFoundation
import Foundation
extension AVVideoCodecType {
init?(withString string: String) {
switch string {
case "h264":
self = .h264
return
case "h265":
self = .hevc
return
default:
return nil
}
}
}

View File

@@ -0,0 +1,23 @@
//
// EnumParserError.swift
// mrousavy
//
// Created by Marc Rousavy on 18.12.20.
// Copyright © 2020 mrousavy. All rights reserved.
//
import Foundation
/**
An error raised when the given descriptor (TypeScript string union type) cannot be parsed and converted to a Swift enum.
*/
enum EnumParserError: Error {
/**
Raised when the descriptor is not supported on the current OS.
*/
case unsupportedOS(supportedOnOS: String)
/**
Raised when the descriptor does not match any of the possible values.
*/
case invalidValue
}

View File

@@ -0,0 +1,63 @@
//
// PixelFormat.swift
// VisionCamera
//
// Created by Marc Rousavy on 17.08.23.
// Copyright © 2023 mrousavy. All rights reserved.
//
import AVFoundation
import Foundation
enum PixelFormat {
case yuv
case rgb
case dng
case native
case unknown
var unionValue: String {
switch self {
case .yuv:
return "yuv"
case .rgb:
return "rgb"
case .dng:
return "dng"
case .native:
return "native"
case .unknown:
return "unknown"
}
}
init(unionValue: String) throws {
switch unionValue {
case "yuv":
self = .yuv
case "rgb":
self = .rgb
case "dng":
self = .dng
case "native":
self = .native
case "unknown":
self = .unknown
default:
throw CameraError.parameter(.invalid(unionName: "pixelFormat", receivedValue: unionValue))
}
}
init(mediaSubType: OSType) {
switch mediaSubType {
case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange:
self = .yuv
case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
self = .yuv
case kCVPixelFormatType_32BGRA:
self = .rgb
default:
self = .unknown
}
}
}

View File

@@ -0,0 +1,31 @@
//
// UIInterfaceOrientation+descriptor.swift
// VisionCamera
//
// Created by Marc Rousavy on 04.01.22.
// Copyright © 2022 mrousavy. All rights reserved.
//
import Foundation
import UIKit
extension UIInterfaceOrientation {
init(withString string: String) throws {
switch string {
case "portrait":
self = .portrait
return
case "portrait-upside-down":
self = .portraitUpsideDown
return
case "landscape-left":
self = .landscapeLeft
return
case "landscape-right":
self = .landscapeRight
return
default:
throw EnumParserError.invalidValue
}
}
}