From f79f1ea181a04032818c98c367fece8222110d52 Mon Sep 17 00:00:00 2001 From: Jonathan Buchanan Date: Wed, 30 Jun 2021 22:35:24 -0400 Subject: expose public api --- iono/iono.swift | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/iono/iono.swift b/iono/iono.swift index 77a4ec5..e4edb8a 100644 --- a/iono/iono.swift +++ b/iono/iono.swift @@ -16,7 +16,7 @@ import Foundation -protocol IonoMessageHandler { +public protocol IonoMessageHandler { func handleMessage(message: String) } @@ -27,13 +27,13 @@ func notification_callback(payload: Optional>, native.internalOnNotify(payload: string) } -class Iono { +public class Iono { var instance: OpaquePointer! var work_queue: DispatchQueue var initialization_group: DispatchGroup var messageHandler: IonoMessageHandler? - init() { + public init() { work_queue = DispatchQueue(label: "NodeQueue", qos: .userInitiated) initialization_group = DispatchGroup() initialization_group.notify(queue: work_queue) { @@ -58,18 +58,18 @@ class Iono { notifyNative() } - func internalOnNotify(payload: String) { + public func internalOnNotify(payload: String) { if let handler = messageHandler { handler.handleMessage(message: payload) } } - func notifyNative() { + public func notifyNative() { initialization_group.wait() __notifyNative(instance) } - func evalSimpleJs(source: String) -> String { + public func evalSimpleJs(source: String) -> String { var result: String? scheduleNodeThreadSync { let cResult = __evalJs(self.instance, source.cString(using: .utf8)) @@ -81,13 +81,13 @@ class Iono { return result! } - func evalNodeCode(source: String) { + public func evalNodeCode(source: String) { scheduleNodeThreadAsync { __makeCallbackNative(self.instance, source.cString(using: .utf8)) } } - func sendMessage(message: String) { + public func sendMessage(message: String) { let encoded = message.data(using: .utf8)!.base64EncodedString() let source = """ if (global.__iono_onMessage) { @@ -100,11 +100,11 @@ class Iono { evalNodeCode(source: source) } - func waitStopped() { + public func waitStopped() { } - func putModuleCode(modName: String, code: String) { + public func putModuleCode(modName: String, code: String) { scheduleNodeThreadSync { __putModuleCodeNative(self.instance, modName.cString(using: .utf8), code.cString(using: .utf8)) -- cgit v1.2.3