@3dsource/utils 1.0.4 → 1.0.6
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/fesm2022/3dsource-utils.mjs +1812 -0
- package/fesm2022/3dsource-utils.mjs.map +1 -0
- package/index.d.ts +5 -0
- package/{src/lib/color/CMYKtoRGB.ts → lib/color/CMYKtoRGB.d.ts} +1 -11
- package/lib/color/HEXtoRGB.d.ts +5 -0
- package/lib/color/HSVtoRGB.d.ts +21 -0
- package/{src/lib/color/RGBtoCMYK.ts → lib/color/RGBtoCMYK.d.ts} +1 -31
- package/lib/color/RGBtoHEX.d.ts +1 -0
- package/lib/color/RGBtoHSV.d.ts +19 -0
- package/lib/color/hsv.d.ts +1 -0
- package/lib/color/max.d.ts +1 -0
- package/lib/color/min.d.ts +1 -0
- package/lib/color/overlay.d.ts +1 -0
- package/{src/lib/color/rgb.ts → lib/color/rgb.d.ts} +1 -3
- package/lib/color/sub.d.ts +1 -0
- package/lib/color/subtract.d.ts +1 -0
- package/lib/color/sum.d.ts +1 -0
- package/{src/lib/color/toRGB.ts → lib/color/toRGB.d.ts} +1 -7
- package/lib/color/toRGBA.d.ts +1 -0
- package/lib/constants/color-codes.constant.d.ts +9 -0
- package/lib/csv/CSV2Array.d.ts +1 -0
- package/lib/csv/CSV2Records.d.ts +1 -0
- package/lib/csv/ObjectToCSV.d.ts +1 -0
- package/lib/dev/dev3d.d.ts +1 -0
- package/lib/dev/logger.d.ts +11 -0
- package/lib/dev/timeToString.d.ts +5 -0
- package/lib/filenaming/cleanupFileName.d.ts +1 -0
- package/lib/filenaming/makePath.d.ts +1 -0
- package/lib/filenaming/normalizePath.d.ts +1 -0
- package/lib/geom/expandOverRectangle.d.ts +2 -0
- package/lib/geom/fitIntoRectangle.d.ts +2 -0
- package/{src/lib/geom/interfaces/area.interface.ts → lib/geom/interfaces/area.interface.d.ts} +1 -2
- package/{src/lib/geom/interfaces/rect.interface.ts → lib/geom/interfaces/rect.interface.d.ts} +2 -2
- package/lib/geom/interfaces/size.interface.d.ts +4 -0
- package/lib/geom/interfaces//321/201oords.interface.d.ts +4 -0
- package/lib/helpers/BatchLoader.d.ts +47 -0
- package/lib/helpers/KeyboardNumericCode.d.ts +103 -0
- package/lib/helpers/serialize.d.ts +1 -0
- package/lib/helpers/sleep.d.ts +1 -0
- package/lib/helpers/trimLastSlashFromUrl.d.ts +1 -0
- package/lib/image/SaveImage.d.ts +18 -0
- package/lib/image/getCanvasCached.d.ts +4 -0
- package/lib/image/getSnapshot.d.ts +2 -0
- package/lib/image/loadImage.d.ts +1 -0
- package/lib/interfaces/image-output.d.ts +7 -0
- package/{src/lib/interfaces/load-args-tmp.interface.ts → lib/interfaces/load-args-tmp.interface.d.ts} +1 -2
- package/lib/interfaces/load-args.interface.d.ts +15 -0
- package/{src/lib/math/baseSortedIndex.ts → lib/math/baseSortedIndex.d.ts} +1 -19
- package/{src/lib/math/calculateMedian.ts → lib/math/calculateMedian.d.ts} +1 -17
- package/{src/lib/math/circularIndex.ts → lib/math/circularIndex.d.ts} +1 -5
- package/lib/math/clampf.d.ts +8 -0
- package/lib/math/degrees.d.ts +2 -0
- package/{src/lib/math/floatCompare.ts → lib/math/floatCompare.d.ts} +3 -30
- package/{src/lib/math/inverseLerp.ts → lib/math/inverseLerp.d.ts} +1 -22
- package/lib/math/lerp.d.ts +7 -0
- package/{src/lib/mutex/Mutex.ts → lib/mutex/Mutex.d.ts} +8 -15
- package/{src/lib/mutex/Semaphore.ts → lib/mutex/Semaphore.d.ts} +7 -27
- package/lib/mutex/TaskRunner.d.ts +5 -0
- package/{src/lib/predicates/index.ts → lib/predicates/index.d.ts} +1 -1
- package/lib/predicates/operators.d.ts +32 -0
- package/{src/lib/predicates/textForSearch.ts → lib/predicates/textForSearch.d.ts} +1 -17
- package/{src/lib/predicates/where.ts → lib/predicates/where.d.ts} +2 -32
- package/lib/rxjs/leadingTrailingDebounceTime.d.ts +15 -0
- package/{src/lib/rxjs/smoothTransition.ts → lib/rxjs/smoothTransition.d.ts} +1 -19
- package/lib/rxjs/tapLog.d.ts +2 -0
- package/lib/strings/pad.d.ts +8 -0
- package/package.json +13 -2
- package/eslint.config.js +0 -37
- package/ng-package.json +0 -7
- package/src/lib/color/HEXtoRGB.ts +0 -9
- package/src/lib/color/HSVtoRGB.ts +0 -82
- package/src/lib/color/RGBtoHEX.ts +0 -17
- package/src/lib/color/RGBtoHSV.ts +0 -53
- package/src/lib/color/hsv.ts +0 -14
- package/src/lib/color/max.ts +0 -18
- package/src/lib/color/min.ts +0 -18
- package/src/lib/color/overlay.ts +0 -25
- package/src/lib/color/sub.ts +0 -18
- package/src/lib/color/subtract.ts +0 -27
- package/src/lib/color/sum.ts +0 -19
- package/src/lib/color/toRGBA.ts +0 -8
- package/src/lib/constants/color-codes.constant.ts +0 -9
- package/src/lib/csv/CSV2Array.ts +0 -66
- package/src/lib/csv/CSV2Records.ts +0 -56
- package/src/lib/csv/ObjectToCSV.ts +0 -21
- package/src/lib/dev/dev3d.ts +0 -1
- package/src/lib/dev/logger.ts +0 -94
- package/src/lib/dev/timeToString.ts +0 -16
- package/src/lib/filenaming/cleanupFileName.ts +0 -18
- package/src/lib/filenaming/makePath.ts +0 -5
- package/src/lib/filenaming/normalizePath.ts +0 -9
- package/src/lib/geom/expandOverRectangle.ts +0 -17
- package/src/lib/geom/fitIntoRectangle.ts +0 -43
- package/src/lib/geom/interfaces/size.interface.ts +0 -4
- package/src/lib/geom/interfaces//321/201oords.interface.ts +0 -4
- package/src/lib/helpers/BatchLoader.ts +0 -243
- package/src/lib/helpers/KeyboardNumericCode.ts +0 -118
- package/src/lib/helpers/serialize.ts +0 -11
- package/src/lib/helpers/sleep.ts +0 -3
- package/src/lib/helpers/trimLastSlashFromUrl.ts +0 -9
- package/src/lib/image/SaveImage.ts +0 -65
- package/src/lib/image/getCanvasCached.ts +0 -16
- package/src/lib/image/getSnapshot.ts +0 -99
- package/src/lib/image/loadImage.ts +0 -13
- package/src/lib/interfaces/image-output.ts +0 -8
- package/src/lib/interfaces/load-args.interface.ts +0 -15
- package/src/lib/math/clampf.ts +0 -14
- package/src/lib/math/degrees.ts +0 -7
- package/src/lib/math/lerp.ts +0 -12
- package/src/lib/mutex/TaskRunner.ts +0 -26
- package/src/lib/predicates/BooleanPredictors.ts +0 -47
- package/src/lib/rxjs/leadingTrailingDebounceTime.ts +0 -86
- package/src/lib/rxjs/tapLog.ts +0 -13
- package/src/lib/strings/pad.ts +0 -18
- package/tsconfig.lib.json +0 -13
- package/tsconfig.lib.prod.json +0 -11
- /package/{src/lib/color/index.ts → lib/color/index.d.ts} +0 -0
- /package/{src/lib/constants/index.ts → lib/constants/index.d.ts} +0 -0
- /package/{src/lib/csv/index.ts → lib/csv/index.d.ts} +0 -0
- /package/{src/lib/dev/index.ts → lib/dev/index.d.ts} +0 -0
- /package/{src/lib/filenaming/index.ts → lib/filenaming/index.d.ts} +0 -0
- /package/{src/lib/geom/index.ts → lib/geom/index.d.ts} +0 -0
- /package/{src/lib/geom/interfaces/index.ts → lib/geom/interfaces/index.d.ts} +0 -0
- /package/{src/lib/helpers/index.ts → lib/helpers/index.d.ts} +0 -0
- /package/{src/lib/image/index.ts → lib/image/index.d.ts} +0 -0
- /package/{src/lib/interfaces/index.ts → lib/interfaces/index.d.ts} +0 -0
- /package/{src/lib/math/index.ts → lib/math/index.d.ts} +0 -0
- /package/{src/lib/mutex/index.ts → lib/mutex/index.d.ts} +0 -0
- /package/{src/lib/rxjs/index.ts → lib/rxjs/index.d.ts} +0 -0
- /package/{src/lib/strings/index.ts → lib/strings/index.d.ts} +0 -0
- /package/{src/public-api.ts → public-api.d.ts} +0 -0
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Observable } from 'rxjs';
|
|
2
|
-
import { finalize, from, switchMap } from 'rxjs';
|
|
3
|
-
import { Logger } from '../dev';
|
|
4
|
-
import { Mutex } from './Mutex';
|
|
5
|
-
|
|
6
|
-
export class TaskRunner {
|
|
7
|
-
private mutex = new Mutex();
|
|
8
|
-
|
|
9
|
-
runTask(name: string, task: () => Observable<string | null>) {
|
|
10
|
-
// Log that the task is waiting to acquire the mutex
|
|
11
|
-
Logger.log(`${name} waiting to acquire mutex`);
|
|
12
|
-
|
|
13
|
-
return from(this.mutex.acquire()).pipe(
|
|
14
|
-
switchMap((release) => {
|
|
15
|
-
// Log that the mutex has been acquired
|
|
16
|
-
Logger.log(`${name} acquired mutex`);
|
|
17
|
-
return task().pipe(
|
|
18
|
-
finalize(() => {
|
|
19
|
-
Logger.log(`${name} releasing mutex`);
|
|
20
|
-
release();
|
|
21
|
-
}),
|
|
22
|
-
);
|
|
23
|
-
}),
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
type TruthyTypesOf<T> = T extends false | '' | 0 | null | undefined ? never : T;
|
|
2
|
-
type FalsyTypesOf<T> = T extends false | '' | 0 | null | undefined ? T : never;
|
|
3
|
-
type EmptyTypesOf<T> = T extends undefined | null | object | '' ? T : never;
|
|
4
|
-
type NonEmptyTypesOf<T> = T extends undefined | null | object | '' ? never : T;
|
|
5
|
-
/**
|
|
6
|
-
* The Boolean object represents a truth value: true or false.
|
|
7
|
-
* @param value
|
|
8
|
-
* @constructor
|
|
9
|
-
* Returns:boolean
|
|
10
|
-
*/
|
|
11
|
-
export const Truthy: <T>(value: T) => value is TruthyTypesOf<T> = <T>(
|
|
12
|
-
value?: T,
|
|
13
|
-
): value is TruthyTypesOf<T> =>
|
|
14
|
-
!!value && value !== 'false' && value !== 'undefined' && value !== 'null';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The Boolean object represents a INVERSE truth value: true or false.
|
|
18
|
-
* @param value
|
|
19
|
-
* @constructor
|
|
20
|
-
* Returns:boolean
|
|
21
|
-
*/
|
|
22
|
-
export const Falsy: <T>(value: T) => value is FalsyTypesOf<T> = <T>(
|
|
23
|
-
value?: T,
|
|
24
|
-
): value is FalsyTypesOf<T> => !Truthy(value);
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Checks if a value is empty.
|
|
28
|
-
*
|
|
29
|
-
* @param {any} value - The value to check.
|
|
30
|
-
* @return {boolean} Returns true if the value is empty, otherwise false.
|
|
31
|
-
*/
|
|
32
|
-
export const IsEmpty: <T>(value: T) => value is EmptyTypesOf<T> = <T>(
|
|
33
|
-
value: T,
|
|
34
|
-
): value is EmptyTypesOf<T> => {
|
|
35
|
-
return (
|
|
36
|
-
value === undefined ||
|
|
37
|
-
value === null ||
|
|
38
|
-
(typeof value === 'object' && Object.keys(value).length === 0) ||
|
|
39
|
-
(typeof value === 'string' && value.trim().length === 0)
|
|
40
|
-
);
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
export const NotEmpty: <T>(value: T) => value is NonEmptyTypesOf<T> = <T>(
|
|
44
|
-
value: T,
|
|
45
|
-
): value is NonEmptyTypesOf<T> => {
|
|
46
|
-
return !IsEmpty(value);
|
|
47
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { SchedulerLike, Subscriber, Subscription } from 'rxjs';
|
|
2
|
-
import { asyncScheduler, Observable, timer } from 'rxjs';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Emits the most recent value emitted by the source Observable after a
|
|
6
|
-
* specified time span has passed without another source emission.
|
|
7
|
-
*
|
|
8
|
-
* This is a combination of `debounceTime` and `auditTime` operators.
|
|
9
|
-
*
|
|
10
|
-
* The leading value is emitted immediately, and trailing values are debounced.
|
|
11
|
-
*
|
|
12
|
-
* @param dueTime The time to wait before emitting the last value.
|
|
13
|
-
* @param scheduler The scheduler to use for the timeout.
|
|
14
|
-
* @returns A function that returns an Observable that mirrors the source Observable, but applies the specified debouncing.
|
|
15
|
-
*/
|
|
16
|
-
export function leadingTrailingDebounceTime<T>(
|
|
17
|
-
dueTime: number,
|
|
18
|
-
scheduler: SchedulerLike = asyncScheduler,
|
|
19
|
-
): (source: Observable<T>) => Observable<T> {
|
|
20
|
-
return (source: Observable<T>) =>
|
|
21
|
-
new Observable<T>((subscriber: Subscriber<T>) => {
|
|
22
|
-
let hasValue = false;
|
|
23
|
-
let lastValue: T | null = null;
|
|
24
|
-
let timerSubscription: Subscription | null = null;
|
|
25
|
-
let leading = true; // Controls whether we emit immediately.
|
|
26
|
-
|
|
27
|
-
const clearTimer = () => {
|
|
28
|
-
if (timerSubscription) {
|
|
29
|
-
timerSubscription.unsubscribe();
|
|
30
|
-
timerSubscription = null;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const resetValues = () => {
|
|
35
|
-
hasValue = false;
|
|
36
|
-
lastValue = null;
|
|
37
|
-
leading = true; // Reset so the next new value is immediate.
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const emitLastValue = () => {
|
|
41
|
-
if (hasValue && lastValue !== null) {
|
|
42
|
-
subscriber.next(lastValue);
|
|
43
|
-
resetValues();
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const sourceSubscription = source.subscribe({
|
|
48
|
-
next: (value) => {
|
|
49
|
-
// If we are "leading", emit immediately and switch leading off
|
|
50
|
-
if (leading) {
|
|
51
|
-
subscriber.next(value);
|
|
52
|
-
leading = false;
|
|
53
|
-
timerSubscription = timer(dueTime, scheduler).subscribe(() => {
|
|
54
|
-
resetValues();
|
|
55
|
-
clearTimer();
|
|
56
|
-
});
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// Otherwise, save the value and start (or restart) timer
|
|
61
|
-
hasValue = true;
|
|
62
|
-
lastValue = value;
|
|
63
|
-
clearTimer();
|
|
64
|
-
timerSubscription = timer(dueTime, scheduler).subscribe(() => {
|
|
65
|
-
emitLastValue();
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
error: (err: unknown) => {
|
|
69
|
-
clearTimer();
|
|
70
|
-
subscriber.error(err);
|
|
71
|
-
},
|
|
72
|
-
complete: () => {
|
|
73
|
-
// If there is a pending emission, emit it before completing
|
|
74
|
-
clearTimer();
|
|
75
|
-
emitLastValue();
|
|
76
|
-
subscriber.complete();
|
|
77
|
-
},
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
// Cleanup logic
|
|
81
|
-
return () => {
|
|
82
|
-
clearTimer();
|
|
83
|
-
sourceSubscription.unsubscribe();
|
|
84
|
-
};
|
|
85
|
-
});
|
|
86
|
-
}
|
package/src/lib/rxjs/tapLog.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { tap } from 'rxjs/operators';
|
|
2
|
-
import type { Observable } from 'rxjs';
|
|
3
|
-
import { Logger } from '../dev';
|
|
4
|
-
import { COLOR_CODES } from '../constants';
|
|
5
|
-
|
|
6
|
-
export const tapLog =
|
|
7
|
-
<T>(text: string, ...args: any): ((source: Observable<T>) => Observable<T>) =>
|
|
8
|
-
(source: Observable<T>) =>
|
|
9
|
-
source.pipe(
|
|
10
|
-
tap((data) => {
|
|
11
|
-
Logger.colored(...COLOR_CODES.TAP_LOG, text, data, ...args);
|
|
12
|
-
}),
|
|
13
|
-
);
|
package/src/lib/strings/pad.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Adds required number of symbols before input
|
|
3
|
-
* @param input input string
|
|
4
|
-
* @param size amount of total symbols
|
|
5
|
-
* @param symbol filler
|
|
6
|
-
* @returns string
|
|
7
|
-
*/
|
|
8
|
-
export function pad(
|
|
9
|
-
input: number | string,
|
|
10
|
-
size: number,
|
|
11
|
-
symbol = '0',
|
|
12
|
-
): string {
|
|
13
|
-
let s = input + '';
|
|
14
|
-
while (s.length < size) {
|
|
15
|
-
s = symbol + s;
|
|
16
|
-
}
|
|
17
|
-
return s.slice(-size);
|
|
18
|
-
}
|
package/tsconfig.lib.json
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "../../../tsconfig.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"outDir": "../../../out-tsc/lib",
|
|
7
|
-
"declaration": true,
|
|
8
|
-
"declarationMap": true,
|
|
9
|
-
"inlineSources": true,
|
|
10
|
-
"types": []
|
|
11
|
-
},
|
|
12
|
-
"exclude": ["**/*.spec.ts"]
|
|
13
|
-
}
|
package/tsconfig.lib.prod.json
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
-
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
-
{
|
|
4
|
-
"extends": "./tsconfig.lib.json",
|
|
5
|
-
"compilerOptions": {
|
|
6
|
-
"declarationMap": false
|
|
7
|
-
},
|
|
8
|
-
"angularCompilerOptions": {
|
|
9
|
-
"compilationMode": "partial"
|
|
10
|
-
}
|
|
11
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|