Skip to content

Commit

Permalink
Add console, fix DOMKitDemo build (#21)
Browse files Browse the repository at this point in the history
This shouldn't conflict much with #19, as it generates a single `console.swift` file.

Co-authored-by: Jed Fox <[email protected]>
  • Loading branch information
MaxDesiatov and j-f1 authored May 2, 2022
1 parent b56e5fc commit 7aff5d8
Show file tree
Hide file tree
Showing 5 changed files with 126 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
brew install swiftwasm/tap/carton
carton bundle --product DOMKitDemo
carton test --environment defaultBrowser
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions Sources/DOMKit/WebIDL/Strings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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"
Expand Down
105 changes: 105 additions & 0 deletions Sources/DOMKit/WebIDL/console.swift
Original file line number Diff line number Diff line change
@@ -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])
}
}
4 changes: 2 additions & 2 deletions Sources/DOMKitDemo/main.swift
Original file line number Diff line number Diff line change
@@ -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!")
1 change: 1 addition & 0 deletions parse-idl/parse-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ console.log(
"service-workers",
"url",
"streams",
"console",
].map((key) => parsedFiles[key]),
null,
2
Expand Down

0 comments on commit 7aff5d8

Please sign in to comment.