@functionland/react-native-fula 1.54.24 → 1.54.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/Fula.mm +39 -0
- package/ios/Fula.swift +429 -1
- package/package.json +1 -1
package/ios/Fula.mm
CHANGED
|
@@ -198,6 +198,45 @@ RCT_EXTERN_METHOD(getFolderSize:(NSString *)folderPath
|
|
|
198
198
|
RCT_EXTERN_METHOD(getDatastoreSize:(RCTPromiseResolveBlock)resolve
|
|
199
199
|
rejecter:(RCTPromiseRejectBlock)reject)
|
|
200
200
|
|
|
201
|
+
RCT_EXTERN_METHOD(listPlugins:(RCTPromiseResolveBlock)resolve
|
|
202
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
203
|
+
|
|
204
|
+
RCT_EXTERN_METHOD(listActivePlugins:(RCTPromiseResolveBlock)resolve
|
|
205
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
206
|
+
|
|
207
|
+
RCT_EXTERN_METHOD(installPlugin:(NSString *)pluginName
|
|
208
|
+
withParams:(NSString *)params
|
|
209
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
210
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
211
|
+
|
|
212
|
+
RCT_EXTERN_METHOD(uninstallPlugin:(NSString *)pluginName
|
|
213
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
214
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
215
|
+
|
|
216
|
+
RCT_EXTERN_METHOD(showPluginStatus:(NSString *)pluginName
|
|
217
|
+
withLines:(NSInteger)lines
|
|
218
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
219
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
220
|
+
|
|
221
|
+
RCT_EXTERN_METHOD(getInstallOutput:(NSString *)pluginName
|
|
222
|
+
withParams:(NSString *)params
|
|
223
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
224
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
225
|
+
|
|
226
|
+
RCT_EXTERN_METHOD(getInstallStatus:(NSString *)pluginName
|
|
227
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
228
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
229
|
+
|
|
230
|
+
RCT_EXTERN_METHOD(updatePlugin:(NSString *)pluginName
|
|
231
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
232
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
233
|
+
|
|
234
|
+
RCT_EXTERN_METHOD(replicateInPool:(NSArray *)cidArray
|
|
235
|
+
withAccount:(NSString *)account
|
|
236
|
+
withPoolID:(NSString *)poolIDStr
|
|
237
|
+
withResolver:(RCTPromiseResolveBlock)resolve
|
|
238
|
+
withRejecter:(RCTPromiseRejectBlock)reject)
|
|
239
|
+
|
|
201
240
|
+ (BOOL)requiresMainQueueSetup
|
|
202
241
|
{
|
|
203
242
|
return NO;
|
package/ios/Fula.swift
CHANGED
|
@@ -1579,8 +1579,436 @@ class FulaModule: NSObject {
|
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
1581
1581
|
|
|
1582
|
+
@objc(listPlugins:withRejecter:)
|
|
1583
|
+
func listPlugins(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1584
|
+
DispatchQueue.global(qos: .background).async {
|
|
1585
|
+
do {
|
|
1586
|
+
guard let fula = self.fula else {
|
|
1587
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1588
|
+
DispatchQueue.main.async {
|
|
1589
|
+
reject("ERR_FULA", "Fula not initialized", error)
|
|
1590
|
+
}
|
|
1591
|
+
return
|
|
1592
|
+
}
|
|
1593
|
+
|
|
1594
|
+
let result = try fula.listPlugins()
|
|
1595
|
+
guard let resultString = result.toUTF8String() else {
|
|
1596
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Failed to convert plugin list to string"])
|
|
1597
|
+
DispatchQueue.main.async {
|
|
1598
|
+
reject("ERR_FULA", "Plugin List Conversion Error", error)
|
|
1599
|
+
}
|
|
1600
|
+
return
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
DispatchQueue.main.async {
|
|
1604
|
+
resolve(resultString)
|
|
1605
|
+
}
|
|
1606
|
+
} catch let error {
|
|
1607
|
+
print("listPlugins", error.localizedDescription)
|
|
1608
|
+
DispatchQueue.main.async {
|
|
1609
|
+
reject("ERR_FULA", "listPlugins failed", error)
|
|
1610
|
+
}
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1613
|
+
}
|
|
1614
|
+
|
|
1615
|
+
@objc(listActivePlugins:withRejecter:)
|
|
1616
|
+
func listActivePlugins(resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1617
|
+
DispatchQueue.global(qos: .background).async {
|
|
1618
|
+
do {
|
|
1619
|
+
guard let fula = self.fula else {
|
|
1620
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1621
|
+
DispatchQueue.main.async {
|
|
1622
|
+
reject("ERR_FULA", "Fula not initialized", error)
|
|
1623
|
+
}
|
|
1624
|
+
return
|
|
1625
|
+
}
|
|
1626
|
+
|
|
1627
|
+
let result: Data
|
|
1628
|
+
do {
|
|
1629
|
+
result = try fula.listActivePlugins()
|
|
1630
|
+
} catch {
|
|
1631
|
+
print("Error listing active plugins: \(error)")
|
|
1632
|
+
DispatchQueue.main.async {
|
|
1633
|
+
reject("ERR_FULA", "Failed to list active plugins", error)
|
|
1634
|
+
}
|
|
1635
|
+
return
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
guard !result.isEmpty else {
|
|
1639
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Active plugin list is empty"])
|
|
1640
|
+
DispatchQueue.main.async {
|
|
1641
|
+
reject("ERR_FULA", "Empty Active Plugin List", error)
|
|
1642
|
+
}
|
|
1643
|
+
return
|
|
1644
|
+
}
|
|
1645
|
+
|
|
1646
|
+
guard let resultString = String(data: result, encoding: .utf8) else {
|
|
1647
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1003, userInfo: [NSLocalizedDescriptionKey: "Failed to convert active plugin list to string"])
|
|
1648
|
+
DispatchQueue.main.async {
|
|
1649
|
+
reject("ERR_FULA", "Active Plugin List Conversion Error", error)
|
|
1650
|
+
}
|
|
1651
|
+
return
|
|
1652
|
+
}
|
|
1653
|
+
|
|
1654
|
+
DispatchQueue.main.async {
|
|
1655
|
+
resolve(resultString)
|
|
1656
|
+
}
|
|
1657
|
+
} catch let error {
|
|
1658
|
+
print("listActivePlugins unexpected error:", error.localizedDescription)
|
|
1659
|
+
DispatchQueue.main.async {
|
|
1660
|
+
reject("ERR_FULA", "listActivePlugins failed unexpectedly", error)
|
|
1661
|
+
}
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
@objc(installPlugin:withParams:withResolver:withRejecter:)
|
|
1667
|
+
func installPlugin(pluginName: String, params: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1668
|
+
DispatchQueue.global(qos: .background).async {
|
|
1669
|
+
do {
|
|
1670
|
+
guard let fula = self.fula else {
|
|
1671
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1672
|
+
DispatchQueue.main.async {
|
|
1673
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1674
|
+
}
|
|
1675
|
+
return
|
|
1676
|
+
}
|
|
1677
|
+
|
|
1678
|
+
let result = try fula.installPlugin(pluginName, params: params)
|
|
1679
|
+
guard let resultString = result.toUTF8String() else {
|
|
1680
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Failed to convert install result to string"])
|
|
1681
|
+
DispatchQueue.main.async {
|
|
1682
|
+
reject("ERR_FULA_RESULT_CONVERSION", "Install Result Conversion Error", error)
|
|
1683
|
+
}
|
|
1684
|
+
return
|
|
1685
|
+
}
|
|
1686
|
+
|
|
1687
|
+
DispatchQueue.main.async {
|
|
1688
|
+
resolve(resultString)
|
|
1689
|
+
}
|
|
1690
|
+
} catch let error {
|
|
1691
|
+
print("installPlugin error:", error.localizedDescription)
|
|
1692
|
+
DispatchQueue.main.async {
|
|
1693
|
+
reject("ERR_FULA_INSTALL_PLUGIN", "Failed to install plugin: \(pluginName)", error)
|
|
1694
|
+
}
|
|
1695
|
+
}
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
|
|
1699
|
+
@objc(uninstallPlugin:withResolver:withRejecter:)
|
|
1700
|
+
func uninstallPlugin(pluginName: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1701
|
+
DispatchQueue.global(qos: .background).async {
|
|
1702
|
+
do {
|
|
1703
|
+
guard let fula = self.fula else {
|
|
1704
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1705
|
+
DispatchQueue.main.async {
|
|
1706
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1707
|
+
}
|
|
1708
|
+
return
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
let result = try fula.uninstallPlugin(pluginName)
|
|
1712
|
+
guard let resultString = result.toUTF8String() else {
|
|
1713
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Failed to convert uninstall result to string"])
|
|
1714
|
+
DispatchQueue.main.async {
|
|
1715
|
+
reject("ERR_FULA_RESULT_CONVERSION", "Uninstall Result Conversion Error", error)
|
|
1716
|
+
}
|
|
1717
|
+
return
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
DispatchQueue.main.async {
|
|
1721
|
+
resolve(resultString)
|
|
1722
|
+
}
|
|
1723
|
+
} catch let error {
|
|
1724
|
+
print("uninstallPlugin error:", error.localizedDescription)
|
|
1725
|
+
DispatchQueue.main.async {
|
|
1726
|
+
reject("ERR_FULA_UNINSTALL_PLUGIN", "Failed to uninstall plugin: \(pluginName)", error)
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
}
|
|
1731
|
+
|
|
1732
|
+
@objc(showPluginStatus:withLines:withResolver:withRejecter:)
|
|
1733
|
+
func showPluginStatus(pluginName: String, lines: Int, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1734
|
+
DispatchQueue.global(qos: .background).async {
|
|
1735
|
+
do {
|
|
1736
|
+
guard let fula = self.fula else {
|
|
1737
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1738
|
+
DispatchQueue.main.async {
|
|
1739
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1740
|
+
}
|
|
1741
|
+
return
|
|
1742
|
+
}
|
|
1743
|
+
|
|
1744
|
+
let result: Data
|
|
1745
|
+
do {
|
|
1746
|
+
result = try fula.showPluginStatus(pluginName, lines: lines)
|
|
1747
|
+
} catch {
|
|
1748
|
+
print("Error showing plugin status: \(error)")
|
|
1749
|
+
DispatchQueue.main.async {
|
|
1750
|
+
reject("ERR_FULA_SHOW_PLUGIN_STATUS", "Failed to show plugin status", error)
|
|
1751
|
+
}
|
|
1752
|
+
return
|
|
1753
|
+
}
|
|
1754
|
+
|
|
1755
|
+
guard !result.isEmpty else {
|
|
1756
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Plugin status result is empty"])
|
|
1757
|
+
DispatchQueue.main.async {
|
|
1758
|
+
reject("ERR_FULA_EMPTY_RESULT", "Empty Plugin Status Result", error)
|
|
1759
|
+
}
|
|
1760
|
+
return
|
|
1761
|
+
}
|
|
1762
|
+
|
|
1763
|
+
guard let resultString = String(data: result, encoding: .utf8) else {
|
|
1764
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1003, userInfo: [NSLocalizedDescriptionKey: "Failed to convert plugin status to string"])
|
|
1765
|
+
DispatchQueue.main.async {
|
|
1766
|
+
reject("ERR_FULA_RESULT_CONVERSION", "Plugin Status Conversion Error", error)
|
|
1767
|
+
}
|
|
1768
|
+
return
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1771
|
+
DispatchQueue.main.async {
|
|
1772
|
+
resolve(resultString)
|
|
1773
|
+
}
|
|
1774
|
+
} catch {
|
|
1775
|
+
print("showPluginStatus unexpected error:", error.localizedDescription)
|
|
1776
|
+
DispatchQueue.main.async {
|
|
1777
|
+
reject("ERR_FULA_SHOW_PLUGIN_STATUS", "showPluginStatus failed unexpectedly", error)
|
|
1778
|
+
}
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
@objc(getInstallOutput:withParams:withResolver:withRejecter:)
|
|
1784
|
+
func getInstallOutput(pluginName: String, params: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1785
|
+
DispatchQueue.global(qos: .background).async {
|
|
1786
|
+
do {
|
|
1787
|
+
guard let fula = self.fula else {
|
|
1788
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1789
|
+
DispatchQueue.main.async {
|
|
1790
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1791
|
+
}
|
|
1792
|
+
return
|
|
1793
|
+
}
|
|
1794
|
+
|
|
1795
|
+
let result: Data
|
|
1796
|
+
do {
|
|
1797
|
+
result = try fula.getInstallOutput(pluginName, params: params)
|
|
1798
|
+
} catch {
|
|
1799
|
+
print("Error getting install output: \(error)")
|
|
1800
|
+
DispatchQueue.main.async {
|
|
1801
|
+
reject("ERR_FULA_GET_INSTALL_OUTPUT", "Failed to get install output", error)
|
|
1802
|
+
}
|
|
1803
|
+
return
|
|
1804
|
+
}
|
|
1805
|
+
|
|
1806
|
+
guard !result.isEmpty else {
|
|
1807
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Install output is empty"])
|
|
1808
|
+
DispatchQueue.main.async {
|
|
1809
|
+
reject("ERR_FULA_EMPTY_RESULT", "Empty Install Output", error)
|
|
1810
|
+
}
|
|
1811
|
+
return
|
|
1812
|
+
}
|
|
1813
|
+
|
|
1814
|
+
guard let resultString = String(data: result, encoding: .utf8) else {
|
|
1815
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1003, userInfo: [NSLocalizedDescriptionKey: "Failed to convert install output to string"])
|
|
1816
|
+
DispatchQueue.main.async {
|
|
1817
|
+
reject("ERR_FULA_RESULT_CONVERSION", "Install Output Conversion Error", error)
|
|
1818
|
+
}
|
|
1819
|
+
return
|
|
1820
|
+
}
|
|
1821
|
+
|
|
1822
|
+
DispatchQueue.main.async {
|
|
1823
|
+
resolve(resultString)
|
|
1824
|
+
}
|
|
1825
|
+
} catch {
|
|
1826
|
+
print("getInstallOutput unexpected error:", error.localizedDescription)
|
|
1827
|
+
DispatchQueue.main.async {
|
|
1828
|
+
reject("ERR_FULA_GET_INSTALL_OUTPUT", "getInstallOutput failed unexpectedly", error)
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
@objc(getInstallStatus:withResolver:withRejecter:)
|
|
1835
|
+
func getInstallStatus(pluginName: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1836
|
+
DispatchQueue.global(qos: .background).async {
|
|
1837
|
+
do {
|
|
1838
|
+
guard let fula = self.fula else {
|
|
1839
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1840
|
+
DispatchQueue.main.async {
|
|
1841
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1842
|
+
}
|
|
1843
|
+
return
|
|
1844
|
+
}
|
|
1845
|
+
|
|
1846
|
+
let result: Data
|
|
1847
|
+
do {
|
|
1848
|
+
result = try fula.getInstallStatus(pluginName)
|
|
1849
|
+
} catch {
|
|
1850
|
+
print("Error getting install status: \(error)")
|
|
1851
|
+
DispatchQueue.main.async {
|
|
1852
|
+
reject("ERR_FULA_GET_INSTALL_STATUS", "Failed to get install status", error)
|
|
1853
|
+
}
|
|
1854
|
+
return
|
|
1855
|
+
}
|
|
1856
|
+
|
|
1857
|
+
guard !result.isEmpty else {
|
|
1858
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Install status result is empty"])
|
|
1859
|
+
DispatchQueue.main.async {
|
|
1860
|
+
reject("ERR_FULA_EMPTY_RESULT", "Empty Install Status Result", error)
|
|
1861
|
+
}
|
|
1862
|
+
return
|
|
1863
|
+
}
|
|
1864
|
+
|
|
1865
|
+
guard let resultString = String(data: result, encoding: .utf8) else {
|
|
1866
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1003, userInfo: [NSLocalizedDescriptionKey: "Failed to convert install status to string"])
|
|
1867
|
+
DispatchQueue.main.async {
|
|
1868
|
+
reject("ERR_FULA_RESULT_CONVERSION", "Install Status Conversion Error", error)
|
|
1869
|
+
}
|
|
1870
|
+
return
|
|
1871
|
+
}
|
|
1872
|
+
|
|
1873
|
+
DispatchQueue.main.async {
|
|
1874
|
+
resolve(resultString)
|
|
1875
|
+
}
|
|
1876
|
+
} catch {
|
|
1877
|
+
print("getInstallStatus unexpected error:", error.localizedDescription)
|
|
1878
|
+
DispatchQueue.main.async {
|
|
1879
|
+
reject("ERR_FULA_GET_INSTALL_STATUS", "getInstallStatus failed unexpectedly", error)
|
|
1880
|
+
}
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
@objc(updatePlugin:withResolver:withRejecter:)
|
|
1886
|
+
func updatePlugin(pluginName: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1887
|
+
DispatchQueue.global(qos: .background).async {
|
|
1888
|
+
do {
|
|
1889
|
+
guard let fula = self.fula else {
|
|
1890
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1891
|
+
DispatchQueue.main.async {
|
|
1892
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1893
|
+
}
|
|
1894
|
+
return
|
|
1895
|
+
}
|
|
1896
|
+
|
|
1897
|
+
let result: Data
|
|
1898
|
+
do {
|
|
1899
|
+
result = try fula.updatePlugin(pluginName)
|
|
1900
|
+
} catch {
|
|
1901
|
+
print("Error updating plugin: \(error)")
|
|
1902
|
+
DispatchQueue.main.async {
|
|
1903
|
+
reject("ERR_FULA_UPDATE_PLUGIN", "Failed to update plugin: \(pluginName)", error)
|
|
1904
|
+
}
|
|
1905
|
+
return
|
|
1906
|
+
}
|
|
1907
|
+
|
|
1908
|
+
guard !result.isEmpty else {
|
|
1909
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Update plugin result is empty"])
|
|
1910
|
+
DispatchQueue.main.async {
|
|
1911
|
+
reject("ERR_FULA_EMPTY_RESULT", "Empty Update Plugin Result", error)
|
|
1912
|
+
}
|
|
1913
|
+
return
|
|
1914
|
+
}
|
|
1915
|
+
|
|
1916
|
+
guard let resultString = String(data: result, encoding: .utf8) else {
|
|
1917
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1003, userInfo: [NSLocalizedDescriptionKey: "Failed to convert update plugin result to string"])
|
|
1918
|
+
DispatchQueue.main.async {
|
|
1919
|
+
reject("ERR_FULA_RESULT_CONVERSION", "Update Plugin Result Conversion Error", error)
|
|
1920
|
+
}
|
|
1921
|
+
return
|
|
1922
|
+
}
|
|
1923
|
+
|
|
1924
|
+
DispatchQueue.main.async {
|
|
1925
|
+
resolve(resultString)
|
|
1926
|
+
}
|
|
1927
|
+
} catch {
|
|
1928
|
+
print("updatePlugin unexpected error:", error.localizedDescription)
|
|
1929
|
+
DispatchQueue.main.async {
|
|
1930
|
+
reject("ERR_FULA_UPDATE_PLUGIN", "updatePlugin failed unexpectedly", error)
|
|
1931
|
+
}
|
|
1932
|
+
}
|
|
1933
|
+
}
|
|
1934
|
+
}
|
|
1935
|
+
|
|
1936
|
+
@objc(replicateInPool:withAccount:withPoolID:withResolver:withRejecter:)
|
|
1937
|
+
func replicateInPool(cidArray: [String], account: String, poolID: String, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
1938
|
+
DispatchQueue.global(qos: .background).async {
|
|
1939
|
+
do {
|
|
1940
|
+
guard let fula = self.fula else {
|
|
1941
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1001, userInfo: [NSLocalizedDescriptionKey: "Fula instance is not initialized"])
|
|
1942
|
+
DispatchQueue.main.async {
|
|
1943
|
+
reject("ERR_FULA_NOT_INITIALIZED", "Fula not initialized", error)
|
|
1944
|
+
}
|
|
1945
|
+
return
|
|
1946
|
+
}
|
|
1947
|
+
|
|
1948
|
+
guard let poolIDLong = Int64(poolID) else {
|
|
1949
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1002, userInfo: [NSLocalizedDescriptionKey: "Invalid poolID"])
|
|
1950
|
+
DispatchQueue.main.async {
|
|
1951
|
+
reject("ERR_FULA_INVALID_POOL_ID", "Invalid poolID", error)
|
|
1952
|
+
}
|
|
1953
|
+
return
|
|
1954
|
+
}
|
|
1955
|
+
|
|
1956
|
+
guard let poolIDInt = Int(exactly: poolIDLong) else {
|
|
1957
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1003, userInfo: [NSLocalizedDescriptionKey: "PoolID is too large for Int"])
|
|
1958
|
+
DispatchQueue.main.async {
|
|
1959
|
+
reject("ERR_FULA_POOL_ID_OVERFLOW", "PoolID is too large", error)
|
|
1960
|
+
}
|
|
1961
|
+
return
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1964
|
+
let cidString = cidArray.joined(separator: "|")
|
|
1965
|
+
guard let cidsBytes = cidString.data(using: .utf8) else {
|
|
1966
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1004, userInfo: [NSLocalizedDescriptionKey: "Failed to encode CIDs as data"])
|
|
1967
|
+
DispatchQueue.main.async {
|
|
1968
|
+
reject("ERR_FULA_CID_ENCODING", "Failed to encode CIDs", error)
|
|
1969
|
+
}
|
|
1970
|
+
return
|
|
1971
|
+
}
|
|
1972
|
+
|
|
1973
|
+
let result: Data
|
|
1974
|
+
do {
|
|
1975
|
+
result = try fula.replicate(inPool: cidsBytes, account: account, poolID: poolIDInt)
|
|
1976
|
+
} catch {
|
|
1977
|
+
print("Error replicating in pool: \(error)")
|
|
1978
|
+
DispatchQueue.main.async {
|
|
1979
|
+
reject("ERR_FULA_REPLICATION", "Failed to replicate in pool", error)
|
|
1980
|
+
}
|
|
1981
|
+
return
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
guard !result.isEmpty else {
|
|
1985
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1005, userInfo: [NSLocalizedDescriptionKey: "Replication result is empty"])
|
|
1986
|
+
DispatchQueue.main.async {
|
|
1987
|
+
reject("ERR_FULA_EMPTY_RESULT", "Empty replication result", error)
|
|
1988
|
+
}
|
|
1989
|
+
return
|
|
1990
|
+
}
|
|
1991
|
+
|
|
1992
|
+
guard let resultString = String(data: result, encoding: .utf8) else {
|
|
1993
|
+
let error = NSError(domain: "FULAErrorDomain", code: 1006, userInfo: [NSLocalizedDescriptionKey: "Failed to decode result data to string"])
|
|
1994
|
+
DispatchQueue.main.async {
|
|
1995
|
+
reject("ERR_FULA_RESULT_DECODING", "Failed to decode result", error)
|
|
1996
|
+
}
|
|
1997
|
+
return
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
DispatchQueue.main.async {
|
|
2001
|
+
resolve(resultString)
|
|
2002
|
+
}
|
|
2003
|
+
} catch {
|
|
2004
|
+
print("replicateInPool unexpected error:", error.localizedDescription)
|
|
2005
|
+
DispatchQueue.main.async {
|
|
2006
|
+
reject("ERR_FULA_REPLICATE_IN_POOL", "replicateInPool failed unexpectedly", error)
|
|
2007
|
+
}
|
|
2008
|
+
}
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
1582
2011
|
|
|
1583
|
-
//Add Replicate In Pool (replicateInPool)
|
|
1584
2012
|
|
|
1585
2013
|
}
|
|
1586
2014
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@functionland/react-native-fula",
|
|
3
|
-
"version": "1.54.
|
|
3
|
+
"version": "1.54.26",
|
|
4
4
|
"description": "This package is a bridge to use the Fula libp2p protocols in the react-native which is using wnfs",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|