react-native-nitro-image-pipeline 1.3.2 → 1.5.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 +103 -11
- package/android/CMakeLists.txt +4 -0
- package/android/src/main/cpp/GaussianBlur.cpp +165 -0
- package/android/src/main/cpp/GaussianBlur.hpp +52 -0
- package/android/src/main/cpp/GaussianBlurJni.cpp +50 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipeline.kt +153 -74
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/PipelineImageLoader.kt +177 -0
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/BlurTransformation.kt +36 -81
- package/android/src/main/java/com/margelo/nitro/nitroimagepipeline/transform/HardwareBitmapTransformation.kt +45 -0
- package/ios/GaussianBlur.swift +48 -9
- package/ios/HybridNitroImagePipeline.swift +79 -33
- package/ios/PipelineImageLoader.swift +195 -0
- package/ios/RoundedCornersProcessor.swift +5 -0
- package/lib/commonjs/NativePipelineImage.js +71 -0
- package/lib/commonjs/NativePipelineImage.js.map +1 -0
- package/lib/commonjs/index.js +14 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/usePipelineImageLoader.js +69 -0
- package/lib/commonjs/usePipelineImageLoader.js.map +1 -0
- package/lib/module/NativePipelineImage.js +67 -0
- package/lib/module/NativePipelineImage.js.map +1 -0
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/usePipelineImageLoader.js +65 -0
- package/lib/module/usePipelineImageLoader.js.map +1 -0
- package/lib/typescript/src/NativePipelineImage.d.ts +66 -0
- package/lib/typescript/src/NativePipelineImage.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +3 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts +54 -1
- package/lib/typescript/src/specs/nitro-image-toolkit.nitro.d.ts.map +1 -1
- package/lib/typescript/src/usePipelineImageLoader.d.ts +15 -0
- package/lib/typescript/src/usePipelineImageLoader.d.ts.map +1 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.cpp +17 -0
- package/nitrogen/generated/android/c++/JHybridNitroImagePipelineSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JViewOptions.hpp +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/HybridNitroImagePipelineSpec.kt +9 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroimagepipeline/ViewOptions.kt +66 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.cpp +10 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Bridge.hpp +53 -0
- package/nitrogen/generated/ios/NitroImagePipeline-Swift-Cxx-Umbrella.hpp +8 -0
- package/nitrogen/generated/ios/c++/HybridNitroImagePipelineSpecSwift.hpp +20 -0
- package/nitrogen/generated/ios/swift/HybridNitroImagePipelineSpec.swift +2 -0
- package/nitrogen/generated/ios/swift/HybridNitroImagePipelineSpec_cxx.swift +26 -0
- package/nitrogen/generated/ios/swift/ViewOptions.swift +101 -0
- package/nitrogen/generated/shared/c++/HybridNitroImagePipelineSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridNitroImagePipelineSpec.hpp +8 -0
- package/nitrogen/generated/shared/c++/ViewOptions.hpp +104 -0
- package/package.json +4 -3
- package/src/NativePipelineImage.tsx +103 -0
- package/src/index.ts +7 -0
- package/src/specs/nitro-image-toolkit.nitro.ts +56 -1
- package/src/usePipelineImageLoader.ts +82 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { NativeNitroImage } from 'react-native-nitro-image';
|
|
5
|
+
import { cornerRadiusForStyle } from './resizeForStyle';
|
|
6
|
+
import { usePipelineImageLoader } from './usePipelineImageLoader';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The instance `<NativePipelineImage>` exposes through its `ref` — the
|
|
10
|
+
* underlying `NativeNitroImage` host view, with the usual native-view
|
|
11
|
+
* methods (`measure`, …).
|
|
12
|
+
*/
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
/**
|
|
15
|
+
* The fully native-driven variant of `PipelineImage`: after the first render
|
|
16
|
+
* there is **zero JS work per image**. The native view starts the request
|
|
17
|
+
* when it attaches to the window — at its own laid-out size, so nothing
|
|
18
|
+
* waits for an `onLayout` round trip — and cancels it (releasing the bitmap)
|
|
19
|
+
* when it detaches, which makes off-screen list cells free. Loads go through
|
|
20
|
+
* the same pipeline and caches as `useImage`/`preLoadImage`.
|
|
21
|
+
*
|
|
22
|
+
* Compared to `PipelineImage`:
|
|
23
|
+
* - No `onLoad`/`onError` callbacks — the loaded `Image` never crosses into
|
|
24
|
+
* JS. Use `PipelineImage` (or `useImage`) when you need them.
|
|
25
|
+
* - The bitmap is loaded once at the size the view first has; if the view is
|
|
26
|
+
* resized later, the bitmap scales with it instead of reloading.
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* <NativePipelineImage
|
|
30
|
+
* url="https://example.com/photo.jpg"
|
|
31
|
+
* style={{ width: 300, height: 200, borderRadius: 24 }}
|
|
32
|
+
* blur={4}
|
|
33
|
+
* />
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
export const NativePipelineImage = /*#__PURE__*/forwardRef(function NativePipelineImage({
|
|
37
|
+
url,
|
|
38
|
+
blur,
|
|
39
|
+
cornerRadius,
|
|
40
|
+
cache,
|
|
41
|
+
resize,
|
|
42
|
+
style,
|
|
43
|
+
...viewProps
|
|
44
|
+
}, ref) {
|
|
45
|
+
// Same precedence as PipelineImage: an explicit prop wins over style.
|
|
46
|
+
const effectiveCornerRadius = cornerRadius ?? cornerRadiusForStyle(style);
|
|
47
|
+
const loader = usePipelineImageLoader(url, {
|
|
48
|
+
blur,
|
|
49
|
+
cornerRadius: effectiveCornerRadius,
|
|
50
|
+
cache,
|
|
51
|
+
resize
|
|
52
|
+
});
|
|
53
|
+
return /*#__PURE__*/_jsx(NativeNitroImage
|
|
54
|
+
// Before the spread so a caller-provided recyclingKey wins.
|
|
55
|
+
, {
|
|
56
|
+
recyclingKey: url,
|
|
57
|
+
...viewProps,
|
|
58
|
+
ref: ref,
|
|
59
|
+
style: style,
|
|
60
|
+
image: loader
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Reanimated and DevTools read the display name; the forwardRef wrapper
|
|
65
|
+
// would otherwise report as anonymous.
|
|
66
|
+
NativePipelineImage.displayName = 'NativePipelineImage';
|
|
67
|
+
//# sourceMappingURL=NativePipelineImage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["forwardRef","NativeNitroImage","cornerRadiusForStyle","usePipelineImageLoader","jsx","_jsx","NativePipelineImage","url","blur","cornerRadius","cache","resize","style","viewProps","ref","effectiveCornerRadius","loader","recyclingKey","image","displayName"],"sourceRoot":"../../src","sources":["NativePipelineImage.tsx"],"mappings":";;AAAA,SAA4BA,UAAU,QAAQ,OAAO;AAErD,SAASC,gBAAgB,QAAQ,0BAA0B;AAE3D,SAASC,oBAAoB,QAAQ,kBAAkB;AAMvD,SAASC,sBAAsB,QAAQ,0BAA0B;;AAKjE;AACA;AACA;AACA;AACA;AAJA,SAAAC,GAAA,IAAAC,IAAA;AAmCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,mBAAmB,gBAAGN,UAAU,CAG3C,SAASM,mBAAmBA,CAC5B;EAAEC,GAAG;EAAEC,IAAI;EAAEC,YAAY;EAAEC,KAAK;EAAEC,MAAM;EAAEC,KAAK;EAAE,GAAGC;AAAU,CAAC,EAC/DC,GAAG,EACH;EACA;EACA,MAAMC,qBAAqB,GAAGN,YAAY,IAAIP,oBAAoB,CAACU,KAAK,CAAC;EACzE,MAAMI,MAAM,GAAGb,sBAAsB,CAACI,GAAG,EAAE;IACzCC,IAAI;IACJC,YAAY,EAAEM,qBAAqB;IACnCL,KAAK;IACLC;EACF,CAAC,CAAC;EAEF,oBACEN,IAAA,CAACJ;EACC;EAAA;IACAgB,YAAY,EAAEV,GAAI;IAAA,GACdM,SAAS;IACbC,GAAG,EAAEA,GAAI;IACTF,KAAK,EAAEA,KAAM;IACbM,KAAK,EAAEF;EAAO,CACf,CAAC;AAEN,CAAC,CAAC;;AAEF;AACA;AACAV,mBAAmB,CAACa,WAAW,GAAG,qBAAqB","ignoreList":[]}
|
package/lib/module/index.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
export { NativePipelineImage } from './NativePipelineImage';
|
|
3
4
|
export { NitroImagePipeline } from './NitroImagePipeline';
|
|
4
5
|
export { PipelineImage } from './PipelineImage';
|
|
5
6
|
export { cornerRadiusForStyle, resizeForLayout, resizeForStyle } from './resizeForStyle';
|
|
6
7
|
export { useImage } from './useImage';
|
|
8
|
+
export { usePipelineImageLoader } from './usePipelineImageLoader';
|
|
7
9
|
//# sourceMappingURL=index.js.map
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NitroImagePipeline","PipelineImage","cornerRadiusForStyle","resizeForLayout","resizeForStyle","useImage"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,
|
|
1
|
+
{"version":3,"names":["NativePipelineImage","NitroImagePipeline","PipelineImage","cornerRadiusForStyle","resizeForLayout","resizeForStyle","useImage","usePipelineImageLoader"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,SACEA,mBAAmB,QAGd,uBAAuB;AAC9B,SAASC,kBAAkB,QAAQ,sBAAsB;AACzD,SACEC,aAAa,QAGR,iBAAiB;AACxB,SACEC,oBAAoB,EACpBC,eAAe,EACfC,cAAc,QACT,kBAAkB;AAQzB,SAASC,QAAQ,QAAQ,YAAY;AACrC,SAASC,sBAAsB,QAAQ,0BAA0B","ignoreList":[]}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
import { useMemo } from 'react';
|
|
4
|
+
import { NitroImagePipeline } from './NitroImagePipeline';
|
|
5
|
+
/**
|
|
6
|
+
* Creates (and memoizes) an {@linkcode ImageLoader} for `url` to pass to
|
|
7
|
+
* `<NativeNitroImage image={...} />`. The view drives it entirely natively:
|
|
8
|
+
* the request starts when the view attaches — at the view's laid-out size,
|
|
9
|
+
* with no JS round trips — and is cancelled when it detaches. See
|
|
10
|
+
* {@linkcode NitroImagePipeline.createImageLoader}.
|
|
11
|
+
*
|
|
12
|
+
* `blur`/`cornerRadius` are in **points** (unlike `useImage`, where they are
|
|
13
|
+
* bitmap pixels); the screen scale is applied natively. Inline object
|
|
14
|
+
* literals are fine — options are compared by value, not identity.
|
|
15
|
+
*/
|
|
16
|
+
export function usePipelineImageLoader(url, options) {
|
|
17
|
+
// Split the options into primitives (like useImage does) so an inline
|
|
18
|
+
// literal — a new identity every render — doesn't recreate the loader;
|
|
19
|
+
// recreating it would re-trigger the native load.
|
|
20
|
+
const blur = options?.blur;
|
|
21
|
+
const cache = options?.cache;
|
|
22
|
+
const cornerRadius = options?.cornerRadius;
|
|
23
|
+
const isUniformRadius = typeof cornerRadius === 'number';
|
|
24
|
+
const uniformRadius = isUniformRadius ? cornerRadius : 0;
|
|
25
|
+
const hasCornerObject = !isUniformRadius && cornerRadius !== undefined;
|
|
26
|
+
const {
|
|
27
|
+
topLeft = 0,
|
|
28
|
+
topRight = 0,
|
|
29
|
+
bottomLeft = 0,
|
|
30
|
+
bottomRight = 0
|
|
31
|
+
} = isUniformRadius || cornerRadius === undefined ? {} : cornerRadius;
|
|
32
|
+
const resizeWidth = options?.resize?.width;
|
|
33
|
+
const resizeHeight = options?.resize?.height;
|
|
34
|
+
return useMemo(() => {
|
|
35
|
+
const cornerRadiusOption = isUniformRadius ? uniformRadius : hasCornerObject ? {
|
|
36
|
+
topLeft,
|
|
37
|
+
topRight,
|
|
38
|
+
bottomLeft,
|
|
39
|
+
bottomRight
|
|
40
|
+
} : undefined;
|
|
41
|
+
const stableOptions = {
|
|
42
|
+
blur,
|
|
43
|
+
cache,
|
|
44
|
+
cornerRadius: cornerRadiusOption,
|
|
45
|
+
resize: resizeWidth !== undefined && resizeHeight !== undefined ? {
|
|
46
|
+
width: resizeWidth,
|
|
47
|
+
height: resizeHeight
|
|
48
|
+
} : undefined
|
|
49
|
+
};
|
|
50
|
+
const loader = NitroImagePipeline.createImageLoader(url, stableOptions);
|
|
51
|
+
// `NativeNitroImage` needs a way to tell two loader instances apart when
|
|
52
|
+
// diffing its `image` prop; tag the loader with what it will load (the
|
|
53
|
+
// same convention react-native-nitro-image's own loaders use).
|
|
54
|
+
Object.defineProperty(loader, '__source', {
|
|
55
|
+
enumerable: true,
|
|
56
|
+
configurable: true,
|
|
57
|
+
value: {
|
|
58
|
+
url,
|
|
59
|
+
options: stableOptions
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return loader;
|
|
63
|
+
}, [url, blur, cache, isUniformRadius, uniformRadius, hasCornerObject, topLeft, topRight, bottomLeft, bottomRight, resizeWidth, resizeHeight]);
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=usePipelineImageLoader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","NitroImagePipeline","usePipelineImageLoader","url","options","blur","cache","cornerRadius","isUniformRadius","uniformRadius","hasCornerObject","undefined","topLeft","topRight","bottomLeft","bottomRight","resizeWidth","resize","width","resizeHeight","height","cornerRadiusOption","stableOptions","loader","createImageLoader","Object","defineProperty","enumerable","configurable","value"],"sourceRoot":"../../src","sources":["usePipelineImageLoader.ts"],"mappings":";;AAAA,SAASA,OAAO,QAAQ,OAAO;AAG/B,SAASC,kBAAkB,QAAQ,sBAAsB;AAMzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CACpCC,GAAW,EACXC,OAAqB,EACR;EACb;EACA;EACA;EACA,MAAMC,IAAI,GAAGD,OAAO,EAAEC,IAAI;EAC1B,MAAMC,KAAK,GAAGF,OAAO,EAAEE,KAAK;EAC5B,MAAMC,YAAY,GAAGH,OAAO,EAAEG,YAAY;EAC1C,MAAMC,eAAe,GAAG,OAAOD,YAAY,KAAK,QAAQ;EACxD,MAAME,aAAa,GAAGD,eAAe,GAAGD,YAAY,GAAG,CAAC;EACxD,MAAMG,eAAe,GAAG,CAACF,eAAe,IAAID,YAAY,KAAKI,SAAS;EACtE,MAAM;IACJC,OAAO,GAAG,CAAC;IACXC,QAAQ,GAAG,CAAC;IACZC,UAAU,GAAG,CAAC;IACdC,WAAW,GAAG;EAChB,CAAC,GAAGP,eAAe,IAAID,YAAY,KAAKI,SAAS,GAAG,CAAC,CAAC,GAAGJ,YAAY;EACrE,MAAMS,WAAW,GAAGZ,OAAO,EAAEa,MAAM,EAAEC,KAAK;EAC1C,MAAMC,YAAY,GAAGf,OAAO,EAAEa,MAAM,EAAEG,MAAM;EAE5C,OAAOpB,OAAO,CAAC,MAAM;IACnB,MAAMqB,kBAAoD,GAAGb,eAAe,GACxEC,aAAa,GACbC,eAAe,GACb;MAAEE,OAAO;MAAEC,QAAQ;MAAEC,UAAU;MAAEC;IAAY,CAAC,GAC9CJ,SAAS;IACf,MAAMW,aAA0B,GAAG;MACjCjB,IAAI;MACJC,KAAK;MACLC,YAAY,EAAEc,kBAAkB;MAChCJ,MAAM,EACJD,WAAW,KAAKL,SAAS,IAAIQ,YAAY,KAAKR,SAAS,GACnD;QAAEO,KAAK,EAAEF,WAAW;QAAEI,MAAM,EAAED;MAAa,CAAC,GAC5CR;IACR,CAAC;IACD,MAAMY,MAAM,GAAGtB,kBAAkB,CAACuB,iBAAiB,CAACrB,GAAG,EAAEmB,aAAa,CAAC;IACvE;IACA;IACA;IACAG,MAAM,CAACC,cAAc,CAACH,MAAM,EAAE,UAAU,EAAE;MACxCI,UAAU,EAAE,IAAI;MAChBC,YAAY,EAAE,IAAI;MAClBC,KAAK,EAAE;QAAE1B,GAAG;QAAEC,OAAO,EAAEkB;MAAc;IACvC,CAAC,CAAC;IACF,OAAOC,MAAM;EACf,CAAC,EAAE,CACDpB,GAAG,EACHE,IAAI,EACJC,KAAK,EACLE,eAAe,EACfC,aAAa,EACbC,eAAe,EACfE,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,WAAW,EACXC,WAAW,EACXG,YAAY,CACb,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ComponentRef } from 'react';
|
|
2
|
+
import type { HostComponent } from 'react-native';
|
|
3
|
+
import { NativeNitroImage } from 'react-native-nitro-image';
|
|
4
|
+
import type { CacheOption, CornerRadii, ResizeOptions } from './specs/nitro-image-toolkit.nitro';
|
|
5
|
+
type ReactProps<T> = T extends HostComponent<infer P> ? P : never;
|
|
6
|
+
type NativeImageProps = ReactProps<typeof NativeNitroImage>;
|
|
7
|
+
/**
|
|
8
|
+
* The instance `<NativePipelineImage>` exposes through its `ref` — the
|
|
9
|
+
* underlying `NativeNitroImage` host view, with the usual native-view
|
|
10
|
+
* methods (`measure`, …).
|
|
11
|
+
*/
|
|
12
|
+
export type NativePipelineImageRef = ComponentRef<typeof NativeNitroImage>;
|
|
13
|
+
export interface NativePipelineImageProps extends Omit<NativeImageProps, 'image'> {
|
|
14
|
+
/** URL of the image to load through the pipeline. */
|
|
15
|
+
url: string;
|
|
16
|
+
/**
|
|
17
|
+
* Gaussian blur sigma in **points** (density-independent), like
|
|
18
|
+
* `PipelineImage`. Applied natively with the screen scale.
|
|
19
|
+
* @default 0
|
|
20
|
+
*/
|
|
21
|
+
blur?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Corner radius in **points** — a single number or per-corner radii.
|
|
24
|
+
* When omitted, it's derived from `style`'s `borderRadius`-family
|
|
25
|
+
* properties instead — set this prop to override that.
|
|
26
|
+
* @default undefined (derived from `style`, or square corners if unset there)
|
|
27
|
+
*/
|
|
28
|
+
cornerRadius?: number | CornerRadii;
|
|
29
|
+
cache?: CacheOption;
|
|
30
|
+
/**
|
|
31
|
+
* Target bitmap size in **pixels**, overriding the size the native side
|
|
32
|
+
* measures from the view. Rarely needed.
|
|
33
|
+
* @default undefined (measure the view natively)
|
|
34
|
+
*/
|
|
35
|
+
resize?: ResizeOptions;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The fully native-driven variant of `PipelineImage`: after the first render
|
|
39
|
+
* there is **zero JS work per image**. The native view starts the request
|
|
40
|
+
* when it attaches to the window — at its own laid-out size, so nothing
|
|
41
|
+
* waits for an `onLayout` round trip — and cancels it (releasing the bitmap)
|
|
42
|
+
* when it detaches, which makes off-screen list cells free. Loads go through
|
|
43
|
+
* the same pipeline and caches as `useImage`/`preLoadImage`.
|
|
44
|
+
*
|
|
45
|
+
* Compared to `PipelineImage`:
|
|
46
|
+
* - No `onLoad`/`onError` callbacks — the loaded `Image` never crosses into
|
|
47
|
+
* JS. Use `PipelineImage` (or `useImage`) when you need them.
|
|
48
|
+
* - The bitmap is loaded once at the size the view first has; if the view is
|
|
49
|
+
* resized later, the bitmap scales with it instead of reloading.
|
|
50
|
+
* @example
|
|
51
|
+
* ```tsx
|
|
52
|
+
* <NativePipelineImage
|
|
53
|
+
* url="https://example.com/photo.jpg"
|
|
54
|
+
* style={{ width: 300, height: 200, borderRadius: 24 }}
|
|
55
|
+
* blur={4}
|
|
56
|
+
* />
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare const NativePipelineImage: import("react").ForwardRefExoticComponent<NativePipelineImageProps & import("react").RefAttributes<import("react").Component<{
|
|
60
|
+
hybridRef?: import("react-native-nitro-modules").NitroViewWrappedCallback<((ref: import("react-native-nitro-modules").HybridView<import("react-native-nitro-image/lib/typescript/specs/ImageView.nitro").NativeNitroImageViewProps, import("react-native-nitro-image/lib/typescript/specs/ImageView.nitro").NativeNitroImageViewMethods>) => void) | undefined> | undefined;
|
|
61
|
+
image?: import("react-native-nitro-image").Image | import("react-native-nitro-image").ImageLoader;
|
|
62
|
+
resizeMode?: import("react-native-nitro-image/lib/typescript/specs/ImageView.nitro").ResizeMode;
|
|
63
|
+
recyclingKey?: string;
|
|
64
|
+
} & import("react-native").ViewProps, {}, any> & import("react-native").ReactNativeElement>>;
|
|
65
|
+
export {};
|
|
66
|
+
//# sourceMappingURL=NativePipelineImage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NativePipelineImage.d.ts","sourceRoot":"","sources":["../../../src/NativePipelineImage.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAc,MAAM,OAAO,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,aAAa,EACd,MAAM,mCAAmC,CAAC;AAG3C,KAAK,UAAU,CAAC,CAAC,IAAI,CAAC,SAAS,aAAa,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAClE,KAAK,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE5D;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE3E,MAAM,WAAW,wBAAyB,SAAQ,IAAI,CACpD,gBAAgB,EAChB,OAAO,CACR;IACC,qDAAqD;IACrD,GAAG,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;OAIG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB;;;;;4FA0B9B,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
export { NativePipelineImage, type NativePipelineImageProps, type NativePipelineImageRef, } from './NativePipelineImage';
|
|
1
2
|
export { NitroImagePipeline } from './NitroImagePipeline';
|
|
2
3
|
export { PipelineImage, type PipelineImageProps, type PipelineImageRef, } from './PipelineImage';
|
|
3
4
|
export { cornerRadiusForStyle, resizeForLayout, resizeForStyle, } from './resizeForStyle';
|
|
4
|
-
export type { CacheOption, CornerRadii, Options, ResizeOptions, } from './specs/nitro-image-toolkit.nitro';
|
|
5
|
+
export type { CacheOption, CornerRadii, Options, ResizeOptions, ViewOptions, } from './specs/nitro-image-toolkit.nitro';
|
|
5
6
|
export { useImage } from './useImage';
|
|
7
|
+
export { usePipelineImageLoader } from './usePipelineImageLoader';
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,sBAAsB,GAC5B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EACL,aAAa,EACb,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,YAAY,EACV,WAAW,EACX,WAAW,EACX,OAAO,EACP,aAAa,EACb,WAAW,GACZ,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Image } from 'react-native-nitro-image';
|
|
1
|
+
import type { Image, ImageLoader } from 'react-native-nitro-image';
|
|
2
2
|
import type { HybridObject } from 'react-native-nitro-modules';
|
|
3
3
|
export type CacheOption = 'memory' | 'disk' | 'none';
|
|
4
4
|
/**
|
|
@@ -60,11 +60,54 @@ export type Options = {
|
|
|
60
60
|
*/
|
|
61
61
|
resize?: ResizeOptions;
|
|
62
62
|
};
|
|
63
|
+
/**
|
|
64
|
+
* Options for {@linkcode NitroImagePipeline.createImageLoader}. Unlike
|
|
65
|
+
* {@linkcode Options} (used by `loadImage`, where values are bitmap pixels),
|
|
66
|
+
* `blur` and `cornerRadius` here are in **points** (density-independent):
|
|
67
|
+
* the loader runs inside a view and converts to pixels natively with the
|
|
68
|
+
* screen scale. The one exception is {@linkcode resize}, which stays an
|
|
69
|
+
* explicit **pixel** size like everywhere else in the library.
|
|
70
|
+
*/
|
|
71
|
+
export type ViewOptions = {
|
|
72
|
+
/**
|
|
73
|
+
* Gaussian blur sigma in **points**. Multiplied by the screen scale
|
|
74
|
+
* natively, so the same value looks the same on every device.
|
|
75
|
+
* @default 0 (no blur)
|
|
76
|
+
*/
|
|
77
|
+
blur?: number;
|
|
78
|
+
cache?: CacheOption;
|
|
79
|
+
/**
|
|
80
|
+
* Corner radius in **points**, uniform or per-corner. Converted to pixels
|
|
81
|
+
* with the screen scale and baked into the bitmap at the display size.
|
|
82
|
+
* @default 0 (square corners)
|
|
83
|
+
*/
|
|
84
|
+
cornerRadius?: number | CornerRadii;
|
|
85
|
+
/**
|
|
86
|
+
* Target bitmap size in **pixels**, overriding the size measured from the
|
|
87
|
+
* view. Rarely needed — without it the loader resizes to the view's
|
|
88
|
+
* laid-out size × screen scale, which is what you want in a UI.
|
|
89
|
+
* @default undefined (measure the view)
|
|
90
|
+
*/
|
|
91
|
+
resize?: ResizeOptions;
|
|
92
|
+
};
|
|
63
93
|
export interface NitroImagePipeline extends HybridObject<{
|
|
64
94
|
ios: 'swift';
|
|
65
95
|
android: 'kotlin';
|
|
66
96
|
}> {
|
|
67
97
|
loadImage(url: string, options?: Options): Promise<Image>;
|
|
98
|
+
/**
|
|
99
|
+
* Creates an {@linkcode ImageLoader} for `url` that a `<NativeNitroImage>`
|
|
100
|
+
* view drives entirely natively: the request starts when the view attaches
|
|
101
|
+
* to the window — at the view's own laid-out size, with no JS round trips —
|
|
102
|
+
* and is cancelled (and the bitmap released) when it detaches, so
|
|
103
|
+
* off-screen list cells stop costing memory. Loads go through the same
|
|
104
|
+
* pipeline and caches as {@linkcode loadImage}/{@linkcode preLoadImage}.
|
|
105
|
+
*
|
|
106
|
+
* `options` are in **points** (see {@linkcode ViewOptions}); the loader
|
|
107
|
+
* applies the screen scale natively. If the view has no size yet when it
|
|
108
|
+
* attaches, the load waits for its first layout.
|
|
109
|
+
*/
|
|
110
|
+
createImageLoader(url: string, options?: ViewOptions): ImageLoader;
|
|
68
111
|
preLoadImage(url: string): Promise<void>;
|
|
69
112
|
preLoadImages(urls: string[]): Promise<void>;
|
|
70
113
|
/**
|
|
@@ -73,6 +116,16 @@ export interface NitroImagePipeline extends HybridObject<{
|
|
|
73
116
|
* {@linkcode Options.blur}.
|
|
74
117
|
*/
|
|
75
118
|
gaussianBlur(image: Image, radius: number): Promise<Image>;
|
|
119
|
+
/**
|
|
120
|
+
* Caps the in-memory cache of decoded bitmaps at `bytes`, evicting
|
|
121
|
+
* least-recently-used entries immediately if it is currently larger. Pass
|
|
122
|
+
* `0` to disable in-memory caching entirely (the disk cache still works).
|
|
123
|
+
*
|
|
124
|
+
* Defaults: 128 MB on iOS, 25% of the app's memory class on Android. The
|
|
125
|
+
* cache trades RAM for instant re-display; lower it (or use
|
|
126
|
+
* `cache: 'disk'` per request) in memory-constrained apps.
|
|
127
|
+
*/
|
|
128
|
+
setMemoryCacheLimit(bytes: number): void;
|
|
76
129
|
clearCache(): Promise<void>;
|
|
77
130
|
}
|
|
78
131
|
//# sourceMappingURL=nitro-image-toolkit.nitro.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nitro-image-toolkit.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/nitro-image-toolkit.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"nitro-image-toolkit.nitro.d.ts","sourceRoot":"","sources":["../../../../src/specs/nitro-image-toolkit.nitro.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,MAAM,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAErD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,OAAO,GAAG;IACpB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;;;;;;;;;;OAaG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IACpC;;;;;OAKG;IACH,MAAM,CAAC,EAAE,aAAa,CAAC;CACxB,CAAC;AAEF,MAAM,WAAW,kBAAmB,SAAQ,YAAY,CAAC;IACvD,GAAG,EAAE,OAAO,CAAC;IACb,OAAO,EAAE,QAAQ,CAAC;CACnB,CAAC;IACA,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC1D;;;;;;;;;;;OAWG;IACH,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,WAAW,CAAC;IACnE,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7C;;;;OAIG;IACH,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAG3D;;;;;;;;OAQG;IACH,mBAAmB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ImageLoader } from 'react-native-nitro-image';
|
|
2
|
+
import type { ViewOptions } from './specs/nitro-image-toolkit.nitro';
|
|
3
|
+
/**
|
|
4
|
+
* Creates (and memoizes) an {@linkcode ImageLoader} for `url` to pass to
|
|
5
|
+
* `<NativeNitroImage image={...} />`. The view drives it entirely natively:
|
|
6
|
+
* the request starts when the view attaches — at the view's laid-out size,
|
|
7
|
+
* with no JS round trips — and is cancelled when it detaches. See
|
|
8
|
+
* {@linkcode NitroImagePipeline.createImageLoader}.
|
|
9
|
+
*
|
|
10
|
+
* `blur`/`cornerRadius` are in **points** (unlike `useImage`, where they are
|
|
11
|
+
* bitmap pixels); the screen scale is applied natively. Inline object
|
|
12
|
+
* literals are fine — options are compared by value, not identity.
|
|
13
|
+
*/
|
|
14
|
+
export declare function usePipelineImageLoader(url: string, options?: ViewOptions): ImageLoader;
|
|
15
|
+
//# sourceMappingURL=usePipelineImageLoader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePipelineImageLoader.d.ts","sourceRoot":"","sources":["../../../src/usePipelineImageLoader.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAG5D,OAAO,KAAK,EAEV,WAAW,EACZ,MAAM,mCAAmC,CAAC;AAE3C;;;;;;;;;;GAUG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE,WAAW,GACpB,WAAW,CA0Db"}
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
// Forward declaration of `HybridImageSpec` to properly resolve imports.
|
|
11
11
|
namespace margelo::nitro::image { class HybridImageSpec; }
|
|
12
|
+
// Forward declaration of `HybridImageLoaderSpec` to properly resolve imports.
|
|
13
|
+
namespace margelo::nitro::image { class HybridImageLoaderSpec; }
|
|
12
14
|
// Forward declaration of `Options` to properly resolve imports.
|
|
13
15
|
namespace margelo::nitro::nitroimagepipeline { struct Options; }
|
|
14
16
|
// Forward declaration of `CacheOption` to properly resolve imports.
|
|
@@ -17,12 +19,16 @@ namespace margelo::nitro::nitroimagepipeline { enum class CacheOption; }
|
|
|
17
19
|
namespace margelo::nitro::nitroimagepipeline { struct CornerRadii; }
|
|
18
20
|
// Forward declaration of `ResizeOptions` to properly resolve imports.
|
|
19
21
|
namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
22
|
+
// Forward declaration of `ViewOptions` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::nitroimagepipeline { struct ViewOptions; }
|
|
20
24
|
|
|
21
25
|
#include <memory>
|
|
22
26
|
#include <NitroImage/HybridImageSpec.hpp>
|
|
23
27
|
#include <NitroModules/Promise.hpp>
|
|
24
28
|
#include <NitroModules/JPromise.hpp>
|
|
25
29
|
#include <NitroImage/JHybridImageSpec.hpp>
|
|
30
|
+
#include <NitroImage/HybridImageLoaderSpec.hpp>
|
|
31
|
+
#include <NitroImage/JHybridImageLoaderSpec.hpp>
|
|
26
32
|
#include <NitroModules/JUnit.hpp>
|
|
27
33
|
#include <string>
|
|
28
34
|
#include "Options.hpp"
|
|
@@ -36,6 +42,8 @@ namespace margelo::nitro::nitroimagepipeline { struct ResizeOptions; }
|
|
|
36
42
|
#include "JCornerRadii.hpp"
|
|
37
43
|
#include "ResizeOptions.hpp"
|
|
38
44
|
#include "JResizeOptions.hpp"
|
|
45
|
+
#include "ViewOptions.hpp"
|
|
46
|
+
#include "JViewOptions.hpp"
|
|
39
47
|
#include <vector>
|
|
40
48
|
|
|
41
49
|
namespace margelo::nitro::nitroimagepipeline {
|
|
@@ -87,6 +95,11 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
87
95
|
return __promise;
|
|
88
96
|
}();
|
|
89
97
|
}
|
|
98
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> JHybridNitroImagePipelineSpec::createImageLoader(const std::string& url, const std::optional<ViewOptions>& options) {
|
|
99
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<margelo::nitro::image::JHybridImageLoaderSpec::JavaPart>(jni::alias_ref<jni::JString> /* url */, jni::alias_ref<JViewOptions> /* options */)>("createImageLoader");
|
|
100
|
+
auto __result = method(_javaPart, jni::make_jstring(url), options.has_value() ? JViewOptions::fromCpp(options.value()) : nullptr);
|
|
101
|
+
return __result->getJHybridImageLoaderSpec();
|
|
102
|
+
}
|
|
90
103
|
std::shared_ptr<Promise<void>> JHybridNitroImagePipelineSpec::preLoadImage(const std::string& url) {
|
|
91
104
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>(jni::alias_ref<jni::JString> /* url */)>("preLoadImage");
|
|
92
105
|
auto __result = method(_javaPart, jni::make_jstring(url));
|
|
@@ -142,6 +155,10 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
142
155
|
return __promise;
|
|
143
156
|
}();
|
|
144
157
|
}
|
|
158
|
+
void JHybridNitroImagePipelineSpec::setMemoryCacheLimit(double bytes) {
|
|
159
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(double /* bytes */)>("setMemoryCacheLimit");
|
|
160
|
+
method(_javaPart, bytes);
|
|
161
|
+
}
|
|
145
162
|
std::shared_ptr<Promise<void>> JHybridNitroImagePipelineSpec::clearCache() {
|
|
146
163
|
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JPromise::javaobject>()>("clearCache");
|
|
147
164
|
auto __result = method(_javaPart);
|
|
@@ -55,9 +55,11 @@ namespace margelo::nitro::nitroimagepipeline {
|
|
|
55
55
|
public:
|
|
56
56
|
// Methods
|
|
57
57
|
std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> loadImage(const std::string& url, const std::optional<Options>& options) override;
|
|
58
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> createImageLoader(const std::string& url, const std::optional<ViewOptions>& options) override;
|
|
58
59
|
std::shared_ptr<Promise<void>> preLoadImage(const std::string& url) override;
|
|
59
60
|
std::shared_ptr<Promise<void>> preLoadImages(const std::vector<std::string>& urls) override;
|
|
60
61
|
std::shared_ptr<Promise<std::shared_ptr<margelo::nitro::image::HybridImageSpec>>> gaussianBlur(const std::shared_ptr<margelo::nitro::image::HybridImageSpec>& image, double radius) override;
|
|
62
|
+
void setMemoryCacheLimit(double bytes) override;
|
|
61
63
|
std::shared_ptr<Promise<void>> clearCache() override;
|
|
62
64
|
|
|
63
65
|
private:
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JViewOptions.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "ViewOptions.hpp"
|
|
12
|
+
|
|
13
|
+
#include "CacheOption.hpp"
|
|
14
|
+
#include "CornerRadii.hpp"
|
|
15
|
+
#include "JCacheOption.hpp"
|
|
16
|
+
#include "JCornerRadii.hpp"
|
|
17
|
+
#include "JResizeOptions.hpp"
|
|
18
|
+
#include "JVariant_Double_CornerRadii.hpp"
|
|
19
|
+
#include "ResizeOptions.hpp"
|
|
20
|
+
#include <optional>
|
|
21
|
+
#include <variant>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::nitroimagepipeline {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The C++ JNI bridge between the C++ struct "ViewOptions" and the Kotlin data class "ViewOptions".
|
|
29
|
+
*/
|
|
30
|
+
struct JViewOptions final: public jni::JavaClass<JViewOptions> {
|
|
31
|
+
public:
|
|
32
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/nitroimagepipeline/ViewOptions;";
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
/**
|
|
36
|
+
* Convert this Java/Kotlin-based struct to the C++ struct ViewOptions by copying all values to C++.
|
|
37
|
+
*/
|
|
38
|
+
[[maybe_unused]]
|
|
39
|
+
[[nodiscard]]
|
|
40
|
+
ViewOptions toCpp() const {
|
|
41
|
+
static const auto clazz = javaClassStatic();
|
|
42
|
+
static const auto fieldBlur = clazz->getField<jni::JDouble>("blur");
|
|
43
|
+
jni::local_ref<jni::JDouble> blur = this->getFieldValue(fieldBlur);
|
|
44
|
+
static const auto fieldCache = clazz->getField<JCacheOption>("cache");
|
|
45
|
+
jni::local_ref<JCacheOption> cache = this->getFieldValue(fieldCache);
|
|
46
|
+
static const auto fieldCornerRadius = clazz->getField<JVariant_Double_CornerRadii>("cornerRadius");
|
|
47
|
+
jni::local_ref<JVariant_Double_CornerRadii> cornerRadius = this->getFieldValue(fieldCornerRadius);
|
|
48
|
+
static const auto fieldResize = clazz->getField<JResizeOptions>("resize");
|
|
49
|
+
jni::local_ref<JResizeOptions> resize = this->getFieldValue(fieldResize);
|
|
50
|
+
return ViewOptions(
|
|
51
|
+
blur != nullptr ? std::make_optional(blur->value()) : std::nullopt,
|
|
52
|
+
cache != nullptr ? std::make_optional(cache->toCpp()) : std::nullopt,
|
|
53
|
+
cornerRadius != nullptr ? std::make_optional(cornerRadius->toCpp()) : std::nullopt,
|
|
54
|
+
resize != nullptr ? std::make_optional(resize->toCpp()) : std::nullopt
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
public:
|
|
59
|
+
/**
|
|
60
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
61
|
+
*/
|
|
62
|
+
[[maybe_unused]]
|
|
63
|
+
static jni::local_ref<JViewOptions::javaobject> fromCpp(const ViewOptions& value) {
|
|
64
|
+
using JSignature = JViewOptions(jni::alias_ref<jni::JDouble>, jni::alias_ref<JCacheOption>, jni::alias_ref<JVariant_Double_CornerRadii>, jni::alias_ref<JResizeOptions>);
|
|
65
|
+
static const auto clazz = javaClassStatic();
|
|
66
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
67
|
+
return create(
|
|
68
|
+
clazz,
|
|
69
|
+
value.blur.has_value() ? jni::JDouble::valueOf(value.blur.value()) : nullptr,
|
|
70
|
+
value.cache.has_value() ? JCacheOption::fromCpp(value.cache.value()) : nullptr,
|
|
71
|
+
value.cornerRadius.has_value() ? JVariant_Double_CornerRadii::fromCpp(value.cornerRadius.value()) : nullptr,
|
|
72
|
+
value.resize.has_value() ? JResizeOptions::fromCpp(value.resize.value()) : nullptr
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::nitroimagepipeline
|
|
@@ -13,6 +13,7 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
|
13
13
|
import dalvik.annotation.optimization.FastNative
|
|
14
14
|
import com.margelo.nitro.image.HybridImageSpec
|
|
15
15
|
import com.margelo.nitro.core.Promise
|
|
16
|
+
import com.margelo.nitro.image.HybridImageLoaderSpec
|
|
16
17
|
import com.margelo.nitro.core.HybridObject
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -35,6 +36,10 @@ abstract class HybridNitroImagePipelineSpec: HybridObject() {
|
|
|
35
36
|
@Keep
|
|
36
37
|
abstract fun loadImage(url: String, options: Options?): Promise<com.margelo.nitro.image.HybridImageSpec>
|
|
37
38
|
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
@Keep
|
|
41
|
+
abstract fun createImageLoader(url: String, options: ViewOptions?): com.margelo.nitro.image.HybridImageLoaderSpec
|
|
42
|
+
|
|
38
43
|
@DoNotStrip
|
|
39
44
|
@Keep
|
|
40
45
|
abstract fun preLoadImage(url: String): Promise<Unit>
|
|
@@ -47,6 +52,10 @@ abstract class HybridNitroImagePipelineSpec: HybridObject() {
|
|
|
47
52
|
@Keep
|
|
48
53
|
abstract fun gaussianBlur(image: com.margelo.nitro.image.HybridImageSpec, radius: Double): Promise<com.margelo.nitro.image.HybridImageSpec>
|
|
49
54
|
|
|
55
|
+
@DoNotStrip
|
|
56
|
+
@Keep
|
|
57
|
+
abstract fun setMemoryCacheLimit(bytes: Double): Unit
|
|
58
|
+
|
|
50
59
|
@DoNotStrip
|
|
51
60
|
@Keep
|
|
52
61
|
abstract fun clearCache(): Promise<Unit>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ViewOptions.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.nitroimagepipeline
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import java.util.Objects
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "ViewOptions".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class ViewOptions(
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
val blur: Double?,
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val cache: CacheOption?,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val cornerRadius: Variant_Double_CornerRadii?,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val resize: ResizeOptions?
|
|
33
|
+
) {
|
|
34
|
+
/* primary constructor */
|
|
35
|
+
|
|
36
|
+
override fun equals(other: Any?): Boolean {
|
|
37
|
+
if (this === other) return true
|
|
38
|
+
if (other !is ViewOptions) return false
|
|
39
|
+
return Objects.deepEquals(this.blur, other.blur)
|
|
40
|
+
&& Objects.deepEquals(this.cache, other.cache)
|
|
41
|
+
&& Objects.deepEquals(this.cornerRadius, other.cornerRadius)
|
|
42
|
+
&& Objects.deepEquals(this.resize, other.resize)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override fun hashCode(): Int {
|
|
46
|
+
return arrayOf<Any?>(
|
|
47
|
+
blur,
|
|
48
|
+
cache,
|
|
49
|
+
cornerRadius,
|
|
50
|
+
resize
|
|
51
|
+
).contentDeepHashCode()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
companion object {
|
|
55
|
+
/**
|
|
56
|
+
* Constructor called from C++
|
|
57
|
+
*/
|
|
58
|
+
@DoNotStrip
|
|
59
|
+
@Keep
|
|
60
|
+
@Suppress("unused")
|
|
61
|
+
@JvmStatic
|
|
62
|
+
private fun fromCpp(blur: Double?, cache: CacheOption?, cornerRadius: Variant_Double_CornerRadii?, resize: ResizeOptions?): ViewOptions {
|
|
63
|
+
return ViewOptions(blur, cache, cornerRadius, resize)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -41,6 +41,16 @@ namespace margelo::nitro::nitroimagepipeline::bridge::swift {
|
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
// pragma MARK: std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec>
|
|
45
|
+
std::shared_ptr<margelo::nitro::image::HybridImageLoaderSpec> create_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(void* NON_NULL swiftUnsafePointer) noexcept {
|
|
46
|
+
// Implemented in NitroImage
|
|
47
|
+
return margelo::nitro::image::bridge::swift::create_std__shared_ptr_HybridImageLoaderSpec_(swiftUnsafePointer);
|
|
48
|
+
}
|
|
49
|
+
void* NON_NULL get_std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_(std__shared_ptr_margelo__nitro__image__HybridImageLoaderSpec_ cppType) {
|
|
50
|
+
// Implemented in NitroImage
|
|
51
|
+
return margelo::nitro::image::bridge::swift::get_std__shared_ptr_HybridImageLoaderSpec_(cppType);
|
|
52
|
+
}
|
|
53
|
+
|
|
44
54
|
// pragma MARK: std::function<void()>
|
|
45
55
|
Func_void create_Func_void(void* NON_NULL swiftClosureWrapper) noexcept {
|
|
46
56
|
auto swiftClosure = NitroImagePipeline::Func_void::fromUnsafe(swiftClosureWrapper);
|