@camera.ui/rust-postprocessor 0.0.3 → 0.0.4

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/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "externals/norfair-rs"]
2
+ path = externals/norfair-rs
3
+ url = https://github.com/seydx/norfair-rs
@@ -0,0 +1,104 @@
1
+ {
2
+ "git.ignoreLimitWarning": true,
3
+ "editor.tabSize": 2,
4
+ "editor.insertSpaces": true,
5
+ "files.eol": "\n",
6
+ "editor.codeLens": true,
7
+ "editor.formatOnSave": true,
8
+ "js/ts.preferences.importModuleSpecifierEnding": "js",
9
+ "js/ts.tsdk.path": "node_modules/typescript/lib",
10
+ "remote.autoForwardPorts": false,
11
+ "eslint.debug": false,
12
+ "eslint.workingDirectories": [
13
+ {
14
+ "mode": "auto"
15
+ }
16
+ ],
17
+ "rust-analyzer.procMacro.ignored": {
18
+ "napi-derive": [
19
+ "napi"
20
+ ]
21
+ },
22
+ "rust-analyzer.linkedProjects": [
23
+ "./packages/rust-decoder/Cargo.toml",
24
+ "./packages/rust-detector/Cargo.toml",
25
+ "./packages/rust-postprocessor/Cargo.toml",
26
+ "./externals/norfair-rs/Cargo.toml"
27
+ ],
28
+ "python.languageServer": "Pylance",
29
+ "python.analysis.autoImportCompletions": true,
30
+ "python.analysis.typeCheckingMode": "strict",
31
+ "python.analysis.diagnosticSeverityOverrides": {
32
+ "reportMissingTypeStubs": false,
33
+ "reportUnknownMemberType": "warning"
34
+ },
35
+ "python-envs.terminal.autoActivationType": "shellStartup",
36
+ "ruff.nativeServer": true,
37
+ "ruff.fixAll": true,
38
+ "ruff.configuration": "./ruff.toml",
39
+ "tailwindCSS.lint.suggestCanonicalClasses": "ignore",
40
+ "[rust]": {
41
+ "editor.defaultFormatter": "rust-lang.rust-analyzer",
42
+ "editor.codeActionsOnSave": {
43
+ "source.fixAll": "explicit"
44
+ }
45
+ },
46
+ "[javascript]": {
47
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
48
+ "editor.codeActionsOnSave": {
49
+ "source.fixAll.eslint": "explicit",
50
+ "source.fixAll": "explicit",
51
+ "source.organizeImports": "explicit"
52
+ }
53
+ },
54
+ "[typescript]": {
55
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
56
+ "editor.codeActionsOnSave": {
57
+ "source.fixAll.eslint": "explicit",
58
+ "source.fixAll": "explicit",
59
+ "source.organizeImports": "explicit"
60
+ }
61
+ },
62
+ "[vue]": {
63
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
64
+ "editor.codeActionsOnSave": {
65
+ "source.fixAll.eslint": "explicit",
66
+ "source.fixAll": "explicit",
67
+ "source.organizeImports": "explicit"
68
+ }
69
+ },
70
+ "[html]": {
71
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
72
+ "editor.codeActionsOnSave": {
73
+ "source.fixAll.eslint": "explicit",
74
+ "source.fixAll": "explicit",
75
+ "source.organizeImports": "explicit"
76
+ }
77
+ },
78
+ "[json]": {
79
+ "editor.defaultFormatter": "esbenp.prettier-vscode"
80
+ },
81
+ "[python]": {
82
+ "editor.defaultFormatter": "charliermarsh.ruff",
83
+ "editor.tabSize": 4,
84
+ "editor.codeActionsOnSave": {
85
+ "source.organizeImports": "never",
86
+ "source.fixAll": "explicit"
87
+ }
88
+ },
89
+ "[go]": {
90
+ "editor.defaultFormatter": "golang.go",
91
+ "editor.codeActionsOnSave": {
92
+ "source.fixAll": "explicit",
93
+ "source.organizeImports": "explicit",
94
+ "quickfix.gopls": "explicit",
95
+ "refactor.rewrite.gopls": "explicit"
96
+ }
97
+ },
98
+ "[xml]": {
99
+ "editor.formatOnSave": false
100
+ },
101
+ "files.associations": {
102
+ "*.yaml": "yaml"
103
+ }
104
+ }
package/LICENSE.md ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020-2026 seydx <hi@seydx.dev>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,44 @@
1
1
  # @camera.ui/rust-postprocessor
2
2
 
3
+ Native Rust detection post-processing for the [camera.ui](https://github.com/seydx/camera.ui) ecosystem — NMS, IoU, box merging, a multi-class IoU + Kalman object tracker, line-crossing events and zone filtering.
4
+
5
+ Built with [napi-rs](https://napi.rs) — ships prebuilt binaries for Linux (glibc/musl), macOS, Windows and FreeBSD across x64, arm64 and riscv64, so there is no compile step on install.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @camera.ui/rust-postprocessor
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { nms, merge, ObjectTracker } from '@camera.ui/rust-postprocessor';
17
+
18
+ // Greedy non-maximum suppression (per label), normalized [0,1] boxes
19
+ const kept = nms(detections, 0.5);
20
+
21
+ // Cluster nearby/overlapping same-label boxes into union boxes
22
+ const merged = merge(detections, 0.5, 0.02);
23
+
24
+ // Stateful multi-class tracker with stable track ids across frames
25
+ const tracker = new ObjectTracker({ iouThreshold: 0.3, hitCounterMax: 15 });
26
+ const { tracked, crossings } = tracker.update(detections, Date.now());
27
+ ```
28
+
29
+ Also exposes `nmsIndices`, `boxIou`, and tracker configuration for crossing
30
+ lines (`setLines`), detection zones / privacy masks (`setZones`), confidence
31
+ thresholds and ReID. See `index.d.ts` for the full, documented API.
32
+
33
+ ## Development
34
+
35
+ ```bash
36
+ npm install
37
+ npm run build # release build (napi build --platform --release)
38
+ npm run build:debug # debug build
39
+ npm run lint # cargo clippy + eslint
40
+ ```
41
+
3
42
  ---
4
43
 
5
- *Part of the camera.ui ecosystem - A comprehensive camera management solution.*
44
+ _Part of the camera.ui ecosystem - A comprehensive camera management solution._
package/index.d.ts CHANGED
@@ -1,90 +1,55 @@
1
1
  /* auto-generated by NAPI-RS */
2
2
  /* eslint-disable */
3
3
  /**
4
- * Multi-class IoU + Kalman object tracker.
5
- *
6
- * Wraps `norfair-rs` with one sub-tracker per class label. Track ids are
7
- * stable across frames and globally unique across classes. The tracker is
8
- * resolution-independent — feed normalized `[0.0, 1.0]` coordinates.
4
+ * Multi-class IoU + Kalman tracker (norfair-rs, one sub-tracker per label).
5
+ * Track ids are stable and globally unique; feed normalized coordinates.
9
6
  */
10
7
  export declare class ObjectTracker {
11
8
  constructor(options?: ObjectTrackerOptions | undefined | null)
12
9
  /**
13
10
  * Process one frame's detections and return active tracks plus any
14
- * line-crossing events that fired this frame. Detections without
15
- * overlap to existing tracks spawn new ones; existing tracks without a
16
- * matching detection are kept alive via Kalman extrapolation until
17
- * `hitCounterMax` frames have elapsed.
18
- *
19
- * `timestampMs` is forwarded onto emitted crossing events for sequencing
20
- * — pass `Date.now()` (or any monotonic millisecond clock).
21
- *
22
- * `cameraMotion` is the camera ego-motion for this frame step in
23
- * normalized image coordinates (typically derived from PTZ pose delta).
24
- * When provided, Kalman predictions are transformed into a world-stable
25
- * frame so tracks survive pans. Omit (or pass null) for fixed cameras.
11
+ * crossing events. `timestampMs` is forwarded onto crossing events.
12
+ * `cameraMotion` (optional) stabilizes Kalman predictions across pans.
26
13
  */
27
14
  update(detections: Array<Detection>, timestampMs: number, frame?: Buffer | undefined | null, frameWidth?: number | undefined | null, frameHeight?: number | undefined | null, cameraMotion?: CameraMotion | undefined | null): UpdateResult
28
15
  /**
29
- * Replace the configured crossing lines. Pass an empty array to disable
30
- * line crossings entirely. The `aspectRatio` is the camera's
31
- * `width / height` so the perpendicular crossing line ends up visually
32
- * perpendicular to the handle the user drew.
33
- *
34
- * Crossing memory is cleared on every reconfigure so existing tracks
35
- * will fire again the moment they cross a freshly-edited line.
16
+ * Replace the configured crossing lines (empty array disables them).
17
+ * `aspectRatio` is `width / height` so the line renders perpendicular to
18
+ * the drawn handle. Crossing memory is cleared on every call.
36
19
  */
37
20
  setLines(lines: Array<DetectionLine>, aspectRatio: number): void
38
21
  /**
39
- * Replace the configured detection zones (privacy masks + active
40
- * include/exclude regions). Pass an empty array to disable zone
41
- * filtering entirely. Coordinates are in `[0, 100]` UI space — the
42
- * tracker normalizes them internally and auto-closes polygons.
43
- *
44
- * The filter runs at the start of every `update()` call before
45
- * detections reach the underlying tracker.
22
+ * Replace the configured detection zones (empty array disables filtering).
23
+ * Coordinates are in `[0, 100]` UI space; normalized and auto-closed
24
+ * internally. Applied at the start of every `update()`.
46
25
  */
47
26
  setZones(zones: Array<DetectionZone>): void
48
27
  /**
49
- * Set the minimum detection confidence threshold. Detections below
50
- * this score are dropped at the start of every `update()` call before
51
- * they reach the zone filter or tracker. Default 0.0 (no threshold).
28
+ * Drop detections below this score at the start of every `update()`,
29
+ * before zone filtering or tracking. Default 0.0 (no threshold).
52
30
  */
53
31
  setMinConfidence(minConfidence: number): void
54
32
  /**
55
- * Set how many frames a dead track stays available for ReID re-matching.
56
- * When a new detection appears near a dead track's last position,
57
- * norfair merges them — the old track ID is preserved with fresh
58
- * Kalman state. Pass 0 to disable ReID. Use to tie track re-ID
59
- * window to an external cascade timeout (e.g. `cascadeTimeout * fps`).
33
+ * How many frames a dead track stays available for ReID re-matching;
34
+ * the old id is preserved on merge. Pass 0 to disable.
60
35
  */
61
36
  setReidHitCounterMax(frames: number): void
62
37
  /**
63
- * Refresh the ReID counter for all dead tracks back to max. Call every
64
- * frame while a cascade is active so dead tracks never expire during
65
- * the cascade window. Stop calling when the cascade ends.
38
+ * Refresh the ReID counter for all dead tracks back to max. Call each
39
+ * frame while a cascade is active so dead tracks don't expire mid-window.
66
40
  */
67
41
  refreshReid(): void
68
42
  /**
69
- * Apply the configured zones + confidence threshold to a list of
70
- * detections WITHOUT advancing the tracker state. Returns the indices
71
- * (positions in the input array) of the detections that pass the
72
- * filter. Used for the external-sensor-write path where a plugin
73
- * reports detections directly and we want to apply zone filtering
74
- * without running the full tracker.
43
+ * Apply zones + confidence threshold without advancing tracker state,
44
+ * returning the surviving input indices. Used by the external-sensor-write
45
+ * path that needs zone filtering without running the full tracker.
75
46
  */
76
47
  filterIndices(detections: Array<Detection>): Array<number>
77
- /**
78
- * Drop every active track. The next `update()` starts from a clean
79
- * slate and track ids restart from 1. Use this to align tracker state
80
- * with external segment boundaries (e.g. cascade activate/deactivate).
81
- */
48
+ /** Drop every active track; the next `update()` restarts ids from 1. */
82
49
  reset(): void
83
- /** Total number of active tracks across all class buckets. */
84
50
  get trackCount(): number
85
51
  }
86
52
 
87
- /** Bounding box used by [`box_iou`]. */
88
53
  export interface BoundingBox {
89
54
  x: number
90
55
  y: number
@@ -92,22 +57,18 @@ export interface BoundingBox {
92
57
  height: number
93
58
  }
94
59
 
95
- /** Compute IoU between two normalized `[x, y, width, height]` boxes. */
60
+ /** IoU between two normalized `[x, y, width, height]` boxes. */
96
61
  export declare function boxIou(a: BoundingBox, b: BoundingBox): number
97
62
 
98
63
  /**
99
- * Camera ego-motion vector for one frame step, in the same normalized
100
- * `[0.0, 1.0]` coordinate space as detections. `x` positive = camera panned
101
- * right; `y` positive = camera tilted down. When passed to
102
- * `ObjectTracker.update()`, Kalman predictions are transformed into a
103
- * world-stable frame so tracks survive camera pans without losing their id.
64
+ * Camera ego-motion for one frame step in normalized coords; when supplied
65
+ * to `update()`, Kalman predictions are transformed to survive pans.
104
66
  */
105
67
  export interface CameraMotion {
106
68
  x: number
107
69
  y: number
108
70
  }
109
71
 
110
- /** Detection in normalized image coordinates `[0.0, 1.0]`. */
111
72
  export interface Detection {
112
73
  x: number
113
74
  y: number
@@ -118,10 +79,8 @@ export interface Detection {
118
79
  }
119
80
 
120
81
  /**
121
- * User-facing crossing line definition.
122
- *
123
- * `points` are the two handle endpoints in `[0, 100]` UI coordinates.
124
- * `labels` is the set of allowed detection labels — empty means "any label".
82
+ * `points` are the two handle endpoints in `[0, 100]` UI coordinates;
83
+ * empty `labels` means "any label".
125
84
  */
126
85
  export interface DetectionLine {
127
86
  name: string
@@ -130,33 +89,22 @@ export interface DetectionLine {
130
89
  points: Array<Array<number>>
131
90
  }
132
91
 
133
- /**
134
- * User-facing detection zone definition (matches the SDK shape).
135
- *
136
- * `points` are polygon vertices in `[0, 100]` UI coordinates. The
137
- * polygon is auto-closed so the caller does not need to repeat the
138
- * first vertex at the end.
139
- */
92
+ /** `points` are polygon vertices in `[0, 100]` UI coordinates; auto-closed. */
140
93
  export interface DetectionZone {
141
94
  labels: Array<string>
142
95
  filter: ZoneFilterMode
143
- /**
144
- * Match mode (intersect vs contain). Mapped to `type` on the JS side
145
- * of the SDK — the consumer is responsible for translating that field.
146
- */
96
+ /** Mapped to `type` on the JS side of the SDK. */
147
97
  matchType: ZoneMatchType
148
98
  isPrivacyMask: boolean
149
99
  points: Array<Array<number>>
150
100
  }
151
101
 
152
- /** Crossing event emitted by [`ObjectTracker::update`]. */
153
102
  export interface LineCrossingEvent {
154
103
  lineName: string
155
104
  direction: LineDirection
156
105
  trackId: number
157
106
  label: string
158
107
  confidence: number
159
- /** Frame timestamp in milliseconds (forwarded from the `update()` call). */
160
108
  timestampMs: number
161
109
  prevX: number
162
110
  prevY: number
@@ -164,12 +112,6 @@ export interface LineCrossingEvent {
164
112
  currY: number
165
113
  }
166
114
 
167
- /**
168
- * Crossing line direction filter.
169
- *
170
- * `"both"` accepts either direction. `"a-to-b"` and `"b-to-a"` only fire
171
- * when the track moves from one specific side to the other.
172
- */
173
115
  export declare const enum LineDirection {
174
116
  Both = 'both',
175
117
  AToB = 'a-to-b',
@@ -177,66 +119,40 @@ export declare const enum LineDirection {
177
119
  }
178
120
 
179
121
  /**
180
- * Cluster nearby/overlapping same-label detections into single union
181
- * boxes via union-find. Two boxes join the same cluster if their
182
- * top-left corners are within `closeThreshold` along both axes OR if
183
- * their IoU exceeds `iouThreshold`. Each cluster collapses to one
184
- * `Detection` whose box covers the axis-aligned union of all members
185
- * (clamped to `[0, 1]`) and whose confidence is the maximum in the
186
- * cluster. Different labels are never clustered together.
122
+ * Cluster nearby/overlapping same-label detections into union boxes. Boxes
123
+ * join when their top-left corners are within `closeThreshold` on both axes
124
+ * or their IoU exceeds `iouThreshold`; the cluster keeps the max confidence.
187
125
  */
188
126
  export declare function merge(detections: Array<Detection>, iouThreshold: number, closeThreshold: number): Array<Detection>
189
127
 
190
128
  /**
191
- * Run greedy non-maximum suppression on a list of detections.
192
- *
193
- * Detections are suppressed only against higher-confidence boxes of the
194
- * same `label`. Output is sorted by confidence descending. Pass
195
- * `maxDetections` to cap the result length.
129
+ * Greedy NMS, suppressing only against higher-confidence boxes of the same
130
+ * `label`. Output sorted by confidence descending.
196
131
  */
197
132
  export declare function nms(detections: Array<Detection>, iouThreshold: number, maxDetections?: number | undefined | null): Array<Detection>
198
133
 
199
134
  /**
200
- * Run greedy NMS and return the **indices** (positions in the input
201
- * array) of the surviving detections, sorted by confidence descending.
202
- * Use this instead of [`nms`] when the caller needs to preserve extra
203
- * fields on the original detection objects (e.g. face identity, plate
204
- * text) that would be lost by the Detection → RustDetection round-trip.
135
+ * Like [`nms`] but returns the surviving input indices, so callers can keep
136
+ * extra fields that the Detection round-trip would drop.
205
137
  */
206
138
  export declare function nmsIndices(detections: Array<Detection>, iouThreshold: number): Array<number>
207
139
 
208
- /** Constructor options for [`ObjectTracker`]. */
209
140
  export interface ObjectTrackerOptions {
210
- /**
211
- * IoU threshold above which a candidate is matched to an existing track.
212
- * Higher = stricter matching. Default 0.3.
213
- */
141
+ /** Default 0.3. */
214
142
  iouThreshold?: number
215
- /**
216
- * Frames a track survives without a fresh detection (Kalman extrapolation
217
- * continues during this window). Default 15.
218
- */
143
+ /** Frames a track survives without a fresh detection. Default 15. */
219
144
  hitCounterMax?: number
220
- /**
221
- * Frames a new track must be matched before getting a permanent id —
222
- * filters one-frame false positives. Default 3.
223
- */
145
+ /** Frames a new track must be matched before getting a permanent id. Default 3. */
224
146
  initializationDelay?: number
225
- /**
226
- * Frames a dead track stays available for ReID re-matching. When a new
227
- * detection appears near a dead track, norfair merges them — the old
228
- * track ID is preserved. Default: disabled.
229
- */
147
+ /** Frames a dead track stays available for ReID re-matching. Default: disabled. */
230
148
  reidHitCounterMax?: number
231
149
  /**
232
- * Cosine distance threshold for appearance-based ReID matching.
233
- * Lower = stricter. Only used when a frame buffer is provided to `update()`.
234
- * Default: 0.4.
150
+ * Cosine distance threshold for appearance ReID; only used when a frame
151
+ * buffer is passed to `update()`. Default 0.4.
235
152
  */
236
153
  reidEmbeddingThreshold?: number
237
154
  }
238
155
 
239
- /** Detection with stable identity assigned by [`ObjectTracker`]. */
240
156
  export interface TrackedDetection {
241
157
  x: number
242
158
  y: number
@@ -244,56 +160,29 @@ export interface TrackedDetection {
244
160
  height: number
245
161
  confidence: number
246
162
  label: string
247
- /** Stable id across frames. Resets only on `ObjectTracker::reset()`. */
248
163
  trackId: number
249
- /** Number of frames this track has existed (1 on first emit). */
250
164
  trackAge: number
251
- /**
252
- * True when the box is being kept alive by Kalman extrapolation
253
- * instead of a fresh detection match this frame.
254
- */
165
+ /** True when the box is kept alive by Kalman extrapolation, not a fresh match. */
255
166
  trackLost: boolean
256
- /**
257
- * Centroid speed magnitude in normalized units per frame step, i.e.
258
- * `sqrt(vx² + vy²)` of the velocity vector below. 0 when the track
259
- * has only one sample so far. Consumers can compare against a
260
- * threshold (typical: 0.001–0.01) to distinguish moving from
261
- * stationary tracks.
262
- */
167
+ /** `sqrt(vx² + vy²)` in normalized units per frame; 0 with only one sample. */
263
168
  trackSpeed: number
264
- /**
265
- * Centroid velocity X component in normalized units per frame step.
266
- * Signed: positive = moving right, negative = moving left. Kalman
267
- * state update happens once per `ObjectTracker::update()` call.
268
- */
269
169
  trackVelocityX: number
270
- /**
271
- * Centroid velocity Y component in normalized units per frame step.
272
- * Signed: positive = moving down, negative = moving up. Kalman
273
- * state update happens once per `ObjectTracker::update()` call.
274
- */
275
170
  trackVelocityY: number
276
171
  }
277
172
 
278
- /**
279
- * Result of [`ObjectTracker::update`] — active tracks plus any crossings
280
- * fired this frame.
281
- */
282
173
  export interface UpdateResult {
283
174
  tracked: Array<TrackedDetection>
284
175
  crossings: Array<LineCrossingEvent>
285
176
  }
286
177
 
287
- /** How an active zone affects matching detections. */
288
178
  export declare const enum ZoneFilterMode {
289
179
  Include = 'include',
290
180
  Exclude = 'exclude'
291
181
  }
292
182
 
293
- /** Where in the polygon the box must sit for the zone to apply. */
294
183
  export declare const enum ZoneMatchType {
295
184
  /** Any overlap with the polygon counts. */
296
185
  Intersect = 'intersect',
297
- /** All four corners of the box must be inside the polygon. */
186
+ /** All four corners must be inside the polygon. */
298
187
  Contain = 'contain'
299
188
  }
package/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // @ts-nocheck
4
4
  /* auto-generated by NAPI-RS */
5
5
 
6
- const { readFileSync } = require('node:fs')
6
+ const { readFileSync } = require('fs')
7
7
  let nativeBinding = null
8
8
  const loadErrors = []
9
9
 
@@ -33,7 +33,7 @@ const isMuslFromFilesystem = () => {
33
33
 
34
34
  const isMuslFromReport = () => {
35
35
  let report = null
36
- if (typeof process.report?.getReport === 'function') {
36
+ if (process.report && typeof process.report.getReport === 'function') {
37
37
  process.report.excludeNetwork = true
38
38
  report = process.report.getReport()
39
39
  }
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@camera.ui/rust-postprocessor-android-arm64')
79
79
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@camera.ui/rust-postprocessor-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -105,7 +105,7 @@ function requireNative() {
105
105
  }
106
106
  } else if (process.platform === 'win32') {
107
107
  if (process.arch === 'x64') {
108
- if (process.config?.variables?.shlib_suffix === 'dll.a' || process.config?.variables?.node_target_type === 'shared_library') {
108
+ if ((process.config && process.config.variables && process.config.variables.shlib_suffix === 'dll.a') || (process.config && process.config.variables && process.config.variables.node_target_type === 'shared_library')) {
109
109
  try {
110
110
  return require('./rust-postprocessor.win32-x64-gnu.node')
111
111
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@camera.ui/rust-postprocessor-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@camera.ui/rust-postprocessor-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@camera.ui/rust-postprocessor-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@camera.ui/rust-postprocessor-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@camera.ui/rust-postprocessor-darwin-universal')
184
184
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@camera.ui/rust-postprocessor-darwin-x64')
200
200
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@camera.ui/rust-postprocessor-darwin-arm64')
216
216
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@camera.ui/rust-postprocessor-freebsd-x64')
236
236
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@camera.ui/rust-postprocessor-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@camera.ui/rust-postprocessor-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@camera.ui/rust-postprocessor-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@camera.ui/rust-postprocessor-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@camera.ui/rust-postprocessor-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@camera.ui/rust-postprocessor-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@camera.ui/rust-postprocessor-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@camera.ui/rust-postprocessor-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@camera.ui/rust-postprocessor-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@camera.ui/rust-postprocessor-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@camera.ui/rust-postprocessor-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@camera.ui/rust-postprocessor-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@camera.ui/rust-postprocessor-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@camera.ui/rust-postprocessor-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@camera.ui/rust-postprocessor-openharmony-x64')
494
494
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@camera.ui/rust-postprocessor-openharmony-arm')
510
510
  const bindingPackageVersion = require('@camera.ui/rust-postprocessor-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.0.2' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.0.2 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.0.4' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.0.4 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -525,23 +525,33 @@ function requireNative() {
525
525
 
526
526
  nativeBinding = requireNative()
527
527
 
528
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
528
+ // NAPI_RS_FORCE_WASI is a tri-state flag:
529
+ // unset / any other value → native binding preferred, WASI is only a fallback
530
+ // 'true' → force WASI fallback even if native loaded
531
+ // 'error' → force WASI and throw if no WASI binding is found
532
+ // Treating any non-empty string as truthy (the historical behavior) meant
533
+ // NAPI_RS_FORCE_WASI=false, NAPI_RS_FORCE_WASI=0, etc. inadvertently triggered
534
+ // the WASI path, causing ENOENT for packages shipped without a .wasi.cjs file.
535
+ const forceWasi =
536
+ process.env.NAPI_RS_FORCE_WASI === 'true' || process.env.NAPI_RS_FORCE_WASI === 'error'
537
+
538
+ if (!nativeBinding || forceWasi) {
529
539
  let wasiBinding = null
530
540
  let wasiBindingError = null
531
541
  try {
532
542
  wasiBinding = require('./rust-postprocessor.wasi.cjs')
533
543
  nativeBinding = wasiBinding
534
544
  } catch (err) {
535
- if (process.env.NAPI_RS_FORCE_WASI) {
545
+ if (forceWasi) {
536
546
  wasiBindingError = err
537
547
  }
538
548
  }
539
- if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
549
+ if (!nativeBinding || forceWasi) {
540
550
  try {
541
551
  wasiBinding = require('@camera.ui/rust-postprocessor-wasm32-wasi')
542
552
  nativeBinding = wasiBinding
543
553
  } catch (err) {
544
- if (process.env.NAPI_RS_FORCE_WASI) {
554
+ if (forceWasi) {
545
555
  if (!wasiBindingError) {
546
556
  wasiBindingError = err
547
557
  } else {
@@ -560,17 +570,18 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
560
570
 
561
571
  if (!nativeBinding) {
562
572
  if (loadErrors.length > 0) {
563
- throw new Error(
573
+ const error = new Error(
564
574
  `Cannot find native binding. ` +
565
575
  `npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). ` +
566
576
  'Please try `npm i` again after removing both package-lock.json and node_modules directory.',
567
- {
568
- cause: loadErrors.reduce((err, cur) => {
569
- cur.cause = err
570
- return cur
571
- }),
572
- },
573
577
  )
578
+ // assign instead of the `new Error(message, { cause })` options form,
579
+ // which Node < 16.9 silently ignores
580
+ error.cause = loadErrors.reduce((err, cur) => {
581
+ cur.cause = err
582
+ return cur
583
+ })
584
+ throw error
574
585
  }
575
586
  throw new Error(`Failed to load native binding`)
576
587
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@camera.ui/rust-postprocessor",
3
- "version": "0.0.3",
4
- "description": "camera.ui rust postprocessor",
5
- "author": "seydx (https://github.com/seydx/camera.ui)",
3
+ "version": "0.0.4",
4
+ "description": "Native Rust detection post-processing (NMS, IoU, merge, object tracking, line crossing & zone filtering) for the camera.ui ecosystem",
5
+ "author": "seydx (https://github.com/seydx)",
6
6
  "main": "index.js",
7
7
  "types": "index.d.ts",
8
8
  "type": "commonjs",
@@ -39,25 +39,25 @@
39
39
  "version": "napi version"
40
40
  },
41
41
  "devDependencies": {
42
- "@napi-rs/cli": "^3.6.2",
42
+ "@napi-rs/cli": "^3.7.2",
43
43
  "@stylistic/eslint-plugin": "^5.10.0",
44
- "@typescript-eslint/parser": "^8.58.2",
45
- "concurrently": "^9.2.1",
44
+ "@typescript-eslint/parser": "^8.61.1",
45
+ "concurrently": "^10.0.3",
46
46
  "cross-env": "^10.1.0",
47
47
  "eslint": "9.39.2",
48
- "globals": "^17.5.0",
49
- "prettier": "^3.8.3",
48
+ "globals": "^17.6.0",
49
+ "prettier": "^3.8.4",
50
50
  "rimraf": "^6.1.3",
51
51
  "set-interval-async": "^3.0.3",
52
- "sharp": "^0.34.5",
52
+ "sharp": "^0.35.1",
53
53
  "typescript": "5.9.3",
54
- "typescript-eslint": "^8.58.2",
55
- "updates": "^17.15.5"
54
+ "typescript-eslint": "^8.61.1",
55
+ "updates": "^17.18.0"
56
56
  },
57
57
  "bugs": {
58
- "url": "https://github.com/seydx/camera.ui/issues"
58
+ "url": "https://github.com/cameraui/rust-postprocessor/issues"
59
59
  },
60
- "homepage": "https://github.com/seydx/camera.ui#readme",
60
+ "homepage": "https://github.com/cameraui/rust-postprocessor#readme",
61
61
  "keywords": [
62
62
  "camera-ui",
63
63
  "postprocessing",
@@ -66,21 +66,21 @@
66
66
  "license": "MIT",
67
67
  "repository": {
68
68
  "type": "git",
69
- "url": "git+https://github.com/seydx/camera.ui.git"
69
+ "url": "git+https://github.com/cameraui/rust-postprocessor.git"
70
70
  },
71
71
  "engines": {
72
72
  "node": ">= 10"
73
73
  },
74
74
  "optionalDependencies": {
75
- "@camera.ui/rust-postprocessor-darwin-x64": "0.0.3",
76
- "@camera.ui/rust-postprocessor-win32-x64-msvc": "0.0.3",
77
- "@camera.ui/rust-postprocessor-linux-x64-gnu": "0.0.3",
78
- "@camera.ui/rust-postprocessor-linux-x64-musl": "0.0.3",
79
- "@camera.ui/rust-postprocessor-freebsd-x64": "0.0.3",
80
- "@camera.ui/rust-postprocessor-darwin-arm64": "0.0.3",
81
- "@camera.ui/rust-postprocessor-win32-arm64-msvc": "0.0.3",
82
- "@camera.ui/rust-postprocessor-linux-arm64-gnu": "0.0.3",
83
- "@camera.ui/rust-postprocessor-linux-arm64-musl": "0.0.3",
84
- "@camera.ui/rust-postprocessor-linux-riscv64-gnu": "0.0.3"
75
+ "@camera.ui/rust-postprocessor-darwin-x64": "0.0.4",
76
+ "@camera.ui/rust-postprocessor-win32-x64-msvc": "0.0.4",
77
+ "@camera.ui/rust-postprocessor-linux-x64-gnu": "0.0.4",
78
+ "@camera.ui/rust-postprocessor-linux-x64-musl": "0.0.4",
79
+ "@camera.ui/rust-postprocessor-freebsd-x64": "0.0.4",
80
+ "@camera.ui/rust-postprocessor-darwin-arm64": "0.0.4",
81
+ "@camera.ui/rust-postprocessor-win32-arm64-msvc": "0.0.4",
82
+ "@camera.ui/rust-postprocessor-linux-arm64-gnu": "0.0.4",
83
+ "@camera.ui/rust-postprocessor-linux-arm64-musl": "0.0.4",
84
+ "@camera.ui/rust-postprocessor-linux-riscv64-gnu": "0.0.4"
85
85
  }
86
86
  }
@@ -0,0 +1,139 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # Bump the package version, commit it, tag it and push. The Release workflow
5
+ # then cross-compiles every platform binary and publishes the main package plus
6
+ # its platform packages to npm via OIDC trusted publishing (with provenance).
7
+ #
8
+ # tag vX.Y.Z -> bumps package.json, triggers the Release workflow (npm)
9
+ #
10
+ # The platform packages under npm/* stay at 0.0.0 in git; `napi prepublish`
11
+ # stamps them with the real version during the publish job.
12
+
13
+ ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
14
+
15
+ GREEN='\033[0;32m'
16
+ RED='\033[0;31m'
17
+ YELLOW='\033[1;33m'
18
+ CYAN='\033[0;36m'
19
+ NC='\033[0m'
20
+
21
+ usage() {
22
+ cat <<EOF
23
+ Usage: scripts/release.sh <version|major|minor|patch> [--yes] [--skip-checks]
24
+
25
+ Examples:
26
+ scripts/release.sh 0.0.9
27
+ scripts/release.sh patch
28
+ scripts/release.sh minor
29
+
30
+ Options:
31
+ --yes, -y Push without the confirmation prompt.
32
+ --skip-checks Skip the local lint (the bindings rebuild always runs).
33
+ EOF
34
+ exit 1
35
+ }
36
+
37
+ SPEC="${1:-}"
38
+ YES=false
39
+ SKIP_CHECKS=false
40
+ for arg in "${@:2}"; do
41
+ case "$arg" in
42
+ --yes | -y) YES=true ;;
43
+ --skip-checks) SKIP_CHECKS=true ;;
44
+ *)
45
+ echo "Unknown option: $arg"
46
+ usage
47
+ ;;
48
+ esac
49
+ done
50
+
51
+ [ -z "$SPEC" ] && usage
52
+
53
+ cd "$ROOT"
54
+
55
+ # Safety: clean tree, on main, not behind origin.
56
+ if [ -n "$(git status --porcelain)" ]; then
57
+ echo -e "${RED}Working tree not clean - commit or stash first.${NC}"
58
+ exit 1
59
+ fi
60
+ branch="$(git rev-parse --abbrev-ref HEAD)"
61
+ if [ "$branch" != "main" ]; then
62
+ echo -e "${RED}Not on main (on '$branch').${NC}"
63
+ exit 1
64
+ fi
65
+ git fetch -q origin main || true
66
+ if [ -n "$(git rev-list HEAD..origin/main 2>/dev/null)" ]; then
67
+ echo -e "${RED}Local main is behind origin/main - pull first.${NC}"
68
+ exit 1
69
+ fi
70
+
71
+ cur="$(node -p "require('./package.json').version")"
72
+
73
+ bump() {
74
+ local IFS='.'
75
+ read -r ma mi pa <<<"$1"
76
+ case "$2" in
77
+ major) echo "$((ma + 1)).0.0" ;;
78
+ minor) echo "$ma.$((mi + 1)).0" ;;
79
+ patch) echo "$ma.$mi.$((pa + 1))" ;;
80
+ esac
81
+ }
82
+
83
+ case "$SPEC" in
84
+ major | minor | patch) NEW="$(bump "$cur" "$SPEC")" ;;
85
+ *) NEW="$SPEC" ;;
86
+ esac
87
+
88
+ if ! echo "$NEW" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then
89
+ echo -e "${RED}Invalid version '$NEW' (expected X.Y.Z).${NC}"
90
+ exit 1
91
+ fi
92
+
93
+ TAG="v$NEW"
94
+
95
+ if git rev-parse "$TAG" >/dev/null 2>&1; then
96
+ echo -e "${RED}Tag $TAG already exists.${NC}"
97
+ exit 1
98
+ fi
99
+
100
+ echo -e "${CYAN}Releasing rust-postprocessor: $cur -> $NEW (tag $TAG)${NC}"
101
+
102
+ # Bump the top-level version first (leave scripts.version = "napi version") so the
103
+ # rebuild below regenerates index.js / index.d.ts with the new version baked in.
104
+ node -e 'const fs=require("fs");const p=require("./package.json");p.version=process.argv[1];fs.writeFileSync("package.json",JSON.stringify(p,null,2)+"\n")' "$NEW"
105
+
106
+ if [ "$SKIP_CHECKS" = false ]; then
107
+ echo -e "${YELLOW}Running lint...${NC}"
108
+ npm run lint
109
+ fi
110
+
111
+ # Always rebuild so the committed (and published) bindings match the new version.
112
+ echo -e "${YELLOW}Regenerating native bindings...${NC}"
113
+ npm run build:debug
114
+
115
+ git add package.json index.js index.d.ts
116
+
117
+ git commit -q -m "release: v$NEW"
118
+ echo -e "${GREEN}Committed version bump.${NC}"
119
+
120
+ git tag "$TAG"
121
+ echo -e "${GREEN}Created tag $TAG.${NC}"
122
+
123
+ if [ "$YES" = false ]; then
124
+ printf "Push main + %s and trigger the release? [y/N] " "$TAG"
125
+ read -r ans
126
+ case "$ans" in
127
+ y | Y | yes) ;;
128
+ *)
129
+ git tag -d "$TAG" >/dev/null
130
+ git reset -q --hard HEAD~1
131
+ echo "Aborted - tag and bump commit were undone locally."
132
+ exit 0
133
+ ;;
134
+ esac
135
+ fi
136
+
137
+ git push -q origin main
138
+ git push -q origin "$TAG"
139
+ echo -e "${GREEN}Pushed. Watch the release workflow under the repo's Actions tab.${NC}"
package/CHANGELOG.md DELETED
@@ -1,8 +0,0 @@
1
- All notable changes to this project will be documented in this file.
2
-
3
- The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
4
- and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
5
-
6
- ## [X.X.X] - ???
7
-
8
- - Initial Release
package/CONTRIBUTING.md DELETED
@@ -1 +0,0 @@
1
- # Contributing