Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
42 lines (33 loc) · 1.09 KB

File metadata and controls

42 lines (33 loc) · 1.09 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// @ts-check
import { BridgeJSPlayground } from './app.js';
Error.stackTraceLimit = Infinity;
const SWIFT_INPUT = `import JavaScriptKit
@JS public func calculateTotal(price: Double, quantity: Int) -> Double {
return price * Double(quantity)
}
@JS class ShoppingCart {
private var items: [(name: String, price: Double, quantity: Int)] = []
@JS init() {}
@JS public func addItem(name: String, price: Double, quantity: Int) {
items.append((name, price, quantity))
}
@JS public func getTotal() -> Double {
return items.reduce(0) { $0 + $1.price * Double($1.quantity) }
}
}`
const DTS_INPUT = `export type Console = {
log(message: string): void;
}
export function console(): Console;`
// Initialize the playground when the page loads
document.addEventListener('DOMContentLoaded', async () => {
try {
const playground = new BridgeJSPlayground();
await playground.initialize({
swift: SWIFT_INPUT,
dts: DTS_INPUT
});
} catch (error) {
console.error('Failed to initialize playground:', error);
}
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.