@digipair/skill-webcam 0.89.0 → 0.91.0-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/.swcrc ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "jsc": {
3
+ "target": "es2017",
4
+ "parser": {
5
+ "syntax": "typescript",
6
+ "decorators": true,
7
+ "dynamicImport": true
8
+ },
9
+ "transform": {
10
+ "decoratorMetadata": true,
11
+ "legacyDecorator": true
12
+ },
13
+ "keepClassNames": true,
14
+ "externalHelpers": true,
15
+ "loose": true
16
+ },
17
+ "module": {
18
+ "type": "es6"
19
+ },
20
+ "sourceMaps": true,
21
+ "exclude": [
22
+ "jest.config.ts",
23
+ ".*\\.spec.tsx?$",
24
+ ".*\\.test.tsx?$",
25
+ "./src/jest-setup.ts$",
26
+ "./**/jest-setup.ts$"
27
+ ]
28
+ }
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # mylib
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Building
6
+
7
+ Run `nx build mylib` to build the library.
@@ -0,0 +1,22 @@
1
+ import baseConfig from '../../eslint.config.mjs';
2
+
3
+ export default [
4
+ ...baseConfig,
5
+ {
6
+ files: ['**/*.json'],
7
+ rules: {
8
+ '@nx/dependency-checks': [
9
+ 'error',
10
+ {
11
+ ignoredFiles: [
12
+ '{projectRoot}/eslint.config.{js,cjs,mjs}',
13
+ '{projectRoot}/rollup.config.{js,ts,mjs,mts,cjs,cts}',
14
+ ],
15
+ },
16
+ ],
17
+ },
18
+ languageOptions: {
19
+ parser: await import('jsonc-eslint-parser'),
20
+ },
21
+ },
22
+ ];
package/package.json CHANGED
@@ -1,14 +1,28 @@
1
1
  {
2
2
  "name": "@digipair/skill-webcam",
3
- "version": "0.89.0",
3
+ "version": "0.91.0-0",
4
+ "type": "module",
5
+ "main": "dist/libs/skill-webcam/index.cjs.js",
6
+ "module": "dist/libs/skill-webcam/index.esm.js",
7
+ "types": "dist/libs/skill-webcam/index.esm.d.ts",
8
+ "exports": {
9
+ "./package.json": "./libs/skill-webcam/package.json",
10
+ ".": {
11
+ "development": "./dist/libs/skill-webcam/src/index.ts",
12
+ "types": "./dist/libs/skill-webcam/index.esm.d.ts",
13
+ "import": "./dist/libs/skill-webcam/index.esm.js",
14
+ "default": "./dist/libs/skill-webcam/index.cjs.js"
15
+ }
16
+ },
4
17
  "keywords": [
5
18
  "digipair",
6
19
  "service",
7
20
  "tool"
8
21
  ],
9
- "dependencies": {
10
- "node-webcam": "^0.8.2"
22
+ "nx": {
23
+ "name": "skill-webcam"
11
24
  },
12
- "main": "./index.cjs.js",
13
- "module": "./index.esm.js"
14
- }
25
+ "dependencies": {
26
+ "@digipair/engine": "0.91.0-0"
27
+ }
28
+ }
@@ -0,0 +1,28 @@
1
+ const { withNx } = require('@nx/rollup/with-nx');
2
+
3
+ module.exports = withNx(
4
+ {
5
+ main: 'libs/skill-webcam/src/index.ts',
6
+ outputPath: 'dist/libs/skill-webcam',
7
+ tsConfig: 'libs/skill-webcam/tsconfig.lib.json',
8
+ compiler: 'swc',
9
+ format: ['esm', "cjs"],
10
+ assets: [
11
+ {
12
+ input: 'libs/skill-webcam/',
13
+ glob: 'package.json',
14
+ output: '.'
15
+ },
16
+ {
17
+ input: 'libs/skill-webcam/src/',
18
+ glob: '*.json',
19
+ output: '.'
20
+ }
21
+ ]
22
+ },
23
+ {
24
+ // Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
25
+ // e.g.
26
+ // output: { sourcemap: true },
27
+ }
28
+ );
@@ -0,0 +1,7 @@
1
+ import { skillWebcam } from './skill-webcam';
2
+
3
+ describe('skillWebcam', () => {
4
+ it('should work', () => {
5
+ expect(skillWebcam()).toEqual('skill-webcam');
6
+ });
7
+ });
@@ -0,0 +1,51 @@
1
+ import { PinsSettings } from '@digipair/engine';
2
+ import * as NodeWebcam from 'node-webcam';
3
+
4
+ class WebcamService {
5
+ async capture(params: any, _pinsSettingsList: PinsSettings[], _context: any) {
6
+ const { width = 1280, height = 720, quality = 100, output = 'jpeg', device, verbose = false } = params;
7
+ const opts: NodeWebcam.WebcamOptions = {
8
+ width,
9
+ height,
10
+ quality,
11
+ delay: 0,
12
+ saveShots: false,
13
+ output,
14
+ device: device ?? false,
15
+ callbackReturn: 'base64',
16
+ verbose,
17
+ };
18
+
19
+ const webcam = NodeWebcam.create(opts);
20
+ const result = await new Promise<string>((resolve, reject) => {
21
+ webcam.capture("capture", (err, data) => {
22
+ if (err) {
23
+ reject(err);
24
+ } else {
25
+ resolve(data as string);
26
+ }
27
+ });
28
+ });
29
+ webcam.clear();
30
+
31
+ return result;
32
+ }
33
+
34
+ async list(_params: any, _pinsSettingsList: PinsSettings[], _context: any) {
35
+ let webcam = NodeWebcam.create({});
36
+ const list = (await new Promise<string[]>((resolve) => {
37
+ webcam.list((data) => {
38
+ resolve(data);
39
+ });
40
+ })).map(camera => camera.replace(/^=> /g, ''));
41
+ webcam.clear();
42
+
43
+ return list;
44
+ }
45
+ }
46
+
47
+ export const capture = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
48
+ new WebcamService().capture(params, pinsSettingsList, context);
49
+
50
+ export const list = (params: any, pinsSettingsList: PinsSettings[], context: any) =>
51
+ new WebcamService().list(params, pinsSettingsList, context);
package/tsconfig.json ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "files": [],
4
+ "include": [],
5
+ "references": [
6
+ {
7
+ "path": "../engine"
8
+ },
9
+ {
10
+ "path": "./tsconfig.lib.json"
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "compilerOptions": {
4
+ "rootDir": "src",
5
+ "outDir": "dist",
6
+ "tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
7
+ "emitDeclarationOnly": true,
8
+ "module": "esnext",
9
+ "moduleResolution": "node",
10
+ "forceConsistentCasingInFileNames": true,
11
+ "types": ["node"]
12
+ },
13
+ "include": ["src/**/*.ts"],
14
+ "references": [
15
+ {
16
+ "path": "../engine/tsconfig.lib.json"
17
+ }
18
+ ]
19
+ }
package/index.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/index";
package/index.cjs.js DELETED
@@ -1,69 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var NodeWebcam = require('node-webcam');
6
-
7
- function _interopNamespace(e) {
8
- if (e && e.__esModule) return e;
9
- var n = Object.create(null);
10
- if (e) {
11
- Object.keys(e).forEach(function (k) {
12
- if (k !== 'default') {
13
- var d = Object.getOwnPropertyDescriptor(e, k);
14
- Object.defineProperty(n, k, d.get ? d : {
15
- enumerable: true,
16
- get: function () { return e[k]; }
17
- });
18
- }
19
- });
20
- }
21
- n["default"] = e;
22
- return Object.freeze(n);
23
- }
24
-
25
- var NodeWebcam__namespace = /*#__PURE__*/_interopNamespace(NodeWebcam);
26
-
27
- let WebcamService = class WebcamService {
28
- async capture(params, _pinsSettingsList, _context) {
29
- const { width = 1280, height = 720, quality = 100, output = 'jpeg', device, verbose = false } = params;
30
- const opts = {
31
- width,
32
- height,
33
- quality,
34
- delay: 0,
35
- saveShots: false,
36
- output,
37
- device: device != null ? device : false,
38
- callbackReturn: 'base64',
39
- verbose
40
- };
41
- const webcam = NodeWebcam__namespace.create(opts);
42
- const result = await new Promise((resolve, reject)=>{
43
- webcam.capture("capture", (err, data)=>{
44
- if (err) {
45
- reject(err);
46
- } else {
47
- resolve(data);
48
- }
49
- });
50
- });
51
- webcam.clear();
52
- return result;
53
- }
54
- async list(_params, _pinsSettingsList, _context) {
55
- let webcam = NodeWebcam__namespace.create({});
56
- const list = (await new Promise((resolve)=>{
57
- webcam.list((data)=>{
58
- resolve(data);
59
- });
60
- })).map((camera)=>camera.replace(/^=> /g, ''));
61
- webcam.clear();
62
- return list;
63
- }
64
- };
65
- const capture = (params, pinsSettingsList, context)=>new WebcamService().capture(params, pinsSettingsList, context);
66
- const list = (params, pinsSettingsList, context)=>new WebcamService().list(params, pinsSettingsList, context);
67
-
68
- exports.capture = capture;
69
- exports.list = list;
package/index.esm.js DELETED
@@ -1,44 +0,0 @@
1
- import * as NodeWebcam from 'node-webcam';
2
-
3
- let WebcamService = class WebcamService {
4
- async capture(params, _pinsSettingsList, _context) {
5
- const { width = 1280, height = 720, quality = 100, output = 'jpeg', device, verbose = false } = params;
6
- const opts = {
7
- width,
8
- height,
9
- quality,
10
- delay: 0,
11
- saveShots: false,
12
- output,
13
- device: device != null ? device : false,
14
- callbackReturn: 'base64',
15
- verbose
16
- };
17
- const webcam = NodeWebcam.create(opts);
18
- const result = await new Promise((resolve, reject)=>{
19
- webcam.capture("capture", (err, data)=>{
20
- if (err) {
21
- reject(err);
22
- } else {
23
- resolve(data);
24
- }
25
- });
26
- });
27
- webcam.clear();
28
- return result;
29
- }
30
- async list(_params, _pinsSettingsList, _context) {
31
- let webcam = NodeWebcam.create({});
32
- const list = (await new Promise((resolve)=>{
33
- webcam.list((data)=>{
34
- resolve(data);
35
- });
36
- })).map((camera)=>camera.replace(/^=> /g, ''));
37
- webcam.clear();
38
- return list;
39
- }
40
- };
41
- const capture = (params, pinsSettingsList, context)=>new WebcamService().capture(params, pinsSettingsList, context);
42
- const list = (params, pinsSettingsList, context)=>new WebcamService().list(params, pinsSettingsList, context);
43
-
44
- export { capture, list };
@@ -1,3 +0,0 @@
1
- import { PinsSettings } from '@digipair/engine';
2
- export declare const capture: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string>;
3
- export declare const list: (params: any, pinsSettingsList: PinsSettings[], context: any) => Promise<string[]>;
File without changes
File without changes
File without changes