Initial Commit
This commit is contained in:
192
Sources/HRW/GenHTML/Elements/Audio.swift
Normal file
192
Sources/HRW/GenHTML/Elements/Audio.swift
Normal file
@@ -0,0 +1,192 @@
|
||||
//
|
||||
// Audio.swift
|
||||
// HTMLStandard
|
||||
//
|
||||
// Generated on 09/23/2025.
|
||||
// THIS FILE IS GENERATED. DO NOT EDIT.
|
||||
//
|
||||
import Foundation
|
||||
|
||||
/// <audio> Audio player
|
||||
public class Audio : HTMLNode, IEmbedded, IFlow, IInteractive, IPalpable, IPhrasing {
|
||||
|
||||
public enum Crossorigin : String, CaseIterable {
|
||||
|
||||
case anonymous
|
||||
case useCredentials = "use-credentials"
|
||||
|
||||
public init?(rawValue: Substring) {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
|
||||
else
|
||||
{ return nil }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: Substring) throws {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == expect })
|
||||
else
|
||||
{ throw AppError("Unexpected value for Crossorigin: \(expect)") }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: String) throws {
|
||||
guard let result = Crossorigin(rawValue: expect) else {
|
||||
throw AppError("Unexpected value for Crossorigin: \(expect)")
|
||||
}
|
||||
self = result
|
||||
}
|
||||
|
||||
static func parseList(_ value:String?, _ separator:String = " ") throws -> [Crossorigin] {
|
||||
guard let value = value else { return [] }
|
||||
var iterator = value.componentsIterator(separatedBy: separator)
|
||||
let result = try iterator.map { input in
|
||||
return try expect(Crossorigin(rawValue: input), "unexpected value for Crossorigin: \(input)")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
public enum Preload : String, CaseIterable {
|
||||
|
||||
case auto
|
||||
case metadata
|
||||
case none
|
||||
|
||||
public init?(rawValue: Substring) {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == rawValue })
|
||||
else
|
||||
{ return nil }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: Substring) throws {
|
||||
guard
|
||||
let value = Self.allCases.first(where: { $0.rawValue == expect })
|
||||
else
|
||||
{ throw AppError("Unexpected value for Preload: \(expect)") }
|
||||
|
||||
self = value
|
||||
}
|
||||
|
||||
public init(expect: String) throws {
|
||||
guard let result = Preload(rawValue: expect) else {
|
||||
throw AppError("Unexpected value for Preload: \(expect)")
|
||||
}
|
||||
self = result
|
||||
}
|
||||
|
||||
static func parseList(_ value:String?, _ separator:String = " ") throws -> [Preload] {
|
||||
guard let value = value else { return [] }
|
||||
var iterator = value.componentsIterator(separatedBy: separator)
|
||||
let result = try iterator.map { input in
|
||||
return try expect(Preload(rawValue: input), "unexpected value for Preload: \(input)")
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
/// Hint that the media resource can be started automatically when the page is loaded.
|
||||
public var autoplay:Bool = false
|
||||
|
||||
/// Show user agent controls.
|
||||
public var controls:Bool = false
|
||||
|
||||
/// How the element handles crossorigin requests.
|
||||
public var crossorigin:Crossorigin? = nil
|
||||
|
||||
/// Whether to loop the media resource.
|
||||
public var loop:Bool = false
|
||||
|
||||
/// Whether to mute the media resource by default.
|
||||
public var muted:Bool = false
|
||||
|
||||
/// Hints how much buffering the media resource will likely need.
|
||||
public var preload:Preload? = nil
|
||||
|
||||
/// Address of the resource. Valid non-empty URL potentially surrounded by spaces.
|
||||
public var src:URL? = nil
|
||||
|
||||
|
||||
public init(_ attributes:[String:String], _ parser:XMLParser? = nil) throws {
|
||||
var globalAttr = GlobalAttributesBuilder()
|
||||
for (key, attValue) in attributes {
|
||||
switch (key) {
|
||||
case "autoplay":
|
||||
autoplay = true
|
||||
continue
|
||||
case "controls":
|
||||
controls = true
|
||||
continue
|
||||
case "crossorigin":
|
||||
crossorigin = try Crossorigin(expect: attValue)
|
||||
continue
|
||||
case "loop":
|
||||
loop = true
|
||||
continue
|
||||
case "muted":
|
||||
muted = true
|
||||
continue
|
||||
case "preload":
|
||||
preload = try Preload(expect: attValue)
|
||||
continue
|
||||
case "src":
|
||||
src = try URL(expect: attValue)
|
||||
continue
|
||||
|
||||
default: break
|
||||
}
|
||||
if globalAttr.trySetGlobalAttribute(key, attValue) {
|
||||
continue
|
||||
}
|
||||
throw AppError("Unexpected attribute: \(key)")
|
||||
}
|
||||
var allItems:[HTMLNode] = []
|
||||
while let obj = try parser?.readObject(endTag: "audio", xmlToHtmlMapper) {
|
||||
allItems.append(obj)
|
||||
}
|
||||
super.init(globalAttr, allItems)
|
||||
}
|
||||
|
||||
|
||||
public override func renderAttributes() -> String {
|
||||
var result = super.renderAttributes()
|
||||
if autoplay {
|
||||
result += " autoplay"
|
||||
}
|
||||
if controls {
|
||||
result += " controls"
|
||||
}
|
||||
if let crossorigin = crossorigin {
|
||||
result += " crossorigin='\(crossorigin.rawValue)'"
|
||||
}
|
||||
if loop {
|
||||
result += " loop"
|
||||
}
|
||||
if muted {
|
||||
result += " muted"
|
||||
}
|
||||
if let preload = preload {
|
||||
result += " preload='\(preload.rawValue)'"
|
||||
}
|
||||
if let src = src {
|
||||
result += " src='\(src.absoluteString)'"
|
||||
}
|
||||
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
override var nodeName: String {
|
||||
return "audio"
|
||||
}
|
||||
|
||||
override var isVoidElement: Bool {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user