detect react-native

pull/356/head
Vladimir Mandic 2023-01-31 08:54:50 -05:00
parent 870433ece2
commit 6fb4d04df3
12 changed files with 1090 additions and 1073 deletions

View File

@ -9,11 +9,11 @@
## Changelog
### **HEAD -> main** 2023/01/29 mandic00@live.com
### **3.0.4** 2023/01/29 mandic00@live.com
### **origin/main** 2023/01/21 mandic00@live.com
- make naviator calls safe
- fix facedetector-only configs

File diff suppressed because one or more lines are too long

17
dist/human.esm.js vendored
View File

@ -31963,11 +31963,20 @@ function canvas(width, height) {
throw new Error("canvas error: attempted to run in web worker but OffscreenCanvas is not supported");
c = new OffscreenCanvas(width, height);
} else {
if (typeof document === "undefined")
if (typeof document !== "undefined") {
c = document.createElement("canvas");
c.width = width;
c.height = height;
} else if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
if (typeof env.Canvas !== "undefined")
c = new env.Canvas(width, height);
else if (typeof globalThis.Canvas !== "undefined")
c = new globalThis.Canvas(width, height);
else
throw new Error("canvas error: attempted to use canvas in react-native without canvas support installed");
} else {
throw new Error("canvas error: attempted to run in browser but DOM is not defined");
c = document.createElement("canvas");
c.width = width;
c.height = height;
}
}
} else {
if (typeof env.Canvas !== "undefined")

File diff suppressed because one or more lines are too long

2
dist/human.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

2
dist/human.node.js vendored

File diff suppressed because one or more lines are too long

View File

@ -80,7 +80,7 @@
"devDependencies": {
"@html-eslint/eslint-plugin": "^0.16.0",
"@html-eslint/parser": "^0.16.0",
"@microsoft/api-extractor": "^7.34.0",
"@microsoft/api-extractor": "^7.34.1",
"@tensorflow/tfjs-backend-cpu": "^4.2.0",
"@tensorflow/tfjs-backend-wasm": "^4.2.0",
"@tensorflow/tfjs-backend-webgl": "^4.2.0",
@ -91,8 +91,8 @@
"@tensorflow/tfjs-node-gpu": "^4.2.0",
"@types/node": "^18.11.18",
"@types/offscreencanvas": "^2019.7.0",
"@typescript-eslint/eslint-plugin": "^5.49.0",
"@typescript-eslint/parser": "^5.49.0",
"@typescript-eslint/eslint-plugin": "^5.50.0",
"@typescript-eslint/parser": "^5.50.0",
"@vladmandic/build": "^0.7.15",
"@vladmandic/pilogger": "^0.4.7",
"@vladmandic/tfjs": "github:vladmandic/tfjs",
@ -109,6 +109,6 @@
"rimraf": "^4.1.2",
"tslib": "^2.5.0",
"typedoc": "0.23.24",
"typescript": "4.9.4"
"typescript": "4.9.5"
}
}

View File

@ -39,10 +39,18 @@ export function canvas(width: number, height: number): AnyCanvas {
if (typeof OffscreenCanvas === 'undefined') throw new Error('canvas error: attempted to run in web worker but OffscreenCanvas is not supported');
c = new OffscreenCanvas(width, height);
} else { // otherwise use DOM canvas
if (typeof document === 'undefined') throw new Error('canvas error: attempted to run in browser but DOM is not defined');
c = document.createElement('canvas');
c.width = width;
c.height = height;
if (typeof document !== 'undefined') {
c = document.createElement('canvas');
c.width = width;
c.height = height;
} else if (typeof navigator !== 'undefined' && navigator.product === 'ReactNative') {
// @ts-ignore // env.canvas is an external monkey-patch
if (typeof env.Canvas !== 'undefined') c = new env.Canvas(width, height);
else if (typeof globalThis.Canvas !== 'undefined') c = new globalThis.Canvas(width, height);
else throw new Error('canvas error: attempted to use canvas in react-native without canvas support installed');
} else {
throw new Error('canvas error: attempted to run in browser but DOM is not defined');
}
}
} else { // if not running in browser, there is no "default" canvas object, so we need monkey patch or fail
// @ts-ignore // env.canvas is an external monkey-patch

View File

@ -1,50 +1,50 @@
2023-01-29 12:08:34 DATA:  Build {"name":"@vladmandic/human","version":"3.0.4"}
2023-01-29 12:08:34 INFO:  Application: {"name":"@vladmandic/human","version":"3.0.4"}
2023-01-29 12:08:34 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2023-01-29 12:08:34 INFO:  Toolchain: {"build":"0.7.15","esbuild":"0.16.17","typescript":"4.9.4","typedoc":"0.23.24","eslint":"8.33.0"}
2023-01-29 12:08:34 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2023-01-29 12:08:34 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2023-01-29 12:08:34 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1289,"outputBytes":361}
2023-01-29 12:08:34 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":569,"outputBytes":924}
2023-01-29 12:08:34 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":80,"inputBytes":672214,"outputBytes":318024}
2023-01-29 12:08:34 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":577,"outputBytes":928}
2023-01-29 12:08:34 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":80,"inputBytes":672218,"outputBytes":318028}
2023-01-29 12:08:34 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":665,"outputBytes":1876}
2023-01-29 12:08:34 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":80,"inputBytes":673166,"outputBytes":318139}
2023-01-29 12:08:34 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1375,"outputBytes":670}
2023-01-29 12:08:34 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":80,"inputBytes":671960,"outputBytes":316599}
2023-01-29 12:08:34 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":10,"inputBytes":1375,"outputBytes":1151306}
2023-01-29 12:08:34 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":80,"inputBytes":1822596,"outputBytes":1463846}
2023-01-29 12:08:34 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":80,"inputBytes":1822596,"outputBytes":1929881}
2023-01-29 12:08:38 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":15}
2023-01-29 12:08:40 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true}
2023-01-29 12:08:40 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6117,"outputBytes":2901}
2023-01-29 12:08:40 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17503,"outputBytes":9403}
2023-01-29 12:08:50 STATE: Lint: {"locations":["**/*.json","src/**/*.ts","test/**/*.js","demo/**/*.js","**/*.md"],"files":169,"errors":0,"warnings":0}
2023-01-29 12:08:50 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2023-01-29 12:08:50 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs-core.d.ts","output":"types/tfjs-core.d.ts"}
2023-01-29 12:08:50 INFO:  Done...
2023-01-29 12:08:50 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs.d.ts","output":"types/tfjs.esm.d.ts"}
2023-01-29 12:08:50 STATE: Copy: {"input":"src/types/tsconfig.json","output":"types/tsconfig.json"}
2023-01-29 12:08:50 STATE: Copy: {"input":"src/types/eslint.json","output":"types/.eslintrc.json"}
2023-01-29 12:08:50 STATE: Copy: {"input":"src/types/tfjs.esm.d.ts","output":"dist/tfjs.esm.d.ts"}
2023-01-29 12:08:50 STATE: Filter: {"input":"types/tfjs-core.d.ts"}
2023-01-29 12:08:51 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":204}
2023-01-29 12:08:51 STATE: Filter: {"input":"types/human.d.ts"}
2023-01-29 12:08:51 STATE: Write: {"output":"dist/human.esm-nobundle.d.ts"}
2023-01-29 12:08:51 STATE: Write: {"output":"dist/human.esm.d.ts"}
2023-01-29 12:08:51 STATE: Write: {"output":"dist/human.d.ts"}
2023-01-29 12:08:51 STATE: Write: {"output":"dist/human.node-gpu.d.ts"}
2023-01-29 12:08:51 STATE: Write: {"output":"dist/human.node.d.ts"}
2023-01-29 12:08:51 STATE: Write: {"output":"dist/human.node-wasm.d.ts"}
2023-01-29 12:08:51 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2023-01-29 12:08:51 STATE: Models {"folder":"./models","models":12}
2023-01-29 12:08:51 STATE: Models {"folder":"../human-models/models","models":41}
2023-01-29 12:08:51 STATE: Models {"folder":"../blazepose/model/","models":4}
2023-01-29 12:08:51 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2023-01-29 12:08:51 STATE: Models {"folder":"../efficientpose/models","models":3}
2023-01-29 12:08:51 STATE: Models {"folder":"../insightface/models","models":5}
2023-01-29 12:08:51 STATE: Models {"folder":"../movenet/models","models":3}
2023-01-29 12:08:51 STATE: Models {"folder":"../nanodet/models","models":4}
2023-01-29 12:08:51 STATE: Models: {"count":55,"totalSize":372917743}
2023-01-29 12:08:51 INFO:  Human Build complete... {"logFile":"test/build.log"}
2023-01-31 08:51:47 DATA:  Build {"name":"@vladmandic/human","version":"3.0.4"}
2023-01-31 08:51:47 INFO:  Application: {"name":"@vladmandic/human","version":"3.0.4"}
2023-01-31 08:51:47 INFO:  Environment: {"profile":"production","config":".build.json","package":"package.json","tsconfig":true,"eslintrc":true,"git":true}
2023-01-31 08:51:47 INFO:  Toolchain: {"build":"0.7.15","esbuild":"0.16.17","typescript":"4.9.5","typedoc":"0.23.24","eslint":"8.33.0"}
2023-01-31 08:51:47 INFO:  Build: {"profile":"production","steps":["clean","compile","typings","typedoc","lint","changelog"]}
2023-01-31 08:51:47 STATE: Clean: {"locations":["dist/*","types/*","typedoc/*"]}
2023-01-31 08:51:47 STATE: Compile: {"name":"tfjs/browser/version","format":"esm","platform":"browser","input":"tfjs/tf-version.ts","output":"dist/tfjs.version.js","files":1,"inputBytes":1289,"outputBytes":361}
2023-01-31 08:51:47 STATE: Compile: {"name":"tfjs/nodejs/cpu","format":"cjs","platform":"node","input":"tfjs/tf-node.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":569,"outputBytes":924}
2023-01-31 08:51:47 STATE: Compile: {"name":"human/nodejs/cpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node.js","files":80,"inputBytes":672712,"outputBytes":318340}
2023-01-31 08:51:47 STATE: Compile: {"name":"tfjs/nodejs/gpu","format":"cjs","platform":"node","input":"tfjs/tf-node-gpu.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":577,"outputBytes":928}
2023-01-31 08:51:47 STATE: Compile: {"name":"human/nodejs/gpu","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-gpu.js","files":80,"inputBytes":672716,"outputBytes":318344}
2023-01-31 08:51:47 STATE: Compile: {"name":"tfjs/nodejs/wasm","format":"cjs","platform":"node","input":"tfjs/tf-node-wasm.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":665,"outputBytes":1876}
2023-01-31 08:51:47 STATE: Compile: {"name":"human/nodejs/wasm","format":"cjs","platform":"node","input":"src/human.ts","output":"dist/human.node-wasm.js","files":80,"inputBytes":673664,"outputBytes":318455}
2023-01-31 08:51:47 STATE: Compile: {"name":"tfjs/browser/esm/nobundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":2,"inputBytes":1375,"outputBytes":670}
2023-01-31 08:51:47 STATE: Compile: {"name":"human/browser/esm/nobundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm-nobundle.js","files":80,"inputBytes":672458,"outputBytes":316915}
2023-01-31 08:51:47 STATE: Compile: {"name":"tfjs/browser/esm/bundle","format":"esm","platform":"browser","input":"tfjs/tf-browser.ts","output":"dist/tfjs.esm.js","files":10,"inputBytes":1375,"outputBytes":1151306}
2023-01-31 08:51:47 STATE: Compile: {"name":"human/browser/iife/bundle","format":"iife","platform":"browser","input":"src/human.ts","output":"dist/human.js","files":80,"inputBytes":1823094,"outputBytes":1464164}
2023-01-31 08:51:47 STATE: Compile: {"name":"human/browser/esm/bundle","format":"esm","platform":"browser","input":"src/human.ts","output":"dist/human.esm.js","files":80,"inputBytes":1823094,"outputBytes":1930337}
2023-01-31 08:51:51 STATE: Typings: {"input":"src/human.ts","output":"types/lib","files":15}
2023-01-31 08:51:53 STATE: TypeDoc: {"input":"src/human.ts","output":"typedoc","objects":77,"generated":true}
2023-01-31 08:51:53 STATE: Compile: {"name":"demo/typescript","format":"esm","platform":"browser","input":"demo/typescript/index.ts","output":"demo/typescript/index.js","files":1,"inputBytes":6117,"outputBytes":2901}
2023-01-31 08:51:53 STATE: Compile: {"name":"demo/faceid","format":"esm","platform":"browser","input":"demo/faceid/index.ts","output":"demo/faceid/index.js","files":2,"inputBytes":17503,"outputBytes":9403}
2023-01-31 08:52:02 STATE: Lint: {"locations":["**/*.json","src/**/*.ts","test/**/*.js","demo/**/*.js","**/*.md"],"files":169,"errors":0,"warnings":0}
2023-01-31 08:52:02 STATE: ChangeLog: {"repository":"https://github.com/vladmandic/human","branch":"main","output":"CHANGELOG.md"}
2023-01-31 08:52:02 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs-core.d.ts","output":"types/tfjs-core.d.ts"}
2023-01-31 08:52:02 INFO:  Done...
2023-01-31 08:52:02 STATE: Copy: {"input":"node_modules/@vladmandic/tfjs/types/tfjs.d.ts","output":"types/tfjs.esm.d.ts"}
2023-01-31 08:52:02 STATE: Copy: {"input":"src/types/tsconfig.json","output":"types/tsconfig.json"}
2023-01-31 08:52:02 STATE: Copy: {"input":"src/types/eslint.json","output":"types/.eslintrc.json"}
2023-01-31 08:52:02 STATE: Copy: {"input":"src/types/tfjs.esm.d.ts","output":"dist/tfjs.esm.d.ts"}
2023-01-31 08:52:02 STATE: Filter: {"input":"types/tfjs-core.d.ts"}
2023-01-31 08:52:04 STATE: API-Extractor: {"succeeeded":true,"errors":0,"warnings":204}
2023-01-31 08:52:04 STATE: Filter: {"input":"types/human.d.ts"}
2023-01-31 08:52:04 STATE: Write: {"output":"dist/human.esm-nobundle.d.ts"}
2023-01-31 08:52:04 STATE: Write: {"output":"dist/human.esm.d.ts"}
2023-01-31 08:52:04 STATE: Write: {"output":"dist/human.d.ts"}
2023-01-31 08:52:04 STATE: Write: {"output":"dist/human.node-gpu.d.ts"}
2023-01-31 08:52:04 STATE: Write: {"output":"dist/human.node.d.ts"}
2023-01-31 08:52:04 STATE: Write: {"output":"dist/human.node-wasm.d.ts"}
2023-01-31 08:52:04 INFO:  Analyze models: {"folders":8,"result":"models/models.json"}
2023-01-31 08:52:04 STATE: Models {"folder":"./models","models":12}
2023-01-31 08:52:04 STATE: Models {"folder":"../human-models/models","models":41}
2023-01-31 08:52:04 STATE: Models {"folder":"../blazepose/model/","models":4}
2023-01-31 08:52:04 STATE: Models {"folder":"../anti-spoofing/model","models":1}
2023-01-31 08:52:04 STATE: Models {"folder":"../efficientpose/models","models":3}
2023-01-31 08:52:04 STATE: Models {"folder":"../insightface/models","models":5}
2023-01-31 08:52:04 STATE: Models {"folder":"../movenet/models","models":3}
2023-01-31 08:52:04 STATE: Models {"folder":"../nanodet/models","models":4}
2023-01-31 08:52:04 STATE: Models: {"count":55,"totalSize":372917743}
2023-01-31 08:52:04 INFO:  Human Build complete... {"logFile":"test/build.log"}

File diff suppressed because it is too large Load Diff