@chipmobilesdk/rn-camera 0.3.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 +152 -0
- package/README.md +47 -14
- 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 +25 -6
- package/src/config/types.ts +8 -0
- package/src/core/captureController.ts +11 -1
- package/src/core/contract.ts +109 -0
- package/src/core/controller.ts +96 -148
- package/src/core/sessionRuntime.ts +242 -0
- package/src/index.ts +7 -13
- package/src/native/cameraEngine.ts +28 -8
- package/src/native/visionSurface.ts +43 -18
- package/src/react/CameraPreview.tsx +40 -7
- package/src/react/VisionCameraFeed.tsx +61 -5
- package/src/react/hooks.ts +1 -1
- package/src/storage/artifactStore.ts +9 -2
- package/src/testing/testCameraAdapter.ts +29 -7
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCameraController = useCameraController;
|
|
7
|
+
exports.useCameraState = useCameraState;
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _controller = require("../core/controller.js");
|
|
10
|
+
/**
|
|
11
|
+
* React bindings for the camera controller.
|
|
12
|
+
*
|
|
13
|
+
* `useCameraController` owns the controller lifetime and disposes it on
|
|
14
|
+
* unmount, which is what guarantees the camera is released when a screen goes
|
|
15
|
+
* away (FR-016).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
function useCameraController(options) {
|
|
19
|
+
// Options usually arrive as a fresh object literal each render; capturing
|
|
20
|
+
// them in a ref keeps the controller stable for the component's lifetime.
|
|
21
|
+
const optionsRef = (0, _react.useRef)(options);
|
|
22
|
+
// Construction has no side effects (the controller subscribes on first use),
|
|
23
|
+
// so a controller React builds and discards here costs nothing.
|
|
24
|
+
const [controller, setController] = (0, _react.useState)(() => (0, _controller.createCameraController)(optionsRef.current));
|
|
25
|
+
const disposedRef = (0, _react.useRef)(new WeakSet());
|
|
26
|
+
(0, _react.useEffect)(() => {
|
|
27
|
+
// StrictMode, and React's planned offscreen reuse, run the cleanup and then
|
|
28
|
+
// this effect again on the same component. Disposal is final, so the old
|
|
29
|
+
// controller cannot be revived; replace it. Before this, the screen kept a
|
|
30
|
+
// dead controller after the remount and the camera never started.
|
|
31
|
+
const disposed = disposedRef.current;
|
|
32
|
+
if (disposed.has(controller)) {
|
|
33
|
+
setController((0, _controller.createCameraController)(optionsRef.current));
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
return () => {
|
|
37
|
+
disposed.add(controller);
|
|
38
|
+
controller.dispose().catch(() => undefined);
|
|
39
|
+
};
|
|
40
|
+
}, [controller]);
|
|
41
|
+
return controller;
|
|
42
|
+
}
|
|
43
|
+
function useCameraState(controller) {
|
|
44
|
+
// `subscribe` is a property of the controller object, so it is stable for the
|
|
45
|
+
// controller's lifetime, which is what useSyncExternalStore requires. The
|
|
46
|
+
// store read is tear-free, unlike the previous useState copy, which could
|
|
47
|
+
// miss a change made between render and effect.
|
|
48
|
+
return (0, _react.useSyncExternalStore)(controller.subscribe, () => controller.state, () => controller.state);
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_react","require","_controller","useCameraController","options","optionsRef","useRef","controller","setController","useState","createCameraController","current","disposedRef","WeakSet","useEffect","disposed","has","undefined","add","dispose","catch","useCameraState","useSyncExternalStore","subscribe","state"],"sourceRoot":"../../../src","sources":["react/hooks.ts"],"mappings":";;;;;;;AAQA,IAAAA,MAAA,GAAAC,OAAA;AAGA,IAAAC,WAAA,GAAAD,OAAA;AAXA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWO,SAASE,mBAAmBA,CAACC,OAAgC,EAAoB;EACvF;EACA;EACA,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAACF,OAAO,CAAC;EAClC;EACA;EACA,MAAM,CAACG,UAAU,EAAEC,aAAa,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM,IAAAC,kCAAsB,EAACL,UAAU,CAACM,OAAO,CAAC,CAAC;EAC9F,MAAMC,WAAW,GAAG,IAAAN,aAAM,EAAC,IAAIO,OAAO,CAAmB,CAAC,CAAC;EAE3D,IAAAC,gBAAS,EAAC,MAAM;IACf;IACA;IACA;IACA;IACA,MAAMC,QAAQ,GAAGH,WAAW,CAACD,OAAO;IACpC,IAAII,QAAQ,CAACC,GAAG,CAACT,UAAU,CAAC,EAAE;MAC7BC,aAAa,CAAC,IAAAE,kCAAsB,EAACL,UAAU,CAACM,OAAO,CAAC,CAAC;MACzD,OAAOM,SAAS;IACjB;IACA,OAAO,MAAM;MACZF,QAAQ,CAACG,GAAG,CAACX,UAAU,CAAC;MACxBA,UAAU,CAACY,OAAO,CAAC,CAAC,CAACC,KAAK,CAAC,MAAMH,SAAS,CAAC;IAC5C,CAAC;EACF,CAAC,EAAE,CAACV,UAAU,CAAC,CAAC;EAEhB,OAAOA,UAAU;AAClB;AAEO,SAASc,cAAcA,CAACd,UAA4B,EAAe;EACzE;EACA;EACA;EACA;EACA,OAAO,IAAAe,2BAAoB,EAC1Bf,UAAU,CAACgB,SAAS,EACpB,MAAMhB,UAAU,CAACiB,KAAK,EACtB,MAAMjB,UAAU,CAACiB,KAClB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createArtifactStore = createArtifactStore;
|
|
7
|
+
exports.createCacheArtifactStore = createCacheArtifactStore;
|
|
8
|
+
var _errors = require("../diagnostics/errors.js");
|
|
9
|
+
/**
|
|
10
|
+
* ArtifactStore port + default cache-directory adapter (FR-026..FR-029).
|
|
11
|
+
*
|
|
12
|
+
* Package-owned artifacts live in a dedicated `rn-camera` subdirectory of the
|
|
13
|
+
* platform cache directory (research R6). That dedicated prefix is what makes
|
|
14
|
+
* ownership checkable rather than advisory: `owns()` is a path-prefix test, so
|
|
15
|
+
* the package can refuse to delete anything it did not create (FR-028).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/** Minimal filesystem surface the adapter needs. Injectable for tests. */
|
|
19
|
+
|
|
20
|
+
/** Normalizes separators so prefix comparison works on both platforms. */
|
|
21
|
+
function normalize(path) {
|
|
22
|
+
return path.replace(/\\/g, '/').replace(/^file:\/\//, '');
|
|
23
|
+
}
|
|
24
|
+
function createArtifactStore(fs, directoryName = 'rn-camera') {
|
|
25
|
+
const root = `${fs.cacheDirectory().replace(/\/$/, '')}/${directoryName}`;
|
|
26
|
+
const normalizedRoot = normalize(root);
|
|
27
|
+
// Artifacts created by this process are never swept, no matter their age.
|
|
28
|
+
const createdThisProcess = new Set();
|
|
29
|
+
function owns(uri) {
|
|
30
|
+
return normalize(uri).startsWith(`${normalizedRoot}/`);
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
temporaryDirectory() {
|
|
34
|
+
return root;
|
|
35
|
+
},
|
|
36
|
+
owns,
|
|
37
|
+
async remove(uri) {
|
|
38
|
+
if (!owns(uri)) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const path = normalize(uri);
|
|
42
|
+
// Idempotent: a missing artifact is a successful cleanup (FR-027).
|
|
43
|
+
if (await fs.exists(path)) {
|
|
44
|
+
await fs.unlink(path);
|
|
45
|
+
}
|
|
46
|
+
createdThisProcess.delete(path);
|
|
47
|
+
},
|
|
48
|
+
async sweep(olderThanMs) {
|
|
49
|
+
await fs.ensureDirectory(root);
|
|
50
|
+
const entries = await fs.list(root);
|
|
51
|
+
const cutoff = Date.now() - olderThanMs;
|
|
52
|
+
let removed = 0;
|
|
53
|
+
for (const entry of entries) {
|
|
54
|
+
const path = normalize(entry);
|
|
55
|
+
if (createdThisProcess.has(path)) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const created = await fs.createdAt(path);
|
|
59
|
+
if (created < cutoff) {
|
|
60
|
+
await fs.unlink(path);
|
|
61
|
+
removed += 1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return removed;
|
|
65
|
+
},
|
|
66
|
+
async adopt(uri) {
|
|
67
|
+
const path = normalize(uri);
|
|
68
|
+
if (owns(uri)) {
|
|
69
|
+
createdThisProcess.add(path);
|
|
70
|
+
return uri;
|
|
71
|
+
}
|
|
72
|
+
if (!fs.move) {
|
|
73
|
+
throw new _errors.CameraError('storageFailure', 'This FileSystemBridge has no move(), so it cannot adopt a capture');
|
|
74
|
+
}
|
|
75
|
+
await fs.ensureDirectory(root);
|
|
76
|
+
const name = path.slice(path.lastIndexOf('/') + 1) || `capture-${Date.now()}.jpg`;
|
|
77
|
+
const target = `${root}/${name}`;
|
|
78
|
+
await fs.move(path, target);
|
|
79
|
+
createdThisProcess.add(normalize(target));
|
|
80
|
+
return uri.startsWith('file://') ? `file://${normalize(target)}` : target;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Default adapter. The concrete filesystem bridge is supplied by the native
|
|
87
|
+
* layer at runtime; it is a parameter rather than a hard import so the package
|
|
88
|
+
* takes no filesystem dependency of its own.
|
|
89
|
+
*/
|
|
90
|
+
function createCacheArtifactStore(options = {}) {
|
|
91
|
+
const fs = options.fs;
|
|
92
|
+
if (!fs) {
|
|
93
|
+
// A typed error, like every other failure this package reports.
|
|
94
|
+
throw new _errors.CameraError('storageFailure', 'createCacheArtifactStore requires a FileSystemBridge. Pass `fs`, or use ' + 'createTestCamera() in tests.');
|
|
95
|
+
}
|
|
96
|
+
return createArtifactStore(fs, options.directoryName);
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=artifactStore.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_errors","require","normalize","path","replace","createArtifactStore","fs","directoryName","root","cacheDirectory","normalizedRoot","createdThisProcess","Set","owns","uri","startsWith","temporaryDirectory","remove","exists","unlink","delete","sweep","olderThanMs","ensureDirectory","entries","list","cutoff","Date","now","removed","entry","has","created","createdAt","adopt","add","move","CameraError","name","slice","lastIndexOf","target","createCacheArtifactStore","options"],"sourceRoot":"../../../src","sources":["storage/artifactStore.ts"],"mappings":";;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAuBA;;AAsBA;AACA,SAASC,SAASA,CAACC,IAAY,EAAU;EACxC,OAAOA,IAAI,CAACC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAACA,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;AAC1D;AAEO,SAASC,mBAAmBA,CAClCC,EAAoB,EACpBC,aAAa,GAAG,WAAW,EACX;EAChB,MAAMC,IAAI,GAAG,GAAGF,EAAE,CAACG,cAAc,CAAC,CAAC,CAACL,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,IAAIG,aAAa,EAAE;EACzE,MAAMG,cAAc,GAAGR,SAAS,CAACM,IAAI,CAAC;EACtC;EACA,MAAMG,kBAAkB,GAAG,IAAIC,GAAG,CAAS,CAAC;EAE5C,SAASC,IAAIA,CAACC,GAAW,EAAW;IACnC,OAAOZ,SAAS,CAACY,GAAG,CAAC,CAACC,UAAU,CAAC,GAAGL,cAAc,GAAG,CAAC;EACvD;EAEA,OAAO;IACNM,kBAAkBA,CAAA,EAAG;MACpB,OAAOR,IAAI;IACZ,CAAC;IAEDK,IAAI;IAEJ,MAAMI,MAAMA,CAACH,GAAG,EAAE;MACjB,IAAI,CAACD,IAAI,CAACC,GAAG,CAAC,EAAE;QACf;MACD;MACA,MAAMX,IAAI,GAAGD,SAAS,CAACY,GAAG,CA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8B,IAAI,GAAGnC,IAAI,CAACoC,KAAK,CAACpC,IAAI,CAACqC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,IAAI,WAAWb,IAAI,CAACC,GAAG,CAAC,CAAC,MAAM;MACjF,MAAMa,MAAM,GAAG,GAAGjC,IAAI,IAAI8B,IAAI,EAAE;MAChC,MAAMhC,EAAE,CAAC8B,IAAI,CAACjC,IAAI,EAAEsC,MAAM,CAAC;MAC3B9B,kBAAkB,CAACwB,GAAG,CAACjC,SAAS,CAACuC,MAAM,CAAC,CAAC;MACzC,OAAO3B,GAAG,CAACC,UAAU,CAAC,SAAS,CAAC,GAAG,UAAUb,SAAS,CAACuC,MAAM,CAAC,EAAE,GAAGA,MAAM;IAC1E;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACO,SAASC,wBAAwBA,CAACC,OAAqB,GAAG,CAAC,CAAC,EAAiB;EACnF,MAAMrC,EAAE,GAAGqC,OAAO,CAACrC,EAAE;EACrB,IAAI,CAACA,EAAE,EAAE;IACR;IACA,MAAM,IAAI+B,mBAAW,CACpB,gBAAgB,EAChB,0EAA0E,GACzE,8BACF,CAAC;EACF;EACA,OAAOhC,mBAAmB,CAACC,EAAE,EAAEqC,OAAO,CAACpC,aAAa,CAAC;AACtD","ignoreList":[]}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.permissionPortChecks = exports.cameraEngineChecks = void 0;
|
|
7
|
+
exports.runCameraEngineConformance = runCameraEngineConformance;
|
|
8
|
+
exports.runPermissionPortConformance = runPermissionPortConformance;
|
|
9
|
+
var _testing = require("@chipmobilesdk/rn-core/testing");
|
|
10
|
+
/**
|
|
11
|
+
* What any `PermissionPort` and `CameraEngine` must do (IOS-12, CAM-13).
|
|
12
|
+
*
|
|
13
|
+
* The same checks run against the in-memory test adapter and against the real
|
|
14
|
+
* VisionCamera adapters (native module mocked in Jest, or for real on a device),
|
|
15
|
+
* so the fake the app's tests rely on cannot drift from the adapter it stands in
|
|
16
|
+
* for. Each check builds its own port from a harness, under the conditions it
|
|
17
|
+
* needs.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const permissionPortChecks = exports.permissionPortChecks = [{
|
|
21
|
+
name: 'reads the status without prompting',
|
|
22
|
+
async run(harness) {
|
|
23
|
+
const system = harness.create('undetermined');
|
|
24
|
+
(0, _testing.ensure)((await system.port.getStatus()) === 'undetermined', 'expected undetermined');
|
|
25
|
+
(0, _testing.ensure)(system.prompts() === 0, 'getStatus prompted');
|
|
26
|
+
}
|
|
27
|
+
}, {
|
|
28
|
+
name: 'reports a grant after prompting once',
|
|
29
|
+
async run(harness) {
|
|
30
|
+
const system = harness.create('undetermined');
|
|
31
|
+
const state = await system.port.request();
|
|
32
|
+
(0, _testing.ensure)(state === 'granted', `expected granted, got ${state}`);
|
|
33
|
+
(0, _testing.ensure)(system.prompts() === 1, `expected one prompt, got ${system.prompts()}`);
|
|
34
|
+
}
|
|
35
|
+
}, {
|
|
36
|
+
name: 'never prompts again after a permanent denial',
|
|
37
|
+
async run(harness) {
|
|
38
|
+
const system = harness.create('deniedPermanently');
|
|
39
|
+
const state = await system.port.request();
|
|
40
|
+
(0, _testing.ensure)(state === 'deniedPermanently', `expected deniedPermanently, got ${state}`);
|
|
41
|
+
(0, _testing.ensure)(system.prompts() === 0, 'prompted after a permanent denial');
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
name: 'tells subscribers about a change, and nothing after unsubscribing',
|
|
45
|
+
async run(harness) {
|
|
46
|
+
const system = harness.create('undetermined');
|
|
47
|
+
const seen = [];
|
|
48
|
+
const unsubscribe = system.port.subscribe(state => seen.push(state));
|
|
49
|
+
await system.port.request();
|
|
50
|
+
(0, _testing.ensure)(seen.includes('granted'), `subscriber saw ${JSON.stringify(seen)}`);
|
|
51
|
+
unsubscribe();
|
|
52
|
+
unsubscribe();
|
|
53
|
+
const before = seen.length;
|
|
54
|
+
system.setSystemState('deniedPermanently');
|
|
55
|
+
await system.port.getStatus();
|
|
56
|
+
(0, _testing.ensure)(seen.length === before, 'notified after unsubscribing');
|
|
57
|
+
}
|
|
58
|
+
}];
|
|
59
|
+
const cameraEngineChecks = exports.cameraEngineChecks = [{
|
|
60
|
+
name: 'refuses to start without a camera, as cameraUnavailable',
|
|
61
|
+
async run(harness) {
|
|
62
|
+
const engine = harness.create([]);
|
|
63
|
+
let code;
|
|
64
|
+
try {
|
|
65
|
+
await engine.start({});
|
|
66
|
+
} catch (error) {
|
|
67
|
+
code = error.code;
|
|
68
|
+
}
|
|
69
|
+
(0, _testing.ensure)(code === 'cameraUnavailable', `expected cameraUnavailable, got ${String(code)}`);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
name: 'starts when a camera exists',
|
|
73
|
+
async run(harness) {
|
|
74
|
+
await harness.create([{
|
|
75
|
+
position: 'back'
|
|
76
|
+
}]).start({});
|
|
77
|
+
}
|
|
78
|
+
}, {
|
|
79
|
+
name: 'reports capabilities from the cameras present',
|
|
80
|
+
async run(harness) {
|
|
81
|
+
const capabilities = await harness.create([{
|
|
82
|
+
position: 'back',
|
|
83
|
+
hasTorch: true,
|
|
84
|
+
hasFlash: true
|
|
85
|
+
}, {
|
|
86
|
+
position: 'front'
|
|
87
|
+
}]).getCapabilities();
|
|
88
|
+
(0, _testing.ensure)(capabilities.hasCameraHardware, 'no camera hardware reported');
|
|
89
|
+
(0, _testing.ensure)(capabilities.hasTorch && capabilities.hasFlash, 'torch or flash not reported');
|
|
90
|
+
const positions = [...capabilities.availablePositions].sort();
|
|
91
|
+
(0, _testing.ensure)(positions.join(',') === 'back,front', `positions ${positions.join(',')}`);
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
name: 'stops safely, even without a start and twice',
|
|
95
|
+
async run(harness) {
|
|
96
|
+
const engine = harness.create([{
|
|
97
|
+
position: 'back'
|
|
98
|
+
}]);
|
|
99
|
+
await engine.stop();
|
|
100
|
+
await engine.stop();
|
|
101
|
+
}
|
|
102
|
+
}];
|
|
103
|
+
function runPermissionPortConformance(harness) {
|
|
104
|
+
return (0, _testing.runChecks)(() => harness, permissionPortChecks);
|
|
105
|
+
}
|
|
106
|
+
function runCameraEngineConformance(harness) {
|
|
107
|
+
return (0, _testing.runChecks)(() => harness, cameraEngineChecks);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=conformance.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_testing","require","permissionPortChecks","exports","name","run","harness","system","create","ensure","port","getStatus","prompts","state","request","seen","unsubscribe","subscribe","push","includes","JSON","stringify","before","length","setSystemState","cameraEngineChecks","engine","code","start","error","String","position","capabilities","hasTorch","hasFlash","getCapabilities","hasCameraHardware","positions","availablePositions","sort","join","stop","runPermissionPortConformance","runChecks","runCameraEngineConformance"],"sourceRoot":"../../../src","sources":["testing/conformance.ts"],"mappings":";;;;;;;;AASA,IAAAA,QAAA,GAAAC,OAAA;AATA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAoCO,MAAMC,oBAAyD,GAAAC,OAAA,CAAAD,oBAAA,GAAG,CACxE;EACCE,IAAI,EAAE,oCAAoC;EAC1C,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAMC,MAAM,GAAGD,OAAO,CAACE,MAAM,CAAC,cAAc,CAAC;IAC7C,IAAAC,eAAM,EAAC,CAAC,MAAMF,MAAM,CAACG,IAAI,CAACC,SAAS,CAAC,CAAC,MAAM,cAAc,EAAE,uBAAuB,CAAC;IACnF,IAAAF,eAAM,EAACF,MAAM,CAACK,OAAO,CAAC,CAAC,KAAK,CAAC,EAAE,oBAAoB,CAAC;EACrD;AACD,CAAC,EACD;EACCR,IAAI,EAAE,sCAAsC;EAC5C,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAMC,MAAM,GA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CAAC,CAAC,CACrFI,eAAe,CAAC,CAAC;IACnB,IAAA1B,eAAM,EAACuB,YAAY,CAACI,iBAAiB,EAAE,6BAA6B,CAAC;IACrE,IAAA3B,eAAM,EAACuB,YAAY,CAACC,QAAQ,IAAID,YAAY,CAACE,QAAQ,EAAE,6BAA6B,CAAC;IACrF,MAAMG,SAAS,GAAG,CAAC,GAAGL,YAAY,CAACM,kBAAkB,CAAC,CAACC,IAAI,CAAC,CAAC;IAC7D,IAAA9B,eAAM,EAAC4B,SAAS,CAACG,IAAI,CAAC,GAAG,CAAC,KAAK,YAAY,EAAE,aAAaH,SAAS,CAACG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;EACjF;AACD,CAAC,EACD;EACCpC,IAAI,EAAE,8CAA8C;EACpD,MAAMC,GAAGA,CAACC,OAAO,EAAE;IAClB,MAAMoB,MAAM,GAAGpB,OAAO,CAACE,MAAM,CAAC,CAAC;MAAEuB,QAAQ,EAAE;IAAO,CAAC,CAAC,CAAC;IACrD,MAAML,MAAM,CAACe,IAAI,CAAC,CAAC;IACnB,MAAMf,MAAM,CAACe,IAAI,CAAC,CAAC;EACpB;AACD,CAAC,CACD;AAEM,SAASC,4BAA4BA,CAC3CpC,OAA0B,EACG;EAC7B,OAAO,IAAAqC,kBAAS,EAAC,MAAMrC,OAAO,EAAEJ,oBAAoB,CAAC;AACtD;AAEO,SAAS0C,0BAA0BA,CAACtC,OAAsB,EAA8B;EAC9F,OAAO,IAAAqC,kBAAS,EAAC,MAAMrC,OAAO,EAAEmB,kBAAkB,CAAC;AACpD","ignoreList":[]}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "DEFAULT_TEST_CAPABILITIES", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _testCameraAdapter.DEFAULT_TEST_CAPABILITIES;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "cameraEngineChecks", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _conformance.cameraEngineChecks;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "createMemoryFileSystem", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _testCameraAdapter.createMemoryFileSystem;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "createTestCamera", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _testCameraAdapter.createTestCamera;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "permissionPortChecks", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _conformance.permissionPortChecks;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "runCameraEngineConformance", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function () {
|
|
39
|
+
return _conformance.runCameraEngineConformance;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "runPermissionPortConformance", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function () {
|
|
45
|
+
return _conformance.runPermissionPortConformance;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
var _testCameraAdapter = require("./testCameraAdapter.js");
|
|
49
|
+
var _conformance = require("./conformance.js");
|
|
50
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_testCameraAdapter","require","_conformance"],"sourceRoot":"../../../src","sources":["testing/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,IAAAA,kBAAA,GAAAC,OAAA;AAOA,IAAAC,YAAA,GAAAD,OAAA","ignoreList":[]}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.DEFAULT_TEST_CAPABILITIES = void 0;
|
|
7
|
+
exports.createMemoryFileSystem = createMemoryFileSystem;
|
|
8
|
+
exports.createTestCamera = createTestCamera;
|
|
9
|
+
var _rnCore = require("@chipmobilesdk/rn-core");
|
|
10
|
+
var _types = require("../config/types.js");
|
|
11
|
+
var _errors = require("../diagnostics/errors.js");
|
|
12
|
+
var _artifactStore = require("../storage/artifactStore.js");
|
|
13
|
+
var _captureController = require("../core/captureController.js");
|
|
14
|
+
/**
|
|
15
|
+
* Deterministic in-memory camera for tests (FR-041, SC-010).
|
|
16
|
+
*
|
|
17
|
+
* These are real implementations of the same published ports the production
|
|
18
|
+
* adapters implement, not a parallel mock — so a contract change breaks them at
|
|
19
|
+
* compile time and they cannot drift. Nothing here touches a native module, the
|
|
20
|
+
* filesystem, or a permission API.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
function createMemoryFileSystem(root = '/cache') {
|
|
24
|
+
const files = new Map();
|
|
25
|
+
const directories = new Set();
|
|
26
|
+
return {
|
|
27
|
+
cacheDirectory: () => root,
|
|
28
|
+
async exists(path) {
|
|
29
|
+
return files.has(path);
|
|
30
|
+
},
|
|
31
|
+
async unlink(path) {
|
|
32
|
+
files.delete(path);
|
|
33
|
+
},
|
|
34
|
+
async list(directory) {
|
|
35
|
+
const prefix = `${directory.replace(/\/$/, '')}/`;
|
|
36
|
+
return Array.from(files.keys()).filter(path => path.startsWith(prefix));
|
|
37
|
+
},
|
|
38
|
+
async createdAt(path) {
|
|
39
|
+
return files.get(path) ?? Date.now();
|
|
40
|
+
},
|
|
41
|
+
async ensureDirectory(directory) {
|
|
42
|
+
directories.add(directory);
|
|
43
|
+
},
|
|
44
|
+
async move(from, to) {
|
|
45
|
+
if (!files.has(from)) {
|
|
46
|
+
throw new Error('No such file');
|
|
47
|
+
}
|
|
48
|
+
files.set(to, files.get(from) ?? Date.now());
|
|
49
|
+
files.delete(from);
|
|
50
|
+
},
|
|
51
|
+
seed(path, createdAtMs) {
|
|
52
|
+
files.set(path, createdAtMs);
|
|
53
|
+
},
|
|
54
|
+
paths: () => Array.from(files.keys())
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const DEFAULT_TEST_CAPABILITIES = exports.DEFAULT_TEST_CAPABILITIES = {
|
|
58
|
+
availablePositions: ['back', 'front'],
|
|
59
|
+
hasFlash: true,
|
|
60
|
+
hasTorch: true,
|
|
61
|
+
supportsOrientationChange: true,
|
|
62
|
+
hasCameraHardware: true
|
|
63
|
+
};
|
|
64
|
+
function createTestCamera(config = {}) {
|
|
65
|
+
const fs = createMemoryFileSystem(config.cacheRoot ?? '/cache');
|
|
66
|
+
const store = (0, _artifactStore.createArtifactStore)(fs);
|
|
67
|
+
const capabilities = {
|
|
68
|
+
...DEFAULT_TEST_CAPABILITIES,
|
|
69
|
+
...config.capabilities
|
|
70
|
+
};
|
|
71
|
+
let permission = config.permission ?? 'undetermined';
|
|
72
|
+
let captureError = config.captureError ?? null;
|
|
73
|
+
let startError = config.startError ?? null;
|
|
74
|
+
let torch = false;
|
|
75
|
+
let starts = 0;
|
|
76
|
+
let stops = 0;
|
|
77
|
+
let sequence = 0;
|
|
78
|
+
let promptCount = 0;
|
|
79
|
+
const produced = [];
|
|
80
|
+
// The same listener sets as the real adapters, so a throwing subscriber behaves
|
|
81
|
+
// identically here and on a device.
|
|
82
|
+
const permissionListeners = (0, _rnCore.createListenerSet)();
|
|
83
|
+
const appStateListeners = (0, _rnCore.createListenerSet)();
|
|
84
|
+
const interruptionListeners = (0, _rnCore.createListenerSet)();
|
|
85
|
+
let requestThrows = false;
|
|
86
|
+
const permissions = {
|
|
87
|
+
async getStatus() {
|
|
88
|
+
return permission;
|
|
89
|
+
},
|
|
90
|
+
async request() {
|
|
91
|
+
if (requestThrows) {
|
|
92
|
+
// What a native module that cannot be reached does.
|
|
93
|
+
throw new Error('permission request failed');
|
|
94
|
+
}
|
|
95
|
+
// Mirrors the real adapter: never re-prompt after a permanent denial.
|
|
96
|
+
if (permission === 'deniedPermanently') {
|
|
97
|
+
return permission;
|
|
98
|
+
}
|
|
99
|
+
if (permission === 'undetermined' || permission === 'denied') {
|
|
100
|
+
promptCount += 1;
|
|
101
|
+
permission = 'granted';
|
|
102
|
+
}
|
|
103
|
+
permissionListeners.notify(permission);
|
|
104
|
+
return permission;
|
|
105
|
+
},
|
|
106
|
+
subscribe: listener => permissionListeners.add(listener)
|
|
107
|
+
};
|
|
108
|
+
const engine = {
|
|
109
|
+
subscribeToInterruptions: listener => interruptionListeners.add(listener),
|
|
110
|
+
async start() {
|
|
111
|
+
starts += 1;
|
|
112
|
+
if (startError) {
|
|
113
|
+
throw new _errors.CameraError(startError);
|
|
114
|
+
}
|
|
115
|
+
if (!capabilities.hasCameraHardware) {
|
|
116
|
+
throw new _errors.CameraError('cameraUnavailable');
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
async stop() {
|
|
120
|
+
stops += 1;
|
|
121
|
+
torch = false;
|
|
122
|
+
},
|
|
123
|
+
async capture(request) {
|
|
124
|
+
if (captureError) {
|
|
125
|
+
throw new _errors.CameraError(captureError);
|
|
126
|
+
}
|
|
127
|
+
sequence += 1;
|
|
128
|
+
const position = request.cameraPosition ?? 'back';
|
|
129
|
+
const uri = request.destination ?? `${store.temporaryDirectory()}/capture-${sequence}.jpg`;
|
|
130
|
+
fs.seed(uri, Date.now());
|
|
131
|
+
const image = {
|
|
132
|
+
uri,
|
|
133
|
+
mimeType: 'image/jpeg',
|
|
134
|
+
width: 1920,
|
|
135
|
+
height: 1080,
|
|
136
|
+
timestamp: Date.now(),
|
|
137
|
+
cameraPosition: position,
|
|
138
|
+
ownership: request.destination ? 'appOwned' : 'packageTemporary',
|
|
139
|
+
// Clamped the way the real path clamps it, not a second copy of 0.9.
|
|
140
|
+
effectiveQuality: (0, _captureController.clampQuality)(request.quality),
|
|
141
|
+
effectiveMaxDimension: request.maxDimension === undefined ? (0, _types.unavailable)() : (0, _types.known)(request.maxDimension),
|
|
142
|
+
fileSize: (0, _types.known)(1024),
|
|
143
|
+
orientation: (0, _types.known)(0),
|
|
144
|
+
...config.captureResult
|
|
145
|
+
};
|
|
146
|
+
produced.push(image);
|
|
147
|
+
return image;
|
|
148
|
+
},
|
|
149
|
+
async setTorch(enabled) {
|
|
150
|
+
torch = enabled;
|
|
151
|
+
},
|
|
152
|
+
async getCapabilities() {
|
|
153
|
+
return capabilities;
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return {
|
|
157
|
+
engine,
|
|
158
|
+
permissions,
|
|
159
|
+
store,
|
|
160
|
+
fs,
|
|
161
|
+
subscribeToAppState: listener => appStateListeners.add(listener),
|
|
162
|
+
setAppState(status) {
|
|
163
|
+
appStateListeners.notify(status);
|
|
164
|
+
},
|
|
165
|
+
setPermission(state) {
|
|
166
|
+
permission = state;
|
|
167
|
+
permissionListeners.notify(state);
|
|
168
|
+
},
|
|
169
|
+
emitInterruption(code = 'interrupted') {
|
|
170
|
+
// The OS took the camera away. A live session hears about it, and the
|
|
171
|
+
// next start attempt fails until the app clears it.
|
|
172
|
+
startError = code;
|
|
173
|
+
interruptionListeners.notify(code);
|
|
174
|
+
},
|
|
175
|
+
emitPermissionRequestFailure(enabled) {
|
|
176
|
+
requestThrows = enabled;
|
|
177
|
+
},
|
|
178
|
+
setCaptureError(code) {
|
|
179
|
+
captureError = code;
|
|
180
|
+
},
|
|
181
|
+
setStartError(code) {
|
|
182
|
+
startError = code;
|
|
183
|
+
},
|
|
184
|
+
prompts: () => promptCount,
|
|
185
|
+
captures: () => produced,
|
|
186
|
+
torchState: () => torch,
|
|
187
|
+
startCount: () => starts,
|
|
188
|
+
stopCount: () => stops
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
//# sourceMappingURL=testCameraAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_rnCore","require","_types","_errors","_artifactStore","_captureController","createMemoryFileSystem","root","files","Map","directories","Set","cacheDirectory","exists","path","has","unlink","delete","list","directory","prefix","replace","Array","from","keys","filter","startsWith","createdAt","get","Date","now","ensureDirectory","add","move","to","Error","set","seed","createdAtMs","paths","DEFAULT_TEST_CAPABILITIES","exports","availablePositions","hasFlash","hasTorch","supportsOrientationChange","hasCameraHardware","createTestCamera","config","fs","cacheRoot","store","createArtifactStore","capabilities","permission","captureError","startError","torch","starts","stops","sequence","promptCount","produced","permissionListeners","createListenerSet","appStateListeners","interruptionListeners","requestThrows","permissions","getStatus","request","notify","subscribe","listener","engine","subscribeToInterruptions","start","CameraError","stop","capture","position","cameraPosition","uri","destination","temporaryDirectory","image","mimeType","width","height","timestamp","ownership","effectiveQuality","clampQuality","quality","effectiveMaxDimension","maxDimension","undefined","unavailable","known","fileSize","orientation","captureResult","push","setTorch","enabled","getCapabilities","subscribeToAppState","setAppState","status","setPermission","state","emitInterruption","code","emitPermissionRequestFailure","setCaptureError","setStartError","prompts","captures","torchState","startCount","stopCount"],"sourceRoot":"../../../src","sources":["testing/testCameraAdapter.ts"],"mappings":";;;;;;;;AASA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AASA,IAAAE,OAAA,GAAAF,OAAA;AAGA,IAAAG,cAAA,GAAAH,OAAA;AAMA,IAAAI,kBAAA,GAAAJ,OAAA;AA7BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+BO,SAASK,sBAAsBA,CAACC,IAAI,GAAG,QAAQ,EAAoB;EACzE,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAiB,CAAC;EACvC,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAS,CAAC;EAErC,OAAO;IACNC,cAAc,EAAEA,CAAA,KAAML,IAAI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AmB,CAACQ,MAAM,CAACuC,KAAK,CAAC;IAClC,CAAC;IAEDC,gBAAgBA,CAACC,IAAqB,GAAG,aAAa,EAAE;MACvD;MACA;MACAxD,UAAU,GAAGwD,IAAI;MACjB9C,qBAAqB,CAACK,MAAM,CAACyC,IAAI,CAAC;IACnC,CAAC;IAEDC,4BAA4BA,CAACT,OAAO,EAAE;MACrCrC,aAAa,GAAGqC,OAAO;IACxB,CAAC;IAEDU,eAAeA,CAACF,IAAI,EAAE;MACrBzD,YAAY,GAAGyD,IAAI;IACpB,CAAC;IAEDG,aAAaA,CAACH,IAAI,EAAE;MACnBxD,UAAU,GAAGwD,IAAI;IAClB,CAAC;IAEDI,OAAO,EAAEA,CAAA,KAAMvD,WAAW;IAC1BwD,QAAQ,EAAEA,CAAA,KAAMvD,QAAQ;IACxBwD,UAAU,EAAEA,CAAA,KAAM7D,KAAK;IACvB8D,UAAU,EAAEA,CAAA,KAAM7D,MAAM;IACxB8D,SAAS,EAAEA,CAAA,KAAM7D;EAClB,CAAC;AACF","ignoreList":[]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public type contract for @chipmobilesdk/rn-camera.
|
|
5
|
+
*
|
|
6
|
+
* Every type here is re-exported from `src/index.ts` (LIB-002/LIB-003). See
|
|
7
|
+
* `specs/006-rn-camera-package/contracts/public-api.md` for the authoritative
|
|
8
|
+
* contract and `data-model.md` for the rules behind each field.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/** Camera authorization status. Seven distinguishable outcomes (FR-004). */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A metadata field the platform could not determine (FR-022). Distinct from an
|
|
15
|
+
* absent property so consumers can tell "not reported" from "not asked for".
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export function known(value) {
|
|
19
|
+
return {
|
|
20
|
+
available: true,
|
|
21
|
+
value
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export function unavailable() {
|
|
25
|
+
return {
|
|
26
|
+
available: false
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** What this device and platform actually support (FR-033). */
|
|
31
|
+
|
|
32
|
+
/** Instruction to take one still photo. Carries no business context (FR-002). */
|
|
33
|
+
|
|
34
|
+
/** Result of one successful capture. Always a file reference (FR-021/FR-021a). */
|
|
35
|
+
|
|
36
|
+
/** Options accepted when starting a session. */
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Relationship between captured-image space and on-screen preview space.
|
|
40
|
+
* Consumed by the pure mapping functions in `geometry/coordinateMapping`.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/** Aggregate observable state exposed by the controller. */
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Structural view of a CameraError, kept here so `CameraState` does not create
|
|
47
|
+
* a circular import with the diagnostics module.
|
|
48
|
+
*/
|
|
49
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["known","value","available","unavailable"],"sourceRoot":"../../../src","sources":["config/types.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAoBA;AACA;AACA;AACA;;AAYA,OAAO,SAASA,KAAKA,CAAIC,KAAQ,EAAY;EAC5C,OAAO;IAAEC,SAAS,EAAE,IAAI;IAAED;EAAM,CAAC;AAClC;AAEA,OAAO,SAASE,WAAWA,CAAA,EAAgB;EAC1C,OAAO;IAAED,SAAS,EAAE;EAAM,CAAC;AAC5B;;AAEA;;AASA;;AAgBA;;AAgBA;;AAKA;AACA;AACA;AACA;;AAwBA;;AAkBA;AACA;AACA;AACA","ignoreList":[]}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Capability gating (FR-033, FR-034).
|
|
5
|
+
*
|
|
6
|
+
* An unsupported capability must produce an `unsupportedCapability` result, not
|
|
7
|
+
* an unexpected failure — that is what lets an app hide a control instead of
|
|
8
|
+
* discovering at tap time that the device has no flash.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { CameraError } from "../diagnostics/errors.js";
|
|
12
|
+
export const EMPTY_CAPABILITIES = {
|
|
13
|
+
availablePositions: [],
|
|
14
|
+
hasFlash: false,
|
|
15
|
+
hasTorch: false,
|
|
16
|
+
supportsOrientationChange: false,
|
|
17
|
+
hasCameraHardware: false
|
|
18
|
+
};
|
|
19
|
+
export function supportsPosition(profile, position) {
|
|
20
|
+
return profile?.availablePositions.includes(position) ?? false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** `off` is always legal — it is the absence of flash, not a use of it. */
|
|
24
|
+
export function supportsFlashMode(profile, mode) {
|
|
25
|
+
return mode === 'off' ? true : profile?.hasFlash === true;
|
|
26
|
+
}
|
|
27
|
+
export function supportsTorch(profile) {
|
|
28
|
+
return profile?.hasTorch === true;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Throws the uniform unsupported error so every gate reads the same way. */
|
|
32
|
+
export function assertSupported(supported, what) {
|
|
33
|
+
if (!supported) {
|
|
34
|
+
throw new CameraError('unsupportedCapability', `Not supported on this device: ${what}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=capabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["CameraError","EMPTY_CAPABILITIES","availablePositions","hasFlash","hasTorch","supportsOrientationChange","hasCameraHardware","supportsPosition","profile","position","includes","supportsFlashMode","mode","supportsTorch","assertSupported","supported","what"],"sourceRoot":"../../../src","sources":["core/capabilities.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;;AAGA,SAASA,WAAW,QAAQ,0BAAuB;AAEnD,OAAO,MAAMC,kBAAqC,GAAG;EACpDC,kBAAkB,EAAE,EAAE;EACtBC,QAAQ,EAAE,KAAK;EACfC,QAAQ,EAAE,KAAK;EACfC,yBAAyB,EAAE,KAAK;EAChCC,iBAAiB,EAAE;AACpB,CAAC;AAED,OAAO,SAASC,gBAAgBA,CAC/BC,OAAiC,EACjCC,QAAwB,EACd;EACV,OAAOD,OAAO,EAAEN,kBAAkB,CAACQ,QAAQ,CAACD,QAAQ,CAAC,IAAI,KAAK;AAC/D;;AAEA;AACA,OAAO,SAASE,iBAAiBA,CAACH,OAAiC,EAAEI,IAAe,EAAW;EAC9F,OAAOA,IAAI,KAAK,KAAK,GAAG,IAAI,GAAGJ,OAAO,EAAEL,QAAQ,KAAK,IAAI;AAC1D;AAEA,OAAO,SAASU,aAAaA,CAACL,OAAiC,EAAW;EACzE,OAAOA,OAAO,EAAEJ,QAAQ,KAAK,IAAI;AAClC;;AAEA;AACA,OAAO,SAASU,eAAeA,CAACC,SAAkB,EAAEC,IAAY,EAAQ;EACvE,IAAI,CAACD,SAAS,EAAE;IACf,MAAM,IAAIf,WAAW,CAAC,uBAAuB,EAAE,iCAAiCgB,IAAI,EAAE,CAAC;EACxF;AACD","ignoreList":[]}
|