cactus-react-native 1.0.1 → 1.1.0
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/README.md +609 -56
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusCrypto.kt +23 -15
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusDeviceInfo.kt +12 -9
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusFileSystem.kt +42 -41
- package/android/src/main/java/com/margelo/nitro/cactus/HybridCactusImage.kt +81 -0
- package/android/src/main/jniLibs/arm64-v8a/libcactus.a +0 -0
- package/cpp/HybridCactus.cpp +161 -44
- package/cpp/HybridCactus.hpp +34 -14
- package/cpp/HybridCactusUtil.cpp +13 -11
- package/cpp/HybridCactusUtil.hpp +9 -9
- package/cpp/cactus_ffi.h +28 -1
- package/ios/HybridCactusImage.swift +53 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/cactus_ffi.h +28 -1
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/engine.h +237 -7
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/ffi_utils.h +158 -43
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/graph.h +23 -2
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/Headers/kernel.h +52 -0
- package/ios/cactus.xcframework/ios-arm64/cactus.framework/cactus +0 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/cactus_ffi.h +28 -1
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/engine.h +237 -7
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/ffi_utils.h +158 -43
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/graph.h +23 -2
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/Headers/kernel.h +52 -0
- package/ios/cactus.xcframework/ios-arm64-simulator/cactus.framework/cactus +0 -0
- package/lib/module/api/Database.js +23 -0
- package/lib/module/api/Database.js.map +1 -1
- package/lib/module/api/RemoteLM.js +201 -0
- package/lib/module/api/RemoteLM.js.map +1 -0
- package/lib/module/classes/CactusLM.js +56 -28
- package/lib/module/classes/CactusLM.js.map +1 -1
- package/lib/module/classes/CactusSTT.js +137 -0
- package/lib/module/classes/CactusSTT.js.map +1 -0
- package/lib/module/config/CactusConfig.js +4 -0
- package/lib/module/config/CactusConfig.js.map +1 -1
- package/lib/module/constants/packageVersion.js +1 -1
- package/lib/module/hooks/useCactusLM.js +44 -16
- package/lib/module/hooks/useCactusLM.js.map +1 -1
- package/lib/module/hooks/useCactusSTT.js +234 -0
- package/lib/module/hooks/useCactusSTT.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/native/Cactus.js +52 -3
- package/lib/module/native/Cactus.js.map +1 -1
- package/lib/module/native/CactusFileSystem.js +2 -3
- package/lib/module/native/CactusFileSystem.js.map +1 -1
- package/lib/module/native/CactusImage.js +13 -0
- package/lib/module/native/CactusImage.js.map +1 -0
- package/lib/module/native/index.js +1 -0
- package/lib/module/native/index.js.map +1 -1
- package/lib/module/specs/CactusImage.nitro.js +4 -0
- package/lib/module/specs/CactusImage.nitro.js.map +1 -0
- package/lib/module/telemetry/Telemetry.js +53 -1
- package/lib/module/telemetry/Telemetry.js.map +1 -1
- package/lib/module/types/CactusSTT.js +2 -0
- package/lib/module/types/CactusSTT.js.map +1 -0
- package/lib/typescript/src/api/Database.d.ts +1 -0
- package/lib/typescript/src/api/Database.d.ts.map +1 -1
- package/lib/typescript/src/api/RemoteLM.d.ts +14 -0
- package/lib/typescript/src/api/RemoteLM.d.ts.map +1 -0
- package/lib/typescript/src/classes/CactusLM.d.ts +8 -5
- package/lib/typescript/src/classes/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/classes/CactusSTT.d.ts +25 -0
- package/lib/typescript/src/classes/CactusSTT.d.ts.map +1 -0
- package/lib/typescript/src/config/CactusConfig.d.ts +1 -0
- package/lib/typescript/src/config/CactusConfig.d.ts.map +1 -1
- package/lib/typescript/src/constants/packageVersion.d.ts +1 -1
- package/lib/typescript/src/hooks/useCactusLM.d.ts +5 -4
- package/lib/typescript/src/hooks/useCactusLM.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCactusSTT.d.ts +20 -0
- package/lib/typescript/src/hooks/useCactusSTT.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/native/Cactus.d.ts +10 -3
- package/lib/typescript/src/native/Cactus.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusFileSystem.d.ts +1 -1
- package/lib/typescript/src/native/CactusFileSystem.d.ts.map +1 -1
- package/lib/typescript/src/native/CactusImage.d.ts +6 -0
- package/lib/typescript/src/native/CactusImage.d.ts.map +1 -0
- package/lib/typescript/src/native/index.d.ts +1 -0
- package/lib/typescript/src/native/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/Cactus.nitro.d.ts +4 -1
- package/lib/typescript/src/specs/Cactus.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/CactusImage.nitro.d.ts +9 -0
- package/lib/typescript/src/specs/CactusImage.nitro.d.ts.map +1 -0
- package/lib/typescript/src/telemetry/Telemetry.d.ts +5 -1
- package/lib/typescript/src/telemetry/Telemetry.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusLM.d.ts +11 -6
- package/lib/typescript/src/types/CactusLM.d.ts.map +1 -1
- package/lib/typescript/src/types/CactusSTT.d.ts +37 -0
- package/lib/typescript/src/types/CactusSTT.d.ts.map +1 -0
- package/nitro.json +4 -0
- package/nitrogen/generated/android/c++/JHybridCactusImageSpec.cpp +81 -0
- package/nitrogen/generated/android/c++/JHybridCactusImageSpec.hpp +66 -0
- package/nitrogen/generated/android/cactus+autolinking.cmake +2 -0
- package/nitrogen/generated/android/cactusOnLoad.cpp +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/cactus/HybridCactusImageSpec.kt +62 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.cpp +17 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Bridge.hpp +17 -0
- package/nitrogen/generated/ios/Cactus-Swift-Cxx-Umbrella.hpp +5 -0
- package/nitrogen/generated/ios/CactusAutolinking.mm +8 -0
- package/nitrogen/generated/ios/CactusAutolinking.swift +15 -0
- package/nitrogen/generated/ios/c++/HybridCactusImageSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCactusImageSpecSwift.hpp +85 -0
- package/nitrogen/generated/ios/swift/HybridCactusImageSpec.swift +58 -0
- package/nitrogen/generated/ios/swift/HybridCactusImageSpec_cxx.swift +158 -0
- package/nitrogen/generated/shared/c++/HybridCactusImageSpec.cpp +22 -0
- package/nitrogen/generated/shared/c++/HybridCactusImageSpec.hpp +64 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridCactusSpec.hpp +4 -1
- package/package.json +1 -1
- package/src/api/Database.ts +27 -0
- package/src/api/RemoteLM.ts +273 -0
- package/src/classes/CactusLM.ts +76 -40
- package/src/classes/CactusSTT.ts +182 -0
- package/src/config/CactusConfig.ts +4 -0
- package/src/constants/packageVersion.ts +1 -1
- package/src/hooks/useCactusLM.ts +53 -22
- package/src/hooks/useCactusSTT.ts +285 -0
- package/src/index.tsx +14 -2
- package/src/native/Cactus.ts +100 -6
- package/src/native/CactusFileSystem.ts +2 -2
- package/src/native/CactusImage.ts +20 -0
- package/src/native/index.ts +1 -0
- package/src/specs/Cactus.nitro.ts +14 -1
- package/src/specs/CactusImage.nitro.ts +12 -0
- package/src/telemetry/Telemetry.ts +78 -1
- package/src/types/CactusLM.ts +12 -6
- package/src/types/CactusSTT.ts +42 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { CactusLMCompleteResult } from '../types/CactusLM';
|
|
2
|
+
import type { CactusSTTTranscribeResult } from '../types/CactusSTT';
|
|
2
3
|
export interface LogRecord {
|
|
3
4
|
framework: 'react-native';
|
|
4
5
|
framework_version: string;
|
|
5
|
-
event_type: 'init' | 'completion' | 'embedding';
|
|
6
|
+
event_type: 'init' | 'completion' | 'transcription' | 'embedding' | 'image_embedding' | 'audio_embedding';
|
|
6
7
|
model: string;
|
|
7
8
|
success: boolean;
|
|
8
9
|
message?: string;
|
|
@@ -25,6 +26,9 @@ export declare class Telemetry {
|
|
|
25
26
|
static init(cactusTelemetryToken?: string): Promise<void>;
|
|
26
27
|
static logInit(model: string, success: boolean, message?: string): Promise<void>;
|
|
27
28
|
static logCompletion(model: string, success: boolean, message?: string, result?: CactusLMCompleteResult): Promise<void>;
|
|
29
|
+
static logTranscribe(model: string, success: boolean, message?: string, result?: CactusSTTTranscribeResult): Promise<void>;
|
|
28
30
|
static logEmbedding(model: string, success: boolean, message?: string): Promise<void>;
|
|
31
|
+
static logImageEmbedding(model: string, success: boolean, message?: string): Promise<void>;
|
|
32
|
+
static logAudioEmbedding(model: string, success: boolean, message?: string): Promise<void>;
|
|
29
33
|
}
|
|
30
34
|
//# sourceMappingURL=Telemetry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Telemetry.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/Telemetry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"Telemetry.d.ts","sourceRoot":"","sources":["../../../../src/telemetry/Telemetry.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,WAAW,SAAS;IAExB,SAAS,EAAE,cAAc,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAG1B,UAAU,EACN,MAAM,GACN,YAAY,GACZ,eAAe,GACf,WAAW,GACX,iBAAiB,GACjB,iBAAiB,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IAGnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAS;IAC7C,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAS;IAClC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAS;IAEjC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAA0C;IAC9E,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAOpC;mBAEmB,SAAS;WAiChB,aAAa,IAAI,OAAO;WAIlB,IAAI,CAAC,oBAAoB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;WAyBxD,OAAO,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;WAcF,aAAa,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,sBAAsB,GAC9B,OAAO,CAAC,IAAI,CAAC;WAkBF,aAAa,CACzB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,yBAAyB,GACjC,OAAO,CAAC,IAAI,CAAC;WAkBF,YAAY,CACxB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;WAcF,iBAAiB,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;WAcF,iBAAiB,CAC7B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC;CAajB"}
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export interface CactusLMParams {
|
|
2
2
|
model?: string;
|
|
3
3
|
contextSize?: number;
|
|
4
|
+
corpusDir?: string;
|
|
4
5
|
}
|
|
5
6
|
export interface CactusLMDownloadParams {
|
|
6
7
|
onProgress?: (progress: number) => void;
|
|
7
8
|
}
|
|
8
9
|
export interface Message {
|
|
9
10
|
role: 'user' | 'assistant' | 'system';
|
|
10
|
-
content
|
|
11
|
+
content?: string;
|
|
12
|
+
images?: string[];
|
|
11
13
|
}
|
|
12
|
-
export interface
|
|
14
|
+
export interface CompleteOptions {
|
|
13
15
|
temperature?: number;
|
|
14
16
|
topP?: number;
|
|
15
17
|
topK?: number;
|
|
@@ -17,7 +19,6 @@ export interface Options {
|
|
|
17
19
|
stopSequences?: string[];
|
|
18
20
|
}
|
|
19
21
|
export interface Tool {
|
|
20
|
-
type: 'function';
|
|
21
22
|
name: string;
|
|
22
23
|
description: string;
|
|
23
24
|
parameters: {
|
|
@@ -33,9 +34,10 @@ export interface Tool {
|
|
|
33
34
|
}
|
|
34
35
|
export interface CactusLMCompleteParams {
|
|
35
36
|
messages: Message[];
|
|
36
|
-
options?:
|
|
37
|
+
options?: CompleteOptions;
|
|
37
38
|
tools?: Tool[];
|
|
38
39
|
onToken?: (token: string) => void;
|
|
40
|
+
mode?: 'local' | 'hybrid';
|
|
39
41
|
}
|
|
40
42
|
export interface CactusLMCompleteResult {
|
|
41
43
|
success: boolean;
|
|
@@ -59,7 +61,10 @@ export interface CactusLMEmbedParams {
|
|
|
59
61
|
export interface CactusLMEmbedResult {
|
|
60
62
|
embedding: number[];
|
|
61
63
|
}
|
|
62
|
-
export interface
|
|
63
|
-
|
|
64
|
+
export interface CactusLMImageEmbedParams {
|
|
65
|
+
imagePath: string;
|
|
66
|
+
}
|
|
67
|
+
export interface CactusLMImageEmbedResult {
|
|
68
|
+
embedding: number[];
|
|
64
69
|
}
|
|
65
70
|
//# sourceMappingURL=CactusLM.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CactusLM.d.ts","sourceRoot":"","sources":["../../../../src/types/CactusLM.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"CactusLM.d.ts","sourceRoot":"","sources":["../../../../src/types/CactusLM.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,OAAO;IACtB,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;IACtC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,eAAe;IAC9B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,IAAI;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE;QACV,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE;YACV,CAAC,GAAG,EAAE,MAAM,GAAG;gBACb,IAAI,EAAE,MAAM,CAAC;gBACb,WAAW,EAAE,MAAM,CAAC;aACrB,CAAC;SACH,CAAC;QACF,QAAQ,EAAE,MAAM,EAAE,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,KAAK,CAAC,EAAE,IAAI,EAAE,CAAC;IACf,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,IAAI,CAAC,EAAE,OAAO,GAAG,QAAQ,CAAC;CAC3B;AAED,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,CAAC,EAAE;QACd,IAAI,EAAE,MAAM,CAAC;QACb,SAAS,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;SAAE,CAAC;KACnC,EAAE,CAAC;IACJ,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;IAClC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,wBAAwB;IACvC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface CactusSTTParams {
|
|
2
|
+
model?: string;
|
|
3
|
+
contextSize?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface CactusSTTDownloadParams {
|
|
6
|
+
onProgress?: (progress: number) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface TranscribeOptions {
|
|
9
|
+
temperature?: number;
|
|
10
|
+
topP?: number;
|
|
11
|
+
topK?: number;
|
|
12
|
+
maxTokens?: number;
|
|
13
|
+
stopSequences?: string[];
|
|
14
|
+
}
|
|
15
|
+
export interface CactusSTTTranscribeParams {
|
|
16
|
+
audioFilePath: string;
|
|
17
|
+
prompt?: string;
|
|
18
|
+
options?: TranscribeOptions;
|
|
19
|
+
onToken?: (token: string) => void;
|
|
20
|
+
}
|
|
21
|
+
export interface CactusSTTTranscribeResult {
|
|
22
|
+
success: boolean;
|
|
23
|
+
response: string;
|
|
24
|
+
timeToFirstTokenMs: number;
|
|
25
|
+
totalTimeMs: number;
|
|
26
|
+
tokensPerSecond: number;
|
|
27
|
+
prefillTokens: number;
|
|
28
|
+
decodeTokens: number;
|
|
29
|
+
totalTokens: number;
|
|
30
|
+
}
|
|
31
|
+
export interface CactusSTTAudioEmbedParams {
|
|
32
|
+
audioPath: string;
|
|
33
|
+
}
|
|
34
|
+
export interface CactusSTTAudioEmbedResult {
|
|
35
|
+
embedding: number[];
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=CactusSTT.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CactusSTT.d.ts","sourceRoot":"","sources":["../../../../src/types/CactusSTT.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,uBAAuB;IACtC,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B;AAED,MAAM,WAAW,yBAAyB;IACxC,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,iBAAiB,CAAC;IAC5B,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC;AAED,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB"}
|
package/nitro.json
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JHybridCactusImageSpec.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JHybridCactusImageSpec.hpp"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
#include <string>
|
|
13
|
+
#include <NitroModules/Promise.hpp>
|
|
14
|
+
#include <NitroModules/JPromise.hpp>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::cactus {
|
|
17
|
+
|
|
18
|
+
jni::local_ref<JHybridCactusImageSpec::jhybriddata> JHybridCactusImageSpec::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
19
|
+
return makeCxxInstance(jThis);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
void JHybridCactusImageSpec::registerNatives() {
|
|
23
|
+
registerHybrid({
|
|
24
|
+
makeNativeMethod("initHybrid", JHybridCactusImageSpec::initHybrid),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
size_t JHybridCactusImageSpec::getExternalMemorySize() noexcept {
|
|
29
|
+
static const auto method = javaClassStatic()->getMethod<jlong()>("getMemorySize");
|
|
30
|
+
return method(_javaPart);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
void JHybridCactusImageSpec::dispose() noexcept {
|
|
34
|
+
static const auto method = javaClassStatic()->getMethod<void()>("dispose");
|
|
35
|
+
method(_javaPart);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
std::string JHybridCactusImageSpec::toString() {
|
|
39
|
+
static const auto method = javaClassStatic()->getMethod<jni::JString()>("toString");
|
|
40
|
+
auto javaString = method(_javaPart);
|
|
41
|
+
return javaString->toStdString();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Properties
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
// Methods
|
|
48
|
+
std::shared_ptr<Promise<std::string>> JHybridCactusImageSpec::base64(const std::string& path) {
|
|
49
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* path */)>("base64");
|
|
50
|
+
auto __result = method(_javaPart, jni::make_jstring(path));
|
|
51
|
+
return [&]() {
|
|
52
|
+
auto __promise = Promise<std::string>::create();
|
|
53
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
54
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
55
|
+
__promise->resolve(__result->toStdString());
|
|
56
|
+
});
|
|
57
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
58
|
+
jni::JniException __jniError(__throwable);
|
|
59
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
60
|
+
});
|
|
61
|
+
return __promise;
|
|
62
|
+
}();
|
|
63
|
+
}
|
|
64
|
+
std::shared_ptr<Promise<std::string>> JHybridCactusImageSpec::resize(const std::string& path, double height, double width, double quality) {
|
|
65
|
+
static const auto method = javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* path */, double /* height */, double /* width */, double /* quality */)>("resize");
|
|
66
|
+
auto __result = method(_javaPart, jni::make_jstring(path), height, width, quality);
|
|
67
|
+
return [&]() {
|
|
68
|
+
auto __promise = Promise<std::string>::create();
|
|
69
|
+
__result->cthis()->addOnResolvedListener([=](const jni::alias_ref<jni::JObject>& __boxedResult) {
|
|
70
|
+
auto __result = jni::static_ref_cast<jni::JString>(__boxedResult);
|
|
71
|
+
__promise->resolve(__result->toStdString());
|
|
72
|
+
});
|
|
73
|
+
__result->cthis()->addOnRejectedListener([=](const jni::alias_ref<jni::JThrowable>& __throwable) {
|
|
74
|
+
jni::JniException __jniError(__throwable);
|
|
75
|
+
__promise->reject(std::make_exception_ptr(__jniError));
|
|
76
|
+
});
|
|
77
|
+
return __promise;
|
|
78
|
+
}();
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
} // namespace margelo::nitro::cactus
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCactusImageSpec.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <NitroModules/JHybridObject.hpp>
|
|
11
|
+
#include <fbjni/fbjni.h>
|
|
12
|
+
#include "HybridCactusImageSpec.hpp"
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
namespace margelo::nitro::cactus {
|
|
18
|
+
|
|
19
|
+
using namespace facebook;
|
|
20
|
+
|
|
21
|
+
class JHybridCactusImageSpec: public jni::HybridClass<JHybridCactusImageSpec, JHybridObject>,
|
|
22
|
+
public virtual HybridCactusImageSpec {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/cactus/HybridCactusImageSpec;";
|
|
25
|
+
static jni::local_ref<jhybriddata> initHybrid(jni::alias_ref<jhybridobject> jThis);
|
|
26
|
+
static void registerNatives();
|
|
27
|
+
|
|
28
|
+
protected:
|
|
29
|
+
// C++ constructor (called from Java via `initHybrid()`)
|
|
30
|
+
explicit JHybridCactusImageSpec(jni::alias_ref<jhybridobject> jThis) :
|
|
31
|
+
HybridObject(HybridCactusImageSpec::TAG),
|
|
32
|
+
HybridBase(jThis),
|
|
33
|
+
_javaPart(jni::make_global(jThis)) {}
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
~JHybridCactusImageSpec() override {
|
|
37
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
38
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
size_t getExternalMemorySize() noexcept override;
|
|
43
|
+
void dispose() noexcept override;
|
|
44
|
+
std::string toString() override;
|
|
45
|
+
|
|
46
|
+
public:
|
|
47
|
+
inline const jni::global_ref<JHybridCactusImageSpec::javaobject>& getJavaPart() const noexcept {
|
|
48
|
+
return _javaPart;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
// Properties
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
// Methods
|
|
57
|
+
std::shared_ptr<Promise<std::string>> base64(const std::string& path) override;
|
|
58
|
+
std::shared_ptr<Promise<std::string>> resize(const std::string& path, double height, double width, double quality) override;
|
|
59
|
+
|
|
60
|
+
private:
|
|
61
|
+
friend HybridBase;
|
|
62
|
+
using HybridBase::HybridBase;
|
|
63
|
+
jni::global_ref<JHybridCactusImageSpec::javaobject> _javaPart;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
} // namespace margelo::nitro::cactus
|
|
@@ -37,11 +37,13 @@ target_sources(
|
|
|
37
37
|
../nitrogen/generated/shared/c++/HybridCactusCryptoSpec.cpp
|
|
38
38
|
../nitrogen/generated/shared/c++/HybridCactusDeviceInfoSpec.cpp
|
|
39
39
|
../nitrogen/generated/shared/c++/HybridCactusFileSystemSpec.cpp
|
|
40
|
+
../nitrogen/generated/shared/c++/HybridCactusImageSpec.cpp
|
|
40
41
|
../nitrogen/generated/shared/c++/HybridCactusUtilSpec.cpp
|
|
41
42
|
# Android-specific Nitrogen C++ sources
|
|
42
43
|
../nitrogen/generated/android/c++/JHybridCactusCryptoSpec.cpp
|
|
43
44
|
../nitrogen/generated/android/c++/JHybridCactusDeviceInfoSpec.cpp
|
|
44
45
|
../nitrogen/generated/android/c++/JHybridCactusFileSystemSpec.cpp
|
|
46
|
+
../nitrogen/generated/android/c++/JHybridCactusImageSpec.cpp
|
|
45
47
|
)
|
|
46
48
|
|
|
47
49
|
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
#include "JHybridCactusDeviceInfoSpec.hpp"
|
|
20
20
|
#include "JHybridCactusFileSystemSpec.hpp"
|
|
21
21
|
#include "JFunc_void_double.hpp"
|
|
22
|
+
#include "JHybridCactusImageSpec.hpp"
|
|
22
23
|
#include "HybridCactus.hpp"
|
|
23
24
|
#include "HybridCactusUtil.hpp"
|
|
24
25
|
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
@@ -36,6 +37,7 @@ int initialize(JavaVM* vm) {
|
|
|
36
37
|
margelo::nitro::cactus::JHybridCactusDeviceInfoSpec::registerNatives();
|
|
37
38
|
margelo::nitro::cactus::JHybridCactusFileSystemSpec::registerNatives();
|
|
38
39
|
margelo::nitro::cactus::JFunc_void_double_cxx::registerNatives();
|
|
40
|
+
margelo::nitro::cactus::JHybridCactusImageSpec::registerNatives();
|
|
39
41
|
|
|
40
42
|
// Register Nitro Hybrid Objects
|
|
41
43
|
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
@@ -80,6 +82,14 @@ int initialize(JavaVM* vm) {
|
|
|
80
82
|
return instance->cthis()->shared();
|
|
81
83
|
}
|
|
82
84
|
);
|
|
85
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
86
|
+
"CactusImage",
|
|
87
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
88
|
+
static DefaultConstructableObject<JHybridCactusImageSpec::javaobject> object("com/margelo/nitro/cactus/HybridCactusImage");
|
|
89
|
+
auto instance = object.create();
|
|
90
|
+
return instance->cthis()->shared();
|
|
91
|
+
}
|
|
92
|
+
);
|
|
83
93
|
});
|
|
84
94
|
}
|
|
85
95
|
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCactusImageSpec.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.cactus
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.Promise
|
|
14
|
+
import com.margelo.nitro.core.HybridObject
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A Kotlin class representing the CactusImage HybridObject.
|
|
18
|
+
* Implement this abstract class to create Kotlin-based instances of CactusImage.
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress(
|
|
23
|
+
"KotlinJniMissingFunction", "unused",
|
|
24
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
25
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
26
|
+
)
|
|
27
|
+
abstract class HybridCactusImageSpec: HybridObject() {
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
private var mHybridData: HybridData = initHybrid()
|
|
30
|
+
|
|
31
|
+
init {
|
|
32
|
+
super.updateNative(mHybridData)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun updateNative(hybridData: HybridData) {
|
|
36
|
+
mHybridData = hybridData
|
|
37
|
+
super.updateNative(hybridData)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Default implementation of `HybridObject.toString()`
|
|
41
|
+
override fun toString(): String {
|
|
42
|
+
return "[HybridObject CactusImage]"
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Properties
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
// Methods
|
|
49
|
+
@DoNotStrip
|
|
50
|
+
@Keep
|
|
51
|
+
abstract fun base64(path: String): Promise<String>
|
|
52
|
+
|
|
53
|
+
@DoNotStrip
|
|
54
|
+
@Keep
|
|
55
|
+
abstract fun resize(path: String, height: Double, width: Double, quality: Double): Promise<String>
|
|
56
|
+
|
|
57
|
+
private external fun initHybrid(): HybridData
|
|
58
|
+
|
|
59
|
+
companion object {
|
|
60
|
+
protected const val TAG = "HybridCactusImageSpec"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include "HybridCactusCryptoSpecSwift.hpp"
|
|
13
13
|
#include "HybridCactusDeviceInfoSpecSwift.hpp"
|
|
14
14
|
#include "HybridCactusFileSystemSpecSwift.hpp"
|
|
15
|
+
#include "HybridCactusImageSpecSwift.hpp"
|
|
15
16
|
|
|
16
17
|
namespace margelo::nitro::cactus::bridge::swift {
|
|
17
18
|
|
|
@@ -118,5 +119,21 @@ namespace margelo::nitro::cactus::bridge::swift {
|
|
|
118
119
|
Cactus::HybridCactusFileSystemSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
119
120
|
return swiftPart.toUnsafe();
|
|
120
121
|
}
|
|
122
|
+
|
|
123
|
+
// pragma MARK: std::shared_ptr<HybridCactusImageSpec>
|
|
124
|
+
std::shared_ptr<HybridCactusImageSpec> create_std__shared_ptr_HybridCactusImageSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
125
|
+
Cactus::HybridCactusImageSpec_cxx swiftPart = Cactus::HybridCactusImageSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
|
126
|
+
return std::make_shared<margelo::nitro::cactus::HybridCactusImageSpecSwift>(swiftPart);
|
|
127
|
+
}
|
|
128
|
+
void* NON_NULL get_std__shared_ptr_HybridCactusImageSpec_(std__shared_ptr_HybridCactusImageSpec_ cppType) {
|
|
129
|
+
std::shared_ptr<margelo::nitro::cactus::HybridCactusImageSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::cactus::HybridCactusImageSpecSwift>(cppType);
|
|
130
|
+
#ifdef NITRO_DEBUG
|
|
131
|
+
if (swiftWrapper == nullptr) [[unlikely]] {
|
|
132
|
+
throw std::runtime_error("Class \"HybridCactusImageSpec\" is not implemented in Swift!");
|
|
133
|
+
}
|
|
134
|
+
#endif
|
|
135
|
+
Cactus::HybridCactusImageSpec_cxx& swiftPart = swiftWrapper->getSwiftPart();
|
|
136
|
+
return swiftPart.toUnsafe();
|
|
137
|
+
}
|
|
121
138
|
|
|
122
139
|
} // namespace margelo::nitro::cactus::bridge::swift
|
|
@@ -16,6 +16,8 @@ namespace margelo::nitro::cactus { class HybridCactusCryptoSpec; }
|
|
|
16
16
|
namespace margelo::nitro::cactus { class HybridCactusDeviceInfoSpec; }
|
|
17
17
|
// Forward declaration of `HybridCactusFileSystemSpec` to properly resolve imports.
|
|
18
18
|
namespace margelo::nitro::cactus { class HybridCactusFileSystemSpec; }
|
|
19
|
+
// Forward declaration of `HybridCactusImageSpec` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::cactus { class HybridCactusImageSpec; }
|
|
19
21
|
|
|
20
22
|
// Forward declarations of Swift defined types
|
|
21
23
|
// Forward declaration of `HybridCactusCryptoSpec_cxx` to properly resolve imports.
|
|
@@ -24,12 +26,15 @@ namespace Cactus { class HybridCactusCryptoSpec_cxx; }
|
|
|
24
26
|
namespace Cactus { class HybridCactusDeviceInfoSpec_cxx; }
|
|
25
27
|
// Forward declaration of `HybridCactusFileSystemSpec_cxx` to properly resolve imports.
|
|
26
28
|
namespace Cactus { class HybridCactusFileSystemSpec_cxx; }
|
|
29
|
+
// Forward declaration of `HybridCactusImageSpec_cxx` to properly resolve imports.
|
|
30
|
+
namespace Cactus { class HybridCactusImageSpec_cxx; }
|
|
27
31
|
|
|
28
32
|
// Include C++ defined types
|
|
29
33
|
#include "DeviceInfo.hpp"
|
|
30
34
|
#include "HybridCactusCryptoSpec.hpp"
|
|
31
35
|
#include "HybridCactusDeviceInfoSpec.hpp"
|
|
32
36
|
#include "HybridCactusFileSystemSpec.hpp"
|
|
37
|
+
#include "HybridCactusImageSpec.hpp"
|
|
33
38
|
#include <NitroModules/Promise.hpp>
|
|
34
39
|
#include <NitroModules/PromiseHolder.hpp>
|
|
35
40
|
#include <NitroModules/Result.hpp>
|
|
@@ -369,5 +374,17 @@ namespace margelo::nitro::cactus::bridge::swift {
|
|
|
369
374
|
inline Result_std__shared_ptr_Promise_void___ create_Result_std__shared_ptr_Promise_void___(const std::exception_ptr& error) noexcept {
|
|
370
375
|
return Result<std::shared_ptr<Promise<void>>>::withError(error);
|
|
371
376
|
}
|
|
377
|
+
|
|
378
|
+
// pragma MARK: std::shared_ptr<HybridCactusImageSpec>
|
|
379
|
+
/**
|
|
380
|
+
* Specialized version of `std::shared_ptr<HybridCactusImageSpec>`.
|
|
381
|
+
*/
|
|
382
|
+
using std__shared_ptr_HybridCactusImageSpec_ = std::shared_ptr<HybridCactusImageSpec>;
|
|
383
|
+
std::shared_ptr<HybridCactusImageSpec> create_std__shared_ptr_HybridCactusImageSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
|
|
384
|
+
void* NON_NULL get_std__shared_ptr_HybridCactusImageSpec_(std__shared_ptr_HybridCactusImageSpec_ cppType);
|
|
385
|
+
|
|
386
|
+
// pragma MARK: std::weak_ptr<HybridCactusImageSpec>
|
|
387
|
+
using std__weak_ptr_HybridCactusImageSpec_ = std::weak_ptr<HybridCactusImageSpec>;
|
|
388
|
+
inline std__weak_ptr_HybridCactusImageSpec_ weakify_std__shared_ptr_HybridCactusImageSpec_(const std::shared_ptr<HybridCactusImageSpec>& strong) noexcept { return strong; }
|
|
372
389
|
|
|
373
390
|
} // namespace margelo::nitro::cactus::bridge::swift
|
|
@@ -16,12 +16,15 @@ namespace margelo::nitro::cactus { class HybridCactusCryptoSpec; }
|
|
|
16
16
|
namespace margelo::nitro::cactus { class HybridCactusDeviceInfoSpec; }
|
|
17
17
|
// Forward declaration of `HybridCactusFileSystemSpec` to properly resolve imports.
|
|
18
18
|
namespace margelo::nitro::cactus { class HybridCactusFileSystemSpec; }
|
|
19
|
+
// Forward declaration of `HybridCactusImageSpec` to properly resolve imports.
|
|
20
|
+
namespace margelo::nitro::cactus { class HybridCactusImageSpec; }
|
|
19
21
|
|
|
20
22
|
// Include C++ defined types
|
|
21
23
|
#include "DeviceInfo.hpp"
|
|
22
24
|
#include "HybridCactusCryptoSpec.hpp"
|
|
23
25
|
#include "HybridCactusDeviceInfoSpec.hpp"
|
|
24
26
|
#include "HybridCactusFileSystemSpec.hpp"
|
|
27
|
+
#include "HybridCactusImageSpec.hpp"
|
|
25
28
|
#include <NitroModules/Promise.hpp>
|
|
26
29
|
#include <NitroModules/Result.hpp>
|
|
27
30
|
#include <exception>
|
|
@@ -46,6 +49,8 @@ namespace Cactus { class HybridCactusCryptoSpec_cxx; }
|
|
|
46
49
|
namespace Cactus { class HybridCactusDeviceInfoSpec_cxx; }
|
|
47
50
|
// Forward declaration of `HybridCactusFileSystemSpec_cxx` to properly resolve imports.
|
|
48
51
|
namespace Cactus { class HybridCactusFileSystemSpec_cxx; }
|
|
52
|
+
// Forward declaration of `HybridCactusImageSpec_cxx` to properly resolve imports.
|
|
53
|
+
namespace Cactus { class HybridCactusImageSpec_cxx; }
|
|
49
54
|
|
|
50
55
|
// Include Swift defined types
|
|
51
56
|
#if __has_include("Cactus-Swift.h")
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
#include "HybridCactusFileSystemSpecSwift.hpp"
|
|
16
16
|
#include "HybridCactusCryptoSpecSwift.hpp"
|
|
17
17
|
#include "HybridCactusDeviceInfoSpecSwift.hpp"
|
|
18
|
+
#include "HybridCactusImageSpecSwift.hpp"
|
|
18
19
|
|
|
19
20
|
@interface CactusAutolinking : NSObject
|
|
20
21
|
@end
|
|
@@ -64,6 +65,13 @@
|
|
|
64
65
|
return hybridObject;
|
|
65
66
|
}
|
|
66
67
|
);
|
|
68
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
69
|
+
"CactusImage",
|
|
70
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
71
|
+
std::shared_ptr<HybridCactusImageSpec> hybridObject = Cactus::CactusAutolinking::createCactusImage();
|
|
72
|
+
return hybridObject;
|
|
73
|
+
}
|
|
74
|
+
);
|
|
67
75
|
}
|
|
68
76
|
|
|
69
77
|
@end
|
|
@@ -52,4 +52,19 @@ public final class CactusAutolinking {
|
|
|
52
52
|
return __cxxWrapped.getCxxPart()
|
|
53
53
|
}()
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Creates an instance of a Swift class that implements `HybridCactusImageSpec`,
|
|
58
|
+
* and wraps it in a Swift class that can directly interop with C++ (`HybridCactusImageSpec_cxx`)
|
|
59
|
+
*
|
|
60
|
+
* This is generated by Nitrogen and will initialize the class specified
|
|
61
|
+
* in the `"autolinking"` property of `nitro.json` (in this case, `HybridCactusImage`).
|
|
62
|
+
*/
|
|
63
|
+
public static func createCactusImage() -> bridge.std__shared_ptr_HybridCactusImageSpec_ {
|
|
64
|
+
let hybridObject = HybridCactusImage()
|
|
65
|
+
return { () -> bridge.std__shared_ptr_HybridCactusImageSpec_ in
|
|
66
|
+
let __cxxWrapped = hybridObject.getCxxWrapper()
|
|
67
|
+
return __cxxWrapped.getCxxPart()
|
|
68
|
+
}()
|
|
69
|
+
}
|
|
55
70
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCactusImageSpecSwift.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "HybridCactusImageSpecSwift.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::cactus {
|
|
11
|
+
} // namespace margelo::nitro::cactus
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridCactusImageSpecSwift.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include "HybridCactusImageSpec.hpp"
|
|
11
|
+
|
|
12
|
+
// Forward declaration of `HybridCactusImageSpec_cxx` to properly resolve imports.
|
|
13
|
+
namespace Cactus { class HybridCactusImageSpec_cxx; }
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
#include <string>
|
|
18
|
+
#include <NitroModules/Promise.hpp>
|
|
19
|
+
|
|
20
|
+
#include "Cactus-Swift-Cxx-Umbrella.hpp"
|
|
21
|
+
|
|
22
|
+
namespace margelo::nitro::cactus {
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The C++ part of HybridCactusImageSpec_cxx.swift.
|
|
26
|
+
*
|
|
27
|
+
* HybridCactusImageSpecSwift (C++) accesses HybridCactusImageSpec_cxx (Swift), and might
|
|
28
|
+
* contain some additional bridging code for C++ <> Swift interop.
|
|
29
|
+
*
|
|
30
|
+
* Since this obviously introduces an overhead, I hope at some point in
|
|
31
|
+
* the future, HybridCactusImageSpec_cxx can directly inherit from the C++ class HybridCactusImageSpec
|
|
32
|
+
* to simplify the whole structure and memory management.
|
|
33
|
+
*/
|
|
34
|
+
class HybridCactusImageSpecSwift: public virtual HybridCactusImageSpec {
|
|
35
|
+
public:
|
|
36
|
+
// Constructor from a Swift instance
|
|
37
|
+
explicit HybridCactusImageSpecSwift(const Cactus::HybridCactusImageSpec_cxx& swiftPart):
|
|
38
|
+
HybridObject(HybridCactusImageSpec::TAG),
|
|
39
|
+
_swiftPart(swiftPart) { }
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
// Get the Swift part
|
|
43
|
+
inline Cactus::HybridCactusImageSpec_cxx& getSwiftPart() noexcept {
|
|
44
|
+
return _swiftPart;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
inline size_t getExternalMemorySize() noexcept override {
|
|
49
|
+
return _swiftPart.getMemorySize();
|
|
50
|
+
}
|
|
51
|
+
void dispose() noexcept override {
|
|
52
|
+
_swiftPart.dispose();
|
|
53
|
+
}
|
|
54
|
+
std::string toString() override {
|
|
55
|
+
return _swiftPart.toString();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
// Properties
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
public:
|
|
63
|
+
// Methods
|
|
64
|
+
inline std::shared_ptr<Promise<std::string>> base64(const std::string& path) override {
|
|
65
|
+
auto __result = _swiftPart.base64(path);
|
|
66
|
+
if (__result.hasError()) [[unlikely]] {
|
|
67
|
+
std::rethrow_exception(__result.error());
|
|
68
|
+
}
|
|
69
|
+
auto __value = std::move(__result.value());
|
|
70
|
+
return __value;
|
|
71
|
+
}
|
|
72
|
+
inline std::shared_ptr<Promise<std::string>> resize(const std::string& path, double height, double width, double quality) override {
|
|
73
|
+
auto __result = _swiftPart.resize(path, std::forward<decltype(height)>(height), std::forward<decltype(width)>(width), std::forward<decltype(quality)>(quality));
|
|
74
|
+
if (__result.hasError()) [[unlikely]] {
|
|
75
|
+
std::rethrow_exception(__result.error());
|
|
76
|
+
}
|
|
77
|
+
auto __value = std::move(__result.value());
|
|
78
|
+
return __value;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private:
|
|
82
|
+
Cactus::HybridCactusImageSpec_cxx _swiftPart;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
} // namespace margelo::nitro::cactus
|