@camera.ui/camera-ui-rust-motion 0.0.17 → 0.0.18

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/bundle.zip ADDED
Binary file
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "displayName": "RUST Motion",
3
3
  "name": "@camera.ui/camera-ui-rust-motion",
4
- "version": "0.0.17",
4
+ "version": "0.0.18",
5
5
  "description": "camera.ui rust motion detection plugin",
6
6
  "author": "seydx (https://github.com/seydx/camera.ui)",
7
7
  "main": "./dist/index.js",
8
- "type": "module",
8
+ "type": "commonjs",
9
9
  "scripts": {
10
10
  "build": "rimraf dist && tsc",
11
11
  "build:rust": "napi build --release",
@@ -18,39 +18,25 @@
18
18
  "build:riscv64": "CROSS_CONTAINER_OPTS=--platform=linux/amd64 cross +nightly build --message-format=json-render-diagnostics > cross.log --target riscv64gc-unknown-linux-gnu --release && npm run build:rust",
19
19
  "build:freebsd": "cross-env RUSTFLAGS='-C target-feature=+avx2,+sse4.1' CROSS_CONTAINER_OPTS=--platform=linux/amd64 cross +nightly build --message-format=json-render-diagnostics > cross.log --target x86_64-unknown-freebsd --release && npm run build:rust",
20
20
  "build:linux-arm64": "cross-env RUSTFLAGS='-C target-feature=+neon' CROSS_CONTAINER_OPTS=--platform=linux/amd64 cross +nightly build --message-format=json-render-diagnostics > cross.log --target aarch64-unknown-linux-gnu --release && npm run build:rust",
21
+ "bundle": "npm run format && npm run lint && npm run build && cui bundle",
21
22
  "clean": "cargo clean && rimraf --glob *.node",
22
23
  "clean:cargo": "cargo clean",
23
24
  "format": "prettier --write 'src/' --ignore-unknown --no-error-on-unmatched-pattern && cargo fmt",
24
25
  "install-updates": "npm i --save",
25
- "prepublishOnly": "npm i --package-lock-only && npm run lint && npm run format && npm run build",
26
- "lint": "eslint --fix --ext .js,.ts . && cargo clippy",
26
+ "lint": "cargo clippy && eslint .",
27
+ "lint:fix": "cargo clippy --fix && eslint --fix .",
28
+ "prepublishOnly": "node -e \"if(!process.env.SAFE_PUBLISH){console.error('Error: Please use @camera.ui/cli to publish the plugin:\\n npm run publish:alpha\\n npm run publish:beta\\n npm run publish:latest\\n');process.exit(1)}\"",
29
+ "publish:alpha": "cui publish --alpha",
30
+ "publish:beta": "cui publish --beta",
31
+ "publish:latest": "cui publish --latest",
27
32
  "update": "updates --update ./"
28
33
  },
29
- "devDependencies": {
30
- "@camera.ui/types": "^0.0.77",
31
- "@napi-rs/cli": "^2.18.4",
32
- "@rushstack/eslint-patch": "^1.10.4",
33
- "@typescript-eslint/eslint-plugin": "^8.10.0",
34
- "@typescript-eslint/parser": "^8.10.0",
35
- "concurrently": "^9.0.1",
36
- "copyfiles": "^2.4.1",
37
- "cross-env": "^7.0.3",
38
- "eslint": "8.57.0",
39
- "eslint-config-prettier": "^9.1.0",
40
- "eslint-plugin-prettier": "^5.2.1",
41
- "prettier": "^3.3.3",
42
- "rimraf": "^6.0.1",
43
- "set-interval-async": "^3.0.3",
44
- "sharp": "^0.33.5",
45
- "typescript": "^5.6.3",
46
- "updates": "^16.4.0"
47
- },
48
34
  "bugs": {
49
35
  "url": "https://github.com/seydx/camera.ui/issues"
50
36
  },
51
37
  "engines": {
52
- "camera.ui": ">=0.0.34-alpha.2",
53
- "node": ">=20.17.0"
38
+ "camera.ui": ">=0.0.34-alpha.4",
39
+ "node": ">=20.18.0"
54
40
  },
55
41
  "homepage": "https://github.com/seydx/camera.ui#readme",
56
42
  "keywords": [
@@ -84,6 +70,7 @@
84
70
  "dependencies": [],
85
71
  "options": {
86
72
  "extendedMotionDetection": true
87
- }
73
+ },
74
+ "bundled": true
88
75
  }
89
- }
76
+ }
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
package/LICENSE.md DELETED
@@ -1,22 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2023-2024 seydx <dev@seydx.com>
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 DELETED
@@ -1 +0,0 @@
1
- # @camera.ui/camera-ui-rust-motion
@@ -1,4 +0,0 @@
1
- export declare const DEFAULT_MOTION_AREA = 400;
2
- export declare const DEFAULT_THRESHOLD = 50;
3
- export declare const DEFAULT_BLUR_RADIUS = 5;
4
- export declare const DEFAULT_DILATION_SIZE = 5;
package/dist/defaults.js DELETED
@@ -1,5 +0,0 @@
1
- export const DEFAULT_MOTION_AREA = 400;
2
- export const DEFAULT_THRESHOLD = 50;
3
- export const DEFAULT_BLUR_RADIUS = 5;
4
- export const DEFAULT_DILATION_SIZE = 5;
5
- //# sourceMappingURL=defaults.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../src/defaults.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAG,CAAC;AACvC,MAAM,CAAC,MAAM,iBAAiB,GAAG,EAAE,CAAC;AACpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AACrC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC"}
@@ -1,20 +0,0 @@
1
- import type { CameraDevice, CameraStorage, PluginAPI } from '@camera.ui/types';
2
- import { type CameraStorageValues } from './types.js';
3
- export declare class CameraDetector {
4
- cameraStorage: CameraStorage<CameraStorageValues>;
5
- private api;
6
- private cameraDevice;
7
- private cameraLogger;
8
- private started;
9
- private closed;
10
- private restarting;
11
- private imageProcessor?;
12
- constructor(cameraDevice: CameraDevice, api: PluginAPI);
13
- start(): Promise<void>;
14
- close(): void;
15
- private startDetection;
16
- private restart;
17
- private detect;
18
- private defaultSettings;
19
- private createCameraStorage;
20
- }
package/dist/detector.js DELETED
@@ -1,209 +0,0 @@
1
- import { DEFAULT_BLUR_RADIUS, DEFAULT_DILATION_SIZE, DEFAULT_MOTION_AREA, DEFAULT_THRESHOLD } from './defaults.js';
2
- import { getAddon } from './utils/addon.js';
3
- import {} from './types.js';
4
- const addon = getAddon();
5
- export class CameraDetector {
6
- cameraStorage;
7
- api;
8
- cameraDevice;
9
- cameraLogger;
10
- started = false;
11
- closed = false;
12
- restarting = false;
13
- imageProcessor;
14
- constructor(cameraDevice, api) {
15
- this.api = api;
16
- this.cameraDevice = cameraDevice;
17
- this.cameraLogger = cameraDevice.logger;
18
- this.cameraStorage = this.createCameraStorage();
19
- if (!addon) {
20
- this.cameraLogger.error(this.cameraDevice.name, `Failed to load motion detection addon! Platform: ${process.platform}, Arch: ${process.arch}`);
21
- return;
22
- }
23
- this.imageProcessor = new addon.ImageProcessor();
24
- this.cameraDevice.onConnected.subscribe((connected) => {
25
- if (connected) {
26
- this.start();
27
- }
28
- else {
29
- this.close();
30
- }
31
- });
32
- }
33
- async start() {
34
- if (!this.started) {
35
- this.started = true;
36
- this.closed = false;
37
- this.cameraLogger.log(this.cameraDevice.name, 'Starting motion detection');
38
- await this.startDetection();
39
- }
40
- }
41
- close() {
42
- if (!this.closed) {
43
- this.started = false;
44
- this.closed = true;
45
- this.cameraLogger.log(this.cameraDevice.name, 'Stopping motion detection');
46
- this.imageProcessor?.resetState();
47
- }
48
- }
49
- async startDetection() {
50
- try {
51
- await this.detect();
52
- }
53
- catch (error) {
54
- this.imageProcessor?.resetState();
55
- this.cameraLogger.error(this.cameraDevice.name, 'Error generating frames', error);
56
- await this.restart();
57
- }
58
- }
59
- async restart() {
60
- if (this.restarting || this.closed) {
61
- return;
62
- }
63
- this.restarting = true;
64
- this.cameraLogger.log(this.cameraDevice.name, 'Restarting motion detection in 2s...');
65
- this.imageProcessor?.resetState();
66
- await new Promise((resolve) => setTimeout(resolve, 2000));
67
- this.restarting = false;
68
- if (this.cameraDevice.connected && !this.closed) {
69
- await this.startDetection();
70
- }
71
- else {
72
- this.cameraLogger.log(this.cameraDevice.name, 'Camera is not connected, skipping restart');
73
- }
74
- }
75
- async detect() {
76
- if (!this.imageProcessor) {
77
- return;
78
- }
79
- for await (const frame of this.cameraDevice.getFrames()) {
80
- if (this.closed || this.restarting) {
81
- break;
82
- }
83
- const motionArea = this.cameraStorage.values.area;
84
- const threshold = this.cameraStorage.values.threshold;
85
- const dilationSize = this.cameraStorage.values.dilationSize;
86
- let blurRadius = this.cameraStorage.values.blurRadius;
87
- if (blurRadius % 2 === 0) {
88
- blurRadius += 1;
89
- }
90
- const frameImage = await frame.toBuffer({
91
- format: {
92
- to: 'gray',
93
- },
94
- resize: {
95
- width: 640,
96
- height: 0,
97
- },
98
- });
99
- if (this.closed || this.restarting) {
100
- break;
101
- }
102
- const detections = [];
103
- const { width, height } = frameImage.info;
104
- const boundingBoxes = this.imageProcessor.processImage(frameImage.image, width, height, threshold, blurRadius, dilationSize, motionArea);
105
- for (const box of boundingBoxes) {
106
- detections.push({
107
- label: 'motion',
108
- confidence: 1,
109
- boundingBox: box,
110
- inputWidth: frameImage.info.width,
111
- inputHeight: frameImage.info.height,
112
- origWidth: frame.metadata.origWidth,
113
- origHeight: frame.metadata.origHeight,
114
- });
115
- }
116
- await this.cameraDevice.updateState('motion', { detections: detections }, frame);
117
- }
118
- this.imageProcessor.resetState();
119
- }
120
- defaultSettings() {
121
- if (this.cameraStorage.values.area !== DEFAULT_MOTION_AREA) {
122
- this.cameraStorage.setValue('area', DEFAULT_MOTION_AREA);
123
- }
124
- if (this.cameraStorage.values.threshold !== DEFAULT_THRESHOLD) {
125
- this.cameraStorage.setValue('threshold', DEFAULT_THRESHOLD);
126
- }
127
- if (this.cameraStorage.values.blurRadius !== DEFAULT_BLUR_RADIUS) {
128
- this.cameraStorage.setValue('blurRadius', DEFAULT_BLUR_RADIUS);
129
- }
130
- if (this.cameraStorage.values.dilationSize !== DEFAULT_DILATION_SIZE) {
131
- this.cameraStorage.setValue('dilationSize', DEFAULT_DILATION_SIZE);
132
- }
133
- }
134
- createCameraStorage() {
135
- const cameraStorage = this.api.storageController.createCameraStorage(this, this.cameraDevice.id, {
136
- area: {
137
- type: 'number',
138
- key: 'area',
139
- title: 'Area',
140
- description: 'Minimum area for a motion detection',
141
- store: true,
142
- defaultValue: DEFAULT_MOTION_AREA,
143
- minimum: 10,
144
- maximum: 1000,
145
- step: 1,
146
- required: true,
147
- onSet: async (newValue, oldValue) => {
148
- this.cameraLogger.log(this.cameraDevice.name, `Motion area changed from ${oldValue} to ${newValue}`);
149
- },
150
- },
151
- threshold: {
152
- type: 'number',
153
- key: 'threshold',
154
- title: 'Threshold',
155
- description: 'Threshold for motion detection',
156
- store: true,
157
- defaultValue: DEFAULT_THRESHOLD,
158
- minimum: 1,
159
- maximum: 255,
160
- step: 1,
161
- required: true,
162
- onSet: async (newValue, oldValue) => {
163
- this.cameraLogger.log(this.cameraDevice.name, `Motion threshold changed from ${oldValue} to ${newValue}`);
164
- },
165
- },
166
- blurRadius: {
167
- type: 'number',
168
- key: 'blurRadius',
169
- title: 'Blur Radius',
170
- description: 'Blur radius for motion detection',
171
- store: true,
172
- defaultValue: DEFAULT_BLUR_RADIUS,
173
- minimum: 1,
174
- maximum: 21,
175
- step: 1,
176
- required: true,
177
- onSet: async (newValue, oldValue) => {
178
- this.cameraLogger.log(this.cameraDevice.name, `Motion blur radius changed from ${oldValue} to ${newValue}`);
179
- },
180
- },
181
- dilationSize: {
182
- type: 'number',
183
- key: 'dilationSize',
184
- title: 'Dilation Size',
185
- description: 'Dilation size for motion detection',
186
- store: true,
187
- defaultValue: DEFAULT_DILATION_SIZE,
188
- minimum: 1,
189
- maximum: 31,
190
- step: 1,
191
- required: true,
192
- onSet: async (newValue, oldValue) => {
193
- this.cameraLogger.log(this.cameraDevice.name, `Motion dilation size changed from ${oldValue} to ${newValue}`);
194
- },
195
- },
196
- reset: {
197
- type: 'button',
198
- title: 'Default Settings',
199
- key: 'default',
200
- description: 'Reset motion detection settings to default',
201
- onSet: async () => {
202
- this.defaultSettings();
203
- },
204
- },
205
- });
206
- return cameraStorage;
207
- }
208
- }
209
- //# sourceMappingURL=detector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"detector.js","sourceRoot":"","sources":["../src/detector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACnH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAA4B,MAAM,YAAY,CAAC;AAEtD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC;AAEzB,MAAM,OAAO,cAAc;IAClB,aAAa,CAAqC;IAEjD,GAAG,CAAY;IACf,YAAY,CAAe;IAC3B,YAAY,CAAgB;IAE5B,OAAO,GAAG,KAAK,CAAC;IAChB,MAAM,GAAG,KAAK,CAAC;IACf,UAAU,GAAG,KAA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API } from '@camera.ui/types';
2
- export default class RUSTMotion implements BasePlugin {
3
- logger: LoggerService;
4
- api: PluginAPI;
5
- private cameras;
6
- private detectors;
7
- constructor(logger: LoggerService, api: PluginAPI);
8
- configureCameras(cameras: CameraDevice[]): void;
9
- onFormSubmit(actionId: string, payload: any): Promise<FormSubmitResponse | void>;
10
- private start;
11
- private stop;
12
- private cameraSelected;
13
- private cameraDeselected;
14
- private createDetector;
15
- private removeDetector;
16
- }
package/dist/index.js DELETED
@@ -1,60 +0,0 @@
1
- import { CameraDetector } from './detector.js';
2
- export default class RUSTMotion {
3
- logger;
4
- api;
5
- cameras = new Map();
6
- detectors = new Map();
7
- constructor(logger, api) {
8
- this.api = api;
9
- this.logger = logger;
10
- this.api.on('finishLaunching', this.start.bind(this));
11
- this.api.on('shutdown', this.stop.bind(this));
12
- this.api.deviceManager.on('cameraSelected', this.cameraSelected.bind(this));
13
- this.api.deviceManager.on('cameraDeselected', this.cameraDeselected.bind(this));
14
- }
15
- configureCameras(cameras) {
16
- for (const camera of cameras) {
17
- this.cameras.set(camera.id, camera);
18
- }
19
- }
20
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
21
- async onFormSubmit(actionId, payload) { }
22
- async start() {
23
- this.logger.log('Plugin started');
24
- for (const camera of this.cameras) {
25
- this.createDetector(camera[1]);
26
- }
27
- }
28
- stop() {
29
- this.logger.log('Plugin stopped');
30
- for (const detector of this.detectors.values()) {
31
- detector.close();
32
- }
33
- this.detectors.clear();
34
- }
35
- cameraSelected(camera) {
36
- this.logger.log(`Camera added: ${camera.name}`);
37
- this.cameras.set(camera.id, camera);
38
- this.createDetector(camera);
39
- }
40
- cameraDeselected(cameraId) {
41
- const camera = this.cameras.get(cameraId);
42
- if (camera) {
43
- this.logger.log(`Camera removed: ${camera.name}`);
44
- this.removeDetector(cameraId);
45
- this.cameras.delete(cameraId);
46
- }
47
- }
48
- createDetector(cameraDevice) {
49
- const detector = new CameraDetector(cameraDevice, this.api);
50
- this.detectors.set(cameraDevice.id, detector);
51
- }
52
- removeDetector(cameraId) {
53
- const detector = this.detectors.get(cameraId);
54
- if (detector) {
55
- detector.close();
56
- this.detectors.delete(cameraId);
57
- }
58
- }
59
- }
60
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAI/C,MAAM,CAAC,OAAO,OAAO,UAAU;IACtB,MAAM,CAAgB;IACtB,GAAG,CAAY;IAEd,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,SAAS,GAAG,IAAI,GAAG,EAA0B,CAAC;IAEtD,YAAY,MAAqB,EAAE,GAAc;QAC/C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QAErB,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9C,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,gBAAgB,EAAE,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5E,IAAI,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC,kBAAkB,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAClF,CAAC;IAEM,gBAAgB,CAAC,OAAuB;QAC7C,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM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cAAc,CAAC,YAA0B;QAC/C,MAAM,QAAQ,GAAG,IAAI,cAAc,CAAC,YAAY,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;QAC5D,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,EAAE,QAAQ,CAAC,CAAC;IAChD,CAAC;IAEO,cAAc,CAAC,QAAgB;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE9C,IAAI,QAAQ,EAAE,CAAC;YACb,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAClC,CAAC;IACH,CAAC;CACF"}
package/dist/types.d.ts DELETED
@@ -1,18 +0,0 @@
1
- import type { BoundingBox } from '@camera.ui/types';
2
- export interface CameraStorageValues {
3
- area: number;
4
- threshold: number;
5
- blurRadius: number;
6
- dilationSize: number;
7
- }
8
- export declare class ImageProcessor {
9
- previousBlurredImage?: Uint8Array;
10
- constructor();
11
- processImage(frame: Uint8Array, width: number, height: number, threshold: number, blurRadius: number, dilateSize: number, minArea: number): BoundingBox[];
12
- resetState(): void;
13
- }
14
- export interface Addon {
15
- ImageProcessor: {
16
- new (): ImageProcessor;
17
- };
18
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- import type { Addon } from '../types.js';
2
- export declare const decoderPath: () => string | undefined;
3
- export declare const getAddon: () => Addon | undefined;
@@ -1,59 +0,0 @@
1
- import { createRequire } from 'node:module';
2
- import { dirname, join } from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- const __filename = fileURLToPath(import.meta.url);
5
- const __dirname = dirname(__filename);
6
- const require = createRequire(import.meta.url);
7
- const ADDON_NAME = 'rust_detector';
8
- export const decoderPath = () => {
9
- const platform = process.platform;
10
- const arch = process.arch;
11
- let targetDir;
12
- switch (platform) {
13
- case 'darwin':
14
- targetDir = `${ADDON_NAME}_macos`;
15
- break;
16
- case 'win32':
17
- if (arch === 'x64') {
18
- targetDir = `${ADDON_NAME}_windows_x64`;
19
- }
20
- break;
21
- case 'linux':
22
- if (arch === 'x64') {
23
- targetDir = `${ADDON_NAME}_linux_x64`;
24
- }
25
- else if (arch === 'arm64') {
26
- targetDir = `${ADDON_NAME}_linux_arm64`;
27
- }
28
- else if (arch === 'riscv64') {
29
- targetDir = `${ADDON_NAME}_linux_riscv64`;
30
- }
31
- break;
32
- case 'freebsd':
33
- if (arch === 'x64') {
34
- targetDir = `${ADDON_NAME}_freebsd`;
35
- }
36
- break;
37
- }
38
- if (!targetDir) {
39
- return;
40
- }
41
- return join(__dirname, '../../binary', targetDir, 'detector.node');
42
- };
43
- let addon;
44
- export const getAddon = () => {
45
- if (!addon) {
46
- const addonPath = decoderPath();
47
- if (!addonPath) {
48
- return;
49
- }
50
- try {
51
- addon = require(addonPath);
52
- }
53
- catch {
54
- //
55
- }
56
- }
57
- return addon;
58
- };
59
- //# sourceMappingURL=addon.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"addon.js","sourceRoot":"","sources":["../../src/utils/addon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC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