diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0076fd3e..c69c7367 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -19,6 +19,7 @@ jobs: brew install swiftwasm/tap/carton + carton bundle --product DOMKitDemo carton test --environment defaultBrowser env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/Sources/DOMKit/WebIDL/Strings.swift b/Sources/DOMKit/WebIDL/Strings.swift index ae59925e..027c07c4 100644 --- a/Sources/DOMKit/WebIDL/Strings.swift +++ b/Sources/DOMKit/WebIDL/Strings.swift @@ -326,6 +326,7 @@ import JavaScriptKit @usableFromInline static let ariaValueText: JSString = "ariaValueText" @usableFromInline static let arrayBuffer: JSString = "arrayBuffer" @usableFromInline static let `as`: JSString = "as" + @usableFromInline static let assert: JSString = "assert" @usableFromInline static let assign: JSString = "assign" @usableFromInline static let assignedElements: JSString = "assignedElements" @usableFromInline static let assignedNodes: JSString = "assignedNodes" @@ -450,6 +451,7 @@ import JavaScriptKit @usableFromInline static let composite: JSString = "composite" @usableFromInline static let computedOffset: JSString = "computedOffset" @usableFromInline static let confirm: JSString = "confirm" + @usableFromInline static let console: JSString = "console" @usableFromInline static let contains: JSString = "contains" @usableFromInline static let content: JSString = "content" @usableFromInline static let contentDocument: JSString = "contentDocument" @@ -463,6 +465,8 @@ import JavaScriptKit @usableFromInline static let cookie: JSString = "cookie" @usableFromInline static let cookieEnabled: JSString = "cookieEnabled" @usableFromInline static let coords: JSString = "coords" + @usableFromInline static let count: JSString = "count" + @usableFromInline static let countReset: JSString = "countReset" @usableFromInline static let createAttribute: JSString = "createAttribute" @usableFromInline static let createAttributeNS: JSString = "createAttributeNS" @usableFromInline static let createCDATASection: JSString = "createCDATASection" @@ -506,6 +510,7 @@ import JavaScriptKit @usableFromInline static let dataTransfer: JSString = "dataTransfer" @usableFromInline static let dataset: JSString = "dataset" @usableFromInline static let dateTime: JSString = "dateTime" + @usableFromInline static let debug: JSString = "debug" @usableFromInline static let declare: JSString = "declare" @usableFromInline static let decode: JSString = "decode" @usableFromInline static let decoding: JSString = "decoding" @@ -543,6 +548,7 @@ import JavaScriptKit @usableFromInline static let dir: JSString = "dir" @usableFromInline static let dirName: JSString = "dirName" @usableFromInline static let direction: JSString = "direction" + @usableFromInline static let dirxml: JSString = "dirxml" @usableFromInline static let disable: JSString = "disable" @usableFromInline static let disabled: JSString = "disabled" @usableFromInline static let disconnect: JSString = "disconnect" @@ -678,6 +684,9 @@ import JavaScriptKit @usableFromInline static let globalAlpha: JSString = "globalAlpha" @usableFromInline static let globalCompositeOperation: JSString = "globalCompositeOperation" @usableFromInline static let go: JSString = "go" + @usableFromInline static let group: JSString = "group" + @usableFromInline static let groupCollapsed: JSString = "groupCollapsed" + @usableFromInline static let groupEnd: JSString = "groupEnd" @usableFromInline static let handled: JSString = "handled" @usableFromInline static let hangingBaseline: JSString = "hangingBaseline" @usableFromInline static let hardwareConcurrency: JSString = "hardwareConcurrency" @@ -723,6 +732,7 @@ import JavaScriptKit @usableFromInline static let indeterminate: JSString = "indeterminate" @usableFromInline static let index: JSString = "index" @usableFromInline static let inert: JSString = "inert" + @usableFromInline static let info: JSString = "info" @usableFromInline static let initCompositionEvent: JSString = "initCompositionEvent" @usableFromInline static let initCustomEvent: JSString = "initCustomEvent" @usableFromInline static let initEvent: JSString = "initEvent" @@ -810,6 +820,7 @@ import JavaScriptKit @usableFromInline static let location: JSString = "location" @usableFromInline static let locationbar: JSString = "locationbar" @usableFromInline static let locked: JSString = "locked" + @usableFromInline static let log: JSString = "log" @usableFromInline static let longDesc: JSString = "longDesc" @usableFromInline static let lookupNamespaceURI: JSString = "lookupNamespaceURI" @usableFromInline static let lookupPrefix: JSString = "lookupPrefix" @@ -1315,6 +1326,7 @@ import JavaScriptKit @usableFromInline static let tFoot: JSString = "tFoot" @usableFromInline static let tHead: JSString = "tHead" @usableFromInline static let tabIndex: JSString = "tabIndex" + @usableFromInline static let table: JSString = "table" @usableFromInline static let tagName: JSString = "tagName" @usableFromInline static let taintEnabled: JSString = "taintEnabled" @usableFromInline static let takeRecords: JSString = "takeRecords" @@ -1330,6 +1342,9 @@ import JavaScriptKit @usableFromInline static let textRendering: JSString = "textRendering" @usableFromInline static let textTracks: JSString = "textTracks" @usableFromInline static let throwIfAborted: JSString = "throwIfAborted" + @usableFromInline static let time: JSString = "time" + @usableFromInline static let timeEnd: JSString = "timeEnd" + @usableFromInline static let timeLog: JSString = "timeLog" @usableFromInline static let timeOrigin: JSString = "timeOrigin" @usableFromInline static let timeStamp: JSString = "timeStamp" @usableFromInline static let timeline: JSString = "timeline" @@ -1347,6 +1362,7 @@ import JavaScriptKit @usableFromInline static let toolbar: JSString = "toolbar" @usableFromInline static let top: JSString = "top" @usableFromInline static let total: JSString = "total" + @usableFromInline static let trace: JSString = "trace" @usableFromInline static let track: JSString = "track" @usableFromInline static let transfer: JSString = "transfer" @usableFromInline static let transferControlToOffscreen: JSString = "transferControlToOffscreen" @@ -1398,6 +1414,7 @@ import JavaScriptKit @usableFromInline static let vspace: JSString = "vspace" @usableFromInline static let w: JSString = "w" @usableFromInline static let waiting: JSString = "waiting" + @usableFromInline static let warn: JSString = "warn" @usableFromInline static let webkitMatchesSelector: JSString = "webkitMatchesSelector" @usableFromInline static let whatToShow: JSString = "whatToShow" @usableFromInline static let whenDefined: JSString = "whenDefined" diff --git a/Sources/DOMKit/WebIDL/console.swift b/Sources/DOMKit/WebIDL/console.swift new file mode 100644 index 00000000..d61e67e0 --- /dev/null +++ b/Sources/DOMKit/WebIDL/console.swift @@ -0,0 +1,105 @@ +// This file was auto-generated by WebIDLToSwift. DO NOT EDIT! + +import JavaScriptEventLoop +import JavaScriptKit + +public enum console { + @inlinable public static var jsObject: JSObject { + JSObject.global[Strings.console].object! + } + + @inlinable public static func assert(condition: Bool? = nil, data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.assert].function!(this: this, arguments: [condition?.jsValue ?? .undefined] + data.map(\.jsValue)) + } + + @inlinable public static func clear() { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.clear].function!(this: this, arguments: []) + } + + @inlinable public static func debug(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.debug].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func error(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.error].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func info(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.info].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func log(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.log].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func table(tabularData: JSValue? = nil, properties: [String]? = nil) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.table].function!(this: this, arguments: [tabularData?.jsValue ?? .undefined, properties?.jsValue ?? .undefined]) + } + + @inlinable public static func trace(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.trace].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func warn(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.warn].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func dir(item: JSValue? = nil, options: JSObject? = nil) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.dir].function!(this: this, arguments: [item?.jsValue ?? .undefined, options?.jsValue ?? .undefined]) + } + + @inlinable public static func dirxml(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.dirxml].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func count(label: String? = nil) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.count].function!(this: this, arguments: [label?.jsValue ?? .undefined]) + } + + @inlinable public static func countReset(label: String? = nil) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.countReset].function!(this: this, arguments: [label?.jsValue ?? .undefined]) + } + + @inlinable public static func group(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.group].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func groupCollapsed(data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.groupCollapsed].function!(this: this, arguments: data.map(\.jsValue)) + } + + @inlinable public static func groupEnd() { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.groupEnd].function!(this: this, arguments: []) + } + + @inlinable public static func time(label: String? = nil) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.time].function!(this: this, arguments: [label?.jsValue ?? .undefined]) + } + + @inlinable public static func timeLog(label: String? = nil, data: JSValue...) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.timeLog].function!(this: this, arguments: [label?.jsValue ?? .undefined] + data.map(\.jsValue)) + } + + @inlinable public static func timeEnd(label: String? = nil) { + let this = JSObject.global[Strings.console].object! + _ = this[Strings.timeEnd].function!(this: this, arguments: [label?.jsValue ?? .undefined]) + } +} diff --git a/Sources/DOMKitDemo/main.swift b/Sources/DOMKitDemo/main.swift index 30bee067..82074f78 100644 --- a/Sources/DOMKitDemo/main.swift +++ b/Sources/DOMKitDemo/main.swift @@ -1,10 +1,10 @@ import JavaScriptKit import DOMKit -let document = global.document +let document = globalThis.document let header = HTMLElement(from: document.createElement(localName: "h1"))! header.innerText = "Hello World!" -_ = document.body.appendChild(node: header) +_ = document.body!.appendChild(node: header) console.log(data: "Hello, world!") diff --git a/parse-idl/parse-all.js b/parse-idl/parse-all.js index c35564cf..a992f772 100644 --- a/parse-idl/parse-all.js +++ b/parse-idl/parse-all.js @@ -22,6 +22,7 @@ console.log( "service-workers", "url", "streams", + "console", ].map((key) => parsedFiles[key]), null, 2