@chipmobilesdk/rn-camera 0.4.0 → 0.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/CHANGELOG.md +130 -0
- package/README.md +11 -7
- package/lib/commonjs/config/types.js +54 -0
- package/lib/commonjs/config/types.js.map +1 -0
- package/lib/commonjs/core/capabilities.js +45 -0
- package/lib/commonjs/core/capabilities.js.map +1 -0
- package/lib/commonjs/core/captureController.js +107 -0
- package/lib/commonjs/core/captureController.js.map +1 -0
- package/lib/commonjs/core/contract.js +16 -0
- package/lib/commonjs/core/contract.js.map +1 -0
- package/lib/commonjs/core/controller.js +452 -0
- package/lib/commonjs/core/controller.js.map +1 -0
- package/lib/commonjs/core/sessionMachine.js +116 -0
- package/lib/commonjs/core/sessionMachine.js.map +1 -0
- package/lib/commonjs/core/sessionRuntime.js +218 -0
- package/lib/commonjs/core/sessionRuntime.js.map +1 -0
- package/lib/commonjs/diagnostics/errors.js +86 -0
- package/lib/commonjs/diagnostics/errors.js.map +1 -0
- package/lib/commonjs/diagnostics/logger.js +40 -0
- package/lib/commonjs/diagnostics/logger.js.map +1 -0
- package/lib/commonjs/geometry/coordinateMapping.js +156 -0
- package/lib/commonjs/geometry/coordinateMapping.js.map +1 -0
- package/lib/commonjs/index.js +130 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/native/cameraEngine.js +86 -0
- package/lib/commonjs/native/cameraEngine.js.map +1 -0
- package/lib/commonjs/native/visionCameraPeer.js +28 -0
- package/lib/commonjs/native/visionCameraPeer.js.map +1 -0
- package/lib/commonjs/native/visionSurface.js +38 -0
- package/lib/commonjs/native/visionSurface.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/permissions/permissionPort.js +105 -0
- package/lib/commonjs/permissions/permissionPort.js.map +1 -0
- package/lib/commonjs/react/CameraPreview.js +136 -0
- package/lib/commonjs/react/CameraPreview.js.map +1 -0
- package/lib/commonjs/react/VisionCameraFeed.js +196 -0
- package/lib/commonjs/react/VisionCameraFeed.js.map +1 -0
- package/lib/commonjs/react/hooks.js +50 -0
- package/lib/commonjs/react/hooks.js.map +1 -0
- package/lib/commonjs/storage/artifactStore.js +98 -0
- package/lib/commonjs/storage/artifactStore.js.map +1 -0
- package/lib/commonjs/testing/conformance.js +109 -0
- package/lib/commonjs/testing/conformance.js.map +1 -0
- package/lib/commonjs/testing/index.js +50 -0
- package/lib/commonjs/testing/index.js.map +1 -0
- package/lib/commonjs/testing/testCameraAdapter.js +191 -0
- package/lib/commonjs/testing/testCameraAdapter.js.map +1 -0
- package/lib/module/config/types.js +49 -0
- package/lib/module/config/types.js.map +1 -0
- package/lib/module/core/capabilities.js +37 -0
- package/lib/module/core/capabilities.js.map +1 -0
- package/lib/module/core/captureController.js +98 -0
- package/lib/module/core/captureController.js.map +1 -0
- package/lib/module/core/contract.js +12 -0
- package/lib/module/core/contract.js.map +1 -0
- package/lib/module/core/controller.js +442 -0
- package/lib/module/core/controller.js.map +1 -0
- package/lib/module/core/sessionMachine.js +109 -0
- package/lib/module/core/sessionMachine.js.map +1 -0
- package/lib/module/core/sessionRuntime.js +215 -0
- package/lib/module/core/sessionRuntime.js.map +1 -0
- package/lib/module/diagnostics/errors.js +79 -0
- package/lib/module/diagnostics/errors.js.map +1 -0
- package/lib/module/diagnostics/logger.js +35 -0
- package/lib/module/diagnostics/logger.js.map +1 -0
- package/lib/module/geometry/coordinateMapping.js +149 -0
- package/lib/module/geometry/coordinateMapping.js.map +1 -0
- package/lib/module/index.js +44 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/native/cameraEngine.js +83 -0
- package/lib/module/native/cameraEngine.js.map +1 -0
- package/lib/module/native/visionCameraPeer.js +24 -0
- package/lib/module/native/visionCameraPeer.js.map +1 -0
- package/lib/module/native/visionSurface.js +34 -0
- package/lib/module/native/visionSurface.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/permissions/permissionPort.js +101 -0
- package/lib/module/permissions/permissionPort.js.map +1 -0
- package/lib/module/react/CameraPreview.js +130 -0
- package/lib/module/react/CameraPreview.js.map +1 -0
- package/lib/module/react/VisionCameraFeed.js +190 -0
- package/lib/module/react/VisionCameraFeed.js.map +1 -0
- package/lib/module/react/hooks.js +45 -0
- package/lib/module/react/hooks.js.map +1 -0
- package/lib/module/storage/artifactStore.js +94 -0
- package/lib/module/storage/artifactStore.js.map +1 -0
- package/lib/module/testing/conformance.js +102 -0
- package/lib/module/testing/conformance.js.map +1 -0
- package/lib/module/testing/index.js +13 -0
- package/lib/module/testing/index.js.map +1 -0
- package/lib/module/testing/testCameraAdapter.js +185 -0
- package/lib/module/testing/testCameraAdapter.js.map +1 -0
- package/lib/typescript/commonjs/config/types.d.ts +122 -0
- package/lib/typescript/commonjs/config/types.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/capabilities.d.ts +16 -0
- package/lib/typescript/commonjs/core/capabilities.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/captureController.d.ts +48 -0
- package/lib/typescript/commonjs/core/captureController.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/contract.d.ts +92 -0
- package/lib/typescript/commonjs/core/contract.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/controller.d.ts +15 -0
- package/lib/typescript/commonjs/core/controller.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/sessionMachine.d.ts +46 -0
- package/lib/typescript/commonjs/core/sessionMachine.d.ts.map +1 -0
- package/lib/typescript/commonjs/core/sessionRuntime.d.ts +64 -0
- package/lib/typescript/commonjs/core/sessionRuntime.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts +24 -0
- package/lib/typescript/commonjs/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/diagnostics/logger.d.ts +24 -0
- package/lib/typescript/commonjs/diagnostics/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/geometry/coordinateMapping.d.ts +23 -0
- package/lib/typescript/commonjs/geometry/coordinateMapping.d.ts.map +1 -0
- package/lib/typescript/commonjs/index.d.ts +32 -0
- package/lib/typescript/commonjs/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/cameraEngine.d.ts +50 -0
- package/lib/typescript/commonjs/native/cameraEngine.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/visionCameraPeer.d.ts +2 -0
- package/lib/typescript/commonjs/native/visionCameraPeer.d.ts.map +1 -0
- package/lib/typescript/commonjs/native/visionSurface.d.ts +41 -0
- package/lib/typescript/commonjs/native/visionSurface.d.ts.map +1 -0
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/permissions/permissionPort.d.ts +24 -0
- package/lib/typescript/commonjs/permissions/permissionPort.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/CameraPreview.d.ts +25 -0
- package/lib/typescript/commonjs/react/CameraPreview.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/VisionCameraFeed.d.ts +31 -0
- package/lib/typescript/commonjs/react/VisionCameraFeed.d.ts.map +1 -0
- package/lib/typescript/commonjs/react/hooks.d.ts +12 -0
- package/lib/typescript/commonjs/react/hooks.d.ts.map +1 -0
- package/lib/typescript/commonjs/storage/artifactStore.d.ts +54 -0
- package/lib/typescript/commonjs/storage/artifactStore.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts +37 -0
- package/lib/typescript/commonjs/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/index.d.ts +12 -0
- package/lib/typescript/commonjs/testing/index.d.ts.map +1 -0
- package/lib/typescript/commonjs/testing/testCameraAdapter.d.ts +61 -0
- package/lib/typescript/commonjs/testing/testCameraAdapter.d.ts.map +1 -0
- package/lib/typescript/module/config/types.d.ts +122 -0
- package/lib/typescript/module/config/types.d.ts.map +1 -0
- package/lib/typescript/module/core/capabilities.d.ts +16 -0
- package/lib/typescript/module/core/capabilities.d.ts.map +1 -0
- package/lib/typescript/module/core/captureController.d.ts +48 -0
- package/lib/typescript/module/core/captureController.d.ts.map +1 -0
- package/lib/typescript/module/core/contract.d.ts +92 -0
- package/lib/typescript/module/core/contract.d.ts.map +1 -0
- package/lib/typescript/module/core/controller.d.ts +15 -0
- package/lib/typescript/module/core/controller.d.ts.map +1 -0
- package/lib/typescript/module/core/sessionMachine.d.ts +46 -0
- package/lib/typescript/module/core/sessionMachine.d.ts.map +1 -0
- package/lib/typescript/module/core/sessionRuntime.d.ts +64 -0
- package/lib/typescript/module/core/sessionRuntime.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/errors.d.ts +24 -0
- package/lib/typescript/module/diagnostics/errors.d.ts.map +1 -0
- package/lib/typescript/module/diagnostics/logger.d.ts +24 -0
- package/lib/typescript/module/diagnostics/logger.d.ts.map +1 -0
- package/lib/typescript/module/geometry/coordinateMapping.d.ts +23 -0
- package/lib/typescript/module/geometry/coordinateMapping.d.ts.map +1 -0
- package/lib/typescript/module/index.d.ts +32 -0
- package/lib/typescript/module/index.d.ts.map +1 -0
- package/lib/typescript/module/native/cameraEngine.d.ts +50 -0
- package/lib/typescript/module/native/cameraEngine.d.ts.map +1 -0
- package/lib/typescript/module/native/visionCameraPeer.d.ts +2 -0
- package/lib/typescript/module/native/visionCameraPeer.d.ts.map +1 -0
- package/lib/typescript/module/native/visionSurface.d.ts +41 -0
- package/lib/typescript/module/native/visionSurface.d.ts.map +1 -0
- package/lib/typescript/module/package.json +1 -0
- package/lib/typescript/module/permissions/permissionPort.d.ts +24 -0
- package/lib/typescript/module/permissions/permissionPort.d.ts.map +1 -0
- package/lib/typescript/module/react/CameraPreview.d.ts +25 -0
- package/lib/typescript/module/react/CameraPreview.d.ts.map +1 -0
- package/lib/typescript/module/react/VisionCameraFeed.d.ts +31 -0
- package/lib/typescript/module/react/VisionCameraFeed.d.ts.map +1 -0
- package/lib/typescript/module/react/hooks.d.ts +12 -0
- package/lib/typescript/module/react/hooks.d.ts.map +1 -0
- package/lib/typescript/module/storage/artifactStore.d.ts +54 -0
- package/lib/typescript/module/storage/artifactStore.d.ts.map +1 -0
- package/lib/typescript/module/testing/conformance.d.ts +37 -0
- package/lib/typescript/module/testing/conformance.d.ts.map +1 -0
- package/lib/typescript/module/testing/index.d.ts +12 -0
- package/lib/typescript/module/testing/index.d.ts.map +1 -0
- package/lib/typescript/module/testing/testCameraAdapter.d.ts +61 -0
- package/lib/typescript/module/testing/testCameraAdapter.d.ts.map +1 -0
- package/package.json +49 -13
- package/skills/sdk-rn-camera/SKILL.md +6 -3
- package/src/index.ts +4 -12
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Session lifecycle state machine (FR-014..FR-019).
|
|
5
|
+
*
|
|
6
|
+
* Pure and synchronous: it decides what a transition means, the controller
|
|
7
|
+
* performs the I/O. That split is what makes every lifecycle rule in
|
|
8
|
+
* `data-model.md` section 2 testable without a camera.
|
|
9
|
+
*
|
|
10
|
+
* Backgrounding STOPS rather than pauses. Both operating systems can reclaim
|
|
11
|
+
* the camera anyway, and holding it risks leaving the OS camera indicator lit
|
|
12
|
+
* after the app is no longer in front of the user (FR-015).
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { CameraError } from "../diagnostics/errors.js";
|
|
16
|
+
export const initialSession = {
|
|
17
|
+
status: 'idle',
|
|
18
|
+
error: null
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** Statuses from which a fresh start is allowed (FR-019). */
|
|
22
|
+
const STARTABLE = new Set(['idle', 'stopped', 'error']);
|
|
23
|
+
export function canStart(status) {
|
|
24
|
+
return STARTABLE.has(status);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Capture is only ever legal from a fully active session (FR-020). */
|
|
28
|
+
export function canCapture(status) {
|
|
29
|
+
return status === 'active';
|
|
30
|
+
}
|
|
31
|
+
function fail(code) {
|
|
32
|
+
return {
|
|
33
|
+
status: 'error',
|
|
34
|
+
error: new CameraError(code)
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
export function sessionReducer(snapshot, event) {
|
|
38
|
+
const {
|
|
39
|
+
status
|
|
40
|
+
} = snapshot;
|
|
41
|
+
switch (event.type) {
|
|
42
|
+
case 'START':
|
|
43
|
+
if (!canStart(status)) {
|
|
44
|
+
// Refuse rather than silently stealing the camera from the surface
|
|
45
|
+
// that already holds it (FR-019).
|
|
46
|
+
return {
|
|
47
|
+
status,
|
|
48
|
+
error: new CameraError('sessionConflict')
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
status: 'starting',
|
|
53
|
+
error: null
|
|
54
|
+
};
|
|
55
|
+
case 'STARTED':
|
|
56
|
+
return status === 'starting' ? {
|
|
57
|
+
status: 'active',
|
|
58
|
+
error: null
|
|
59
|
+
} : snapshot;
|
|
60
|
+
case 'START_TIMEOUT':
|
|
61
|
+
// Never sit in `starting` forever when frames stop arriving.
|
|
62
|
+
return status === 'starting' ? fail('captureFailed') : snapshot;
|
|
63
|
+
case 'PAUSE':
|
|
64
|
+
return status === 'active' ? {
|
|
65
|
+
status: 'paused',
|
|
66
|
+
error: null
|
|
67
|
+
} : snapshot;
|
|
68
|
+
case 'RESUME':
|
|
69
|
+
return status === 'paused' ? {
|
|
70
|
+
status: 'starting',
|
|
71
|
+
error: null
|
|
72
|
+
} : snapshot;
|
|
73
|
+
case 'STOP':
|
|
74
|
+
if (status === 'stopped' || status === 'idle') {
|
|
75
|
+
return snapshot;
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
status: 'stopping',
|
|
79
|
+
error: snapshot.error
|
|
80
|
+
};
|
|
81
|
+
case 'STOPPED':
|
|
82
|
+
return {
|
|
83
|
+
status: 'stopped',
|
|
84
|
+
error: null
|
|
85
|
+
};
|
|
86
|
+
case 'BACKGROUND':
|
|
87
|
+
// Release, do not hold (FR-015).
|
|
88
|
+
if (status === 'active' || status === 'paused' || status === 'starting') {
|
|
89
|
+
return {
|
|
90
|
+
status: 'stopping',
|
|
91
|
+
error: null
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return snapshot;
|
|
95
|
+
case 'FOREGROUND':
|
|
96
|
+
if (event.surfaceMounted && (status === 'stopped' || status === 'idle')) {
|
|
97
|
+
return {
|
|
98
|
+
status: 'starting',
|
|
99
|
+
error: null
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return snapshot;
|
|
103
|
+
case 'FAIL':
|
|
104
|
+
return fail(event.code);
|
|
105
|
+
default:
|
|
106
|
+
return snapshot;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=sessionMachine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CameraError","initialSession","status","error","STARTABLE","Set","canStart","has","canCapture","fail","code","sessionReducer","snapshot","event","type","surfaceMounted"],"sourceRoot":"../../../src","sources":["core/sessionMachine.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,QAA8B,0BAAuB;AAmBzE,OAAO,MAAMC,cAA+B,GAAG;EAAEC,MAAM,EAAE,MAAM;EAAEC,KAAK,EAAE;AAAK,CAAC;;AAE9E;AACA,MAAMC,SAAqC,GAAG,IAAIC,GAAG,CAAgB,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAElG,OAAO,SAASC,QAAQA,CAACJ,MAAqB,EAAW;EACxD,OAAOE,SAAS,CAACG,GAAG,CAACL,MAAM,CAAC;AAC7B;;AAEA;AACA,OAAO,SAASM,UAAUA,CAACN,MAAqB,EAAW;EAC1D,OAAOA,MAAM,KAAK,QAAQ;AAC3B;AAEA,SAASO,IAAIA,CAACC,IAAqB,EAAmB;EACrD,OAAO;IAAER,MAAM,EAAE,OAAO;IAAEC,KAAK,EAAE,IAAIH,WAAW,CAACU,IAAI;EAAE,CAAC;AACzD;AAEA,OAAO,SAASC,cAAcA,CAACC,QAAyB,EAAEC,KAAmB,EAAmB;EAC/F,MAAM;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QAAK,CAAC;MAC3C;MACA,OAAOS,QAAQ;IAEhB,KAAK,YAAY;MAChB,IAAIC,KAAK,CAACE,cAAc,KAAKb,MAAM,KAAK,SAAS,IAAIA,MAAM,KAAK,MAAM,CAAC,EAAE;QACxE,OAAO;UAAEA,MAAM,EAAE,UAAU;UAAEC,KAAK,EAAE;QAAK,CAAC;MAC3C;MACA,OAAOS,QAAQ;IAEhB,KAAK,MAAM;MACV,OAAOH,IAAI,CAACI,KAAK,CAACH,IAAI,CAAC;IAExB;MACC,OAAOE,QAAQ;EACjB;AACD","ignoreList":[]}
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The session's own I/O: starting it, waiting for frames, releasing it, and
|
|
5
|
+
* following the app in and out of the foreground.
|
|
6
|
+
*
|
|
7
|
+
* Split out of `controller.ts`, which had grown to hold three jobs at once:
|
|
8
|
+
* publishing state, running the session, and serving the public API. The
|
|
9
|
+
* decisions still live in `sessionMachine` (pure); this is the part that
|
|
10
|
+
* actually awaits the engine, and the controller composes it.
|
|
11
|
+
*
|
|
12
|
+
* It reads and writes the controller's state through `SessionContext` rather
|
|
13
|
+
* than owning it: one snapshot reaches subscribers, whichever part of the
|
|
14
|
+
* controller changed it.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { isCameraError } from "../diagnostics/errors.js";
|
|
18
|
+
|
|
19
|
+
/** What the runtime needs from the controller that owns the state. */
|
|
20
|
+
|
|
21
|
+
export function createSessionRuntime(context) {
|
|
22
|
+
let surfaceInfo = null;
|
|
23
|
+
/** Resolved by the surface's own report, or by the start timeout. */
|
|
24
|
+
let pendingStart = null;
|
|
25
|
+
let appStatus = 'active';
|
|
26
|
+
let resumeOnForeground = false;
|
|
27
|
+
let releasing;
|
|
28
|
+
|
|
29
|
+
/** Torch must never survive leaving the active state (FR-034b). */
|
|
30
|
+
async function forceTorchOff() {
|
|
31
|
+
if (!context.torchEnabled()) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
context.setTorchEnabled(false);
|
|
35
|
+
try {
|
|
36
|
+
await context.engine.setTorch(false);
|
|
37
|
+
} catch {
|
|
38
|
+
// Torch-off is best effort; the session is going away regardless.
|
|
39
|
+
}
|
|
40
|
+
context.emit();
|
|
41
|
+
}
|
|
42
|
+
async function release() {
|
|
43
|
+
await forceTorchOff();
|
|
44
|
+
// Nothing to release. Going through STOP/STOPPED here turned an idle
|
|
45
|
+
// controller into `stopped` on every preview unmount.
|
|
46
|
+
const status = context.session().status;
|
|
47
|
+
if (status === 'idle' || status === 'stopped') {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
context.dispatch({
|
|
51
|
+
type: 'STOP'
|
|
52
|
+
});
|
|
53
|
+
try {
|
|
54
|
+
await context.engine.stop();
|
|
55
|
+
context.dispatch({
|
|
56
|
+
type: 'STOPPED'
|
|
57
|
+
});
|
|
58
|
+
} catch (error) {
|
|
59
|
+
context.dispatch({
|
|
60
|
+
type: 'FAIL',
|
|
61
|
+
code: isCameraError(error) ? error.code : 'captureFailed'
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Waits for the mounted preview to report frames.
|
|
68
|
+
*
|
|
69
|
+
* `engine.start()` only confirms a device exists for the VisionCamera
|
|
70
|
+
* adapter: the session belongs to the `<Camera>` view. Calling the session
|
|
71
|
+
* active there made `capture()` right after `start()` fail with `notReady`,
|
|
72
|
+
* and a camera that never produced a frame left the session in `starting`
|
|
73
|
+
* forever (CAM-08).
|
|
74
|
+
*/
|
|
75
|
+
function awaitSurfaceStart() {
|
|
76
|
+
return new Promise(resolve => {
|
|
77
|
+
const timer = context.scheduler.setTimeout(() => {
|
|
78
|
+
if (pendingStart) {
|
|
79
|
+
pendingStart = null;
|
|
80
|
+
context.dispatch({
|
|
81
|
+
type: 'START_TIMEOUT'
|
|
82
|
+
});
|
|
83
|
+
resolve();
|
|
84
|
+
}
|
|
85
|
+
}, context.startTimeoutMs);
|
|
86
|
+
const finish = () => {
|
|
87
|
+
context.scheduler.clearTimeout(timer);
|
|
88
|
+
pendingStart = null;
|
|
89
|
+
resolve();
|
|
90
|
+
};
|
|
91
|
+
pendingStart = {
|
|
92
|
+
settle: () => {
|
|
93
|
+
context.dispatch({
|
|
94
|
+
type: 'STARTED'
|
|
95
|
+
});
|
|
96
|
+
finish();
|
|
97
|
+
},
|
|
98
|
+
fail: code => {
|
|
99
|
+
context.dispatch({
|
|
100
|
+
type: 'FAIL',
|
|
101
|
+
code
|
|
102
|
+
});
|
|
103
|
+
finish();
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
async function start(options = {}) {
|
|
109
|
+
try {
|
|
110
|
+
await context.engine.start({
|
|
111
|
+
cameraPosition: options.cameraPosition ?? context.cameraPosition()
|
|
112
|
+
});
|
|
113
|
+
} catch (error) {
|
|
114
|
+
context.dispatch({
|
|
115
|
+
type: 'FAIL',
|
|
116
|
+
code: isCameraError(error) ? error.code : 'cameraUnavailable'
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (context.engine.awaitsSurfaceStart !== true || !context.surfaceMounted()) {
|
|
121
|
+
// The engine owns its session, or there is no preview to wait for.
|
|
122
|
+
context.dispatch({
|
|
123
|
+
type: 'STARTED'
|
|
124
|
+
});
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
await awaitSurfaceStart();
|
|
128
|
+
}
|
|
129
|
+
function resumeAfterForeground() {
|
|
130
|
+
if (context.disposed() || appStatus !== 'active' || !resumeOnForeground) {
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
resumeOnForeground = false;
|
|
134
|
+
if (!context.surfaceMounted() || !context.permissionGranted()) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
context.dispatch({
|
|
138
|
+
type: 'FOREGROUND',
|
|
139
|
+
surfaceMounted: true
|
|
140
|
+
});
|
|
141
|
+
if (context.session().status === 'starting') {
|
|
142
|
+
start().catch(() => undefined);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return {
|
|
146
|
+
start,
|
|
147
|
+
release,
|
|
148
|
+
forceTorchOff,
|
|
149
|
+
onAppState(status) {
|
|
150
|
+
appStatus = status;
|
|
151
|
+
if (status === 'background') {
|
|
152
|
+
const running = context.session().status;
|
|
153
|
+
resumeOnForeground ||= running === 'active' || running === 'starting';
|
|
154
|
+
context.dispatch({
|
|
155
|
+
type: 'BACKGROUND'
|
|
156
|
+
});
|
|
157
|
+
releasing = release().catch(() => undefined);
|
|
158
|
+
} else {
|
|
159
|
+
// Wait for a release still in flight, or the restart lands on a
|
|
160
|
+
// `stopping` session and is dropped.
|
|
161
|
+
(releasing ?? Promise.resolve()).then(resumeAfterForeground).catch(() => undefined);
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
reportSurfaceStarted(info) {
|
|
165
|
+
surfaceInfo = info;
|
|
166
|
+
if (info.cameraPosition !== context.cameraPosition()) {
|
|
167
|
+
// The device that mounted is the one taking the photos.
|
|
168
|
+
context.setCameraPosition(info.cameraPosition);
|
|
169
|
+
}
|
|
170
|
+
if (pendingStart) {
|
|
171
|
+
pendingStart.settle();
|
|
172
|
+
} else if (context.session().status === 'starting') {
|
|
173
|
+
context.dispatch({
|
|
174
|
+
type: 'STARTED'
|
|
175
|
+
});
|
|
176
|
+
} else {
|
|
177
|
+
context.emit();
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
reportSurfaceFailed(code) {
|
|
181
|
+
if (pendingStart) {
|
|
182
|
+
pendingStart.fail(code);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
context.dispatch({
|
|
186
|
+
type: 'FAIL',
|
|
187
|
+
code
|
|
188
|
+
});
|
|
189
|
+
},
|
|
190
|
+
onInterruption(code) {
|
|
191
|
+
context.logger.log({
|
|
192
|
+
type: 'session',
|
|
193
|
+
code
|
|
194
|
+
});
|
|
195
|
+
if (pendingStart) {
|
|
196
|
+
pendingStart.fail(code);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
const status = context.session().status;
|
|
200
|
+
if (status !== 'idle' && status !== 'stopped') {
|
|
201
|
+
context.dispatch({
|
|
202
|
+
type: 'FAIL',
|
|
203
|
+
code
|
|
204
|
+
});
|
|
205
|
+
release().catch(() => undefined);
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
surfaceInfo: () => surfaceInfo,
|
|
209
|
+
armResumeOnForeground() {
|
|
210
|
+
resumeOnForeground = false;
|
|
211
|
+
},
|
|
212
|
+
pending: () => releasing
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
//# sourceMappingURL=sessionRuntime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isCameraError","createSessionRuntime","context","surfaceInfo","pendingStart","appStatus","resumeOnForeground","releasing","forceTorchOff","torchEnabled","setTorchEnabled","engine","setTorch","emit","release","status","session","dispatch","type","stop","error","code","awaitSurfaceStart","Promise","resolve","timer","scheduler","setTimeout","startTimeoutMs","finish","clearTimeout","settle","fail","start","options","cameraPosition","awaitsSurfaceStart","surfaceMounted","resumeAfterForeground","disposed","permissionGranted","catch","undefined","onAppState","running","then","reportSurfaceStarted","info","setCameraPosition","reportSurfaceFailed","onInterruption","logger","log","armResumeOnForeground","pending"],"sourceRoot":"../../../src","sources":["core/sessionRuntime.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,aAAa,QAA8B,0BAAuB;;AAM3E;;AA6CA,OAAO,SAASC,oBAAoBA,CAACC,OAAuB,EAAkB;EAC7E,IAAIC,WAA+B,GAAG,IAAI;EAC1C;EACA,IAAIC,YAA0E,GAAG,IAAI;EACrF,IAAIC,SAAkC,GAAG,QAAQ;EACjD,IAAIC,kBAAkB,GA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W;IAE9BkD,qBAAqBA,CAAA,EAAG;MACvB/C,kBAAkB,GAAG,KAAK;IAC3B,CAAC;IAEDgD,OAAO,EAAEA,CAAA,KAAM/C;EAChB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Typed error taxonomy (FR-044) and redaction helper (FR-038).
|
|
5
|
+
*
|
|
6
|
+
* The taxonomy exists so consuming apps can branch on `code` and `recoverable`
|
|
7
|
+
* instead of string-matching messages. Messages never carry file paths or image
|
|
8
|
+
* payloads — `redact` is applied before any value reaches a log sink.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { COMMON_PATTERNS, PATH_PATTERN, SdkError, redactPatterns } from '@chipmobilesdk/rn-core';
|
|
12
|
+
/** Codes the app may retry; everything else ends the session. */
|
|
13
|
+
const RECOVERABLE = new Set(['permissionDenied', 'cameraInUse', 'sessionConflict', 'notReady', 'captureInProgress', 'captureFailed', 'storageFailure', 'unsupportedCapability', 'interrupted']);
|
|
14
|
+
|
|
15
|
+
/** The package's error; an `SdkError` (`@chipmobilesdk/rn-core`) with `pkg: 'rn-camera'`. */
|
|
16
|
+
export class CameraError extends SdkError {
|
|
17
|
+
constructor(code, message) {
|
|
18
|
+
super('rn-camera', code, {
|
|
19
|
+
message,
|
|
20
|
+
retryable: RECOVERABLE.has(code)
|
|
21
|
+
});
|
|
22
|
+
this.name = 'CameraError';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** @deprecated Use `retryable`, the name every SDK package shares. */
|
|
26
|
+
get recoverable() {
|
|
27
|
+
return this.retryable;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export function isCameraError(value) {
|
|
31
|
+
return value instanceof CameraError;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* rn-core's shared patterns (URLs, including file URIs; JWTs; e-mail addresses;
|
|
36
|
+
* UUIDs; base64-ish payload runs) plus POSIX and Windows paths.
|
|
37
|
+
*/
|
|
38
|
+
const PATTERNS = [...COMMON_PATTERNS, PATH_PATTERN];
|
|
39
|
+
const REDACTED = '[redacted]';
|
|
40
|
+
const SENSITIVE_KEYS = new Set(['uri', 'path', 'destination', 'file', 'data', 'base64']);
|
|
41
|
+
function redactString(value) {
|
|
42
|
+
return redactPatterns(value, PATTERNS);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Strips paths and payload-shaped strings from a value before logging (FR-038).
|
|
47
|
+
* Recurses through plain objects and arrays; known-sensitive keys are dropped
|
|
48
|
+
* wholesale rather than pattern-matched, since a bare filename has no separator
|
|
49
|
+
* for the path pattern to catch.
|
|
50
|
+
*/
|
|
51
|
+
export function redact(value) {
|
|
52
|
+
if (typeof value === 'string') {
|
|
53
|
+
return redactString(value);
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(value)) {
|
|
56
|
+
return value.map(redact);
|
|
57
|
+
}
|
|
58
|
+
if (value instanceof CameraError) {
|
|
59
|
+
return {
|
|
60
|
+
code: value.code,
|
|
61
|
+
recoverable: value.retryable
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (value instanceof Error) {
|
|
65
|
+
return {
|
|
66
|
+
name: value.name,
|
|
67
|
+
message: redactString(value.message)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (value && typeof value === 'object') {
|
|
71
|
+
const out = {};
|
|
72
|
+
for (const [key, item] of Object.entries(value)) {
|
|
73
|
+
out[key] = SENSITIVE_KEYS.has(key) ? REDACTED : redact(item);
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["COMMON_PATTERNS","PATH_PATTERN","SdkError","redactPatterns","RECOVERABLE","Set","CameraError","constructor","code","message","retryable","has","name","recoverable","isCameraError","value","PATTERNS","REDACTED","SENSITIVE_KEYS","redactString","redact","Array","isArray","map","Error","out","key","item","Object","entries"],"sourceRoot":"../../../src","sources":["diagnostics/errors.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,eAAe,EAAEC,YAAY,EAAEC,QAAQ,EAAEC,cAAc,QAAQ,wBAAwB;AAehG;AACA,MAAMC,WAAyC,GAAG,IAAIC,GAAG,CAAkB,CAC1E,kBAAkB,EAClB,aAAa,EACb,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,uBAAuB,EACvB,aAAa,CACb,CAAC;;AAEF;AACA,OAAO,MAAMC,WAAW,SAASJ,QAAQ,CAAkB;EAC1DK,WAAWA,CAACC,IAAqB,EAAEC,OAAgB,EAAE;IACpD,KAAK,CAAC,WAAW,EAAED,IAAI,EAAE;MAAEC,OAAO;MAAEC,SAAS,EAAEN,WAAW,CAACO,GAAG,CAACH,IAAI;IAAE,CAAC,CAAC;IACvE,IAAI,CAACI,IAAI,GAAG,aAAa;EAC1B;;EAEA;EACA,IAAIC,WAAWA,CAAA,EAAY;IAC1B,OAAO,IAAI,CAACH,SAAS;EACtB;AACD;AAEA,OAAO,SAASI,aAAaA,CAACC,KAAc,EAAwB;EACnE,OAAOA,KAAK,YAAYT,WAAW;AACpC;;AAEA;AACA;AACA;AACA;AACA,MAAMU,QAAQ,GAAG,CAAC,GAAGhB,eAAe,EAAEC,YAAY,CAAC;AAEnD,MAAMgB,QAAQ,GAAG,YAAY;AAC7B,MAAMC,cAAc,GAAG,IAAIb,GAAG,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;AAExF,SAASc,YAAYA,CAACJ,KAAa,EAAU;EAC5C,OAAOZ,cAAc,CAACY,KAAK,EAAEC,QAAQ,CAAC;AACvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,MAAMA,CAACL,KAAc,EAAW;EAC/C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC9B,OAAOI,YAAY,CAACJ,KAAK,CAAC;EAC3B;EACA,IAAIM,KAAK,CAACC,OAAO,CAACP,KAAK,CAAC,EAAE;IACzB,OAAOA,KAAK,CAACQ,GAAG,CAACH,MAAM,CAAC;EACzB;EACA,IAAIL,KAAK,YAAYT,WAAW,EAAE;IACjC,OAAO;MAAEE,IAAI,EAAEO,KAAK,CAACP,IAAI;MAAEK,WAAW,EAAEE,KAAK,CAACL;IAAU,CAAC;EAC1D;EACA,IAAIK,KAAK,YAAYS,KAAK,EAAE;IAC3B,OAAO;MAAEZ,IAAI,EAAEG,KAAK,CAACH,IAAI;MAAEH,OAAO,EAAEU,YAAY,CAACJ,KAAK,CAACN,OAAO;IAAE,CAAC;EAClE;EACA,IAAIM,KAAK,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IACvC,MAAMU,GAA4B,GAAG,CAAC,CAAC;IACvC,KAAK,MAAM,CAACC,GAAG,EAAEC,IAAI,CAAC,IAAIC,MAAM,CAACC,OAAO,CAACd,KAAK,CAAC,EAAE;MAChDU,GAAG,CAACC,GAAG,CAAC,GAAGR,cAAc,CAACP,GAAG,CAACe,GAAG,CAAC,GAAGT,QAAQ,GAAGG,MAAM,CAACO,IAAI,CAAC;IAC7D;IACA,OAAOF,GAAG;EACX;EACA,OAAOV,KAAK;AACb","ignoreList":[]}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Optional consumer-supplied logger (research R4).
|
|
5
|
+
*
|
|
6
|
+
* The default is no logging at all, so FR-038 holds whether or not a consumer
|
|
7
|
+
* opts in. Event bodies carry codes and states only — never file paths, never
|
|
8
|
+
* image data — so an opted-in logger still cannot leak an image path.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { createDiagnosticChannel } from '@chipmobilesdk/rn-core';
|
|
12
|
+
const channel = createDiagnosticChannel('rn-camera');
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Every event also reaches the app's SDK sinks (`installSdkSink`, CORE-08), as
|
|
16
|
+
* `<type>.<code>`: the same code-and-state body, so nothing new can leak.
|
|
17
|
+
*/
|
|
18
|
+
export function withSdkSinks(logger) {
|
|
19
|
+
return {
|
|
20
|
+
log(event) {
|
|
21
|
+
channel.emit(`${event.type}.${event.code}`, event.code === 'listener-threw' ? 'error' : event.recoverable === false ? 'warn' : 'info', event.recoverable === undefined ? undefined : {
|
|
22
|
+
retryable: event.recoverable
|
|
23
|
+
});
|
|
24
|
+
logger.log(event);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** No-op logger used when the consumer supplies none. */
|
|
30
|
+
export const silentLogger = {
|
|
31
|
+
log() {
|
|
32
|
+
// Intentionally empty: logging is opt-in.
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createDiagnosticChannel","channel","withSdkSinks","logger","log","event","emit","type","code","recoverable","undefined","retryable","silentLogger"],"sourceRoot":"../../../src","sources":["diagnostics/logger.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,uBAAuB,QAAQ,wBAAwB;AAchE,MAAMC,OAAO,GAAGD,uBAAuB,CAAC,WAAW,CAAC;;AAEpD;AACA;AACA;AACA;AACA,OAAO,SAASE,YAAYA,CAACC,MAAoB,EAAgB;EAChE,OAAO;IACNC,GAAGA,CAACC,KAAK,EAAE;MACVJ,OAAO,CAACK,IAAI,CACX,GAAGD,KAAK,CAACE,IAAI,IAAIF,KAAK,CAACG,IAAI,EAAE,EAC7BH,KAAK,CAACG,IAAI,KAAK,gBAAgB,GAAG,OAAO,GAAGH,KAAK,CAACI,WAAW,KAAK,KAAK,GAAG,MAAM,GAAG,MAAM,EACzFJ,KAAK,CAACI,WAAW,KAAKC,SAAS,GAAGA,SAAS,GAAG;QAAEC,SAAS,EAAEN,KAAK,CAACI;MAAY,CAC9E,CAAC;MACDN,MAAM,CAACC,GAAG,CAACC,KAAK,CAAC;IAClB;EACD,CAAC;AACF;;AAEA;AACA,OAAO,MAAMO,YAA0B,GAAG;EACzCR,GAAGA,CAAA,EAAG;IACL;EAAA;AAEF,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bidirectional coordinate mapping between preview space and captured-image
|
|
5
|
+
* space (FR-036, SC-012).
|
|
6
|
+
*
|
|
7
|
+
* Pure functions with no native involvement (research R5). Everything needed is
|
|
8
|
+
* already known in JavaScript, so keeping this pure is what makes the 2-pixel
|
|
9
|
+
* round-trip tolerance verifiable in CI rather than only on a device.
|
|
10
|
+
*
|
|
11
|
+
* Composition order, preview -> image: undo mirror, undo letterbox/crop offset,
|
|
12
|
+
* undo scale, undo orientation. Image -> preview reverses it exactly.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Orientation rotates the image for display, swapping dimensions at 90/270. */
|
|
16
|
+
function isQuarterTurn(orientation) {
|
|
17
|
+
const normalized = (orientation % 360 + 360) % 360;
|
|
18
|
+
return normalized === 90 || normalized === 270;
|
|
19
|
+
}
|
|
20
|
+
function normalizeOrientation(orientation) {
|
|
21
|
+
const normalized = (Math.round(orientation / 90) * 90 % 360 + 360) % 360;
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
24
|
+
function projection(geometry) {
|
|
25
|
+
const swap = isQuarterTurn(geometry.orientation);
|
|
26
|
+
const displayWidth = swap ? geometry.imageHeight : geometry.imageWidth;
|
|
27
|
+
const displayHeight = swap ? geometry.imageWidth : geometry.imageHeight;
|
|
28
|
+
const scaleX = geometry.previewWidth / displayWidth;
|
|
29
|
+
const scaleY = geometry.previewHeight / displayHeight;
|
|
30
|
+
// `cover` fills and crops the overflow; `contain` fits and letterboxes.
|
|
31
|
+
const scale = geometry.resizeMode === 'cover' ? Math.max(scaleX, scaleY) : Math.min(scaleX, scaleY);
|
|
32
|
+
return {
|
|
33
|
+
scale,
|
|
34
|
+
// Negative under `cover` (cropped away), positive under `contain`
|
|
35
|
+
// (letterbox bands). The same arithmetic covers both.
|
|
36
|
+
offsetX: (geometry.previewWidth - displayWidth * scale) / 2,
|
|
37
|
+
offsetY: (geometry.previewHeight - displayHeight * scale) / 2,
|
|
38
|
+
displayWidth,
|
|
39
|
+
displayHeight
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Display-space point -> original image point, undoing the rotation. */
|
|
44
|
+
function unrotate(point, geometry) {
|
|
45
|
+
switch (normalizeOrientation(geometry.orientation)) {
|
|
46
|
+
case 90:
|
|
47
|
+
return {
|
|
48
|
+
x: point.y,
|
|
49
|
+
y: geometry.imageHeight - point.x
|
|
50
|
+
};
|
|
51
|
+
case 180:
|
|
52
|
+
return {
|
|
53
|
+
x: geometry.imageWidth - point.x,
|
|
54
|
+
y: geometry.imageHeight - point.y
|
|
55
|
+
};
|
|
56
|
+
case 270:
|
|
57
|
+
return {
|
|
58
|
+
x: geometry.imageWidth - point.y,
|
|
59
|
+
y: point.x
|
|
60
|
+
};
|
|
61
|
+
default:
|
|
62
|
+
return point;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Original image point -> display-space point, applying the rotation. */
|
|
67
|
+
function rotate(point, geometry) {
|
|
68
|
+
switch (normalizeOrientation(geometry.orientation)) {
|
|
69
|
+
case 90:
|
|
70
|
+
return {
|
|
71
|
+
x: geometry.imageHeight - point.y,
|
|
72
|
+
y: point.x
|
|
73
|
+
};
|
|
74
|
+
case 180:
|
|
75
|
+
return {
|
|
76
|
+
x: geometry.imageWidth - point.x,
|
|
77
|
+
y: geometry.imageHeight - point.y
|
|
78
|
+
};
|
|
79
|
+
case 270:
|
|
80
|
+
return {
|
|
81
|
+
x: point.y,
|
|
82
|
+
y: geometry.imageWidth - point.x
|
|
83
|
+
};
|
|
84
|
+
default:
|
|
85
|
+
return point;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Maps a preview-space point into captured-image space. Points outside the
|
|
91
|
+
* visible region stay representable (they fall outside the image bounds) rather
|
|
92
|
+
* than being clamped to an edge, so callers can detect an out-of-frame overlay.
|
|
93
|
+
*/
|
|
94
|
+
export function mapPointToImage(point, geometry) {
|
|
95
|
+
const {
|
|
96
|
+
scale,
|
|
97
|
+
offsetX,
|
|
98
|
+
offsetY
|
|
99
|
+
} = projection(geometry);
|
|
100
|
+
const x = geometry.isMirrored ? geometry.previewWidth - point.x : point.x;
|
|
101
|
+
return unrotate({
|
|
102
|
+
x: (x - offsetX) / scale,
|
|
103
|
+
y: (point.y - offsetY) / scale
|
|
104
|
+
}, geometry);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** Maps a captured-image point into preview space. Exact inverse of the above. */
|
|
108
|
+
export function mapPointToPreview(point, geometry) {
|
|
109
|
+
const {
|
|
110
|
+
scale,
|
|
111
|
+
offsetX,
|
|
112
|
+
offsetY
|
|
113
|
+
} = projection(geometry);
|
|
114
|
+
const rotated = rotate(point, geometry);
|
|
115
|
+
const x = rotated.x * scale + offsetX;
|
|
116
|
+
return {
|
|
117
|
+
x: geometry.isMirrored ? geometry.previewWidth - x : x,
|
|
118
|
+
y: rotated.y * scale + offsetY
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Axis-aligned bounding box of the mapped corners — exact for quarter turns. */
|
|
123
|
+
function boundsOf(a, b) {
|
|
124
|
+
return {
|
|
125
|
+
x: Math.min(a.x, b.x),
|
|
126
|
+
y: Math.min(a.y, b.y),
|
|
127
|
+
width: Math.abs(b.x - a.x),
|
|
128
|
+
height: Math.abs(b.y - a.y)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
export function mapRectToImage(rect, geometry) {
|
|
132
|
+
return boundsOf(mapPointToImage({
|
|
133
|
+
x: rect.x,
|
|
134
|
+
y: rect.y
|
|
135
|
+
}, geometry), mapPointToImage({
|
|
136
|
+
x: rect.x + rect.width,
|
|
137
|
+
y: rect.y + rect.height
|
|
138
|
+
}, geometry));
|
|
139
|
+
}
|
|
140
|
+
export function mapRectToPreview(rect, geometry) {
|
|
141
|
+
return boundsOf(mapPointToPreview({
|
|
142
|
+
x: rect.x,
|
|
143
|
+
y: rect.y
|
|
144
|
+
}, geometry), mapPointToPreview({
|
|
145
|
+
x: rect.x + rect.width,
|
|
146
|
+
y: rect.y + rect.height
|
|
147
|
+
}, geometry));
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=coordinateMapping.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["isQuarterTurn","orientation","normalized","normalizeOrientation","Math","round","projection","geometry","swap","displayWidth","imageHeight","imageWidth","displayHeight","scaleX","previewWidth","scaleY","previewHeight","scale","resizeMode","max","min","offsetX","offsetY","unrotate","point","x","y","rotate","mapPointToImage","isMirrored","mapPointToPreview","rotated","boundsOf","a","b","width","abs","height","mapRectToImage","rect","mapRectToPreview"],"sourceRoot":"../../../src","sources":["geometry/coordinateMapping.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;AACA,SAASA,aAAaA,CAACC,WAAmB,EAAW;EACpD,MAAMC,UAAU,GAAG,CAAED,WAAW,GAAG,GAAG,GAAI,GAAG,IAAI,GAAG;EACpD,OAAOC,UAAU,KAAK,EAAE,IAAIA,UAAU,KAAK,GAAG;AAC/C;AAEA,SAASC,oBAAoBA,CAACF,WAAmB,EAAsB;EACtE,MAAMC,UAAU,GAAG,CAAGE,IAAI,CAACC,KAAK,CAACJ,WAAW,GAAG,EAAE,C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b;EAAE,CAAC,EAAEnB,QAAQ,CAAC,EACnDqB,eAAe,CAAC;IAAEH,CAAC,EAAEc,IAAI,CAACd,CAAC,GAAGc,IAAI,CAACJ,KAAK;IAAET,CAAC,EAAEa,IAAI,CAACb,CAAC,GAAGa,IAAI,CAACF;EAAO,CAAC,EAAE9B,QAAQ,CAC9E,CAAC;AACF;AAEA,OAAO,SAASiC,gBAAgBA,CAACD,IAAU,EAAEhC,QAAyB,EAAQ;EAC7E,OAAOyB,QAAQ,CACdF,iBAAiB,CAAC;IAAEL,CAAC,EAAEc,IAAI,CAACd,CAAC;IAAEC,CAAC,EAAEa,IAAI,CAACb;EAAE,CAAC,EAAEnB,QAAQ,CAAC,EACrDuB,iBAAiB,CAAC;IAAEL,CAAC,EAAEc,IAAI,CAACd,CAAC,GAAGc,IAAI,CAACJ,KAAK;IAAET,CAAC,EAAEa,IAAI,CAACb,CAAC,GAAGa,IAAI,CAACF;EAAO,CAAC,EAAE9B,QAAQ,CAChF,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @chipmobilesdk/rn-camera — reusable camera infrastructure for
|
|
5
|
+
* ChipMobileSdk-family React Native apps.
|
|
6
|
+
*
|
|
7
|
+
* This is the single public entrypoint (LIB-003). Modules under `core/`,
|
|
8
|
+
* `native/`, `permissions/`, `storage/`, `geometry/`, `diagnostics/`, and
|
|
9
|
+
* `testing/` are private; import them only through this file.
|
|
10
|
+
*
|
|
11
|
+
* The package contains no business logic, sends nothing over the network, and
|
|
12
|
+
* writes nothing to the device gallery. Phase one runs no on-device inference —
|
|
13
|
+
* see the reserved frame-processing extension point in the README.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Public types
|
|
17
|
+
|
|
18
|
+
export { known, unavailable } from "./config/types.js";
|
|
19
|
+
|
|
20
|
+
// Controller
|
|
21
|
+
export { createCameraController, DEFAULT_TEMPORARY_TTL_MS } from "./core/controller.js";
|
|
22
|
+
|
|
23
|
+
// Ports + default adapters
|
|
24
|
+
|
|
25
|
+
export { createSurfaceRegistry } from "./native/visionSurface.js";
|
|
26
|
+
export { createVisionCameraEngine } from "./native/cameraEngine.js";
|
|
27
|
+
export { createVisionCameraPermissions } from "./permissions/permissionPort.js";
|
|
28
|
+
export { createArtifactStore, createCacheArtifactStore } from "./storage/artifactStore.js";
|
|
29
|
+
|
|
30
|
+
// React surface
|
|
31
|
+
export { CameraPreview } from "./react/CameraPreview.js";
|
|
32
|
+
export { useCameraController, useCameraState } from "./react/hooks.js";
|
|
33
|
+
|
|
34
|
+
// Coordinate mapping (pure)
|
|
35
|
+
export { mapPointToImage, mapPointToPreview, mapRectToImage, mapRectToPreview } from "./geometry/coordinateMapping.js";
|
|
36
|
+
|
|
37
|
+
// Diagnostics
|
|
38
|
+
export { CameraError, isCameraError, redact } from "./diagnostics/errors.js";
|
|
39
|
+
|
|
40
|
+
// The test adapter (FR-041) is not here: it lives at `@chipmobilesdk/rn-camera/testing`.
|
|
41
|
+
// Re-exporting it from this entrypoint put the fake camera in the module graph of
|
|
42
|
+
// every app that imports the package, and Metro does not tree-shake it back out
|
|
43
|
+
// (PERF-14). It is still the same published ports the real adapters implement.
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["known","unavailable","createCameraController","DEFAULT_TEMPORARY_TTL_MS","createSurfaceRegistry","createVisionCameraEngine","createVisionCameraPermissions","createArtifactStore","createCacheArtifactStore","CameraPreview","useCameraController","useCameraState","mapPointToImage","mapPointToPreview","mapRectToImage","mapRectToPreview","CameraError","isCameraError","redact"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAqBA,SAASA,KAAK,EAAEC,WAAW,QAAQ,mBAAgB;;AAEnD;AACA,SAASC,sBAAsB,EAAEC,wBAAwB,QAAQ,sBAAmB;;AAGpF;;AAGA,SAASC,qBAAqB,QAAQ,2BAAwB;AAC9D,SAASC,wBAAwB,QAAQ,0BAAuB;AAEhE,SAASC,6BAA6B,QAAQ,iCAA8B;AAE5E,SAASC,mBAAmB,EAAEC,wBAAwB,QAAQ,4BAAyB;;AAEvF;AACA,SAASC,aAAa,QAAQ,0BAAuB;AAErD,SAASC,mBAAmB,EAAEC,cAAc,QAAQ,kBAAe;;AAEnE;AACA,SACCC,eAAe,EACfC,iBAAiB,EACjBC,cAAc,EACdC,gBAAgB,QACV,iCAA8B;;AAErC;AACA,SAASC,WAAW,EAAEC,aAAa,EAAEC,MAAM,QAAQ,yBAAsB;;AAIzE;AACA;AACA;AACA","ignoreList":[]}
|