alphavalid-sdk 0.0.1 → 0.0.3

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.
@@ -0,0 +1,15 @@
1
+ //#region src/index.ts
2
+ var e = class {
3
+ async start(e) {
4
+ let t = await navigator.mediaDevices.getUserMedia({ video: { facingMode: "user" } });
5
+ this.video = document.createElement("video"), this.video.srcObject = t, this.video.autoplay = !0, this.video.playsInline = !0, e.container.appendChild(this.video);
6
+ }
7
+ async capture() {
8
+ let e = document.createElement("canvas");
9
+ return e.width = this.video.videoWidth, e.height = this.video.videoHeight, e.getContext("2d")?.drawImage(this.video, 0, 0), new Promise((t) => {
10
+ e.toBlob((e) => t(e), "image/jpeg");
11
+ });
12
+ }
13
+ };
14
+ //#endregion
15
+ export { e as AlphaValid };
@@ -1 +1 @@
1
- (function(e){typeof define==`function`&&define.amd?define([],e):e()})(function(){});
1
+ (function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.AlphaValid={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),e.AlphaValid=class{async start(e){let t=await navigator.mediaDevices.getUserMedia({video:{facingMode:`user`}});this.video=document.createElement(`video`),this.video.srcObject=t,this.video.autoplay=!0,this.video.playsInline=!0,e.container.appendChild(this.video)}async capture(){let e=document.createElement(`canvas`);return e.width=this.video.videoWidth,e.height=this.video.videoHeight,e.getContext(`2d`)?.drawImage(this.video,0,0),new Promise(t=>{e.toBlob(e=>t(e),`image/jpeg`)})}}});
package/package.json CHANGED
@@ -1,10 +1,17 @@
1
1
  {
2
2
  "name": "alphavalid-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "SDK de validação facial e liveness",
5
5
  "main": "dist/alphavalid.umd.js",
6
6
  "module": "dist/alphavalid.es.js",
7
+ "types": "dist/index.d.ts",
7
8
  "scripts": {
8
- "build": "vite build"
9
+ "build": "npx vite build",
10
+ "types": "tsc -p tsconfig.json",
11
+ "build:all": "rm -rf dist && npm run build && npm run types"
12
+ },
13
+ "devDependencies": {
14
+ "typescript": "^6.0.2",
15
+ "vite": "^8.0.2"
9
16
  }
10
- }
17
+ }
package/src/index.ts CHANGED
@@ -0,0 +1,29 @@
1
+ export class AlphaValid {
2
+ private video!: HTMLVideoElement;
3
+
4
+ async start(options: any) {
5
+ const stream = await navigator.mediaDevices.getUserMedia({
6
+ video: { facingMode: "user" }
7
+ });
8
+
9
+ this.video = document.createElement("video");
10
+ this.video.srcObject = stream;
11
+ this.video.autoplay = true;
12
+ this.video.playsInline = true;
13
+
14
+ options.container.appendChild(this.video);
15
+ }
16
+
17
+ async capture(): Promise<Blob> {
18
+ const canvas = document.createElement("canvas");
19
+ canvas.width = this.video.videoWidth;
20
+ canvas.height = this.video.videoHeight;
21
+
22
+ const ctx = canvas.getContext("2d");
23
+ ctx?.drawImage(this.video, 0, 0);
24
+
25
+ return new Promise((resolve) => {
26
+ canvas.toBlob((blob) => resolve(blob!), "image/jpeg");
27
+ });
28
+ }
29
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2019",
4
+ "module": "ESNext",
5
+ "lib": ["DOM", "ES2019"],
6
+
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "emitDeclarationOnly": true,
10
+
11
+ "outDir": "dist",
12
+ "rootDir": "src",
13
+
14
+ "strict": true,
15
+ "skipLibCheck": true
16
+ },
17
+ "include": ["src"]
18
+ }
package/vite.config.ts CHANGED
@@ -1,17 +1,19 @@
1
1
  import { defineConfig } from 'vite';
2
2
 
3
3
  export default defineConfig({
4
- // Force Vite to treat this project as a library build (no index.html)
5
- appType: 'custom',
4
+ appType: 'custom', // 🔥 ISSO AQUI RESOLVE O BUG DO INDEX.HTML
5
+
6
6
  publicDir: false,
7
+
7
8
  build: {
8
- copyPublicDir: false,
9
- emptyOutDir: true,
10
9
  lib: {
11
10
  entry: 'src/index.ts',
12
11
  name: 'AlphaValid',
13
12
  formats: ['es', 'umd'],
14
13
  fileName: (format) => `alphavalid.${format}.js`
14
+ },
15
+ rollupOptions: {
16
+ external: []
15
17
  }
16
18
  }
17
19
  });