vivth 1.2.3 → 1.3.1
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/README.md +609 -586
- package/README.src.md +5 -1
- package/bun.lock +6 -0
- package/index.mjs +10 -6
- package/package.json +3 -1
- package/src/bundler/CompileJS.mjs +11 -8
- package/src/bundler/EsBundler.mjs +4 -2
- package/src/bundler/FSInline.mjs +3 -0
- package/src/bundler/FSInlineAnalyzer.mjs +31 -7
- package/src/bundler/FSInlineBundled.mjs +5 -1
- package/src/bundler/adds/ToBundledJSPlugin.mjs +3 -4
- package/src/class/Console.mjs +12 -4
- package/src/class/Derived.mjs +5 -1
- package/src/class/Effect.mjs +6 -6
- package/src/class/EnvSignal.mjs +1 -8
- package/src/class/EventSignal.mjs +8 -7
- package/src/class/FileSafe.mjs +1 -1
- package/src/class/ListSignal.mjs +18 -10
- package/src/class/LitExp.mjs +241 -204
- package/src/class/Paths.mjs +10 -8
- package/src/class/QChannel.mjs +14 -7
- package/src/class/SafeExit.mjs +16 -7
- package/src/class/Signal.mjs +8 -7
- package/src/class/WorkerMainThread.mjs +45 -24
- package/src/class/WorkerMainThreadBundled.mjs +42 -24
- package/src/class/WorkerThread.mjs +21 -7
- package/src/common/Base64URL.mjs +2 -2
- package/src/common/Base64URLFromFile.mjs +1 -1
- package/src/doc/JSautoDOC.mjs +101 -62
- package/src/doc/correctBeforeParse.mjs +139 -0
- package/src/doc/parsedFile.mjs +127 -76
- package/src/function/CreateImmutable.mjs +12 -7
- package/src/function/GetRuntime.mjs +8 -3
- package/src/function/LazyFactory.mjs +10 -4
- package/src/function/Try.mjs +4 -1
- package/src/function/TryAsync.mjs +2 -1
- package/src/function/TrySync.mjs +3 -1
- package/src/function/TsToMjs.mjs +7 -4
- package/src/types/AnyButUndefined.mjs +1 -0
- package/src/types/LitExpResultType.mjs +7 -0
- package/src/types/Runtime.mjs +1 -1
- package/tsconfig.json +27 -5
- package/types/dev/workerThreadClass.d.mts +1 -1
- package/types/index.d.mts +7 -6
- package/types/src/bundler/CompileJS.d.mts +14 -9
- package/types/src/bundler/EsBundler.d.mts +1 -1
- package/types/src/class/Derived.d.mts +4 -64
- package/types/src/class/Effect.d.mts +8 -8
- package/types/src/class/EnvSignal.d.mts +0 -1
- package/types/src/class/EventSignal.d.mts +5 -5
- package/types/src/class/FileSafe.d.mts +2 -2
- package/types/src/class/ListSignal.d.mts +1 -1
- package/types/src/class/LitExp.d.mts +49 -53
- package/types/src/class/Paths.d.mts +4 -4
- package/types/src/class/QChannel.d.mts +1 -1
- package/types/src/class/SafeExit.d.mts +3 -3
- package/types/src/class/Signal.d.mts +3 -3
- package/types/src/class/WorkerMainThread.d.mts +13 -8
- package/types/src/class/WorkerMainThreadBundled.d.mts +13 -8
- package/types/src/class/WorkerThread.d.mts +4 -4
- package/types/src/common/Base64URL.d.mts +2 -2
- package/types/src/common/Base64URLFromFile.d.mts +2 -2
- package/types/src/doc/JSautoDOC.d.mts +34 -12
- package/types/src/doc/correctBeforeParse.d.mts +2 -0
- package/types/src/doc/parsedFile.d.mts +7 -10
- package/types/src/function/CreateImmutable.d.mts +2 -2
- package/types/src/function/Try.d.mts +2 -2
- package/types/src/function/TryAsync.d.mts +2 -2
- package/types/src/function/TrySync.d.mts +3 -2
- package/types/src/function/TsToMjs.d.mts +2 -2
- package/types/src/types/LitExpResultType.d.mts +7 -0
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"
|
|
3
|
+
"checkJs": true,
|
|
4
4
|
"declaration": true,
|
|
5
5
|
"emitDeclarationOnly": true,
|
|
6
6
|
"outDir": "./types",
|
|
7
|
-
"module": "esnext",
|
|
8
|
-
"target": "esnext",
|
|
9
|
-
"moduleResolution": "node",
|
|
10
7
|
"esModuleInterop": true,
|
|
11
|
-
"
|
|
8
|
+
"removeComments": false,
|
|
9
|
+
|
|
10
|
+
// Environment setup & latest features
|
|
11
|
+
"lib": ["ESNext"],
|
|
12
|
+
"target": "ESNext",
|
|
13
|
+
"module": "Preserve",
|
|
14
|
+
"moduleDetection": "force",
|
|
15
|
+
"allowJs": true,
|
|
16
|
+
|
|
17
|
+
// Bundler mode
|
|
18
|
+
"moduleResolution": "bundler",
|
|
19
|
+
"allowImportingTsExtensions": true,
|
|
20
|
+
"verbatimModuleSyntax": true,
|
|
21
|
+
"noEmit": false,
|
|
22
|
+
|
|
23
|
+
// Best practices
|
|
24
|
+
"strict": true,
|
|
25
|
+
"skipLibCheck": true,
|
|
26
|
+
"noFallthroughCasesInSwitch": true,
|
|
27
|
+
"noUncheckedIndexedAccess": true,
|
|
28
|
+
"noImplicitOverride": true,
|
|
29
|
+
|
|
30
|
+
// Some stricter flags (disabled by default)
|
|
31
|
+
"noUnusedLocals": false,
|
|
32
|
+
"noUnusedParameters": false,
|
|
33
|
+
"noPropertyAccessFromIndexSignature": false
|
|
12
34
|
},
|
|
13
35
|
"include": ["./index.mjs", "./src", "./dev"]
|
|
14
36
|
}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export const workerThreadClass: {
|
|
6
6
|
new (handler: (ev: any, isLastOnQ: () => boolean) => any): WorkerThread<any, any>;
|
|
7
|
-
#refs: Parameters<(typeof WorkerThread)["setup"]>[0];
|
|
7
|
+
#refs: Parameters<(typeof WorkerThread)["setup"]>[0] | undefined;
|
|
8
8
|
setup<RECEIVE, POST>(refs: {
|
|
9
9
|
parentPort: typeof import("worker_threads")["parentPort"];
|
|
10
10
|
}): typeof WorkerThread<RECEIVE, POST>;
|
package/types/index.d.mts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
export { CompileJS } from "./src/bundler/CompileJS.mjs";
|
|
1
2
|
export { CreateESPlugin } from "./src/bundler/CreateESPlugin.mjs";
|
|
2
3
|
export { EsBundler } from "./src/bundler/EsBundler.mjs";
|
|
3
4
|
export { FSInline } from "./src/bundler/FSInline.mjs";
|
|
4
5
|
export { FSInlineAnalyzer } from "./src/bundler/FSInlineAnalyzer.mjs";
|
|
5
|
-
export {
|
|
6
|
+
export { Console } from "./src/class/Console.mjs";
|
|
6
7
|
export { Derived } from "./src/class/Derived.mjs";
|
|
7
8
|
export { Effect } from "./src/class/Effect.mjs";
|
|
8
9
|
export { EnvSignal } from "./src/class/EnvSignal.mjs";
|
|
@@ -10,29 +11,28 @@ export { EventSignal } from "./src/class/EventSignal.mjs";
|
|
|
10
11
|
export { FileSafe } from "./src/class/FileSafe.mjs";
|
|
11
12
|
export { ListDerived } from "./src/class/ListDerived.mjs";
|
|
12
13
|
export { ListSignal } from "./src/class/ListSignal.mjs";
|
|
14
|
+
export { LitExp } from "./src/class/LitExp.mjs";
|
|
13
15
|
export { Paths } from "./src/class/Paths.mjs";
|
|
14
16
|
export { QChannel } from "./src/class/QChannel.mjs";
|
|
15
17
|
export { SafeExit } from "./src/class/SafeExit.mjs";
|
|
16
18
|
export { Setup } from "./src/class/Setup.mjs";
|
|
17
19
|
export { Signal } from "./src/class/Signal.mjs";
|
|
18
20
|
export { WorkerMainThread } from "./src/class/WorkerMainThread.mjs";
|
|
19
|
-
export {
|
|
21
|
+
export { Base64URL } from "./src/common/Base64URL.mjs";
|
|
20
22
|
export { Base64URLFromFile } from "./src/common/Base64URLFromFile.mjs";
|
|
21
23
|
export { EventNameSpace } from "./src/common/EventNameSpace.mjs";
|
|
22
24
|
export { JSautoDOC } from "./src/doc/JSautoDOC.mjs";
|
|
23
|
-
export {
|
|
25
|
+
export { CreateImmutable } from "./src/function/CreateImmutable.mjs";
|
|
24
26
|
export { EventCheck } from "./src/function/EventCheck.mjs";
|
|
25
27
|
export { EventObject } from "./src/function/EventObject.mjs";
|
|
26
|
-
export { IsAsync } from "./src/function/IsAsync.mjs";
|
|
27
28
|
export { GetRuntime } from "./src/function/GetRuntime.mjs";
|
|
29
|
+
export { IsAsync } from "./src/function/IsAsync.mjs";
|
|
28
30
|
export { LazyFactory } from "./src/function/LazyFactory.mjs";
|
|
29
31
|
export { Timeout } from "./src/function/Timeout.mjs";
|
|
30
32
|
export { Try } from "./src/function/Try.mjs";
|
|
31
33
|
export { TryAsync } from "./src/function/TryAsync.mjs";
|
|
32
34
|
export { TrySync } from "./src/function/TrySync.mjs";
|
|
33
35
|
export { TsToMjs } from "./src/function/TsToMjs.mjs";
|
|
34
|
-
export { Base64URL } from "./src/common/Base64URL.mjs";
|
|
35
|
-
export { CreateImmutable } from "./src/function/CreateImmutable.mjs";
|
|
36
36
|
export { WorkerResult } from "./src/class/WorkerResult.mjs";
|
|
37
37
|
export { WorkerThread } from "./src/class/WorkerThread.mjs";
|
|
38
38
|
export { ToBundledJSPlugin } from "./src/bundler/adds/ToBundledJSPlugin.mjs";
|
|
@@ -41,6 +41,7 @@ export type ExtnameType = import("./src/types/ExtnameType.mjs").ExtnameType;
|
|
|
41
41
|
export type IsListSignal = import("./src/types/IsListSignal.mjs").IsListSignal;
|
|
42
42
|
export type ListArg = import("./src/types/ListArg.mjs").ListArg;
|
|
43
43
|
export type LitExpKeyType = import("./src/types/LitExpKeyType.mjs").LitExpKeyType;
|
|
44
|
+
export type LitExpResultType<KEYS extends import("./src/types/LitExpKeyType.mjs").LitExpKeyType> = import("./src/types/LitExpResultType.mjs").LitExpResultType<KEYS>;
|
|
44
45
|
export type MutationType = import("./src/types/MutationType.mjs").MutationType;
|
|
45
46
|
export type QCBFIFOReturn = import("./src/types/QCBFIFOReturn.mjs").QCBFIFOReturn;
|
|
46
47
|
export type QCBReturn = import("./src/types/QCBReturn.mjs").QCBReturn;
|
|
@@ -37,10 +37,10 @@
|
|
|
37
37
|
* - no need to add the output/outdir, as it use the `options.outDir`;
|
|
38
38
|
* @param {ReturnType<CreateESPlugin>[]} [options.esBundlerPlugins]
|
|
39
39
|
* - plugins for `EsBundler`;
|
|
40
|
-
* @return {ReturnType<TryAsync<{compileResult:Promise<any
|
|
41
|
-
* commandCalled: string;
|
|
42
|
-
* compiledBinFile: string;
|
|
43
|
-
* bundledJSFile:string
|
|
40
|
+
* @return {ReturnType<typeof TryAsync<{compileResult:Promise<any>|undefined,
|
|
41
|
+
* commandCalled: string|undefined;
|
|
42
|
+
* compiledBinFile: string|undefined;
|
|
43
|
+
* bundledJSFile:string|undefined
|
|
44
44
|
* }>>}
|
|
45
45
|
* @example
|
|
46
46
|
* import { join } from 'node:path';
|
|
@@ -72,13 +72,18 @@
|
|
|
72
72
|
*/
|
|
73
73
|
export function CompileJS({ entryPoint, minifyFirst, encoding, outDir, compiler, compilerArguments, esBundlerPlugins, }: {
|
|
74
74
|
entryPoint: string;
|
|
75
|
-
encoding?: BufferEncoding;
|
|
75
|
+
encoding?: BufferEncoding | undefined;
|
|
76
76
|
minifyFirst: boolean;
|
|
77
77
|
outDir: string;
|
|
78
|
-
compiler?: "pkg" | "bun" | "deno";
|
|
79
|
-
compilerArguments?: Record<string, string
|
|
80
|
-
esBundlerPlugins?:
|
|
81
|
-
}): ReturnType<typeof TryAsync
|
|
78
|
+
compiler?: "pkg" | "bun" | "deno" | undefined;
|
|
79
|
+
compilerArguments?: Record<string, string> | undefined;
|
|
80
|
+
esBundlerPlugins?: import("esbuild").Plugin[] | undefined;
|
|
81
|
+
}): ReturnType<typeof TryAsync<{
|
|
82
|
+
compileResult: Promise<any> | undefined;
|
|
83
|
+
commandCalled: string | undefined;
|
|
84
|
+
compiledBinFile: string | undefined;
|
|
85
|
+
bundledJSFile: string | undefined;
|
|
86
|
+
}>>;
|
|
82
87
|
export type PlatformKey = "win32" | "linux" | "darwin" | string;
|
|
83
88
|
export type CreateESPlugin = typeof import("./CreateESPlugin.mjs")["CreateESPlugin"];
|
|
84
89
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
@@ -30,7 +30,7 @@ export function EsBundler({ content, extension, root, withBinHeader }: {
|
|
|
30
30
|
content: string;
|
|
31
31
|
root: string;
|
|
32
32
|
extension: ".mts" | ".ts" | ".mjs";
|
|
33
|
-
withBinHeader?: boolean;
|
|
33
|
+
withBinHeader?: boolean | undefined;
|
|
34
34
|
}, esbuildOptions?: Omit<Parameters<typeof build>[0], "entryPoints" | "bundle" | "write" | "sourcemap">): ReturnType<typeof TryAsync<string>>;
|
|
35
35
|
import { build } from 'esbuild';
|
|
36
36
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
@@ -9,7 +9,7 @@ export class Derived<VALUE> extends Signal<VALUE> {
|
|
|
9
9
|
* @description
|
|
10
10
|
* - Derived used [Signal](#signal) and [Effect](#effect) under the hood;
|
|
11
11
|
* @param {(effectInstanceOptions:Omit<Effect["options"] &
|
|
12
|
-
* Derived["options"], unwrapLazy>) =>
|
|
12
|
+
* Derived<VALUE>["options"], unwrapLazy>) =>
|
|
13
13
|
* Promise<VALUE>} derivedFunction
|
|
14
14
|
* @example
|
|
15
15
|
* import { Signal, Derived } from 'vivth';
|
|
@@ -27,67 +27,7 @@ export class Derived<VALUE> extends Signal<VALUE> {
|
|
|
27
27
|
*
|
|
28
28
|
* count.value++;
|
|
29
29
|
*/
|
|
30
|
-
constructor(derivedFunction: (effectInstanceOptions: Omit<Effect["options"] &
|
|
31
|
-
/**
|
|
32
|
-
* @instance options
|
|
33
|
-
* @description
|
|
34
|
-
* - return this value tandem with `isLastCalled`, to not to update the value of this instance, even when returning early;
|
|
35
|
-
* @type {Object}
|
|
36
|
-
* @example
|
|
37
|
-
* import { Signal, Derived } from 'vivth';
|
|
38
|
-
*
|
|
39
|
-
* const count = new Signal(0);
|
|
40
|
-
* const double = new Derived(async({
|
|
41
|
-
* subscribe,
|
|
42
|
-
* dontUpdate,
|
|
43
|
-
* isLastCalled,
|
|
44
|
-
* }) => {
|
|
45
|
-
* const currentValue = subscribe(count).value;
|
|
46
|
-
* if (!(await isLastCalled(10))) {
|
|
47
|
-
* return dontUpdate;
|
|
48
|
-
* }
|
|
49
|
-
* const res = await fetch(`some/path/${curentValue.toString()}`);
|
|
50
|
-
* if (!(await isLastCalled())) {
|
|
51
|
-
* return dontUpdate; // this will prevent race condition, even if the earlier fetch return late;
|
|
52
|
-
* }
|
|
53
|
-
* return res;
|
|
54
|
-
* });
|
|
55
|
-
*
|
|
56
|
-
* count.value++;
|
|
57
|
-
*/
|
|
58
|
-
dontUpdate: any;
|
|
59
|
-
} & {
|
|
60
|
-
"vivth:unwrapLazy;": () => {
|
|
61
|
-
/**
|
|
62
|
-
* @instance options
|
|
63
|
-
* @description
|
|
64
|
-
* - return this value tandem with `isLastCalled`, to not to update the value of this instance, even when returning early;
|
|
65
|
-
* @type {Object}
|
|
66
|
-
* @example
|
|
67
|
-
* import { Signal, Derived } from 'vivth';
|
|
68
|
-
*
|
|
69
|
-
* const count = new Signal(0);
|
|
70
|
-
* const double = new Derived(async({
|
|
71
|
-
* subscribe,
|
|
72
|
-
* dontUpdate,
|
|
73
|
-
* isLastCalled,
|
|
74
|
-
* }) => {
|
|
75
|
-
* const currentValue = subscribe(count).value;
|
|
76
|
-
* if (!(await isLastCalled(10))) {
|
|
77
|
-
* return dontUpdate;
|
|
78
|
-
* }
|
|
79
|
-
* const res = await fetch(`some/path/${curentValue.toString()}`);
|
|
80
|
-
* if (!(await isLastCalled())) {
|
|
81
|
-
* return dontUpdate; // this will prevent race condition, even if the earlier fetch return late;
|
|
82
|
-
* }
|
|
83
|
-
* return res;
|
|
84
|
-
* });
|
|
85
|
-
*
|
|
86
|
-
* count.value++;
|
|
87
|
-
*/
|
|
88
|
-
dontUpdate: any;
|
|
89
|
-
};
|
|
90
|
-
}), "vivth:unwrapLazy;">) => Promise<VALUE>);
|
|
30
|
+
constructor(derivedFunction: (effectInstanceOptions: Omit<Effect["options"] & Derived<VALUE>["options"], "vivth:unwrapLazy;">) => Promise<VALUE>);
|
|
91
31
|
/**
|
|
92
32
|
* @description
|
|
93
33
|
* - additional helper to be accessed on effect;
|
|
@@ -120,7 +60,7 @@ export class Derived<VALUE> extends Signal<VALUE> {
|
|
|
120
60
|
*
|
|
121
61
|
* count.value++;
|
|
122
62
|
*/
|
|
123
|
-
dontUpdate:
|
|
63
|
+
dontUpdate: Object;
|
|
124
64
|
} & {
|
|
125
65
|
"vivth:unwrapLazy;": () => {
|
|
126
66
|
/**
|
|
@@ -150,7 +90,7 @@ export class Derived<VALUE> extends Signal<VALUE> {
|
|
|
150
90
|
*
|
|
151
91
|
* count.value++;
|
|
152
92
|
*/
|
|
153
|
-
dontUpdate:
|
|
93
|
+
dontUpdate: Object;
|
|
154
94
|
};
|
|
155
95
|
};
|
|
156
96
|
}
|
|
@@ -71,9 +71,9 @@ export class Effect {
|
|
|
71
71
|
* @instance options
|
|
72
72
|
* @description
|
|
73
73
|
* - normally it's passed as argument to constructor, however it is also accessible from `options` property;
|
|
74
|
-
* @template
|
|
75
|
-
* @param {
|
|
76
|
-
* @returns {
|
|
74
|
+
* @template V
|
|
75
|
+
* @param {Signal<V>} signal
|
|
76
|
+
* @returns {Signal<V>}
|
|
77
77
|
* @example
|
|
78
78
|
* import { Effect } from 'vivth';
|
|
79
79
|
*
|
|
@@ -82,7 +82,7 @@ export class Effect {
|
|
|
82
82
|
* })
|
|
83
83
|
* effect.options.subscribe(signalInstance);
|
|
84
84
|
*/
|
|
85
|
-
subscribe: <
|
|
85
|
+
subscribe: <V>(signal: Signal<V>) => Signal<V>;
|
|
86
86
|
/**
|
|
87
87
|
* @instance options
|
|
88
88
|
* @description
|
|
@@ -127,9 +127,9 @@ export class Effect {
|
|
|
127
127
|
* @instance options
|
|
128
128
|
* @description
|
|
129
129
|
* - normally it's passed as argument to constructor, however it is also accessible from `options` property;
|
|
130
|
-
* @template
|
|
131
|
-
* @param {
|
|
132
|
-
* @returns {
|
|
130
|
+
* @template V
|
|
131
|
+
* @param {Signal<V>} signal
|
|
132
|
+
* @returns {Signal<V>}
|
|
133
133
|
* @example
|
|
134
134
|
* import { Effect } from 'vivth';
|
|
135
135
|
*
|
|
@@ -138,7 +138,7 @@ export class Effect {
|
|
|
138
138
|
* })
|
|
139
139
|
* effect.options.subscribe(signalInstance);
|
|
140
140
|
*/
|
|
141
|
-
subscribe: <
|
|
141
|
+
subscribe: <V>(signal: Signal<V>) => Signal<V>;
|
|
142
142
|
/**
|
|
143
143
|
* @instance options
|
|
144
144
|
* @description
|
|
@@ -12,7 +12,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
12
12
|
/**
|
|
13
13
|
* @description
|
|
14
14
|
* - `Map` of `EventSignal`, using the `stringName` of the `EventSignal_instance` as `key`;
|
|
15
|
-
* @type {Map<string, EventSignal
|
|
15
|
+
* @type {Map<string, EventSignal<any>>}
|
|
16
16
|
*/
|
|
17
17
|
static map: Map<string, EventSignal<any>>;
|
|
18
18
|
/**
|
|
@@ -26,13 +26,13 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
26
26
|
* >- the `Promise` nature is to prevent race condition on creating the instance;
|
|
27
27
|
* @param {string} stringName
|
|
28
28
|
* @param {IsListSignal} [isList_]
|
|
29
|
-
* @returns {Promise<EventSignal
|
|
29
|
+
* @returns {Promise<EventSignal<any>>}
|
|
30
30
|
* @example
|
|
31
31
|
* import { EventSignal } from 'vivth';
|
|
32
32
|
*
|
|
33
33
|
* const myEventSignal = await EventSignal.get('dataEvent');
|
|
34
34
|
*/
|
|
35
|
-
static get(stringName: string, isList_?: boolean)
|
|
35
|
+
static get: (stringName: string, isList_?: boolean) => Promise<EventSignal<any>>;
|
|
36
36
|
/**
|
|
37
37
|
* @description
|
|
38
38
|
* - methods of this static property is lazily created;
|
|
@@ -132,7 +132,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
132
132
|
* - is [Signal](#signal) or [ListSignal](#listsignal) instance, depending on the `isList` argument;
|
|
133
133
|
* - if needed to pass along the messages, it can be used as `dispatcher` and `listener` at the same time;
|
|
134
134
|
* - is `lazily` created;
|
|
135
|
-
* @type {Signal
|
|
135
|
+
* @type {Signal<any>|ListSignal<any>}
|
|
136
136
|
* @example
|
|
137
137
|
* import { EventSignal, Effect, Console } from 'vivth';
|
|
138
138
|
*
|
|
@@ -151,7 +151,7 @@ export class EventSignal<ISLIST extends boolean> {
|
|
|
151
151
|
* - is [Derived](#derived) or [ListDerived](#listderived) instance, depending on the `isList` argument;
|
|
152
152
|
* - can be used as listener when passed down value shouldn't be modified manually;
|
|
153
153
|
* - is `lazily` created along with `dispatch`, if `listen` is accessed first, then `dispatch` will also be created automatically;
|
|
154
|
-
* @type {Derived
|
|
154
|
+
* @type {Derived<any>|ListDerived<any>}
|
|
155
155
|
* @example
|
|
156
156
|
* import { EventSignal, Effect, Console } from 'vivth';
|
|
157
157
|
*
|
|
@@ -73,14 +73,14 @@ export class FileSafe {
|
|
|
73
73
|
* - also returning promise of result & error as value;
|
|
74
74
|
* @param {Parameters<mkdir>[0]} outDir
|
|
75
75
|
* - absolute path
|
|
76
|
-
* @returns {ReturnType<typeof TryAsync<string>>}
|
|
76
|
+
* @returns {ReturnType<typeof TryAsync<string|undefined>>}
|
|
77
77
|
* @example
|
|
78
78
|
* import { join } from 'node:path';
|
|
79
79
|
* import { FileSafe, Paths } from 'vivth';
|
|
80
80
|
*
|
|
81
81
|
* const [str, errorMkDir] = await FileSafe.mkdir(join(Paths.root, '/some/path/example'));
|
|
82
82
|
*/
|
|
83
|
-
static mkdir: (outDir: Parameters<typeof mkdir>[0]) => ReturnType<typeof TryAsync<string>>;
|
|
83
|
+
static mkdir: (outDir: Parameters<typeof mkdir>[0]) => ReturnType<typeof TryAsync<string | undefined>>;
|
|
84
84
|
}
|
|
85
85
|
import { TryAsync } from '../function/TryAsync.mjs';
|
|
86
86
|
import { writeFile } from 'node:fs/promises';
|
|
@@ -16,7 +16,7 @@ export class ListSignal<LISTARG extends import("../types/ListArg.mjs").ListArg>
|
|
|
16
16
|
* @param {unknown} value - The value to validate.
|
|
17
17
|
* @returns {value is Array<Record<string, string>>} True if the first item is a valid string record or array is empty.
|
|
18
18
|
*/
|
|
19
|
-
static isValid
|
|
19
|
+
static isValid(value: unknown): value is Array<Record<string, string>>;
|
|
20
20
|
/**
|
|
21
21
|
* @description
|
|
22
22
|
* - usefull for `loops`;
|
|
@@ -13,6 +13,19 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
13
13
|
/**
|
|
14
14
|
* @typedef {import("../types/LitExpKeyType.mjs").LitExpKeyType} LitExpKeyType
|
|
15
15
|
*/
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* - to escape special chars from string literal;
|
|
19
|
+
* - returned value can be used to create instance of RegExp;
|
|
20
|
+
* @param {string} string
|
|
21
|
+
* @returns {string}
|
|
22
|
+
* @example
|
|
23
|
+
* import { LitExp } from 'vivt';
|
|
24
|
+
*
|
|
25
|
+
* const escapedLiteral = LitExp.escape(`something[][;alerk325]`);
|
|
26
|
+
* new RegExp(escapedLiteral, 'g');
|
|
27
|
+
*/
|
|
28
|
+
static escape: (string: string) => string;
|
|
16
29
|
/**
|
|
17
30
|
* @description
|
|
18
31
|
* - constructor helper;
|
|
@@ -52,7 +65,7 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
52
65
|
* // recommended to end the template literal with any string but `key`;
|
|
53
66
|
* })()
|
|
54
67
|
*/
|
|
55
|
-
static prepare
|
|
68
|
+
static prepare<KEYS_1 extends import("../types/LitExpKeyType.mjs").LitExpKeyType>(keysAndDefaultValuePair: KEYS_1): ReturnType<typeof TrySync<(templateStringArray: TemplateStringsArray, ...values: (keyof KEYS_1)[]) => LitExp<KEYS_1>>>;
|
|
56
69
|
/**
|
|
57
70
|
* @template {LitExpKeyType} KEYS
|
|
58
71
|
* @param {KEYS} instance_rules
|
|
@@ -61,14 +74,14 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
61
74
|
* @param {TemplateStringsArray} strings
|
|
62
75
|
* @returns {ReturnType<typeof TrySync<string[]>>}
|
|
63
76
|
*/
|
|
64
|
-
static #processTemplate
|
|
77
|
+
static #processTemplate<KEYS_1 extends import("../types/LitExpKeyType.mjs").LitExpKeyType>(instance_rules: KEYS_1, intance_values: (keyof KEYS_1)[], valueHandler: (value: keyof KEYS_1, regex: RegExp | false) => ReturnType<typeof TrySync<string>>, strings: TemplateStringsArray): ReturnType<typeof TrySync<string[]>>;
|
|
65
78
|
/**
|
|
66
79
|
* @template {LitExpKeyType} KEYS
|
|
67
80
|
* @param {RegExp|false} regex
|
|
68
81
|
* @param {keyof KEYS} value
|
|
69
82
|
* @returns {ReturnType<typeof TrySync<string>>}
|
|
70
83
|
*/
|
|
71
|
-
static #namedChapture
|
|
84
|
+
static #namedChapture<KEYS_1 extends import("../types/LitExpKeyType.mjs").LitExpKeyType>(value: keyof KEYS_1, regex: RegExp | false): ReturnType<typeof TrySync<string>>;
|
|
72
85
|
/**
|
|
73
86
|
* @private
|
|
74
87
|
* @param {KEYS} keys
|
|
@@ -76,6 +89,11 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
76
89
|
* @param {...(keyof KEYS)} values
|
|
77
90
|
*/
|
|
78
91
|
private constructor();
|
|
92
|
+
/**
|
|
93
|
+
* @typedef {ReturnType<LitExp<KEYS>["evaluate"]["execGroups"]>} ExecGroups
|
|
94
|
+
* @typedef {ExecGroups extends [infer First, ...any] ? First : undefined} FirstGroup
|
|
95
|
+
* @typedef {FirstGroup extends { result: any } ? Partial<FirstGroup["result"]> : undefined} Overrides
|
|
96
|
+
*/
|
|
79
97
|
/**
|
|
80
98
|
* @description
|
|
81
99
|
* - instance methods for generating things;
|
|
@@ -85,8 +103,8 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
85
103
|
* @instance make
|
|
86
104
|
* @description
|
|
87
105
|
* - to make string based on the template literal;
|
|
88
|
-
* @param {Partial<
|
|
89
|
-
* @returns {string}
|
|
106
|
+
* @param {Partial<{ [K in keyof KEYS]?: string }>} overrides
|
|
107
|
+
* @returns {string|undefined}
|
|
90
108
|
* @example
|
|
91
109
|
* import { LitExp } from 'vivth';
|
|
92
110
|
*
|
|
@@ -103,15 +121,15 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
103
121
|
*
|
|
104
122
|
* console.log(result); // "templateLiteral:actualvalue;"
|
|
105
123
|
*/
|
|
106
|
-
string: (overrides: Partial<
|
|
124
|
+
string: (overrides: Partial<{ [K in keyof KEYS]?: string; }>) => string | undefined;
|
|
107
125
|
} & {
|
|
108
126
|
"vivth:unwrapLazy;": () => {
|
|
109
127
|
/**
|
|
110
128
|
* @instance make
|
|
111
129
|
* @description
|
|
112
130
|
* - to make string based on the template literal;
|
|
113
|
-
* @param {Partial<
|
|
114
|
-
* @returns {string}
|
|
131
|
+
* @param {Partial<{ [K in keyof KEYS]?: string }>} overrides
|
|
132
|
+
* @returns {string|undefined}
|
|
115
133
|
* @example
|
|
116
134
|
* import { LitExp } from 'vivth';
|
|
117
135
|
*
|
|
@@ -128,7 +146,7 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
128
146
|
*
|
|
129
147
|
* console.log(result); // "templateLiteral:actualvalue;"
|
|
130
148
|
*/
|
|
131
|
-
string: (overrides: Partial<
|
|
149
|
+
string: (overrides: Partial<{ [K in keyof KEYS]?: string; }>) => string | undefined;
|
|
132
150
|
};
|
|
133
151
|
};
|
|
134
152
|
/**
|
|
@@ -179,11 +197,11 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
179
197
|
* console.log(whole); // "templateLiteral:Something;"
|
|
180
198
|
* console.log(myKey); // "Something"
|
|
181
199
|
*/
|
|
182
|
-
execGroups
|
|
200
|
+
execGroups(string: string, options: {
|
|
183
201
|
flags: ConstructorParameters<typeof RegExp>[1];
|
|
184
202
|
whiteSpaceSensitive: boolean;
|
|
185
203
|
absoluteLeadAndFollowing: boolean;
|
|
186
|
-
})
|
|
204
|
+
}): ReturnType<typeof TrySync<{
|
|
187
205
|
result: {
|
|
188
206
|
whole: string;
|
|
189
207
|
named: Record<keyof KEYS, string>;
|
|
@@ -196,8 +214,7 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
196
214
|
* - to match all and grouped based on `key`;
|
|
197
215
|
* @param {Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0]} string
|
|
198
216
|
* @param {Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], 'absoluteLeadAndFollowing'>} options
|
|
199
|
-
* @returns {ReturnType<typeof TrySync<
|
|
200
|
-
* regexp: RegExp}>>
|
|
217
|
+
* @returns {ReturnType<typeof TrySync<import('../types/LitExpResultType.mjs').LitExpResultType<KEYS>>>
|
|
201
218
|
* }
|
|
202
219
|
* @example
|
|
203
220
|
* import { LitExp, Console } from 'vivth';
|
|
@@ -221,29 +238,19 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
221
238
|
* return;
|
|
222
239
|
* }
|
|
223
240
|
* const {
|
|
224
|
-
* result: {
|
|
225
|
-
* whole: [whole0, whole1],
|
|
226
|
-
* named: [
|
|
227
|
-
* { myKey: myKeyExec0, },
|
|
228
|
-
* { myKey: myKeyExec1, },
|
|
229
|
-
* ],
|
|
230
|
-
* },
|
|
241
|
+
* result: { whole, named },
|
|
231
242
|
* regexp
|
|
232
243
|
* } = resultOfMatchedAllAndGrouped;
|
|
233
244
|
*
|
|
234
|
-
*
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
245
|
+
* named.foreach(({myKey})=>{
|
|
246
|
+
* // code
|
|
247
|
+
* })
|
|
248
|
+
* whole.foreach((capturedString)=>{
|
|
249
|
+
* // code
|
|
250
|
+
* })
|
|
238
251
|
* })()
|
|
239
252
|
*/
|
|
240
|
-
matchedAllAndGrouped: (string: Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0], options: Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], "absoluteLeadAndFollowing">) => ReturnType<typeof TrySync<
|
|
241
|
-
result: {
|
|
242
|
-
whole: string[];
|
|
243
|
-
named: Array<Record<keyof KEYS, string>>;
|
|
244
|
-
};
|
|
245
|
-
regexp: RegExp;
|
|
246
|
-
}>>;
|
|
253
|
+
matchedAllAndGrouped: (string: Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0], options: Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], "absoluteLeadAndFollowing">) => ReturnType<typeof TrySync<import("../types/LitExpResultType.mjs").LitExpResultType<KEYS>>>;
|
|
247
254
|
} & {
|
|
248
255
|
"vivth:unwrapLazy;": () => {
|
|
249
256
|
/**
|
|
@@ -289,11 +296,11 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
289
296
|
* console.log(whole); // "templateLiteral:Something;"
|
|
290
297
|
* console.log(myKey); // "Something"
|
|
291
298
|
*/
|
|
292
|
-
execGroups
|
|
299
|
+
execGroups(string: string, options: {
|
|
293
300
|
flags: ConstructorParameters<typeof RegExp>[1];
|
|
294
301
|
whiteSpaceSensitive: boolean;
|
|
295
302
|
absoluteLeadAndFollowing: boolean;
|
|
296
|
-
})
|
|
303
|
+
}): ReturnType<typeof TrySync<{
|
|
297
304
|
result: {
|
|
298
305
|
whole: string;
|
|
299
306
|
named: Record<keyof KEYS, string>;
|
|
@@ -306,8 +313,7 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
306
313
|
* - to match all and grouped based on `key`;
|
|
307
314
|
* @param {Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0]} string
|
|
308
315
|
* @param {Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], 'absoluteLeadAndFollowing'>} options
|
|
309
|
-
* @returns {ReturnType<typeof TrySync<
|
|
310
|
-
* regexp: RegExp}>>
|
|
316
|
+
* @returns {ReturnType<typeof TrySync<import('../types/LitExpResultType.mjs').LitExpResultType<KEYS>>>
|
|
311
317
|
* }
|
|
312
318
|
* @example
|
|
313
319
|
* import { LitExp, Console } from 'vivth';
|
|
@@ -331,29 +337,19 @@ export class LitExp<KEYS extends import("../types/LitExpKeyType.mjs").LitExpKeyT
|
|
|
331
337
|
* return;
|
|
332
338
|
* }
|
|
333
339
|
* const {
|
|
334
|
-
* result: {
|
|
335
|
-
* whole: [whole0, whole1],
|
|
336
|
-
* named: [
|
|
337
|
-
* { myKey: myKeyExec0, },
|
|
338
|
-
* { myKey: myKeyExec1, },
|
|
339
|
-
* ],
|
|
340
|
-
* },
|
|
340
|
+
* result: { whole, named },
|
|
341
341
|
* regexp
|
|
342
342
|
* } = resultOfMatchedAllAndGrouped;
|
|
343
343
|
*
|
|
344
|
-
*
|
|
345
|
-
*
|
|
346
|
-
*
|
|
347
|
-
*
|
|
344
|
+
* named.foreach(({myKey})=>{
|
|
345
|
+
* // code
|
|
346
|
+
* })
|
|
347
|
+
* whole.foreach((capturedString)=>{
|
|
348
|
+
* // code
|
|
349
|
+
* })
|
|
348
350
|
* })()
|
|
349
351
|
*/
|
|
350
|
-
matchedAllAndGrouped: (string: Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0], options: Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], "absoluteLeadAndFollowing">) => ReturnType<typeof TrySync<
|
|
351
|
-
result: {
|
|
352
|
-
whole: string[];
|
|
353
|
-
named: Array<Record<keyof KEYS, string>>;
|
|
354
|
-
};
|
|
355
|
-
regexp: RegExp;
|
|
356
|
-
}>>;
|
|
352
|
+
matchedAllAndGrouped: (string: Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0], options: Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], "absoluteLeadAndFollowing">) => ReturnType<typeof TrySync<import("../types/LitExpResultType.mjs").LitExpResultType<KEYS>>>;
|
|
357
353
|
};
|
|
358
354
|
};
|
|
359
355
|
#private;
|
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export class Paths {
|
|
8
8
|
/**
|
|
9
|
-
* @type {Paths}
|
|
9
|
+
* @type {Paths|undefined}
|
|
10
10
|
*/
|
|
11
|
-
static #instance: Paths;
|
|
11
|
+
static #instance: Paths | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* @description
|
|
14
14
|
* - reference for rootPath
|
|
15
15
|
* - `Paths` needed to be instantiated via:
|
|
16
16
|
* >- `Paths` constructor;
|
|
17
17
|
* >- `Setup.paths` constructor;
|
|
18
|
-
* @type {string}
|
|
18
|
+
* @type {string|undefined}
|
|
19
19
|
*/
|
|
20
|
-
static get root(): string;
|
|
20
|
+
static get root(): string | undefined;
|
|
21
21
|
/**
|
|
22
22
|
* @description
|
|
23
23
|
* - normalize path separator to forward slash `/`;
|
|
@@ -30,7 +30,7 @@ export class QChannel<DEFINEDANY extends import("../types/AnyButUndefined.mjs").
|
|
|
30
30
|
* - ensures that each id has only one task running at a time.
|
|
31
31
|
* - calls with the same id will wait for the previous call to finish.
|
|
32
32
|
* @param {AnyButUndefined} id
|
|
33
|
-
* @param {QChannel} instance
|
|
33
|
+
* @param {QChannel<any>} instance
|
|
34
34
|
* @returns {Promise<QCBReturn>} Resolves when it's safe to proceed for the given id, returning a cleanup function
|
|
35
35
|
*/
|
|
36
36
|
static #uniqueCB: (id: import("../types/AnyButUndefined.mjs").AnyButUndefined, instance: QChannel<any>) => Promise<import("../types/QCBReturn.mjs").QCBReturn>;
|
|
@@ -12,9 +12,9 @@ export class SafeExit {
|
|
|
12
12
|
/**
|
|
13
13
|
* @description
|
|
14
14
|
* - only accessible after instantiation;
|
|
15
|
-
* @type {SafeExit}
|
|
15
|
+
* @type {SafeExit|undefined}
|
|
16
16
|
*/
|
|
17
|
-
static instance: SafeExit;
|
|
17
|
+
static instance: SafeExit | undefined;
|
|
18
18
|
/**
|
|
19
19
|
* @description
|
|
20
20
|
* @param {Object} options
|
|
@@ -76,7 +76,7 @@ export class SafeExit {
|
|
|
76
76
|
constructor({ eventNames, terminator, listener }: {
|
|
77
77
|
eventNames: [string, ...string[]];
|
|
78
78
|
terminator: () => void;
|
|
79
|
-
listener?: (eventName: string) => void;
|
|
79
|
+
listener?: ((eventName: string) => void) | undefined;
|
|
80
80
|
});
|
|
81
81
|
/**
|
|
82
82
|
* @description
|