Skip to content

Commit

Permalink
Merge pull request #9 from BlinkID/staging
Browse files Browse the repository at this point in the history
  • Loading branch information
ivancuric authored Apr 5, 2024
2 parents c8fdb19 + 2998b2c commit 3f66003
Show file tree
Hide file tree
Showing 22 changed files with 96 additions and 62 deletions.
5 changes: 2 additions & 3 deletions .changeset/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [
"fixed": [
[
"capture-main",
"capture-wasm",
Expand All @@ -15,5 +14,5 @@
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": ["example-*"]
"ignore": ["example-*", "github-release"]
}
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,41 @@ The SDK will terminate automatically if the video element is dismounted and requ

### Configuring the Capture SDK

The SDK can be configured on initialization using `createCaptureSdk(settings)` . The configuration documentation can be found on [`CaptureSdkSettings`](/packages/capture-main/src/createCaptureSdk.ts#30).
The SDK can be configured on initialization using `createCaptureSdk(settings)` . The configuration documentation can be found on [`CaptureSdkSettings`](/packages/capture-main/src/core/createCaptureSdk.ts#30).

The capturing process is handled using the [`Analyzer`](/packages/capture-wasm/src/Analyzer.ts). The configuration settings for the `Analyzer` can be found on [`AnalyzerSettings`](/packages/capture-wasm/src/AnalyzerSettings.ts).

### Configuring the Capture UI

`createCaptureUi` takes a [`CreateCaptureUiSettings`](/packages/capture-ui/src/createCaptureUi.tsx#52) configuration object as a parameter with both [`CaptureSdkSettings`](/packages/capture-main/src/createCaptureSdk.ts#30) that configures the SDK behaviour, and [`UiSettings`](/packages/capture-ui/src/StoreContext.tsx#36) which configures the UI itself.
`createCaptureUi` takes a [`CreateCaptureUiSettings`](/packages/capture-main/src/ui/createCaptureUi.tsx#52) configuration object as a parameter with both [`CaptureSdkSettings`](/packages/capture-main/src/core/createCaptureSdk.ts#30) that configures the SDK behaviour, and [`UiSettings`](/packages/capture-main/src/ui/StoreContext.tsx#36) which configures the UI itself.

You can configure the mount point of the UI, toggle the display of the onboarding screen and help screens, the error screen and provide your own localization strings.

You can find a list of all the localization strings in [`packages/capture-ui/src/locales/en.ts`](/packages/capture-ui/src/locales/en.ts)
You can find a list of all the localization strings in [`packages/capture-main/src/ui/locales/en.ts`](/packages/capture-main/src/ui/locales/en.ts)

## Advanced usage

### Instantiating the Capture UI with a preloaded `CaptureSdk` instance

In cases you want to reuse the `CaptureSdk` instance between component mounts/dismounts, preload it before showing the UI, or otherwise have greater control over the lifecycle of the SDK, you can use [`createCaptureUiWithInstance`](packages/capture-main/src/ui/createCaptureUi.tsx#67), which instead of SDK settings takes an instance of the `CaptureSdk`. You can see the usage in the `example-solidjs-sdk-preinit`.

### State management and subscriptions

The Capture SDK tracks its internal state on the [`ReactiveStore`](/packages/capture-main/src/zustandStore.ts#8) object, which is implemented using [Zustand](https://github.com/pmndrs/zustand).
The Capture SDK tracks its internal state on the [`ReactiveStore`](/packages/capture-main/src/core/zustandStore.ts#8) object, which is implemented using [Zustand](https://github.com/pmndrs/zustand).

The user can get the internal state of the SDK at any time by calling `getState()` on the `CaptureSdk` object returned by `createCaptureSdk`. `CaptureSdk` is also available on the `CaptureComponent` instance returned by `createCaptureUi`.

You can also subscribe to state changes by calling `CaptureSdk.subscribe()`. Detailed documentation for using this feature is available [here](https://github.com/pmndrs/zustand#using-subscribe-with-selector).

### UI customization

The UI can be customized by either overriding the CSS variables found at `packages/capture-ui/src/root-styles.scss`, or by manually targetting the CSS classes applied to the UI component.
The UI can be customized by either overriding the CSS variables found at `packages/capture-main/src/ui/root-styles.scss`, or by manually targetting the CSS classes applied to the UI component.

All components rendered by the UI are nested under `.mb-style-scope` which provides some base styles.

### Detailed capturing process information

You can find details on the internal state of the capture process using the [`onFrameAnalysis`](/packages/capture-main/src/createCaptureSdk.ts#57) callback. This callback will provide you with an `ImageData` instance of the previously processed frame and the [`FrameAnalysisResult`](/packages/capture-wasm/src/FrameAnalysisResult.ts).
You can find details on the internal state of the capture process using the [`onFrameAnalysis`](/packages/capture-main/src/core/createCaptureSdk.ts#57) callback. This callback will provide you with an `ImageData` instance of the previously processed frame and the [`FrameAnalysisResult`](/packages/capture-wasm/src/FrameAnalysisResult.ts).

### Low-level access Direct API

Expand Down
2 changes: 1 addition & 1 deletion apps/example-solidjs-sdk-preinit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "module",
"dependencies": {
"@microblink/capture": "workspace:*",
"solid-js": "^1.8.1"
"solid-js": "^1.8.3"
},
"devDependencies": {
"@mb/utils": "workspace:*",
Expand Down
2 changes: 1 addition & 1 deletion apps/example-solidjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"type": "module",
"dependencies": {
"@microblink/capture": "workspace:*",
"solid-js": "^1.8.1"
"solid-js": "^1.8.3"
},
"devDependencies": {
"@mb/utils": "workspace:*",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "capture-sdk",
"description": "",
"version": "1.2.0",
"version": "1.1.0",
"author": "",
"scripts": {
"build": "FORCE_COLOR=1 turbo build --no-daemon",
Expand All @@ -16,7 +16,7 @@
"husky": "^8.0.3",
"lint-staged": "^15.0.2",
"syncpack": "^11.2.1",
"turbo": "^1.10.16"
"turbo": "^1.13.2"
},
"license": "ISC"
}
9 changes: 9 additions & 0 deletions packages/capture-main/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# capture-main

## 1.2.1

### Patch Changes

- Version sync
- Updated dependencies
- [email protected]
- [email protected]

## 1.1.1

### Patch Changes
Expand Down
6 changes: 3 additions & 3 deletions packages/capture-main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "capture-main",
"description": "",
"private": true,
"version": "1.1.1",
"version": "1.2.1",
"author": "",
"scripts": {
"build": "concurrently pnpm:build:js pnpm:build:types",
Expand Down Expand Up @@ -51,13 +51,13 @@
"is-plain-obj": "^4.1.0",
"nanoid": "^5.0.2",
"rvfc-polyfill": "^1.0.7",
"solid-js": "^1.8.1",
"solid-js": "^1.8.3",
"solid-slider": "^1.3.15",
"solid-zustand": "^1.7.0",
"tiny-invariant": "^1.3.1",
"ts-pattern": "^5.0.5",
"ua-parser-js": "^1.0.36",
"zustand": "^4.4.3"
"zustand": "^4.4.4"
},
"devDependencies": {
"@acab/ecsstatic": "^0.7.1",
Expand Down
1 change: 1 addition & 0 deletions packages/capture-main/src/core/CaptureSdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ class _CaptureSdk {
zustandStore.setState({
errorState: asError(error),
});
// TODO: do we rethrow here?
return;
}
}
Expand Down
6 changes: 6 additions & 0 deletions packages/capture-published/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @microblink/capture

## 1.2.1

### Patch Changes

- Version sync

## 1.2.0

- Added configuration options for tilt, blur and glare tolerance.
Expand Down
16 changes: 10 additions & 6 deletions packages/capture-published/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,37 +127,41 @@ The SDK will terminate automatically if the video element is dismounted and requ

### Configuring the Capture SDK

The SDK can be configured on initialization using `createCaptureSdk(settings)` . The configuration documentation can be found on [`CaptureSdkSettings`](/packages/capture-main/src/createCaptureSdk.ts#30).
The SDK can be configured on initialization using `createCaptureSdk(settings)` . The configuration documentation can be found on [`CaptureSdkSettings`](/packages/capture-main/src/core/createCaptureSdk.ts#30).

The capturing process is handled using the [`Analyzer`](/packages/capture-wasm/src/Analyzer.ts). The configuration settings for the `Analyzer` can be found on [`AnalyzerSettings`](/packages/capture-wasm/src/AnalyzerSettings.ts).

### Configuring the Capture UI

`createCaptureUi` takes a [`CreateCaptureUiSettings`](/packages/capture-ui/src/createCaptureUi.tsx#52) configuration object as a parameter with both [`CaptureSdkSettings`](/packages/capture-main/src/createCaptureSdk.ts#30) that configures the SDK behaviour, and [`UiSettings`](/packages/capture-ui/src/StoreContext.tsx#36) which configures the UI itself.
`createCaptureUi` takes a [`CreateCaptureUiSettings`](/packages/capture-main/src/ui/createCaptureUi.tsx#52) configuration object as a parameter with both [`CaptureSdkSettings`](/packages/capture-main/src/core/createCaptureSdk.ts#30) that configures the SDK behaviour, and [`UiSettings`](/packages/capture-main/src/ui/StoreContext.tsx#36) which configures the UI itself.

You can configure the mount point of the UI, toggle the display of the onboarding screen and help screens, the error screen and provide your own localization strings.

You can find a list of all the localization strings in [`packages/capture-ui/src/locales/en.ts`](/packages/capture-ui/src/locales/en.ts)
You can find a list of all the localization strings in [`packages/capture-main/src/ui/locales/en.ts`](/packages/capture-main/src/ui/locales/en.ts)

## Advanced usage

### Instantiating the Capture UI with a preloaded `CaptureSdk` instance

In cases you want to reuse the `CaptureSdk` instance between component mounts/dismounts, preload it before showing the UI, or otherwise have greater control over the lifecycle of the SDK, you can use [`createCaptureUiWithInstance`](packages/capture-main/src/ui/createCaptureUi.tsx#67), which instead of SDK settings takes an instance of the `CaptureSdk`. You can see the usage in the `example-solidjs-sdk-preinit`.

### State management and subscriptions

The Capture SDK tracks its internal state on the [`ReactiveStore`](/packages/capture-main/src/zustandStore.ts#8) object, which is implemented using [Zustand](https://github.com/pmndrs/zustand).
The Capture SDK tracks its internal state on the [`ReactiveStore`](/packages/capture-main/src/core/zustandStore.ts#8) object, which is implemented using [Zustand](https://github.com/pmndrs/zustand).

The user can get the internal state of the SDK at any time by calling `getState()` on the `CaptureSdk` object returned by `createCaptureSdk`. `CaptureSdk` is also available on the `CaptureComponent` instance returned by `createCaptureUi`.

You can also subscribe to state changes by calling `CaptureSdk.subscribe()`. Detailed documentation for using this feature is available [here](https://github.com/pmndrs/zustand#using-subscribe-with-selector).

### UI customization

The UI can be customized by either overriding the CSS variables found at `packages/capture-ui/src/root-styles.scss`, or by manually targetting the CSS classes applied to the UI component.
The UI can be customized by either overriding the CSS variables found at `packages/capture-main/src/ui/root-styles.scss`, or by manually targetting the CSS classes applied to the UI component.

All components rendered by the UI are nested under `.mb-style-scope` which provides some base styles.

### Detailed capturing process information

You can find details on the internal state of the capture process using the [`onFrameAnalysis`](/packages/capture-main/src/createCaptureSdk.ts#57) callback. This callback will provide you with an `ImageData` instance of the previously processed frame and the [`FrameAnalysisResult`](/packages/capture-wasm/src/FrameAnalysisResult.ts).
You can find details on the internal state of the capture process using the [`onFrameAnalysis`](/packages/capture-main/src/core/createCaptureSdk.ts#57) callback. This callback will provide you with an `ImageData` instance of the previously processed frame and the [`FrameAnalysisResult`](/packages/capture-wasm/src/FrameAnalysisResult.ts).

### Low-level access Direct API

Expand Down
2 changes: 1 addition & 1 deletion packages/capture-published/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "",
"homepage": "https://microblink.com/",
"repository": "github:BlinkID/capture-browser",
"version": "1.2.0",
"version": "1.2.1",
"scripts": {
"build": "pnpm run create-npm",
"clean": "rimraf .turbo types dist publish-dir public *.tsbuildinfo",
Expand Down
6 changes: 6 additions & 0 deletions packages/capture-wasm/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Release notes

## 1.2.1

### Patch Changes

- Version sync

## 1.2.0

- TODO: add changes here for version 1.2.0
Expand Down
Binary file modified packages/capture-wasm/dist/advanced-threads/capture-wasm.wasm
Binary file not shown.
8 changes: 4 additions & 4 deletions packages/capture-wasm/dist/advanced/capture-wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,14 @@ var createModule = (() => {
var E,
F,
Na = {
60100: (a, b, c, d) => {
60092: (a, b, c, d) => {
a = a ? I(x, a) : "";
b = b ? I(x, b) : "";
c = c ? I(x, c) : "";
d = d ? I(x, d) : "";
throw Error(a + b + c + d);
},
60316: (a, b) => {
60308: (a, b) => {
a = a ? I(x, a) : "";
b = b ? I(x, b) : "";
throw Error(a + b);
Expand Down Expand Up @@ -3801,8 +3801,8 @@ var createModule = (() => {
k.dynCall_iiiiiijj = (a, b, c, d, e, f, g, m, l, n) =>
(k.dynCall_iiiiiijj = Z.ua)(a, b, c, d, e, f, g, m, l, n);
k.__ZN2MB2NN28LinearDefragmentingAllocator10Allocation4nullE = 1024;
k.___start_em_js = 60426;
k.___stop_em_js = 61299;
k.___start_em_js = 60418;
k.___stop_em_js = 61291;
k.addRunDependency = Ea;
k.removeRunDependency = Fa;
k.FS_createPath = $b;
Expand Down
Binary file modified packages/capture-wasm/dist/advanced/capture-wasm.wasm
Binary file not shown.
8 changes: 4 additions & 4 deletions packages/capture-wasm/dist/basic/capture-wasm.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,14 +377,14 @@ var createModule = (() => {
var E,
F,
Na = {
59700: (a, b, c, d) => {
59692: (a, b, c, d) => {
a = a ? I(x, a) : "";
b = b ? I(x, b) : "";
c = c ? I(x, c) : "";
d = d ? I(x, d) : "";
throw Error(a + b + c + d);
},
59916: (a, b) => {
59908: (a, b) => {
a = a ? I(x, a) : "";
b = b ? I(x, b) : "";
throw Error(a + b);
Expand Down Expand Up @@ -3800,8 +3800,8 @@ var createModule = (() => {
k.dynCall_iiiiiijj = (a, b, c, d, e, f, g, m, l, n) =>
(k.dynCall_iiiiiijj = Z.ta)(a, b, c, d, e, f, g, m, l, n);
k.__ZN2MB2NN28LinearDefragmentingAllocator10Allocation4nullE = 1024;
k.___start_em_js = 60026;
k.___stop_em_js = 60449;
k.___start_em_js = 60018;
k.___stop_em_js = 60441;
k.addRunDependency = Ea;
k.removeRunDependency = Fa;
k.FS_createPath = $b;
Expand Down
Binary file modified packages/capture-wasm/dist/basic/capture-wasm.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion packages/capture-wasm/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "capture-wasm",
"description": "Wasm runtime",
"private": true,
"version": "1.0.7",
"version": "1.2.1",
"scripts": {
"build": "tsc",
"clean": "rimraf .turbo types",
Expand Down
8 changes: 8 additions & 0 deletions packages/capture-worker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# capture-worker

## 1.2.1

### Patch Changes

- Version sync
- Updated dependencies
- [email protected]

## 1.1.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion packages/capture-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "capture-worker",
"description": "",
"private": true,
"version": "1.1.1",
"version": "1.2.1",
"scripts": {
"build": "concurrently pnpm:build:js pnpm:build:types",
"build:dev": "concurrently pnpm:build:js-dev pnpm:build:types",
Expand Down
Loading

0 comments on commit 3f66003

Please sign in to comment.