react-native-image-stitcher 0.3.0 → 0.4.1
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/CHANGELOG.md +220 -0
- package/android/src/main/java/io/imagestitcher/rn/RNSARCameraView.kt +137 -124
- package/android/src/main/java/io/imagestitcher/rn/ar/YuvImageConverter.kt +212 -119
- package/dist/camera/Camera.js +70 -58
- package/dist/camera/PanoramaSettings.d.ts +478 -0
- package/dist/camera/PanoramaSettings.js +120 -0
- package/dist/camera/PanoramaSettingsBridge.d.ts +84 -0
- package/dist/camera/PanoramaSettingsBridge.js +208 -0
- package/dist/camera/PanoramaSettingsModal.d.ts +50 -299
- package/dist/camera/PanoramaSettingsModal.js +189 -354
- package/dist/camera/buildPanoramaInitialSettings.d.ts +70 -0
- package/dist/camera/buildPanoramaInitialSettings.js +97 -0
- package/dist/camera/lowMemDevice.d.ts +24 -0
- package/dist/camera/lowMemDevice.js +69 -0
- package/dist/index.d.ts +6 -2
- package/dist/index.js +23 -2
- package/package.json +6 -2
- package/src/camera/Camera.tsx +79 -71
- package/src/camera/PanoramaSettings.ts +605 -0
- package/src/camera/PanoramaSettingsBridge.ts +238 -0
- package/src/camera/PanoramaSettingsModal.tsx +296 -989
- package/src/camera/__tests__/PanoramaSettingsBridge.test.ts +375 -0
- package/src/camera/__tests__/buildPanoramaInitialSettings.test.ts +119 -0
- package/src/camera/__tests__/lowMemDevice.test.ts +52 -0
- package/src/camera/buildPanoramaInitialSettings.ts +139 -0
- package/src/camera/lowMemDevice.ts +71 -0
- package/src/index.ts +42 -3
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
/**
|
|
3
|
+
* lowMemDevice — shared helpers around the iOS BatchStitcher
|
|
4
|
+
* `physicalMemoryBytes` constant.
|
|
5
|
+
*
|
|
6
|
+
* Two consumers (Camera.tsx's `useState` initialiser + the modal's
|
|
7
|
+
* device-mem debug line) had near-identical implementations of the
|
|
8
|
+
* same "read physical memory from NativeModules, classify as
|
|
9
|
+
* low-mem" logic. The F10 Phase 2 review (N2) flagged this as a
|
|
10
|
+
* drift hazard — exactly the kind of subtle duplication that audit
|
|
11
|
+
* fix F1 chased on the native side.
|
|
12
|
+
*
|
|
13
|
+
* Layered for testability:
|
|
14
|
+
*
|
|
15
|
+
* - `isBelowMemThreshold(bytes)` is pure (in: number, out:
|
|
16
|
+
* boolean) — unit-testable.
|
|
17
|
+
* - `getPhysicalMemoryBytes()` reads the RN bridge module — must
|
|
18
|
+
* run on a real device.
|
|
19
|
+
* - `isLowMemDevice()` composes the two for the common case.
|
|
20
|
+
*
|
|
21
|
+
* The 2 GB threshold corresponds to iPhone X / 8 Plus / iPhone 6s
|
|
22
|
+
* era devices; below that, multiband blend + graphcut seam-finder
|
|
23
|
+
* peak memory risks the jetsam threshold mid-stitch. Static value
|
|
24
|
+
* (no runtime config); revisit if the SDK ever targets a wider
|
|
25
|
+
* device range.
|
|
26
|
+
*/
|
|
27
|
+
import { NativeModules } from 'react-native';
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
/** 2 GB in bytes — the cutoff below which `<Camera>` falls back
|
|
31
|
+
* to the feather+skip blender/seam combo for safer peak memory. */
|
|
32
|
+
export const LOW_MEM_THRESHOLD_BYTES = 2 * 1024 * 1024 * 1024;
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Pure classifier. Returns `true` when `bytes` is a positive
|
|
37
|
+
* number strictly below the threshold. Zero / NaN / undefined-shaped
|
|
38
|
+
* inputs return `false` — the safe choice when the native bridge
|
|
39
|
+
* hasn't surfaced the value (assume the device has enough memory
|
|
40
|
+
* for the higher-quality combo; the operator can still flip
|
|
41
|
+
* blender / seamFinder in the modal).
|
|
42
|
+
*/
|
|
43
|
+
export function isBelowMemThreshold(bytes: number): boolean {
|
|
44
|
+
return Number.isFinite(bytes)
|
|
45
|
+
&& bytes > 0
|
|
46
|
+
&& bytes < LOW_MEM_THRESHOLD_BYTES;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Read the device's physical memory from the native bridge.
|
|
52
|
+
* Returns 0 when the bridge isn't loaded or the constant is missing
|
|
53
|
+
* — caller should treat 0 as "unknown".
|
|
54
|
+
*/
|
|
55
|
+
export function getPhysicalMemoryBytes(): number {
|
|
56
|
+
const m = (NativeModules as Record<string, unknown>).BatchStitcher;
|
|
57
|
+
const bytes =
|
|
58
|
+
m && typeof m === 'object'
|
|
59
|
+
? (m as { physicalMemoryBytes?: number }).physicalMemoryBytes
|
|
60
|
+
: undefined;
|
|
61
|
+
return typeof bytes === 'number' ? bytes : 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Composed `getPhysicalMemoryBytes()` + `isBelowMemThreshold()`.
|
|
67
|
+
* Convenience for the common consumer pattern.
|
|
68
|
+
*/
|
|
69
|
+
export function isLowMemDevice(): boolean {
|
|
70
|
+
return isBelowMemThreshold(getPhysicalMemoryBytes());
|
|
71
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -109,11 +109,50 @@ export type { CaptureThumbnailItem } from './camera/CaptureThumbnailStrip';
|
|
|
109
109
|
export { IncrementalPanGuide } from './camera/IncrementalPanGuide';
|
|
110
110
|
export { PanoramaBandOverlay } from './camera/PanoramaBandOverlay';
|
|
111
111
|
export { PanoramaGuidance } from './camera/PanoramaGuidance';
|
|
112
|
+
// Settings modal — the modal is in `PanoramaSettingsModal.tsx`, but
|
|
113
|
+
// the type tree + defaults + JS↔native bridge live in dedicated
|
|
114
|
+
// files since v0.4 (F10). The modal is now a thin presentational
|
|
115
|
+
// component over the typed structure.
|
|
116
|
+
export { PanoramaSettingsModal } from './camera/PanoramaSettingsModal';
|
|
117
|
+
export type { PanoramaSettingsModalProps } from './camera/PanoramaSettingsModal';
|
|
118
|
+
|
|
119
|
+
// Settings types — the v0.4 engine-discriminated structures. Three
|
|
120
|
+
// disjoint top-level types (one per stitching engine), each composed
|
|
121
|
+
// of named sub-trees the corresponding native engine actually reads.
|
|
122
|
+
// See `./camera/PanoramaSettings.ts` for the rationale and the
|
|
123
|
+
// field-by-field native-consumer references.
|
|
112
124
|
export {
|
|
113
|
-
PanoramaSettingsModal,
|
|
114
125
|
DEFAULT_PANORAMA_SETTINGS,
|
|
115
|
-
|
|
116
|
-
|
|
126
|
+
DEFAULT_FLOW_GATE_SETTINGS,
|
|
127
|
+
DEFAULT_SLITSCAN_SETTINGS,
|
|
128
|
+
DEFAULT_HYBRID_SETTINGS,
|
|
129
|
+
} from './camera/PanoramaSettings';
|
|
130
|
+
export type {
|
|
131
|
+
CaptureBaseSettings,
|
|
132
|
+
PanoramaSettings,
|
|
133
|
+
BatchStitcherSettings,
|
|
134
|
+
FrameSelectionSettings,
|
|
135
|
+
FlowGateSettings,
|
|
136
|
+
SlitscanSettings,
|
|
137
|
+
SlitscanPaintingSettings,
|
|
138
|
+
SlitscanRegistrationSettings,
|
|
139
|
+
SlitscanAdvancedSettings,
|
|
140
|
+
Ncc1dSettings,
|
|
141
|
+
Ncc2dSettings,
|
|
142
|
+
PlaneProjectionSettings,
|
|
143
|
+
HybridSettings,
|
|
144
|
+
} from './camera/PanoramaSettings';
|
|
145
|
+
|
|
146
|
+
// Settings → native config adapters. Layer 2 hosts building their
|
|
147
|
+
// own capture flow on top of `incremental.start()` should always
|
|
148
|
+
// pass the result of the matching adapter as `config`; the bridge is
|
|
149
|
+
// the single source of truth for the JS↔native wire format.
|
|
150
|
+
export {
|
|
151
|
+
panoramaSettingsToNativeConfig,
|
|
152
|
+
slitscanSettingsToNativeConfig,
|
|
153
|
+
hybridSettingsToNativeConfig,
|
|
154
|
+
} from './camera/PanoramaSettingsBridge';
|
|
155
|
+
export type { NativeConfigDict } from './camera/PanoramaSettingsBridge';
|
|
117
156
|
export { ViewportCropOverlay } from './camera/ViewportCropOverlay';
|
|
118
157
|
|
|
119
158
|
// ── Capture hooks ─────────────────────────────────────────────────────
|