Skip to content

Commit

Permalink
feat(client-electron): replace json string preview with json tree viewer
Browse files Browse the repository at this point in the history
JSON tree viewer replaced JSON string preview in analyze and recalibrate features.
  • Loading branch information
marcincichocki authored Sep 28, 2022
1 parent 8e7eb28 commit 4d7aa99
Show file tree
Hide file tree
Showing 14 changed files with 498 additions and 116 deletions.
10 changes: 7 additions & 3 deletions src/common/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export function capitalize<T extends string>(value: T) {
return (value[0].toUpperCase() + value.slice(1)) as Capitalize<T>;
}

export function isJSONObject(data: unknown): data is object {
return typeof data === 'object' && data !== null;
}

export function unique<T>(value: T, index: number, array: T[]) {
return array.indexOf(value) === index;
}
Expand Down Expand Up @@ -103,7 +107,7 @@ export function getClosest(n: number, list: number[]) {
return list[index];
}

type JSONValue =
export type JSONValue =
| string
| number
| boolean
Expand Down Expand Up @@ -138,15 +142,15 @@ export class BitMask {
}
}

/** Wait for given amount of miliseconds. */
/** Wait for given amount of milliseconds. */
export function sleep(delay: number) {
return delay ? new Promise((r) => setTimeout(r, delay)) : Promise.resolve();
}

/** Does nothing. */
export const noop = () => {};

/** Check how similiar are 2 strings using Gestalt Pattern Matching algorithm. */
/** Check how similar are 2 strings using Gestalt Pattern Matching algorithm. */
// https://github.com/ben-yocum/gestalt-pattern-matcher/blob/master/gestalt-pattern-matcher.js
export function similarity(s1: string, s2: string) {
const stack = [s1, s2];
Expand Down
10 changes: 5 additions & 5 deletions src/core/ocr/fragments/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export abstract class BreachProtocolFragment<

abstract readonly boundingBox: FragmentBoundingBox;

/** Preprocessed image fragment. */
/** Pre-processed image fragment. */
protected abstract readonly fragment: TImage;

constructor(
Expand Down Expand Up @@ -135,7 +135,7 @@ export abstract class BreachProtocolOCRFragment<
return text.split('\n').filter(Boolean);
}

/** Get closest treshold value for given resolution. */
/** Get closest threshold value for given resolution. */
protected getThreshold(thresholds: Map<number, number> = this.thresholds) {
const { innerHeight } = this.boundingBox;
const list = Array.from(thresholds.keys());
Expand Down Expand Up @@ -247,9 +247,9 @@ export abstract class BreachProtocolCodeFragment<
}

protected chunkLine(line: string) {
// In some localizations font and font spacing is different. Sometimes
// symbols are recognized without whitespaces which cause errors.
// It's better to remove every whitespace character and then to chunk it.
// In some localization font and font spacing is different. Sometimes
// symbols are recognized without white spaces which cause errors.
// It's better to remove every white space character and then to chunk it.
return chunk(line.replace(/\s/g, ''), 2);
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/ocr/result.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class BreachProtocolRecognitionResult {
readonly rawData = this.reduceToRawData();

readonly isValid = this.results
// daemon types can be undedected
// daemon types can be undetected
.filter((r) => r.id !== FragmentId.Types)
.every((r) => r.isValid);

Expand Down
6 changes: 3 additions & 3 deletions src/core/sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,13 +126,13 @@ export class Sequence implements Serializable {
return new Sequence(value, parts);
}

// Sequence break is an index which doesn't have dameon attached.
// Sequence break is an index which doesn't have daemon attached.
// For example daemons: FF 7A and BD BD can create sequence FF 7A BD BD.
// At index 0 and 2 next daemon is not yet started and can be delayed if
// buffer allows it.
// It's not possible to break sequence on overlap. For example daemons:
// FF 7A and 7A BD BD can not be broken on index 2 because they share
// beggining and the end.
// beginning and the end.
private getSequenceBreaks() {
return this.parts
.map((d) => {
Expand Down Expand Up @@ -178,7 +178,7 @@ export function parseDaemons(
}
}

// These sequences are created out of daemons that overlap completly.
// These sequences are created out of daemons that overlap completely.
const childDaemons = baseDaemons.filter((d) => d.isChild);
const regularDaemons = baseDaemons.filter((d) => !d.isChild);

Expand Down
2 changes: 1 addition & 1 deletion src/electron/main/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ export class Main {
}

private async showThridPartyLicesnsesDialog() {
// License files are autogenerated by webpack plugin and put in output.path.
// License files are auto-generated by webpack plugin and put in output.path.
const resourcesPath = this.getResourcesPath('./dist');
const modules = ['main', 'renderer', 'worker', 'preload'];
const contents = await Promise.all(
Expand Down
Loading

0 comments on commit 4d7aa99

Please sign in to comment.