diff --git a/BrowserTests/Package.swift b/BrowserTests/Package.swift index 8e7a3ae..f3662da 100644 --- a/BrowserTests/Package.swift +++ b/BrowserTests/Package.swift @@ -24,7 +24,10 @@ addPage(name: "QSComponents") addPage(name: "QSMarkup") addPage(name: "QSDisplayingData") addPage(name: "QSConditional") -addPage(name: "QSRenderingLists") +addPage(name: "QSLists") +addPage(name: "QSEvents") +addPage(name: "QSUpdating") +addPage(name: "QSSharing") let package = Package( name: "BrowserTests", diff --git a/BrowserTests/Sources/BRTSupport/RenderRoot.swift b/BrowserTests/Sources/BRTSupport/RenderRoot.swift index 0d0f292..8a085c4 100644 --- a/BrowserTests/Sources/BRTSupport/RenderRoot.swift +++ b/BrowserTests/Sources/BRTSupport/RenderRoot.swift @@ -2,8 +2,11 @@ import React import JavaScriptKit import SRTDOM +public var root: ReactRoot? = nil + public func renderRoot(component: some Component) throws { let body = try JSWindow.global.document.body.unwrap("body") let root = ReactRoot(element: body) + BRTSupport.root = root root.render(node: component) } diff --git a/BrowserTests/Sources/BRTSupport/common.css b/BrowserTests/Sources/BRTSupport/common.css new file mode 100644 index 0000000..cae8efc --- /dev/null +++ b/BrowserTests/Sources/BRTSupport/common.css @@ -0,0 +1,55 @@ +* { + box-sizing: border-box; +} + +body { + font-family: sans-serif; + margin: 20px; + padding: 0; +} + +h1 { + margin-top: 0; + font-size: 22px; +} + +h2 { + margin-top: 0; + font-size: 20px; +} + +h3 { + margin-top: 0; + font-size: 18px; +} + +h4 { + margin-top: 0; + font-size: 16px; +} + +h5 { + margin-top: 0; + font-size: 14px; +} + +h6 { + margin-top: 0; + font-size: 12px; +} + +code { + font-size: 1.2em; +} + +ul { + padding-inline-start: 20px; +} + +.avatar { + border-radius: 50%; +} + +.large { + border: 4px solid gold; +} diff --git a/BrowserTests/Sources/GenPagesModule/GenPages.swift b/BrowserTests/Sources/GenPagesModule/GenPages.swift index 08a5667..6e1e4ef 100644 --- a/BrowserTests/Sources/GenPagesModule/GenPages.swift +++ b/BrowserTests/Sources/GenPagesModule/GenPages.swift @@ -40,6 +40,7 @@ public struct GenPages { \(page) + + + + + \ No newline at end of file diff --git a/BrowserTests/pages/QSRenderingLists.html b/BrowserTests/pages/QSLists.html similarity index 52% rename from BrowserTests/pages/QSRenderingLists.html rename to BrowserTests/pages/QSLists.html index 4250453..95063fc 100644 --- a/BrowserTests/pages/QSRenderingLists.html +++ b/BrowserTests/pages/QSLists.html @@ -2,10 +2,11 @@ - QSRenderingLists + QSLists + diff --git a/BrowserTests/pages/QSMarkup.html b/BrowserTests/pages/QSMarkup.html index 3e63040..3ce52ef 100644 --- a/BrowserTests/pages/QSMarkup.html +++ b/BrowserTests/pages/QSMarkup.html @@ -3,6 +3,7 @@ QSMarkup + + + + + \ No newline at end of file diff --git a/BrowserTests/pages/QSUpdating.html b/BrowserTests/pages/QSUpdating.html new file mode 100644 index 0000000..171c5e1 --- /dev/null +++ b/BrowserTests/pages/QSUpdating.html @@ -0,0 +1,14 @@ + + + + + QSUpdating + + + + + + \ No newline at end of file diff --git a/BrowserTests/tsconfig.json b/BrowserTests/tsconfig.json index f74c3e3..66426cf 100644 --- a/BrowserTests/tsconfig.json +++ b/BrowserTests/tsconfig.json @@ -1,6 +1,7 @@ { "compilerOptions": { - "module": "CommonJS", + "module": "ESNext", + "moduleResolution": "Node", "strict": true, "target": "ESNext", "outDir": "js", diff --git a/BrowserTests/vite.config.js b/BrowserTests/vite.config.js index 7343d4f..cce5791 100644 --- a/BrowserTests/vite.config.js +++ b/BrowserTests/vite.config.js @@ -9,7 +9,10 @@ export default defineConfig({ QSMarkup: resolve(__dirname, "pages/QSMarkup.html"), QSDisplayingData: resolve(__dirname, "pages/QSDisplayingData.html"), QSConditional: resolve(__dirname, "pages/QSConditional.html"), - QSRenderingLists: resolve(__dirname, "pages/QSRenderingLists.html"), + QSLists: resolve(__dirname, "pages/QSLists.html"), + QSEvents: resolve(__dirname, "pages/QSEvents.html"), + QSUpdating: resolve(__dirname, "pages/QSUpdating.html"), + QSSharing: resolve(__dirname, "pages/QSSharing.html"), }, }, } diff --git a/Sources/SRTDOM/JSWindow.swift b/Sources/SRTDOM/JSWindow.swift index 40ef22d..b7fbd98 100644 --- a/Sources/SRTDOM/JSWindow.swift +++ b/Sources/SRTDOM/JSWindow.swift @@ -18,6 +18,8 @@ public struct JSWindow: ConvertibleToJSObject & ConstructibleFromJSValue { public var document: JSDocument { .unsafeConstruct(from: jsValue.document) } + public func alert(_ message: String) throws { try jsValue.throws.alert(message) } + public static var global: JSWindow { JSWindow(jsObject: JSObject.global) }