diff --git a/Sources/SwiftSCAD/Environment/Environment.swift b/Sources/SwiftSCAD/Environment/Environment.swift index b12c30a..2a86372 100644 --- a/Sources/SwiftSCAD/Environment/Environment.swift +++ b/Sources/SwiftSCAD/Environment/Environment.swift @@ -3,14 +3,14 @@ import Foundation /// `Environment` provides a flexible container for environment-specific values influencing the rendering of geometries. /// /// You can use `Environment` to customize settings and attributes that affect child geometries within SwiftSCAD. Modifiers allow for dynamic adjustments of the environment, which can be applied to geometries to affect their rendering or behavior. -public struct Environment { - private let values: [ValueKey: Any] +public struct Environment: Sendable { + private let values: [ValueKey: any Sendable] public init() { self.init(values: [:]) } - init(values: [ValueKey: Any]) { + init(values: [ValueKey: any Sendable]) { self.values = values } @@ -18,7 +18,7 @@ public struct Environment { /// /// - Parameter newValues: A dictionary of values to add to the environment. /// - Returns: A new `Environment` instance with the added values. - public func setting(_ newValues: [ValueKey: Any]) -> Environment { + public func setting(_ newValues: [ValueKey: any Sendable]) -> Environment { Environment(values: values.merging(newValues, uniquingKeysWith: { $1 })) } @@ -28,7 +28,7 @@ public struct Environment { /// - key: The key for the value to update or add. /// - value: The new value to set. If `nil`, the key is removed from the environment. /// - Returns: A new `Environment` instance with the updated values. - public func setting(key: ValueKey, value: Any?) -> Environment { + public func setting(key: ValueKey, value: (any Sendable)?) -> Environment { var values = self.values values[key] = value return Environment(values: values) @@ -38,14 +38,14 @@ public struct Environment { /// /// - Parameter key: The key of the value to access. /// - Returns: The value associated with `key` if it exists; otherwise, `nil`. - public subscript(key: ValueKey) -> Any? { + public subscript(key: ValueKey) -> (any Sendable)? { values[key] } } public extension Environment { /// Represents a key for environment values. - struct ValueKey: RawRepresentable, Hashable { + struct ValueKey: RawRepresentable, Hashable, Sendable { public var rawValue: String public init(rawValue: String) { diff --git a/Sources/SwiftSCAD/Environment/Facets.swift b/Sources/SwiftSCAD/Environment/Facets.swift index 8a7bd0f..1acc33a 100644 --- a/Sources/SwiftSCAD/Environment/Facets.swift +++ b/Sources/SwiftSCAD/Environment/Facets.swift @@ -2,7 +2,7 @@ import Foundation public extension Environment { /// An enumeration representing the method for calculating the number of facets (or segments) used in rendering circular geometries. - enum Facets { + enum Facets: Sendable { /// Specifies a fixed number of facets for all circles, regardless of size. case fixed (Int) diff --git a/Sources/SwiftSCAD/Environment/Operation.swift b/Sources/SwiftSCAD/Environment/Operation.swift index dc390ec..7ed0143 100644 --- a/Sources/SwiftSCAD/Environment/Operation.swift +++ b/Sources/SwiftSCAD/Environment/Operation.swift @@ -4,7 +4,7 @@ public extension Environment { private static let key = Environment.ValueKey(rawValue: "SwiftSCAD.Operation") /// Represents a geometric operation, specifically for determining if geometries are being added or subtracted. - enum Operation { + enum Operation: Sendable { /// Represents the addition of geometries. case addition /// Represents the subtraction of geometries, typically used for creating holes or negative spaces within another geometry. diff --git a/Sources/SwiftSCAD/Operations/Alignment/Alignment.swift b/Sources/SwiftSCAD/Operations/Alignment/Alignment.swift index 772a31e..fd06bc7 100644 --- a/Sources/SwiftSCAD/Operations/Alignment/Alignment.swift +++ b/Sources/SwiftSCAD/Operations/Alignment/Alignment.swift @@ -1,6 +1,6 @@ import Foundation -public enum AxisAlignment: Equatable { +public enum AxisAlignment: Equatable, Sendable { case min case mid case max @@ -14,7 +14,7 @@ public enum AxisAlignment: Equatable { } } -public struct GeometryAlignment2D: Equatable { +public struct GeometryAlignment2D: Equatable, Sendable { internal let x: AxisAlignment? internal let y: AxisAlignment? @@ -33,7 +33,7 @@ public struct GeometryAlignment2D: Equatable { } } -public struct GeometryAlignment3D: Equatable { +public struct GeometryAlignment3D: Equatable, Sendable { internal let x: AxisAlignment? internal let y: AxisAlignment? internal let z: AxisAlignment? diff --git a/Sources/SwiftSCAD/Operations/Extrude/Edge Profiles/EdgeProfile.swift b/Sources/SwiftSCAD/Operations/Extrude/Edge Profiles/EdgeProfile.swift index 147dce5..10bde26 100644 --- a/Sources/SwiftSCAD/Operations/Extrude/Edge Profiles/EdgeProfile.swift +++ b/Sources/SwiftSCAD/Operations/Extrude/Edge Profiles/EdgeProfile.swift @@ -1,7 +1,7 @@ import Foundation /// The profile of an edge -public enum EdgeProfile: Equatable { +public enum EdgeProfile: Equatable, Sendable { /// Represents an edge modified to be rounded. /// - Parameter radius: The radius of the curvature applied to the edge, determining the degree of roundness. case fillet (radius: Double) diff --git a/Sources/SwiftSCAD/Shapes/2D/Text/Environment+Text.swift b/Sources/SwiftSCAD/Shapes/2D/Text/Environment+Text.swift index 0f18c2d..e5b4c26 100644 --- a/Sources/SwiftSCAD/Shapes/2D/Text/Environment+Text.swift +++ b/Sources/SwiftSCAD/Shapes/2D/Text/Environment+Text.swift @@ -1,7 +1,7 @@ import Foundation internal extension Environment { - struct TextAttributes { + struct TextAttributes: Sendable { var font: String? var fontStyle: String? var fontSize: Double? @@ -35,7 +35,6 @@ internal extension Environment { e = e.settingTextAttribute(\.fontSize, value: size) } return e - } func withTextAlignment(horizontal: Text.HorizontalAlignment? = nil, vertical: Text.VerticalAlignment? = nil) -> Environment { diff --git a/Sources/SwiftSCAD/Shapes/2D/Text/Text.swift b/Sources/SwiftSCAD/Shapes/2D/Text/Text.swift index 45972e5..fb382e0 100644 --- a/Sources/SwiftSCAD/Shapes/2D/Text/Text.swift +++ b/Sources/SwiftSCAD/Shapes/2D/Text/Text.swift @@ -23,7 +23,7 @@ public struct Text: Geometry2D { /// An enumeration representing the horizontal alignment options for text geometry. /// /// Use these options with ``Geometry2D/usingTextAlignment(horizontal:vertical:)`` to set the horizontal alignment of your text geometry. - public enum HorizontalAlignment: String { + public enum HorizontalAlignment: String, Sendable { /// Aligns the text to the left. case left /// Centers the text horizontally. @@ -40,7 +40,7 @@ public struct Text: Geometry2D { /// - `bottom`: Aligns the text to the bottom. /// /// Use these options with ``Geometry2D/usingTextAlignment(horizontal:vertical:)`` to set the vertical alignment of your text geometry. - public enum VerticalAlignment: String { + public enum VerticalAlignment: String, Sendable { /// Aligns the text to the top. case top /// Centers the text vertically. diff --git a/Sources/SwiftSCAD/Values/Angle/Angle.swift b/Sources/SwiftSCAD/Values/Angle/Angle.swift index 28d10f0..406c5dc 100644 --- a/Sources/SwiftSCAD/Values/Angle/Angle.swift +++ b/Sources/SwiftSCAD/Values/Angle/Angle.swift @@ -1,7 +1,7 @@ import Foundation /// A value representing a geometric angle -public struct Angle { +public struct Angle: Sendable { /// The angle expressed in radians public let radians: Double diff --git a/Sources/SwiftSCAD/Values/Axis/Axes.swift b/Sources/SwiftSCAD/Values/Axis/Axes.swift index 103aa0b..b9ef27f 100644 --- a/Sources/SwiftSCAD/Values/Axis/Axes.swift +++ b/Sources/SwiftSCAD/Values/Axis/Axes.swift @@ -10,7 +10,7 @@ public protocol Axes { /// A set of cartesian axes in two dimensions (X and/or Y) -public struct Axes2D: Axes, OptionSet, Hashable { +public struct Axes2D: Axes, OptionSet, Hashable, Sendable { public typealias Axis = Axis2D public let rawValue: Int @@ -46,7 +46,7 @@ public struct Axes2D: Axes, OptionSet, Hashable { /// A set of cartesian axes in three dimensions (X, Y and/or Z) -public struct Axes3D: Axes, OptionSet, Hashable { +public struct Axes3D: Axes, OptionSet, Hashable, Sendable { public typealias Axis = Axis3D public let rawValue: Int diff --git a/Sources/SwiftSCAD/Values/Axis/Axis.swift b/Sources/SwiftSCAD/Values/Axis/Axis.swift index 7577c4d..80c45d5 100644 --- a/Sources/SwiftSCAD/Values/Axis/Axis.swift +++ b/Sources/SwiftSCAD/Values/Axis/Axis.swift @@ -1,13 +1,13 @@ import Foundation /// One of the cartesian axes in two dimensions (X or Y) -public enum Axis2D: Int, CaseIterable { +public enum Axis2D: Int, CaseIterable, Sendable { case x case y } /// An enumeration representing the three Cartesian axes in a three-dimensional space: X, Y, and Z. -public enum Axis3D: Int, CaseIterable { +public enum Axis3D: Int, CaseIterable, Sendable { case x case y case z @@ -28,7 +28,7 @@ public enum Axis3D: Int, CaseIterable { } /// A direction along an axis -public enum AxisDirection { +public enum AxisDirection: Sendable { /// The positive direction along an axis case positive /// The negative direction along an axis diff --git a/Sources/SwiftSCAD/Values/Bezier/BezierCurve.swift b/Sources/SwiftSCAD/Values/Bezier/BezierCurve.swift index 6e02d57..e8ad334 100644 --- a/Sources/SwiftSCAD/Values/Bezier/BezierCurve.swift +++ b/Sources/SwiftSCAD/Values/Bezier/BezierCurve.swift @@ -1,6 +1,6 @@ import Foundation -internal struct BezierCurve { +internal struct BezierCurve : Sendable { let controlPoints: [V] init(controlPoints: [V]) { diff --git a/Sources/SwiftSCAD/Values/Bezier/BezierPath.swift b/Sources/SwiftSCAD/Values/Bezier/BezierPath.swift index 19e18ee..6a86323 100644 --- a/Sources/SwiftSCAD/Values/Bezier/BezierPath.swift +++ b/Sources/SwiftSCAD/Values/Bezier/BezierPath.swift @@ -8,7 +8,7 @@ public typealias BezierPath3D = BezierPath /// You can create a `BezierPath` by providing a starting point and adding curves and line segments to the path. 2D paths can be used to create `Polygon` shapes. /// /// To create a `BezierPath`, start with the `init(startPoint:)` initializer, specifying the starting point of the path. Then, you can chain calls to `addingLine(to:)`, `addingQuadraticCurve(controlPoint:end:)`, and `addingCubicCurve(controlPoint1:controlPoint2:end:)` to build a complete path. -public struct BezierPath { +public struct BezierPath : Sendable { let startPoint: V let curves: [BezierCurve] diff --git a/Sources/SwiftSCAD/Values/Boundary/Boundary.swift b/Sources/SwiftSCAD/Values/Boundary/Boundary.swift index 3e98f85..9adaac9 100644 --- a/Sources/SwiftSCAD/Values/Boundary/Boundary.swift +++ b/Sources/SwiftSCAD/Values/Boundary/Boundary.swift @@ -3,7 +3,7 @@ import Foundation public typealias Boundary2D = Boundary public typealias Boundary3D = Boundary -public struct Boundary { +public struct Boundary: Sendable { internal let points: [V] internal init(points: [V]) { diff --git a/Sources/SwiftSCAD/Values/Boundary/BoundingBox.swift b/Sources/SwiftSCAD/Values/Boundary/BoundingBox.swift index 94b8ef1..c94c230 100644 --- a/Sources/SwiftSCAD/Values/Boundary/BoundingBox.swift +++ b/Sources/SwiftSCAD/Values/Boundary/BoundingBox.swift @@ -4,7 +4,7 @@ public typealias BoundingBox2D = BoundingBox public typealias BoundingBox3D = BoundingBox /// An axis-aligned bounding volume defined by its minimum and maximum corners, used to calculate and represent the bounding area or volume of shapes or points in a generic vector space. -public struct BoundingBox { +public struct BoundingBox: Sendable { /// The minimum corner point of the bounding volume, typically representing the "lower" corner in geometric space. public let minimum: V /// The maximum corner point of the bounding volume, typically representing the "upper" corner in geometric space. diff --git a/Sources/SwiftSCAD/Values/Color.swift b/Sources/SwiftSCAD/Values/Color.swift index 28df3d2..2cc18d3 100644 --- a/Sources/SwiftSCAD/Values/Color.swift +++ b/Sources/SwiftSCAD/Values/Color.swift @@ -1,10 +1,10 @@ import Foundation -public enum Color { +public enum Color: Sendable { case components (red: Double, green: Double, blue: Double, alpha: Double) case named (Name, alpha: Double) - public enum Name: String { + public enum Name: String, Sendable { case lavender case thistle case plum diff --git a/Sources/SwiftSCAD/Values/Corners/RectangleCornerRadii.swift b/Sources/SwiftSCAD/Values/Corners/RectangleCornerRadii.swift index 4cf5e24..7eaa39a 100644 --- a/Sources/SwiftSCAD/Values/Corners/RectangleCornerRadii.swift +++ b/Sources/SwiftSCAD/Values/Corners/RectangleCornerRadii.swift @@ -1,6 +1,6 @@ import Foundation -internal struct RectangleCornerRadii { +internal struct RectangleCornerRadii: Sendable { let minXminY: Double let maxXminY: Double let maxXmaxY: Double diff --git a/Sources/SwiftSCAD/Values/Corners/RectangleCorners.swift b/Sources/SwiftSCAD/Values/Corners/RectangleCorners.swift index 8a66728..8c5f250 100644 --- a/Sources/SwiftSCAD/Values/Corners/RectangleCorners.swift +++ b/Sources/SwiftSCAD/Values/Corners/RectangleCorners.swift @@ -5,7 +5,7 @@ import Foundation /// `RectangleCorners` allows for specifying and manipulating individual corners or groups of corners of a rectangle. /// It is used for operations that involve corner-specific modifications, such as rounding corners. -public struct RectangleCorners: OptionSet, Hashable { +public struct RectangleCorners: OptionSet, Hashable, Sendable { public let rawValue: Int public init(rawValue: Int) { diff --git a/Sources/SwiftSCAD/Values/Corners/RoundedCornerStyle.swift b/Sources/SwiftSCAD/Values/Corners/RoundedCornerStyle.swift index e926f77..7e8b565 100644 --- a/Sources/SwiftSCAD/Values/Corners/RoundedCornerStyle.swift +++ b/Sources/SwiftSCAD/Values/Corners/RoundedCornerStyle.swift @@ -1,7 +1,7 @@ import Foundation /// Represents the style of rounded corners. -public enum RoundedCornerStyle { +public enum RoundedCornerStyle: Sendable { /// A regular circular corner. case circular /// A squircular corner, forming a more natural and continuous curve. diff --git a/Sources/SwiftSCAD/Values/Rotation3D.swift b/Sources/SwiftSCAD/Values/Rotation3D.swift index 9ba2245..e254394 100644 --- a/Sources/SwiftSCAD/Values/Rotation3D.swift +++ b/Sources/SwiftSCAD/Values/Rotation3D.swift @@ -1,10 +1,10 @@ import Foundation /// A structure representing a rotation in 3D space. -public struct Rotation3D { +public struct Rotation3D: Sendable { internal var rotation: Rotation - internal enum Rotation { + internal enum Rotation: Sendable { case eulerAngles (x: Angle, y: Angle, z: Angle) case axis (Vector3D, angle: Angle) } diff --git a/Sources/SwiftSCAD/Values/SCADValue.swift b/Sources/SwiftSCAD/Values/SCADValue.swift index 6ca9168..1bf8930 100644 --- a/Sources/SwiftSCAD/Values/SCADValue.swift +++ b/Sources/SwiftSCAD/Values/SCADValue.swift @@ -1,6 +1,6 @@ import Foundation -protocol SCADValue { +protocol SCADValue: Sendable { var scadString: String { get } } diff --git a/Sources/SwiftSCAD/Values/Transforms/AffineTransform.swift b/Sources/SwiftSCAD/Values/Transforms/AffineTransform.swift index 35aeb88..9f04a34 100644 --- a/Sources/SwiftSCAD/Values/Transforms/AffineTransform.swift +++ b/Sources/SwiftSCAD/Values/Transforms/AffineTransform.swift @@ -1,6 +1,6 @@ import Foundation -public protocol AffineTransform { +public protocol AffineTransform: Sendable { associatedtype Vector: SwiftSCAD.Vector associatedtype Rotation diff --git a/Sources/SwiftSCAD/Values/Transforms/AffineTransform2D.swift b/Sources/SwiftSCAD/Values/Transforms/AffineTransform2D.swift index 9696bcc..9977905 100644 --- a/Sources/SwiftSCAD/Values/Transforms/AffineTransform2D.swift +++ b/Sources/SwiftSCAD/Values/Transforms/AffineTransform2D.swift @@ -4,7 +4,7 @@ import simd #endif /// An `AffineTransform2D` represents a 2D affine transformation using a 3x3 matrix. -public struct AffineTransform2D: AffineTransform, Equatable { +public struct AffineTransform2D: AffineTransform, Equatable, Sendable { private var matrix: Matrix3x3 internal init(_ matrix: Matrix3x3) { diff --git a/Sources/SwiftSCAD/Values/Transforms/AffineTransform3D.swift b/Sources/SwiftSCAD/Values/Transforms/AffineTransform3D.swift index 1b38fe7..e0f4944 100644 --- a/Sources/SwiftSCAD/Values/Transforms/AffineTransform3D.swift +++ b/Sources/SwiftSCAD/Values/Transforms/AffineTransform3D.swift @@ -4,7 +4,7 @@ import simd #endif /// An `AffineTransform3D` represents a 3D affine transformation using a 4x4 matrix. -public struct AffineTransform3D: AffineTransform, Equatable { +public struct AffineTransform3D: AffineTransform, Equatable, Sendable { private var matrix: Matrix4x4 private init(_ matrix: Matrix4x4) { diff --git a/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix3x3.swift b/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix3x3.swift index 940f831..7840865 100644 --- a/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix3x3.swift +++ b/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix3x3.swift @@ -1,6 +1,6 @@ import Foundation -internal struct BasicMatrix3x3: Equatable { +internal struct BasicMatrix3x3: Equatable, Sendable { typealias Row = [Double] typealias Column = [Double] diff --git a/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix4x4.swift b/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix4x4.swift index acad543..2c9074e 100644 --- a/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix4x4.swift +++ b/Sources/SwiftSCAD/Values/Transforms/Matrix/BasicMatrix4x4.swift @@ -1,6 +1,6 @@ import Foundation -internal struct BasicMatrix4x4: Equatable { +internal struct BasicMatrix4x4: Equatable, Sendable { typealias Row = [Double] typealias Column = [Double] diff --git a/Sources/SwiftSCAD/Values/Vectors/Vector.swift b/Sources/SwiftSCAD/Values/Vectors/Vector.swift index 9fed0ab..299afa5 100644 --- a/Sources/SwiftSCAD/Values/Vectors/Vector.swift +++ b/Sources/SwiftSCAD/Values/Vectors/Vector.swift @@ -1,6 +1,6 @@ import Foundation -public protocol Vector { +public protocol Vector: Sendable { associatedtype Axes: SwiftSCAD.Axes associatedtype Transform: AffineTransform where Transform.Vector == Self diff --git a/Sources/SwiftSCAD/Values/Vectors/Vector2D.swift b/Sources/SwiftSCAD/Values/Vectors/Vector2D.swift index 9e473f7..72addc8 100644 --- a/Sources/SwiftSCAD/Values/Vectors/Vector2D.swift +++ b/Sources/SwiftSCAD/Values/Vectors/Vector2D.swift @@ -8,7 +8,7 @@ import Foundation /// let v2: Vector2D = [10, 15] /// ``` /// -public struct Vector2D: ExpressibleByArrayLiteral, SCADValue, Hashable { +public struct Vector2D: ExpressibleByArrayLiteral, SCADValue, Hashable, Sendable { public var x: Double public var y: Double diff --git a/Sources/SwiftSCAD/Values/Vectors/Vector3D.swift b/Sources/SwiftSCAD/Values/Vectors/Vector3D.swift index e6ee4b0..955bfe2 100644 --- a/Sources/SwiftSCAD/Values/Vectors/Vector3D.swift +++ b/Sources/SwiftSCAD/Values/Vectors/Vector3D.swift @@ -7,7 +7,7 @@ import Foundation /// let v1 = Vector3D(x: 10, y: 15, z: 5) /// let v2: Vector3D = [10, 15, 5] /// ``` -public struct Vector3D: ExpressibleByArrayLiteral, SCADValue, Hashable { +public struct Vector3D: ExpressibleByArrayLiteral, SCADValue, Hashable, Sendable { public var x: Double public var y: Double public var z: Double