|
1 |
| -// Generated using SwiftGen, by O.Halligon — https://github.com/SwiftGen/SwiftGen |
| 1 | +// swiftlint:disable all |
| 2 | +// Generated using SwiftGen — https://github.com/SwiftGen/SwiftGen |
2 | 3 |
|
3 |
| -#if os(OSX) |
4 |
| - import AppKit.NSImage |
5 |
| - internal typealias AssetColorTypeAlias = NSColor |
6 |
| - internal typealias Image = NSImage |
7 |
| -#elseif os(iOS) || os(tvOS) || os(watchOS) |
8 |
| - import UIKit.UIImage |
9 |
| - internal typealias AssetColorTypeAlias = UIColor |
10 |
| - internal typealias Image = UIImage |
| 4 | +#if os(macOS) |
| 5 | + import AppKit |
| 6 | +#elseif os(iOS) |
| 7 | + import UIKit |
| 8 | +#elseif os(tvOS) || os(watchOS) |
| 9 | + import UIKit |
11 | 10 | #endif
|
12 | 11 |
|
13 |
| -// swiftlint:disable superfluous_disable_command |
14 |
| -// swiftlint:disable file_length |
| 12 | +// Deprecated typealiases |
| 13 | +@available(*, deprecated, renamed: "ImageAsset.Image", message: "This typealias will be removed in SwiftGen 7.0") |
| 14 | +internal typealias AssetImageTypeAlias = ImageAsset.Image |
| 15 | + |
| 16 | +// swiftlint:disable superfluous_disable_command file_length implicit_return |
| 17 | + |
| 18 | +// MARK: - Asset Catalogs |
| 19 | + |
| 20 | +// swiftlint:disable identifier_name line_length nesting type_body_length type_name |
| 21 | +internal enum Asset { |
| 22 | + internal static let iconFolder = ImageAsset(name: "icon_folder") |
| 23 | + internal static let iconText = ImageAsset(name: "icon_text") |
| 24 | + internal static let prefBeta = ImageAsset(name: "pref_beta") |
| 25 | + internal static let prefBetaOn = ImageAsset(name: "pref_beta_on") |
| 26 | + internal static let prefExcluded = ImageAsset(name: "pref_excluded") |
| 27 | + internal static let prefExcludedOn = ImageAsset(name: "pref_excluded_on") |
| 28 | + internal static let prefGeneral = ImageAsset(name: "pref_general") |
| 29 | + internal static let prefGeneralOn = ImageAsset(name: "pref_general_on") |
| 30 | + internal static let prefMenu = ImageAsset(name: "pref_menu") |
| 31 | + internal static let prefMenuOn = ImageAsset(name: "pref_menu_on") |
| 32 | + internal static let prefShortcut = ImageAsset(name: "pref_shortcut") |
| 33 | + internal static let prefShortcutOn = ImageAsset(name: "pref_shortcut_on") |
| 34 | + internal static let prefType = ImageAsset(name: "pref_type") |
| 35 | + internal static let prefTypeOn = ImageAsset(name: "pref_type_on") |
| 36 | + internal static let prefUpdate = ImageAsset(name: "pref_update") |
| 37 | + internal static let prefUpdateOn = ImageAsset(name: "pref_update_on") |
| 38 | + internal static let snippetsAddFolder = ImageAsset(name: "snippets_add_folder") |
| 39 | + internal static let snippetsAddFolderOn = ImageAsset(name: "snippets_add_folder_on") |
| 40 | + internal static let snippetsAddSnippet = ImageAsset(name: "snippets_add_snippet") |
| 41 | + internal static let snippetsAddSnippetOn = ImageAsset(name: "snippets_add_snippet_on") |
| 42 | + internal static let snippetsDeleteSnippet = ImageAsset(name: "snippets_delete_snippet") |
| 43 | + internal static let snippetsDeleteSnippetOn = ImageAsset(name: "snippets_delete_snippet_on") |
| 44 | + internal static let snippetsEnableSnippet = ImageAsset(name: "snippets_enable_snippet") |
| 45 | + internal static let snippetsEnableSnippetOn = ImageAsset(name: "snippets_enable_snippet_on") |
| 46 | + internal static let snippetsExport = ImageAsset(name: "snippets_export") |
| 47 | + internal static let snippetsExportOn = ImageAsset(name: "snippets_export_on") |
| 48 | + internal static let snippetsIconFolderBlue = ImageAsset(name: "snippets_icon_folder_blue") |
| 49 | + internal static let snippetsIconFolderWhite = ImageAsset(name: "snippets_icon_folder_white") |
| 50 | + internal static let snippetsImport = ImageAsset(name: "snippets_import") |
| 51 | + internal static let snippetsImportOn = ImageAsset(name: "snippets_import_on") |
| 52 | + internal static let statusbarMenuBlack = ImageAsset(name: "statusbar_menu_black") |
| 53 | + internal static let statusbarMenuWhite = ImageAsset(name: "statusbar_menu_white") |
| 54 | +} |
| 55 | +// swiftlint:enable identifier_name line_length nesting type_body_length type_name |
15 | 56 |
|
16 |
| -@available(*, deprecated, renamed: "ImageAsset") |
17 |
| -internal typealias AssetType = ImageAsset |
| 57 | +// MARK: - Implementation Details |
18 | 58 |
|
19 | 59 | internal struct ImageAsset {
|
20 | 60 | internal fileprivate(set) var name: String
|
21 | 61 |
|
| 62 | + #if os(macOS) |
| 63 | + internal typealias Image = NSImage |
| 64 | + #elseif os(iOS) || os(tvOS) || os(watchOS) |
| 65 | + internal typealias Image = UIImage |
| 66 | + #endif |
| 67 | + |
22 | 68 | internal var image: Image {
|
23 |
| - let bundle = Bundle(for: BundleToken.self) |
| 69 | + let bundle = BundleToken.bundle |
24 | 70 | #if os(iOS) || os(tvOS)
|
25 | 71 | let image = Image(named: name, in: bundle, compatibleWith: nil)
|
26 |
| - #elseif os(OSX) |
27 |
| - let image = bundle.image(forResource: NSImage.Name(name)) |
| 72 | + #elseif os(macOS) |
| 73 | + let name = NSImage.Name(self.name) |
| 74 | + let image = (bundle == .main) ? NSImage(named: name) : bundle.image(forResource: name) |
28 | 75 | #elseif os(watchOS)
|
29 | 76 | let image = Image(named: name)
|
30 | 77 | #endif
|
31 |
| - guard let result = image else { fatalError("Unable to load image named \(name).") } |
| 78 | + guard let result = image else { |
| 79 | + fatalError("Unable to load image named \(name).") |
| 80 | + } |
32 | 81 | return result
|
33 | 82 | }
|
34 | 83 | }
|
35 | 84 |
|
36 |
| -internal struct ColorAsset { |
37 |
| - internal fileprivate(set) var name: String |
38 |
| - |
39 |
| - @available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *) |
40 |
| - internal var color: AssetColorTypeAlias { |
41 |
| - return AssetColorTypeAlias(asset: self) |
42 |
| - } |
43 |
| -} |
44 |
| - |
45 |
| -// swiftlint:disable identifier_name line_length nesting type_body_length type_name |
46 |
| -internal enum Asset { |
47 |
| - internal enum Common { |
48 |
| - internal static let iconFolder = ImageAsset(name: "icon_folder") |
49 |
| - internal static let iconText = ImageAsset(name: "icon_text") |
50 |
| - } |
51 |
| - internal enum Preference { |
52 |
| - internal static let prefBeta = ImageAsset(name: "pref_beta") |
53 |
| - internal static let prefBetaOn = ImageAsset(name: "pref_beta_on") |
54 |
| - internal static let prefExcluded = ImageAsset(name: "pref_excluded") |
55 |
| - internal static let prefExcludedOn = ImageAsset(name: "pref_excluded_on") |
56 |
| - internal static let prefGeneral = ImageAsset(name: "pref_general") |
57 |
| - internal static let prefGeneralOn = ImageAsset(name: "pref_general_on") |
58 |
| - internal static let prefMenu = ImageAsset(name: "pref_menu") |
59 |
| - internal static let prefMenuOn = ImageAsset(name: "pref_menu_on") |
60 |
| - internal static let prefShortcut = ImageAsset(name: "pref_shortcut") |
61 |
| - internal static let prefShortcutOn = ImageAsset(name: "pref_shortcut_on") |
62 |
| - internal static let prefType = ImageAsset(name: "pref_type") |
63 |
| - internal static let prefTypeOn = ImageAsset(name: "pref_type_on") |
64 |
| - internal static let prefUpdate = ImageAsset(name: "pref_update") |
65 |
| - internal static let prefUpdateOn = ImageAsset(name: "pref_update_on") |
66 |
| - } |
67 |
| - internal enum SnippetEditor { |
68 |
| - internal static let snippetsAddFolder = ImageAsset(name: "snippets_add_folder") |
69 |
| - internal static let snippetsAddFolderOn = ImageAsset(name: "snippets_add_folder_on") |
70 |
| - internal static let snippetsAddSnippet = ImageAsset(name: "snippets_add_snippet") |
71 |
| - internal static let snippetsAddSnippetOn = ImageAsset(name: "snippets_add_snippet_on") |
72 |
| - internal static let snippetsDeleteSnippet = ImageAsset(name: "snippets_delete_snippet") |
73 |
| - internal static let snippetsDeleteSnippetOn = ImageAsset(name: "snippets_delete_snippet_on") |
74 |
| - internal static let snippetsEnableSnippet = ImageAsset(name: "snippets_enable_snippet") |
75 |
| - internal static let snippetsEnableSnippetOn = ImageAsset(name: "snippets_enable_snippet_on") |
76 |
| - internal static let snippetsExport = ImageAsset(name: "snippets_export") |
77 |
| - internal static let snippetsExportOn = ImageAsset(name: "snippets_export_on") |
78 |
| - internal static let snippetsIconFolderBlue = ImageAsset(name: "snippets_icon_folder_blue") |
79 |
| - internal static let snippetsIconFolderWhite = ImageAsset(name: "snippets_icon_folder_white") |
80 |
| - internal static let snippetsImport = ImageAsset(name: "snippets_import") |
81 |
| - internal static let snippetsImportOn = ImageAsset(name: "snippets_import_on") |
82 |
| - } |
83 |
| - internal enum StatusIcon { |
84 |
| - internal static let statusbarMenuBlack = ImageAsset(name: "statusbar_menu_black") |
85 |
| - internal static let statusbarMenuWhite = ImageAsset(name: "statusbar_menu_white") |
86 |
| - } |
87 |
| - |
88 |
| - // swiftlint:disable trailing_comma |
89 |
| - internal static let allColors: [ColorAsset] = [ |
90 |
| - ] |
91 |
| - internal static let allImages: [ImageAsset] = [ |
92 |
| - Common.iconFolder, |
93 |
| - Common.iconText, |
94 |
| - Preference.prefBeta, |
95 |
| - Preference.prefBetaOn, |
96 |
| - Preference.prefExcluded, |
97 |
| - Preference.prefExcludedOn, |
98 |
| - Preference.prefGeneral, |
99 |
| - Preference.prefGeneralOn, |
100 |
| - Preference.prefMenu, |
101 |
| - Preference.prefMenuOn, |
102 |
| - Preference.prefShortcut, |
103 |
| - Preference.prefShortcutOn, |
104 |
| - Preference.prefType, |
105 |
| - Preference.prefTypeOn, |
106 |
| - Preference.prefUpdate, |
107 |
| - Preference.prefUpdateOn, |
108 |
| - SnippetEditor.snippetsAddFolder, |
109 |
| - SnippetEditor.snippetsAddFolderOn, |
110 |
| - SnippetEditor.snippetsAddSnippet, |
111 |
| - SnippetEditor.snippetsAddSnippetOn, |
112 |
| - SnippetEditor.snippetsDeleteSnippet, |
113 |
| - SnippetEditor.snippetsDeleteSnippetOn, |
114 |
| - SnippetEditor.snippetsEnableSnippet, |
115 |
| - SnippetEditor.snippetsEnableSnippetOn, |
116 |
| - SnippetEditor.snippetsExport, |
117 |
| - SnippetEditor.snippetsExportOn, |
118 |
| - SnippetEditor.snippetsIconFolderBlue, |
119 |
| - SnippetEditor.snippetsIconFolderWhite, |
120 |
| - SnippetEditor.snippetsImport, |
121 |
| - SnippetEditor.snippetsImportOn, |
122 |
| - StatusIcon.statusbarMenuBlack, |
123 |
| - StatusIcon.statusbarMenuWhite, |
124 |
| - ] |
125 |
| - // swiftlint:enable trailing_comma |
126 |
| - @available(*, deprecated, renamed: "allImages") |
127 |
| - internal static let allValues: [AssetType] = allImages |
128 |
| -} |
129 |
| -// swiftlint:enable identifier_name line_length nesting type_body_length type_name |
130 |
| - |
131 |
| -internal extension Image { |
132 |
| - @available(iOS 1.0, tvOS 1.0, watchOS 1.0, *) |
133 |
| - @available(OSX, deprecated, |
| 85 | +internal extension ImageAsset.Image { |
| 86 | + @available(macOS, deprecated, |
134 | 87 | message: "This initializer is unsafe on macOS, please use the ImageAsset.image property")
|
135 | 88 | convenience init!(asset: ImageAsset) {
|
136 | 89 | #if os(iOS) || os(tvOS)
|
137 |
| - let bundle = Bundle(for: BundleToken.self) |
| 90 | + let bundle = BundleToken.bundle |
138 | 91 | self.init(named: asset.name, in: bundle, compatibleWith: nil)
|
139 |
| - #elseif os(OSX) |
| 92 | + #elseif os(macOS) |
140 | 93 | self.init(named: NSImage.Name(asset.name))
|
141 | 94 | #elseif os(watchOS)
|
142 | 95 | self.init(named: asset.name)
|
143 | 96 | #endif
|
144 | 97 | }
|
145 | 98 | }
|
146 | 99 |
|
147 |
| -internal extension AssetColorTypeAlias { |
148 |
| - @available(iOS 11.0, tvOS 11.0, watchOS 4.0, OSX 10.13, *) |
149 |
| - convenience init!(asset: ColorAsset) { |
150 |
| - let bundle = Bundle(for: BundleToken.self) |
151 |
| - #if os(iOS) || os(tvOS) |
152 |
| - self.init(named: asset.name, in: bundle, compatibleWith: nil) |
153 |
| - #elseif os(OSX) |
154 |
| - self.init(named: NSColor.Name(asset.name), bundle: bundle) |
155 |
| - #elseif os(watchOS) |
156 |
| - self.init(named: asset.name) |
| 100 | +// swiftlint:disable convenience_type |
| 101 | +private final class BundleToken { |
| 102 | + static let bundle: Bundle = { |
| 103 | + #if SWIFT_PACKAGE |
| 104 | + return Bundle.module |
| 105 | + #else |
| 106 | + return Bundle(for: BundleToken.self) |
157 | 107 | #endif
|
158 |
| - } |
| 108 | + }() |
159 | 109 | }
|
160 |
| - |
161 |
| -private final class BundleToken {} |
| 110 | +// swiftlint:enable convenience_type |
0 commit comments