diff --git a/Sources/TokamakDOM/Core.swift b/Sources/TokamakDOM/Core.swift new file mode 100644 index 00000000..ef47c17d --- /dev/null +++ b/Sources/TokamakDOM/Core.swift @@ -0,0 +1,110 @@ +// Copyright 2020 Tokamak contributors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Created by Jed Fox on 7/18/20. +// + +import TokamakCore + +// MARK: Environment & State + +public typealias Environment = TokamakCore.Environment +public typealias EnvironmentObject = TokamakCore.EnvironmentObject + +public typealias ObservableObject = TokamakCore.ObservableObject +public typealias ObservedObject = TokamakCore.ObservedObject +public typealias Published = TokamakCore.Published +public typealias State = TokamakCore.State + +// MARK: Modifiers & Styles + +public typealias ViewModifier = TokamakCore.ViewModifier +public typealias ModifiedContent = TokamakCore.ModifiedContent + +public typealias DefaultTextFieldStyle = TokamakCore.DefaultTextFieldStyle +public typealias PlainTextFieldStyle = TokamakCore.PlainTextFieldStyle +public typealias RoundedBorderTextFieldStyle = TokamakCore.RoundedBorderTextFieldStyle +public typealias SquareBorderTextFieldStyle = TokamakCore.SquareBorderTextFieldStyle + +public typealias DefaultListStyle = TokamakCore.DefaultListStyle +public typealias PlainListStyle = TokamakCore.PlainListStyle +public typealias InsetListStyle = TokamakCore.InsetListStyle +public typealias GroupedListStyle = TokamakCore.GroupedListStyle +public typealias InsetGroupedListStyle = TokamakCore.InsetGroupedListStyle + +public typealias DefaultPickerStyle = TokamakCore.DefaultPickerStyle +public typealias PopUpButtonPickerStyle = TokamakCore.PopUpButtonPickerStyle +public typealias RadioGroupPickerStyle = TokamakCore.RadioGroupPickerStyle +public typealias SegmentedPickerStyle = TokamakCore.SegmentedPickerStyle +public typealias WheelPickerStyle = TokamakCore.WheelPickerStyle + +// MARK: Shapes + +public typealias Shape = TokamakCore.Shape + +public typealias Capsule = TokamakCore.Capsule +public typealias Circle = TokamakCore.Circle +public typealias Ellipse = TokamakCore.Ellipse +public typealias Path = TokamakCore.Path +public typealias Rectangle = TokamakCore.Rectangle +public typealias RoundedRectangle = TokamakCore.RoundedRectangle + +// MARK: Primitive values + +public typealias Color = TokamakCore.Color +public typealias Font = TokamakCore.Font + +public typealias CGAffineTransform = TokamakCore.CGAffineTransform +public typealias CGPoint = TokamakCore.CGPoint +public typealias CGRect = TokamakCore.CGRect +public typealias CGSize = TokamakCore.CGSize + +// MARK: Views + +public typealias Button = TokamakCore.Button +public typealias DisclosureGroup = TokamakCore.DisclosureGroup +public typealias Divider = TokamakCore.Divider +public typealias ForEach = TokamakCore.ForEach +public typealias GridItem = TokamakCore.GridItem +public typealias Group = TokamakCore.Group +public typealias HStack = TokamakCore.HStack +public typealias LazyHGrid = TokamakCore.LazyHGrid +public typealias LazyVGrid = TokamakCore.LazyVGrid +public typealias List = TokamakCore.List +public typealias OutlineGroup = TokamakCore.OutlineGroup +public typealias Picker = TokamakCore.Picker +public typealias ScrollView = TokamakCore.ScrollView +public typealias Section = TokamakCore.Section +public typealias SecureField = TokamakCore.SecureField +public typealias Spacer = TokamakCore.Spacer +public typealias Text = TokamakCore.Text +public typealias TextField = TokamakCore.TextField +public typealias VStack = TokamakCore.VStack +public typealias ZStack = TokamakCore.ZStack + +// MARK: Special Views + +public typealias View = TokamakCore.View +public typealias AnyView = TokamakCore.AnyView +public typealias EmptyView = TokamakCore.EmptyView + +// MARK: Misc + +// FIXME: I would put this inside TokamakCore, but for +// some reason it doesn't get exported with the typealias +extension Text { + public static func + (lhs: Self, rhs: Self) -> Self { + _concatenating(lhs: lhs, rhs: rhs) + } +} diff --git a/Sources/TokamakDOM/Environment/Environment.swift b/Sources/TokamakDOM/Environment/Environment.swift deleted file mode 100644 index a37429b8..00000000 --- a/Sources/TokamakDOM/Environment/Environment.swift +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2020 Tokamak contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Created by Carson Katri on 6/30/20. -// - -import TokamakCore - -public typealias Environment = TokamakCore.Environment -public typealias EnvironmentObject = TokamakCore.EnvironmentObject diff --git a/Sources/TokamakDOM/Modifiers/ViewModifier.swift b/Sources/TokamakDOM/Modifiers/ViewModifier.swift index 6cdd0981..d4c6e079 100644 --- a/Sources/TokamakDOM/Modifiers/ViewModifier.swift +++ b/Sources/TokamakDOM/Modifiers/ViewModifier.swift @@ -14,9 +14,6 @@ import TokamakCore -public typealias ViewModifier = TokamakCore.ViewModifier -public typealias ModifiedContent = TokamakCore.ModifiedContent - public protocol DOMViewModifier { var attributes: [String: String] { get } /// Can the modifier be flattened? diff --git a/Sources/TokamakDOM/Shapes/Path.swift b/Sources/TokamakDOM/Shapes/Path.swift index 55c37037..27f21a72 100644 --- a/Sources/TokamakDOM/Shapes/Path.swift +++ b/Sources/TokamakDOM/Shapes/Path.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias Path = TokamakCore.Path - extension Path: ViewDeferredToRenderer { // TODO: Support transformations func svgFrom(storage: Storage, diff --git a/Sources/TokamakDOM/Shapes/Shape.swift b/Sources/TokamakDOM/Shapes/Shape.swift index 5d4a5c17..8b26a03b 100644 --- a/Sources/TokamakDOM/Shapes/Shape.swift +++ b/Sources/TokamakDOM/Shapes/Shape.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias Shape = TokamakCore.Shape - // Border modifier extension _OverlayModifier: DOMViewModifier where Overlay == _ShapeView<_StrokedShape, Color> { diff --git a/Sources/TokamakDOM/Shapes/_ShapeView.swift b/Sources/TokamakDOM/Shapes/_ShapeView.swift index 6ea3d11c..45d0d093 100644 --- a/Sources/TokamakDOM/Shapes/_ShapeView.swift +++ b/Sources/TokamakDOM/Shapes/_ShapeView.swift @@ -43,9 +43,3 @@ extension _ShapeView: ViewDeferredToRenderer { } } } - -public typealias Rectangle = TokamakCore.Rectangle -public typealias RoundedRectangle = TokamakCore.RoundedRectangle -public typealias Ellipse = TokamakCore.Ellipse -public typealias Circle = TokamakCore.Circle -public typealias Capsule = TokamakCore.Capsule diff --git a/Sources/TokamakDOM/Styles/Styles.swift b/Sources/TokamakDOM/Styles/Styles.swift deleted file mode 100644 index dddd748a..00000000 --- a/Sources/TokamakDOM/Styles/Styles.swift +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2020 Tokamak contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Created by Jed Fox on 06/30/2020. -// - -import TokamakCore - -public typealias DefaultTextFieldStyle = TokamakCore.DefaultTextFieldStyle -public typealias PlainTextFieldStyle = TokamakCore.PlainTextFieldStyle -public typealias RoundedBorderTextFieldStyle = TokamakCore.RoundedBorderTextFieldStyle -public typealias SquareBorderTextFieldStyle = TokamakCore.SquareBorderTextFieldStyle - -public typealias DefaultListStyle = TokamakCore.DefaultListStyle -public typealias PlainListStyle = TokamakCore.PlainListStyle -public typealias InsetListStyle = TokamakCore.InsetListStyle -public typealias GroupedListStyle = TokamakCore.GroupedListStyle -public typealias InsetGroupedListStyle = TokamakCore.InsetGroupedListStyle diff --git a/Sources/TokamakDOM/Tokens/Tokens.swift b/Sources/TokamakDOM/Tokens/Tokens.swift index e605fc51..7de73cc8 100644 --- a/Sources/TokamakDOM/Tokens/Tokens.swift +++ b/Sources/TokamakDOM/Tokens/Tokens.swift @@ -14,22 +14,12 @@ import TokamakCore -public typealias Font = TokamakCore.Font -public typealias Color = TokamakCore.Color - extension Color: CustomStringConvertible { public var description: String { "rgb(\(red * 255), \(green * 255), \(blue * 255), \(opacity * 255))" } } -public typealias CGRect = TokamakCore.CGRect -public typealias CGPoint = TokamakCore.CGPoint -public typealias CGSize = TokamakCore.CGSize -public typealias CGAffineTransform = TokamakCore.CGAffineTransform - -public typealias GridItem = TokamakCore.GridItem - extension GridItem: CustomStringConvertible { public var description: String { switch size { diff --git a/Sources/TokamakDOM/Views/Button.swift b/Sources/TokamakDOM/Views/Button.swift index cb8965ae..49bea4c8 100644 --- a/Sources/TokamakDOM/Views/Button.swift +++ b/Sources/TokamakDOM/Views/Button.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias Button = TokamakCore.Button - extension Button: ViewDeferredToRenderer where Label == Text { public var deferredBody: AnyView { AnyView(HTML("button", listeners: ["click": { _ in _ButtonProxy(self).action() }]) { diff --git a/Sources/TokamakDOM/Views/DisclosureGroup.swift b/Sources/TokamakDOM/Views/DisclosureGroup.swift index 2796f180..6b09857f 100644 --- a/Sources/TokamakDOM/Views/DisclosureGroup.swift +++ b/Sources/TokamakDOM/Views/DisclosureGroup.swift @@ -17,9 +17,6 @@ import TokamakCore -public typealias DisclosureGroup = TokamakCore.DisclosureGroup -public typealias OutlineGroup = TokamakCore.OutlineGroup - extension DisclosureGroup: ViewDeferredToRenderer { var chevron: some View { HTML("div", diff --git a/Sources/TokamakDOM/Views/Divider.swift b/Sources/TokamakDOM/Views/Divider.swift index 0cec9b49..8dc959b7 100644 --- a/Sources/TokamakDOM/Views/Divider.swift +++ b/Sources/TokamakDOM/Views/Divider.swift @@ -14,8 +14,6 @@ import TokamakCore -public typealias Divider = TokamakCore.Divider - extension Divider: AnyHTML { var innerHTML: String? { nil } var tag: String { "hr" } diff --git a/Sources/TokamakDOM/Views/ForEach.swift b/Sources/TokamakDOM/Views/ForEach.swift deleted file mode 100644 index c2cfd5dd..00000000 --- a/Sources/TokamakDOM/Views/ForEach.swift +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2020 Tokamak contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import TokamakCore - -public typealias ForEach = TokamakCore.ForEach diff --git a/Sources/TokamakDOM/Views/Group.swift b/Sources/TokamakDOM/Views/Group.swift deleted file mode 100644 index 01cb28ec..00000000 --- a/Sources/TokamakDOM/Views/Group.swift +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright 2020 Tokamak contributors -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import TokamakCore - -public typealias Group = TokamakCore.Group diff --git a/Sources/TokamakDOM/Views/HStack.swift b/Sources/TokamakDOM/Views/HStack.swift index 049978ba..0139fb53 100644 --- a/Sources/TokamakDOM/Views/HStack.swift +++ b/Sources/TokamakDOM/Views/HStack.swift @@ -14,8 +14,6 @@ import TokamakCore -public typealias HStack = TokamakCore.HStack - extension VerticalAlignment { var cssValue: String { switch self { diff --git a/Sources/TokamakDOM/Views/HTML.swift b/Sources/TokamakDOM/Views/HTML.swift index 4bdf1a55..366cea43 100644 --- a/Sources/TokamakDOM/Views/HTML.swift +++ b/Sources/TokamakDOM/Views/HTML.swift @@ -20,14 +20,6 @@ import TokamakCore public typealias Listener = (JSObjectRef) -> () -public typealias View = TokamakCore.View -public typealias AnyView = TokamakCore.AnyView -public typealias EmptyView = TokamakCore.EmptyView -public typealias State = TokamakCore.State -public typealias ObservableObject = TokamakCore.ObservableObject -public typealias Published = TokamakCore.Published -public typealias ObservedObject = TokamakCore.ObservedObject - protocol AnyHTML { var innerHTML: String? { get } var tag: String { get } diff --git a/Sources/TokamakDOM/Views/LazyHGrid.swift b/Sources/TokamakDOM/Views/LazyHGrid.swift index ebd74959..f7f9177e 100644 --- a/Sources/TokamakDOM/Views/LazyHGrid.swift +++ b/Sources/TokamakDOM/Views/LazyHGrid.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias LazyHGrid = TokamakCore.LazyHGrid - extension LazyHGrid: SpacerContainer { var axis: SpacerContainerAxis { .horizontal } var hasSpacer: Bool { false } diff --git a/Sources/TokamakDOM/Views/LazyVGrid.swift b/Sources/TokamakDOM/Views/LazyVGrid.swift index b9be6c56..a18279e1 100644 --- a/Sources/TokamakDOM/Views/LazyVGrid.swift +++ b/Sources/TokamakDOM/Views/LazyVGrid.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias LazyVGrid = TokamakCore.LazyVGrid - extension LazyVGrid: SpacerContainer { var axis: SpacerContainerAxis { .vertical } var hasSpacer: Bool { false } diff --git a/Sources/TokamakDOM/Views/List.swift b/Sources/TokamakDOM/Views/List.swift index fda6fea5..7556672a 100644 --- a/Sources/TokamakDOM/Views/List.swift +++ b/Sources/TokamakDOM/Views/List.swift @@ -14,9 +14,6 @@ import TokamakCore -public typealias List = TokamakCore.List -public typealias Section = TokamakCore.Section - extension PlainListStyle: ListStyleDeferredToRenderer { public func sectionHeader
(_ header: Header) -> AnyView where Header: View { AnyView(header diff --git a/Sources/TokamakDOM/Views/Picker.swift b/Sources/TokamakDOM/Views/Picker.swift index 05c2939f..5fa076e5 100644 --- a/Sources/TokamakDOM/Views/Picker.swift +++ b/Sources/TokamakDOM/Views/Picker.swift @@ -15,13 +15,6 @@ import JavaScriptKit import TokamakCore -public typealias Picker = TokamakCore.Picker -public typealias PopUpButtonPickerStyle = TokamakCore.PopUpButtonPickerStyle -public typealias RadioGroupPickerStyle = TokamakCore.RadioGroupPickerStyle -public typealias SegmentedPickerStyle = TokamakCore.SegmentedPickerStyle -public typealias WheelPickerStyle = TokamakCore.WheelPickerStyle -public typealias DefaultPickerStyle = TokamakCore.DefaultPickerStyle - extension _PickerContainer: ViewDeferredToRenderer { public var deferredBody: AnyView { AnyView(HTML("label") { diff --git a/Sources/TokamakDOM/Views/ScrollView.swift b/Sources/TokamakDOM/Views/ScrollView.swift index 85b70b75..b9d873e7 100644 --- a/Sources/TokamakDOM/Views/ScrollView.swift +++ b/Sources/TokamakDOM/Views/ScrollView.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias ScrollView = TokamakCore.ScrollView - extension ScrollView: ViewDeferredToRenderer, SpacerContainer { var axis: SpacerContainerAxis { if axes.contains(.horizontal) { diff --git a/Sources/TokamakDOM/Views/SecureField.swift b/Sources/TokamakDOM/Views/SecureField.swift index d804f179..18018e69 100644 --- a/Sources/TokamakDOM/Views/SecureField.swift +++ b/Sources/TokamakDOM/Views/SecureField.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias SecureField = TokamakCore.SecureField - extension SecureField: ViewDeferredToRenderer where Label == Text { public var deferredBody: AnyView { let proxy = _SecureFieldProxy(self) diff --git a/Sources/TokamakDOM/Views/Spacer.swift b/Sources/TokamakDOM/Views/Spacer.swift index c2397127..0ba11a88 100644 --- a/Sources/TokamakDOM/Views/Spacer.swift +++ b/Sources/TokamakDOM/Views/Spacer.swift @@ -14,8 +14,6 @@ import TokamakCore -public typealias Spacer = TokamakCore.Spacer - enum SpacerContainerAxis { case horizontal, vertical } diff --git a/Sources/TokamakDOM/Views/Text.swift b/Sources/TokamakDOM/Views/Text.swift index 628c1607..5eba4924 100644 --- a/Sources/TokamakDOM/Views/Text.swift +++ b/Sources/TokamakDOM/Views/Text.swift @@ -15,16 +15,6 @@ import JavaScriptKit import TokamakCore -public typealias Text = TokamakCore.Text - -// FIXME: I would put this inside TokamakCore, but for -// some reason it doesn't get exported with the typealias -extension Text { - public static func + (lhs: Self, rhs: Self) -> Self { - _concatenating(lhs: lhs, rhs: rhs) - } -} - extension Font.Design: CustomStringConvertible { /// Some default font stacks for the various designs public var description: String { diff --git a/Sources/TokamakDOM/Views/TextField.swift b/Sources/TokamakDOM/Views/TextField.swift index 9af05c09..d0c4dbcb 100644 --- a/Sources/TokamakDOM/Views/TextField.swift +++ b/Sources/TokamakDOM/Views/TextField.swift @@ -17,8 +17,6 @@ import TokamakCore -public typealias TextField = TokamakCore.TextField - func css(for style: TextFieldStyle) -> String { if style is PlainTextFieldStyle { return """ diff --git a/Sources/TokamakDOM/Views/VStack.swift b/Sources/TokamakDOM/Views/VStack.swift index 885b9af6..36371d7b 100644 --- a/Sources/TokamakDOM/Views/VStack.swift +++ b/Sources/TokamakDOM/Views/VStack.swift @@ -14,8 +14,6 @@ import TokamakCore -public typealias VStack = TokamakCore.VStack - extension HorizontalAlignment { var cssValue: String { switch self { diff --git a/Sources/TokamakDOM/Views/ZStack.swift b/Sources/TokamakDOM/Views/ZStack.swift index 7181345f..c7451188 100644 --- a/Sources/TokamakDOM/Views/ZStack.swift +++ b/Sources/TokamakDOM/Views/ZStack.swift @@ -14,8 +14,6 @@ import TokamakCore -public typealias ZStack = TokamakCore.ZStack - struct _ZStack_ContentGridItem: ViewModifier, DOMViewModifier { let attributes = ["style": "grid-area: a;"] @@ -35,7 +33,10 @@ extension ZStack: ViewDeferredToRenderer { align-items: \(alignment.vertical.cssValue) """, ]) { - TupleView(children, children: children.map { AnyView($0.modifier(_ZStack_ContentGridItem())) }) + TupleView( + children, + children: children.map { AnyView($0.modifier(_ZStack_ContentGridItem())) } + ) }) } }