diff --git a/Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift b/Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift index 9d0a5181..ee86def7 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.ExportSwift.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_run") @_cdecl("bjs_run") diff --git a/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift b/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift index d7a6cf71..53f06222 100644 --- a/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift +++ b/Benchmarks/Sources/Generated/BridgeJS.ImportTS.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func benchmarkHelperNoop() -> Void { #if arch(wasm32) @@ -59,7 +41,7 @@ func benchmarkRunner(_ name: String, _ body: JSObject) -> Void { #endif var name = name let nameId = name.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_benchmarkRunner(nameId, Int32(bitPattern: body.id)) } \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift index 4e8edb53..283a3fbb 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ExportSwift.swift @@ -4,19 +4,57 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit +@_spi(BridgeJS) import JavaScriptKit -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) +@_expose(wasm, "bjs_PlayBridgeJS_init") +@_cdecl("bjs_PlayBridgeJS_init") +public func _bjs_PlayBridgeJS_init() -> UnsafeMutableRawPointer { + #if arch(wasm32) + let ret = PlayBridgeJS() + return Unmanaged.passRetained(ret).toOpaque() + #else + fatalError("Only available on WebAssembly") + #endif +} -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_expose(wasm, "bjs_PlayBridgeJS_update") +@_cdecl("bjs_PlayBridgeJS_update") +public func _bjs_PlayBridgeJS_update(_self: UnsafeMutableRawPointer, swiftSourceBytes: Int32, swiftSourceLen: Int32, dtsSourceBytes: Int32, dtsSourceLen: Int32) -> UnsafeMutableRawPointer { + #if arch(wasm32) + do { + let swiftSource = String(unsafeUninitializedCapacity: Int(swiftSourceLen)) { b in + _swift_js_init_memory(swiftSourceBytes, b.baseAddress.unsafelyUnwrapped) + return Int(swiftSourceLen) + } + let dtsSource = String(unsafeUninitializedCapacity: Int(dtsSourceLen)) { b in + _swift_js_init_memory(dtsSourceBytes, b.baseAddress.unsafelyUnwrapped) + return Int(dtsSourceLen) + } + let ret = try Unmanaged.fromOpaque(_self).takeUnretainedValue().update(swiftSource: swiftSource, dtsSource: dtsSource) + return Unmanaged.passRetained(ret).toOpaque() + } catch let error { + if let error = error.thrownValue.object { + withExtendedLifetime(error) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } else { + let jsError = JSError(message: String(describing: error)) + withExtendedLifetime(jsError.jsObject) { + _swift_js_throw(Int32(bitPattern: $0.id)) + } + } + return UnsafeMutableRawPointer(bitPattern: -1).unsafelyUnwrapped + } + #else + fatalError("Only available on WebAssembly") + #endif +} + +@_expose(wasm, "bjs_PlayBridgeJS_deinit") +@_cdecl("bjs_PlayBridgeJS_deinit") +public func _bjs_PlayBridgeJS_deinit(pointer: UnsafeMutableRawPointer) { + Unmanaged.fromOpaque(pointer).release() +} @_expose(wasm, "bjs_PlayBridgeJSOutput_outputJs") @_cdecl("bjs_PlayBridgeJSOutput_outputJs") @@ -24,7 +62,7 @@ public func _bjs_PlayBridgeJSOutput_outputJs(_self: UnsafeMutableRawPointer) -> #if arch(wasm32) var ret = Unmanaged.fromOpaque(_self).takeUnretainedValue().outputJs() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -37,7 +75,7 @@ public func _bjs_PlayBridgeJSOutput_outputDts(_self: UnsafeMutableRawPointer) -> #if arch(wasm32) var ret = Unmanaged.fromOpaque(_self).takeUnretainedValue().outputDts() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -50,7 +88,7 @@ public func _bjs_PlayBridgeJSOutput_importSwiftGlue(_self: UnsafeMutableRawPoint #if arch(wasm32) var ret = Unmanaged.fromOpaque(_self).takeUnretainedValue().importSwiftGlue() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -63,7 +101,7 @@ public func _bjs_PlayBridgeJSOutput_exportSwiftGlue(_self: UnsafeMutableRawPoint #if arch(wasm32) var ret = Unmanaged.fromOpaque(_self).takeUnretainedValue().exportSwiftGlue() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -74,54 +112,4 @@ public func _bjs_PlayBridgeJSOutput_exportSwiftGlue(_self: UnsafeMutableRawPoint @_cdecl("bjs_PlayBridgeJSOutput_deinit") public func _bjs_PlayBridgeJSOutput_deinit(pointer: UnsafeMutableRawPointer) { Unmanaged.fromOpaque(pointer).release() -} - -@_expose(wasm, "bjs_PlayBridgeJS_init") -@_cdecl("bjs_PlayBridgeJS_init") -public func _bjs_PlayBridgeJS_init() -> UnsafeMutableRawPointer { - #if arch(wasm32) - let ret = PlayBridgeJS() - return Unmanaged.passRetained(ret).toOpaque() - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PlayBridgeJS_update") -@_cdecl("bjs_PlayBridgeJS_update") -public func _bjs_PlayBridgeJS_update(_self: UnsafeMutableRawPointer, swiftSourceBytes: Int32, swiftSourceLen: Int32, dtsSourceBytes: Int32, dtsSourceLen: Int32) -> UnsafeMutableRawPointer { - #if arch(wasm32) - do { - let swiftSource = String(unsafeUninitializedCapacity: Int(swiftSourceLen)) { b in - _init_memory(swiftSourceBytes, b.baseAddress.unsafelyUnwrapped) - return Int(swiftSourceLen) - } - let dtsSource = String(unsafeUninitializedCapacity: Int(dtsSourceLen)) { b in - _init_memory(dtsSourceBytes, b.baseAddress.unsafelyUnwrapped) - return Int(dtsSourceLen) - } - let ret = try Unmanaged.fromOpaque(_self).takeUnretainedValue().update(swiftSource: swiftSource, dtsSource: dtsSource) - return Unmanaged.passRetained(ret).toOpaque() - } catch let error { - if let error = error.thrownValue.object { - withExtendedLifetime(error) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } else { - let jsError = JSError(message: String(describing: error)) - withExtendedLifetime(jsError.jsObject) { - _swift_js_throw(Int32(bitPattern: $0.id)) - } - } - return UnsafeMutableRawPointer(bitPattern: -1).unsafelyUnwrapped - } - #else - fatalError("Only available on WebAssembly") - #endif -} - -@_expose(wasm, "bjs_PlayBridgeJS_deinit") -@_cdecl("bjs_PlayBridgeJS_deinit") -public func _bjs_PlayBridgeJS_deinit(pointer: UnsafeMutableRawPointer) { - Unmanaged.fromOpaque(pointer).release() } \ No newline at end of file diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift index 1ffd6c8f..6698cab5 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/BridgeJS.ImportTS.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func createTS2Skeleton() -> TS2Skeleton { #if arch(wasm32) @@ -59,11 +41,11 @@ struct TS2Skeleton { #endif var ts = ts let tsId = ts.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } let ret = bjs_TS2Skeleton_convert(Int32(bitPattern: self.this.id), tsId) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } diff --git a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json index 910ee14a..c4d55d27 100644 --- a/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json +++ b/Examples/PlayBridgeJS/Sources/PlayBridgeJS/Generated/JavaScript/BridgeJS.ExportSwift.json @@ -1,5 +1,53 @@ { "classes" : [ + { + "constructor" : { + "abiName" : "bjs_PlayBridgeJS_init", + "effects" : { + "isAsync" : false, + "isThrows" : false + }, + "parameters" : [ + + ] + }, + "methods" : [ + { + "abiName" : "bjs_PlayBridgeJS_update", + "effects" : { + "isAsync" : false, + "isThrows" : true + }, + "name" : "update", + "parameters" : [ + { + "label" : "swiftSource", + "name" : "swiftSource", + "type" : { + "string" : { + + } + } + }, + { + "label" : "dtsSource", + "name" : "dtsSource", + "type" : { + "string" : { + + } + } + } + ], + "returnType" : { + "swiftHeapObject" : { + "_0" : "PlayBridgeJSOutput" + } + } + } + ], + "name" : "PlayBridgeJS" + }, { "methods" : [ { @@ -68,54 +116,6 @@ } ], "name" : "PlayBridgeJSOutput" - }, - { - "constructor" : { - "abiName" : "bjs_PlayBridgeJS_init", - "effects" : { - "isAsync" : false, - "isThrows" : false - }, - "parameters" : [ - - ] - }, - "methods" : [ - { - "abiName" : "bjs_PlayBridgeJS_update", - "effects" : { - "isAsync" : false, - "isThrows" : true - }, - "name" : "update", - "parameters" : [ - { - "label" : "swiftSource", - "name" : "swiftSource", - "type" : { - "string" : { - - } - } - }, - { - "label" : "dtsSource", - "name" : "dtsSource", - "type" : { - "string" : { - - } - } - } - ], - "returnType" : { - "swiftHeapObject" : { - "_0" : "PlayBridgeJSOutput" - } - } - } - ], - "name" : "PlayBridgeJS" } ], "functions" : [ diff --git a/Package.swift b/Package.swift index 4f4ecd06..f8b3b6e9 100644 --- a/Package.swift +++ b/Package.swift @@ -40,12 +40,14 @@ let package = Package( ? [ .unsafeFlags(["-fdeclspec"]) ] : nil, - swiftSettings: shouldBuildForEmbedded - ? [ - .enableExperimentalFeature("Embedded"), - .enableExperimentalFeature("Extern"), - .unsafeFlags(["-Xfrontend", "-emit-empty-object-file"]), - ] : nil + swiftSettings: [ + .enableExperimentalFeature("Extern") + ] + + (shouldBuildForEmbedded + ? [ + .enableExperimentalFeature("Embedded"), + .unsafeFlags(["-Xfrontend", "-emit-empty-object-file"]), + ] : []) ), .target(name: "_CJavaScriptKit"), .testTarget( diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift index d0b1b781..12960500 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ExportSwift.swift @@ -269,19 +269,7 @@ class ExportSwift { // To update this file, just rebuild your project or run // `swift package bridge-js`. - @_spi(JSObject_id) import JavaScriptKit - - #if arch(wasm32) - @_extern(wasm, module: "bjs", name: "return_string") - private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) - @_extern(wasm, module: "bjs", name: "init_memory") - private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - - @_extern(wasm, module: "bjs", name: "swift_js_retain") - private func _swift_js_retain(_ ptr: Int32) -> Int32 - @_extern(wasm, module: "bjs", name: "swift_js_throw") - private func _swift_js_throw(_ id: Int32) - #endif + @_spi(BridgeJS) import JavaScriptKit """ func renderSwiftGlue() -> String? { @@ -311,6 +299,15 @@ class ExportSwift { self.effects = effects } + private func append(_ item: CodeBlockItemSyntax) { + var item = item + // Add a newline for items after the first one + if !self.body.isEmpty { + item = item.with(\.leadingTrivia, .newline) + } + self.body.append(item) + } + func liftParameter(param: Parameter) { switch param.type { case .bool: @@ -350,11 +347,11 @@ class ExportSwift { let lengthLabel = "\(param.name)Len" let prepare: CodeBlockItemSyntax = """ let \(raw: param.name) = String(unsafeUninitializedCapacity: Int(\(raw: lengthLabel))) { b in - _init_memory(\(raw: bytesLabel), b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(\(raw: bytesLabel), b.baseAddress.unsafelyUnwrapped) return Int(\(raw: lengthLabel)) } """ - body.append(prepare) + append(prepare) abiParameterForwardings.append( LabeledExprSyntax( label: param.label, @@ -392,7 +389,7 @@ class ExportSwift { } } - private func renderCallStatement(callee: ExprSyntax, returnType: BridgeType) -> StmtSyntax { + private func renderCallStatement(callee: ExprSyntax, returnType: BridgeType) -> CodeBlockItemSyntax { var callExpr: ExprSyntax = "\(raw: callee)(\(raw: abiParameterForwardings.map { $0.description }.joined(separator: ", ")))" if effects.isAsync { @@ -408,24 +405,24 @@ class ExportSwift { } let retMutability = returnType == .string ? "var" : "let" if returnType == .void { - return StmtSyntax("\(raw: callExpr)") + return CodeBlockItemSyntax(item: .init(ExpressionStmtSyntax(expression: callExpr))) } else { - return StmtSyntax("\(raw: retMutability) ret = \(raw: callExpr)") + return CodeBlockItemSyntax(item: .init(DeclSyntax("\(raw: retMutability) ret = \(raw: callExpr)"))) } } func call(name: String, returnType: BridgeType) { - let stmt = renderCallStatement(callee: "\(raw: name)", returnType: returnType) - body.append(CodeBlockItemSyntax(item: .stmt(stmt))) + let item = renderCallStatement(callee: "\(raw: name)", returnType: returnType) + append(item) } func callMethod(klassName: String, methodName: String, returnType: BridgeType) { let _selfParam = self.abiParameterForwardings.removeFirst() - let stmt = renderCallStatement( + let item = renderCallStatement( callee: "\(raw: _selfParam).\(raw: methodName)", returnType: returnType ) - body.append(CodeBlockItemSyntax(item: .stmt(stmt))) + append(item) } func lowerReturnValue(returnType: BridgeType) { @@ -452,25 +449,25 @@ class ExportSwift { switch returnType { case .void: break case .int, .float, .double: - body.append("return \(raw: abiReturnType!.swiftType)(ret)") + append("return \(raw: abiReturnType!.swiftType)(ret)") case .bool: - body.append("return Int32(ret ? 1 : 0)") + append("return Int32(ret ? 1 : 0)") case .string: - body.append( + append( """ return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } """ ) case .jsObject(nil): - body.append( + append( """ return _swift_js_retain(Int32(bitPattern: ret.id)) """ ) case .jsObject(_?): - body.append( + append( """ return _swift_js_retain(Int32(bitPattern: ret.this.id)) """ @@ -478,7 +475,7 @@ class ExportSwift { case .swiftHeapObject: // Perform a manual retain on the object, which will be balanced by a // release called via FinalizationRegistry - body.append( + append( """ return Unmanaged.passRetained(ret).toOpaque() """ @@ -581,7 +578,7 @@ class ExportSwift { /// @_cdecl("bjs_Greeter_init") /// public func _bjs_Greeter_init(nameBytes: Int32, nameLen: Int32) -> UnsafeMutableRawPointer { /// let name = String(unsafeUninitializedCapacity: Int(nameLen)) { b in - /// _init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) + /// _swift_js_init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) /// return Int(nameLen) /// } /// let ret = Greeter(name: name) @@ -594,7 +591,7 @@ class ExportSwift { /// let _self = Unmanaged.fromOpaque(pointer).takeUnretainedValue() /// var ret = _self.greet() /// return ret.withUTF8 { ptr in - /// _return_string(ptr.baseAddress, Int32(ptr.count)) + /// _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) /// } /// } /// @_expose(wasm, "bjs_Greeter_deinit") diff --git a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift index 0c5a6cff..4aef01fd 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSCore/ImportTS.swift @@ -109,7 +109,7 @@ struct ImportTS { body.append( """ let \(raw: stringIdName) = \(raw: param.name).withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } """ ) @@ -172,7 +172,7 @@ struct ImportTS { body.append( """ return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } """ @@ -298,25 +298,7 @@ struct ImportTS { // To update this file, just rebuild your project or run // `swift package bridge-js`. - @_spi(JSObject_id) import JavaScriptKit - - #if arch(wasm32) - @_extern(wasm, module: "bjs", name: "make_jsstring") - func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 - #else - func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") - } - #endif - - #if arch(wasm32) - @_extern(wasm, module: "bjs", name: "init_memory_with_result") - func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) - #else - func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") - } - #endif + @_spi(BridgeJS) import JavaScriptKit """ func renderSwiftThunk( diff --git a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift index 5bd6a7e2..05a29aab 100644 --- a/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift +++ b/Plugins/BridgeJS/Sources/BridgeJSLink/BridgeJSLink.swift @@ -129,20 +129,20 @@ struct BridgeJSLink { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len)\(sharedMemory ? ".slice()" : ""); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len)\(sharedMemory ? ".slice()" : ""); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayParameter.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayParameter.Import.js index 1e9fa9d0..f619fcf2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayParameter.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/ArrayParameter.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Interface.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Interface.Import.js index 328ff199..fc6c3fcc 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Interface.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Interface.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Export.js index c86f3fea..0d31689c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Import.js index 584e1308..c8a58a3d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveParameters.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Export.js index d8b29c90..b2a16684 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Import.js index 42f805e4..690514e3 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/PrimitiveReturn.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Export.js index e6dab48d..ca37f7f5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Import.js index 844f6f35..466b7786 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringParameter.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Export.js index 76710fa7..d752e9e7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Import.js index abf1ea28..fb2ee18e 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/StringReturn.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.Export.js index 0595b35a..58df1f25 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/SwiftClass.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.Export.js index f15135ff..6ebd05df 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/Throws.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeAlias.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeAlias.Import.js index 39306e28..41af7fa1 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeAlias.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeAlias.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js index 1e893f6e..52d36b77 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/TypeScriptClass.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Export.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Export.js index 01daf861..29019e90 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Export.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Export.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Import.js b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Import.js index 0fef27b4..f57197b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Import.js +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/BridgeJSLinkTests/VoidParameterVoidReturn.Import.js @@ -18,20 +18,20 @@ export async function createInstantiator(options, swift) { addImports: (importObject) => { const bjs = {}; importObject["bjs"] = bjs; - bjs["return_string"] = function(ptr, len) { + bjs["swift_js_return_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); tmpRetString = textDecoder.decode(bytes); } - bjs["init_memory"] = function(sourceId, bytesPtr) { + bjs["swift_js_init_memory"] = function(sourceId, bytesPtr) { const source = swift.memory.getObject(sourceId); const bytes = new Uint8Array(memory.buffer, bytesPtr); bytes.set(source); } - bjs["make_jsstring"] = function(ptr, len) { + bjs["swift_js_make_js_string"] = function(ptr, len) { const bytes = new Uint8Array(memory.buffer, ptr, len); return swift.memory.retain(textDecoder.decode(bytes)); } - bjs["init_memory_with_result"] = function(ptr, len) { + bjs["swift_js_init_memory_with_result"] = function(ptr, len) { const target = new Uint8Array(memory.buffer, ptr, len); target.set(tmpRetBytes); tmpRetBytes = undefined; diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift index 3c5fd9aa..c686c426 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveParameters.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_check") @_cdecl("bjs_check") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift index 2c35f786..7356f2c8 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/PrimitiveReturn.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_checkInt") @_cdecl("bjs_checkInt") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift index 21978242..69bd66b5 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringParameter.swift @@ -4,26 +4,14 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_checkString") @_cdecl("bjs_checkString") public func _bjs_checkString(aBytes: Int32, aLen: Int32) -> Void { #if arch(wasm32) let a = String(unsafeUninitializedCapacity: Int(aLen)) { b in - _init_memory(aBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(aBytes, b.baseAddress.unsafelyUnwrapped) return Int(aLen) } checkString(a: a) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift index 6aa69da2..536f0623 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/StringReturn.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_checkString") @_cdecl("bjs_checkString") @@ -24,7 +12,7 @@ public func _bjs_checkString() -> Void { #if arch(wasm32) var ret = checkString() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift index 468d7815..d8ca05f2 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/SwiftClass.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_takeGreeter") @_cdecl("bjs_takeGreeter") @@ -33,7 +21,7 @@ public func _bjs_takeGreeter(greeter: UnsafeMutableRawPointer) -> Void { public func _bjs_Greeter_init(nameBytes: Int32, nameLen: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) let name = String(unsafeUninitializedCapacity: Int(nameLen)) { b in - _init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) return Int(nameLen) } let ret = Greeter(name: name) @@ -49,7 +37,7 @@ public func _bjs_Greeter_greet(_self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) var ret = Unmanaged.fromOpaque(_self).takeUnretainedValue().greet() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -61,7 +49,7 @@ public func _bjs_Greeter_greet(_self: UnsafeMutableRawPointer) -> Void { public func _bjs_Greeter_changeName(_self: UnsafeMutableRawPointer, nameBytes: Int32, nameLen: Int32) -> Void { #if arch(wasm32) let name = String(unsafeUninitializedCapacity: Int(nameLen)) { b in - _init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) return Int(nameLen) } Unmanaged.fromOpaque(_self).takeUnretainedValue().changeName(name: name) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift index 1fcad7c4..8b865b7d 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/Throws.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_throwsSomething") @_cdecl("bjs_throwsSomething") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift index 42a1ddda..15e91a0b 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ExportSwiftTests/VoidParameterVoidReturn.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_check") @_cdecl("bjs_check") diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift index b614bd6f..0a85c88f 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/ArrayParameter.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func checkArray(_ a: JSObject) -> Void { #if arch(wasm32) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift index c64e7433..44fbb6ba 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/Interface.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func returnAnimatable() -> Animatable { #if arch(wasm32) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift index 554fd98c..c5d23884 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveParameters.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func check(_ a: Double, _ b: Bool) -> Void { #if arch(wasm32) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift index ec929407..df1a469a 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/PrimitiveReturn.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func checkNumber() -> Double { #if arch(wasm32) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift index d5dd74c6..8cac3ce6 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringParameter.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func checkString(_ a: String) -> Void { #if arch(wasm32) @@ -35,7 +17,7 @@ func checkString(_ a: String) -> Void { #endif var a = a let aId = a.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_checkString(aId) } @@ -51,7 +33,7 @@ func checkStringWithLength(_ a: String, _ b: Double) -> Void { #endif var a = a let aId = a.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_checkStringWithLength(aId, b) } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift index 07fe0722..282476b0 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/StringReturn.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func checkString() -> String { #if arch(wasm32) @@ -35,7 +17,7 @@ func checkString() -> String { #endif let ret = bjs_checkString() return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } \ No newline at end of file diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift index cfd1d2ec..7eeefcc7 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeAlias.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func checkSimple(_ a: Double) -> Void { #if arch(wasm32) diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift index 7afd45cf..39b6a85c 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/TypeScriptClass.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit struct Greeter { let this: JSObject @@ -46,7 +28,7 @@ struct Greeter { #endif var name = name let nameId = name.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } let ret = bjs_Greeter_init(nameId) self.this = JSObject(id: UInt32(bitPattern: ret)) @@ -64,7 +46,7 @@ struct Greeter { #endif let ret = bjs_Greeter_name_get(Int32(bitPattern: self.this.id)) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } @@ -79,7 +61,7 @@ struct Greeter { #endif var newValue = newValue let newValueId = newValue.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_Greeter_name_set(Int32(bitPattern: self.this.id), newValueId) } @@ -111,7 +93,7 @@ struct Greeter { #endif let ret = bjs_Greeter_greet(Int32(bitPattern: self.this.id)) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } @@ -127,7 +109,7 @@ struct Greeter { #endif var name = name let nameId = name.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_Greeter_changeName(Int32(bitPattern: self.this.id), nameId) } diff --git a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift index dc384986..eccd1728 100644 --- a/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift +++ b/Plugins/BridgeJS/Tests/BridgeJSToolTests/__Snapshots__/ImportTSTests/VoidParameterVoidReturn.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func check() -> Void { #if arch(wasm32) diff --git a/Sources/JavaScriptKit/BridgeJSInstrincics.swift b/Sources/JavaScriptKit/BridgeJSInstrincics.swift new file mode 100644 index 00000000..e2c54026 --- /dev/null +++ b/Sources/JavaScriptKit/BridgeJSInstrincics.swift @@ -0,0 +1,59 @@ +#if !arch(wasm32) +private func _onlyAvailableOnWasm() -> Never { + fatalError("Only available on WebAssembly") +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_return_string") +@_spi(BridgeJS) public func _swift_js_return_string(_ ptr: UnsafePointer?, _ len: Int32) +#else +@_spi(BridgeJS) public func _swift_js_return_string(_ ptr: UnsafePointer?, _ len: Int32) { + _onlyAvailableOnWasm() +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_init_memory") +@_spi(BridgeJS) public func _swift_js_init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) +#else +@_spi(BridgeJS) public func _swift_js_init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) { + _onlyAvailableOnWasm() +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_retain") +@_spi(BridgeJS) public func _swift_js_retain(_ ptr: Int32) -> Int32 +#else +@_spi(BridgeJS) public func _swift_js_retain(_ ptr: Int32) -> Int32 { + _onlyAvailableOnWasm() +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_throw") +@_spi(BridgeJS) public func _swift_js_throw(_ id: Int32) +#else +@_spi(BridgeJS) public func _swift_js_throw(_ id: Int32) { + _onlyAvailableOnWasm() +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_make_js_string") +@_spi(BridgeJS) public func _swift_js_make_js_string(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 +#else +@_spi(BridgeJS) public func _swift_js_make_js_string(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { + _onlyAvailableOnWasm() +} +#endif + +#if arch(wasm32) +@_extern(wasm, module: "bjs", name: "swift_js_init_memory_with_result") +@_spi(BridgeJS) public func _swift_js_init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) +#else +@_spi(BridgeJS) public func _swift_js_init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { + _onlyAvailableOnWasm() +} +#endif diff --git a/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift b/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift index 12dbf9e0..8892e987 100644 --- a/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift +++ b/Sources/JavaScriptKit/FundamentalObjects/JSObject.swift @@ -27,10 +27,12 @@ public class JSObject: Equatable, ExpressibleByDictionaryLiteral { #endif @_spi(JSObject_id) + @_spi(BridgeJS) @inlinable public var id: JavaScriptObjectRef { _id } @_spi(JSObject_id) + @_spi(BridgeJS) public init(id: JavaScriptObjectRef) { self._id = id #if compiler(>=6.1) && _runtime(_multithreaded) diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift index 363bf2d9..6c11869f 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ExportSwift.swift @@ -4,19 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "return_string") -private func _return_string(_ ptr: UnsafePointer?, _ len: Int32) -@_extern(wasm, module: "bjs", name: "init_memory") -private func _init_memory(_ sourceId: Int32, _ ptr: UnsafeMutablePointer?) - -@_extern(wasm, module: "bjs", name: "swift_js_retain") -private func _swift_js_retain(_ ptr: Int32) -> Int32 -@_extern(wasm, module: "bjs", name: "swift_js_throw") -private func _swift_js_throw(_ id: Int32) -#endif +@_spi(BridgeJS) import JavaScriptKit @_expose(wasm, "bjs_roundTripVoid") @_cdecl("bjs_roundTripVoid") @@ -77,12 +65,12 @@ public func _bjs_roundTripBool(v: Int32) -> Int32 { public func _bjs_roundTripString(vBytes: Int32, vLen: Int32) -> Void { #if arch(wasm32) let v = String(unsafeUninitializedCapacity: Int(vLen)) { b in - _init_memory(vBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(vBytes, b.baseAddress.unsafelyUnwrapped) return Int(vLen) } var ret = roundTripString(v: v) return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -167,7 +155,7 @@ public func _bjs_throwsWithStringResult() -> Void { do { var ret = try throwsWithStringResult() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } } catch let error { if let error = error.thrownValue.object { @@ -317,7 +305,7 @@ public func _bjs_throwsWithJSObjectResult() -> Int32 { public func _bjs_takeGreeter(g: UnsafeMutableRawPointer, nameBytes: Int32, nameLen: Int32) -> Void { #if arch(wasm32) let name = String(unsafeUninitializedCapacity: Int(nameLen)) { b in - _init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) return Int(nameLen) } takeGreeter(g: Unmanaged.fromOpaque(g).takeUnretainedValue(), name: name) @@ -331,7 +319,7 @@ public func _bjs_takeGreeter(g: UnsafeMutableRawPointer, nameBytes: Int32, nameL public func _bjs_Greeter_init(nameBytes: Int32, nameLen: Int32) -> UnsafeMutableRawPointer { #if arch(wasm32) let name = String(unsafeUninitializedCapacity: Int(nameLen)) { b in - _init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) return Int(nameLen) } let ret = Greeter(name: name) @@ -347,7 +335,7 @@ public func _bjs_Greeter_greet(_self: UnsafeMutableRawPointer) -> Void { #if arch(wasm32) var ret = Unmanaged.fromOpaque(_self).takeUnretainedValue().greet() return ret.withUTF8 { ptr in - _return_string(ptr.baseAddress, Int32(ptr.count)) + _swift_js_return_string(ptr.baseAddress, Int32(ptr.count)) } #else fatalError("Only available on WebAssembly") @@ -359,7 +347,7 @@ public func _bjs_Greeter_greet(_self: UnsafeMutableRawPointer) -> Void { public func _bjs_Greeter_changeName(_self: UnsafeMutableRawPointer, nameBytes: Int32, nameLen: Int32) -> Void { #if arch(wasm32) let name = String(unsafeUninitializedCapacity: Int(nameLen)) { b in - _init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) + _swift_js_init_memory(nameBytes, b.baseAddress.unsafelyUnwrapped) return Int(nameLen) } Unmanaged.fromOpaque(_self).takeUnretainedValue().changeName(name: name) diff --git a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift index 35148cf5..95150e0e 100644 --- a/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift +++ b/Tests/BridgeJSRuntimeTests/Generated/BridgeJS.ImportTS.swift @@ -4,25 +4,7 @@ // To update this file, just rebuild your project or run // `swift package bridge-js`. -@_spi(JSObject_id) import JavaScriptKit - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "make_jsstring") -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 -#else -func _make_jsstring(_ ptr: UnsafePointer?, _ len: Int32) -> Int32 { - fatalError("Only available on WebAssembly") -} -#endif - -#if arch(wasm32) -@_extern(wasm, module: "bjs", name: "init_memory_with_result") -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) -#else -func _init_memory_with_result(_ ptr: UnsafePointer?, _ len: Int32) { - fatalError("Only available on WebAssembly") -} -#endif +@_spi(BridgeJS) import JavaScriptKit func jsRoundTripVoid() -> Void { #if arch(wasm32) @@ -73,11 +55,11 @@ func jsRoundTripString(_ v: String) -> String { #endif var v = v let vId = v.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } let ret = bjs_jsRoundTripString(vId) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } @@ -104,11 +86,11 @@ struct JsGreeter { #endif var name = name let nameId = name.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } var prefix = prefix let prefixId = prefix.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } let ret = bjs_JsGreeter_init(nameId, prefixId) self.this = JSObject(id: UInt32(bitPattern: ret)) @@ -126,7 +108,7 @@ struct JsGreeter { #endif let ret = bjs_JsGreeter_name_get(Int32(bitPattern: self.this.id)) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } @@ -141,7 +123,7 @@ struct JsGreeter { #endif var newValue = newValue let newValueId = newValue.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_JsGreeter_name_set(Int32(bitPattern: self.this.id), newValueId) } @@ -159,7 +141,7 @@ struct JsGreeter { #endif let ret = bjs_JsGreeter_prefix_get(Int32(bitPattern: self.this.id)) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } @@ -176,7 +158,7 @@ struct JsGreeter { #endif let ret = bjs_JsGreeter_greet(Int32(bitPattern: self.this.id)) return String(unsafeUninitializedCapacity: Int(ret)) { b in - _init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) + _swift_js_init_memory_with_result(b.baseAddress.unsafelyUnwrapped, Int32(ret)) return Int(ret) } } @@ -192,7 +174,7 @@ struct JsGreeter { #endif var name = name let nameId = name.withUTF8 { b in - _make_jsstring(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) + _swift_js_make_js_string(b.baseAddress.unsafelyUnwrapped, Int32(b.count)) } bjs_JsGreeter_changeName(Int32(bitPattern: self.this.id), nameId) } diff --git a/Utilities/bridge-js-generate.sh b/Utilities/bridge-js-generate.sh new file mode 100755 index 00000000..b79befa2 --- /dev/null +++ b/Utilities/bridge-js-generate.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package plugin --allow-writing-to-package-directory bridge-js +env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --package-path ./Benchmarks plugin --allow-writing-to-package-directory bridge-js +env JAVASCRIPTKIT_EXPERIMENTAL_BRIDGEJS=1 swift package --package-path ./Examples/PlayBridgeJS plugin --allow-writing-to-package-directory bridge-js + pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy