vivth 1.1.2 → 1.2.0

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.
Files changed (108) hide show
  1. package/.vivth-temp/README.src.md +35 -0
  2. package/README.md +1215 -433
  3. package/README.src.md +5 -2
  4. package/bun.lock +228 -0
  5. package/index.mjs +17 -4
  6. package/package.json +6 -3
  7. package/src/bundler/CompileJS.mjs +258 -0
  8. package/src/bundler/CreateESPlugin.mjs +24 -0
  9. package/src/bundler/EsBundler.mjs +27 -13
  10. package/src/bundler/FSInline.mjs +57 -0
  11. package/src/bundler/FSInlineAnalyzer.mjs +197 -0
  12. package/src/bundler/FSInlineBundled.mjs +34 -0
  13. package/src/bundler/adds/ToBundledJSPlugin.mjs +77 -0
  14. package/src/bundler/adds/externals.mjs +8 -0
  15. package/src/bundler/adds/pluginVivthBundle.mjs +5 -0
  16. package/src/class/Console.mjs +48 -27
  17. package/src/class/Derived.mjs +55 -7
  18. package/src/class/Effect.mjs +100 -39
  19. package/src/class/EnvSignal.mjs +5 -5
  20. package/src/class/EventSignal.mjs +55 -5
  21. package/src/class/FileSafe.mjs +124 -0
  22. package/src/class/ListDerived.mjs +6 -3
  23. package/src/class/ListSignal.mjs +11 -11
  24. package/src/class/LitExp.mjs +405 -0
  25. package/src/class/Paths.mjs +27 -1
  26. package/src/class/QChannel.mjs +79 -28
  27. package/src/class/SafeExit.mjs +31 -11
  28. package/src/class/Setup.mjs +5 -2
  29. package/src/class/Signal.mjs +26 -24
  30. package/src/class/WorkerMainThread.mjs +100 -133
  31. package/src/class/WorkerMainThreadBundled.mjs +216 -0
  32. package/src/class/WorkerThread.mjs +38 -32
  33. package/src/common/Base64URL.mjs +10 -5
  34. package/src/common/Base64URLFromFile.mjs +24 -0
  35. package/src/common/keys.mjs +3 -0
  36. package/src/doc/JSautoDOC.mjs +32 -56
  37. package/src/doc/parsedFile.mjs +37 -36
  38. package/src/function/CreateImmutable.mjs +9 -9
  39. package/src/function/EventCheck.mjs +2 -2
  40. package/src/function/EventObject.mjs +5 -5
  41. package/src/function/GetRuntime.mjs +38 -0
  42. package/src/function/IsAsync.mjs +2 -2
  43. package/src/function/LazyFactory.mjs +13 -13
  44. package/src/function/Timeout.mjs +2 -2
  45. package/src/function/Try.mjs +17 -12
  46. package/src/function/TryAsync.mjs +5 -5
  47. package/src/function/TrySync.mjs +5 -5
  48. package/src/function/TsToMjs.mjs +5 -4
  49. package/src/types/LitExpKeyType.mjs +5 -0
  50. package/src/types/QCBReturn.mjs +1 -1
  51. package/src/types/Runtime.mjs +7 -0
  52. package/types/dev/fsInline.d.mts +1 -0
  53. package/types/dev/test.d.mts +1 -0
  54. package/types/dev/testWorker.d.mts +7 -0
  55. package/types/dev/testbundle.d.mts +1 -0
  56. package/types/dev/workerThreadClass.d.mts +13 -0
  57. package/types/index.d.mts +13 -4
  58. package/types/src/bundler/CompileJS.d.mts +78 -0
  59. package/types/src/bundler/CreateESPlugin.d.mts +17 -0
  60. package/types/src/bundler/EsBundler.d.mts +33 -4
  61. package/types/src/bundler/FSInline.d.mts +43 -0
  62. package/types/src/bundler/FSInlineAnalyzer.d.mts +36 -0
  63. package/types/src/bundler/FSInlineBundled.d.mts +22 -0
  64. package/types/src/bundler/adds/ToBundledJSPlugin.d.mts +16 -0
  65. package/types/src/bundler/adds/externals.d.mts +1 -0
  66. package/types/src/bundler/adds/pluginVivthBundle.d.mts +1 -0
  67. package/types/src/class/Console.d.mts +36 -5
  68. package/types/src/class/Derived.d.mts +132 -5
  69. package/types/src/class/Effect.d.mts +106 -7
  70. package/types/src/class/EnvSignal.d.mts +8 -8
  71. package/types/src/class/EventSignal.d.mts +151 -7
  72. package/types/src/class/FileSafe.d.mts +90 -0
  73. package/types/src/class/ListDerived.d.mts +8 -5
  74. package/types/src/class/ListSignal.d.mts +123 -18
  75. package/types/src/class/LitExp.d.mts +361 -0
  76. package/types/src/class/Paths.d.mts +18 -1
  77. package/types/src/class/QChannel.d.mts +69 -22
  78. package/types/src/class/SafeExit.d.mts +24 -9
  79. package/types/src/class/Setup.d.mts +6 -5
  80. package/types/src/class/Signal.d.mts +73 -17
  81. package/types/src/class/WorkerMainThread.d.mts +39 -37
  82. package/types/src/class/WorkerMainThreadBundled.d.mts +85 -0
  83. package/types/src/class/WorkerThread.d.mts +32 -27
  84. package/types/src/common/Base64URL.d.mts +22 -1
  85. package/types/src/common/Base64URLFromFile.d.mts +16 -0
  86. package/types/src/common/keys.d.mts +1 -0
  87. package/types/src/doc/JSautoDOC.d.mts +3 -19
  88. package/types/src/doc/parsedFile.d.mts +72 -13
  89. package/types/src/function/CreateImmutable.d.mts +27 -2
  90. package/types/src/function/EventCheck.d.mts +15 -0
  91. package/types/src/function/EventObject.d.mts +17 -2
  92. package/types/src/function/GetRuntime.d.mts +2 -0
  93. package/types/src/function/IsAsync.d.mts +18 -0
  94. package/types/src/function/LazyFactory.d.mts +35 -2
  95. package/types/src/function/Timeout.d.mts +16 -0
  96. package/types/src/function/Try.d.mts +52 -1
  97. package/types/src/function/TryAsync.d.mts +22 -1
  98. package/types/src/function/TrySync.d.mts +16 -1
  99. package/types/src/function/TsToMjs.d.mts +19 -0
  100. package/types/src/types/LitExpKeyType.d.mts +1 -0
  101. package/types/src/types/QCBReturn.d.mts +1 -1
  102. package/types/src/types/Runtime.d.mts +1 -0
  103. package/dev/index.mjs +0 -28
  104. package/src/bundler/CompileMJS.mjs +0 -110
  105. package/src/function/WriteFileSafe.mjs +0 -37
  106. package/types/src/bundler/A.d.mts +0 -1
  107. package/types/src/bundler/CompileMJS.d.mts +0 -8
  108. package/types/src/function/WriteFileSafe.d.mts +0 -2
package/README.md CHANGED
@@ -24,11 +24,14 @@ npm i vivth
24
24
  > - fully typed `worker-threads` abstraction;
25
25
  > - ` error as value` function helper;
26
26
  > - opionated `autoDocumentation`;
27
- > - opionated `bundler`;
27
+ > - opionated `bundler`:
28
+ > > - abstracted via `esbuild`;
29
+ > - opionated `compiler`;
30
+ > > - abstracted via `pkg`, `deno`, and `bun`;
28
31
 
29
32
  ## versions:
30
33
 
31
- - `1.0.0:b`:
34
+ - `1.0.0+:b`:
32
35
  > - beta release;
33
36
  > - checking edge cases;
34
37
  > - stable API, the exposed API access are highly unlikely to changes, only the underlying code
@@ -36,29 +39,34 @@ npm i vivth
36
39
 
37
40
  <h2 id="list-of-exported-api-and-typehelpers">list of exported API and typehelpers</h2>
38
41
 
39
- - [CompileMJS](#compilemjs)
42
+ - [CompileJS](#compilejs)
43
+ - [CreateESPlugin](#createesplugin)
40
44
  - [EsBundler](#esbundler)
45
+ - [FSInline](#fsinline)
46
+ - [FSInlineAnalyzer](#fsinlineanalyzer)
41
47
  - [Console](#console)
42
48
  - [Derived](#derived)
43
49
  - [Effect](#effect)
44
50
  - [EnvSignal](#envsignal)
45
51
  - [EventSignal](#eventsignal)
52
+ - [FileSafe](#filesafe)
46
53
  - [ListDerived](#listderived)
47
54
  - [ListSignal](#listsignal)
55
+ - [LitExp](#litexp)
48
56
  - [Paths](#paths)
49
57
  - [QChannel](#qchannel)
50
58
  - [SafeExit](#safeexit)
51
59
  - [Setup](#setup)
52
60
  - [Signal](#signal)
53
61
  - [WorkerMainThread](#workermainthread)
54
- - [WorkerResult](#workerresult)
55
- - [WorkerThread](#workerthread)
56
62
  - [Base64URL](#base64url)
63
+ - [Base64URLFromFile](#base64urlfromfile)
57
64
  - [EventNameSpace](#eventnamespace)
58
65
  - [JSautoDOC](#jsautodoc)
59
66
  - [CreateImmutable](#createimmutable)
60
67
  - [EventCheck](#eventcheck)
61
68
  - [EventObject](#eventobject)
69
+ - [GetRuntime](#getruntime)
62
70
  - [IsAsync](#isasync)
63
71
  - [LazyFactory](#lazyfactory)
64
72
  - [Timeout](#timeout)
@@ -66,50 +74,121 @@ npm i vivth
66
74
  - [TryAsync](#tryasync)
67
75
  - [TrySync](#trysync)
68
76
  - [TsToMjs](#tstomjs)
69
- - [WriteFileSafe](#writefilesafe)
70
77
  - [AnyButUndefined](#anybutundefined)
71
78
  - [ExtnameType](#extnametype)
72
79
  - [IsListSignal](#islistsignal)
73
80
  - [ListArg](#listarg)
81
+ - [LitExpKeyType](#litexpkeytype)
74
82
  - [MutationType](#mutationtype)
75
83
  - [QCBFIFOReturn](#qcbfiforeturn)
76
84
  - [QCBReturn](#qcbreturn)
85
+ - [Runtime](#runtime)
86
+ - [WorkerResult](#workerresult)
87
+ - [WorkerThread](#workerthread)
88
+ - [ToBundledJSPlugin](#tobundledjsplugin)
77
89
 
78
- <h2 id="compilemjs">CompileMJS</h2>
90
+ <h2 id="compilejs">CompileJS</h2>
79
91
 
80
92
 
81
- #### reference:`CompileMJS`
82
- - function to bundle to single mjs file, including the workerThread;
93
+ #### reference:`CompileJS`
94
+ - function to compile `.ts`|`.mts`|`.mjs` file, into a single executable;
95
+ - also generate js representation;
96
+ - uses [pkg](https://www.npmjs.com/package/pkg), [bun](https://bun.com/docs/bundler/executables), and [deno](https://docs.deno.com/runtime/reference/cli/compile/) compiler under the hood;
97
+ >- they are used only as packaging agent, and doesn't necessarily supports their advanced feature, such as, assets bundling(use [FSInline](#fsinline) instead);
98
+ >- `WorkerThread` will be converted to inline using `FSInline` too;
99
+
100
+ !!!WARNING!!!
101
+ !!!WARNING!!!
102
+ !!!WARNING!!!
103
+
104
+ - This function does not obfuscate and will not prevent decompilation. Do not embed environment variables or sensitive information inside `options.entryPoint`;
105
+ - It is designed for quick binarization, allowing execution on machines without `Node.js`, `Bun`, or `Deno` installed;
106
+ - The resulting binary will contain `FSInline` and `WorkerMainThread` target paths Buffers, which are loaded into memory at runtime. If your logic depends on the file system, use `node:fs` or `node:fs/promises` APIs and ship external files alongside the binary (not compiled);
107
+
108
+ !!!WARNING!!!
109
+ !!!WARNING!!!
110
+ !!!WARNING!!!
83
111
 
84
112
  ```js
85
113
  /**
86
114
  * @param {Object} options
87
115
  * @param {string} options.entryPoint
88
- * @param {string} options.outputNoExt
89
- * - no extention needed, result will always be '.mjs';
90
- * @param {BufferEncoding} options.encoding
91
- * @param {boolean} [options.minify]
92
- * - default false;
93
- * @param {boolean} [options.asBinary]
94
- * - default false;
95
- * @returns {Promise<ReturnType<typeof WriteFileSafe>>}
116
+ * - need to be manually prefixed;
117
+ * @param {BufferEncoding} [options.encoding]
118
+ * - write and read encoding for the sources;
119
+ * - default: `utf-8`;
120
+ * @param {boolean} options.minifyFirst
121
+ * - minify the bundle before compilation;
122
+ * @param {string} options.outDir
123
+ * - need manual prefix;
124
+ * @param {'pkg'|'bun'|'deno'} [options.compiler]
125
+ * - default: no comilation, just bundling;
126
+ * - `bun` and `pkg` is checked, if there's bug on `deno`, please report on github for issues;
127
+ * @param {Record<string, string>} [options.compilerArguments]
128
+ * - `key` are to used as `--keyName`;
129
+ * - value are the following value of the key;
130
+ * - no need to add the output/outdir, as it use the `options.outDir`;
131
+ * @return {ReturnType<TryAsync<{compileResult:Promise<any>,
132
+ * commandCalled: string;
133
+ * compiledBinFile: string;
134
+ * bundledJSFile:string
135
+ * }>>}
96
136
  */
97
137
  ```
98
138
  - <i>example</i>:
99
139
  ```js
100
- import { Paths, CompileMJS } from 'vivth';
140
+ import { join } from 'node:path';
101
141
 
102
- new Paths({
103
- root: process?.env?.INIT_CWD ?? process?.cwd(),
104
- });
142
+ import { CompileJS, Paths } from 'vivth';
105
143
 
106
- CompileMJS({
107
- entryPoint: '/index.mjs',
108
- encoding: 'utf-8',
109
- outputNoExt: '/test/compiled',
110
- minify: false,
111
- asBinary: true,
112
- });
144
+ const [[resultPkg, errorPkg], [resultBun, errorBun]] = await Promise.all([
145
+ CompileJS({
146
+ entryPoint: join(Paths.root, '/dev'),
147
+ minifyFirst: true,
148
+ outDir: join(Paths.root, '/dev-pkg'),
149
+ compiler: 'pkg',
150
+ compilerArguments: {
151
+ target: ['node18-win-x64'],
152
+ }
153
+ }),
154
+ CompileJS({
155
+ entryPoint: join(Paths.root, '/dev'),
156
+ minifyFirst: true,
157
+ outDir: join(Paths.root, '/dev-pkg'),
158
+ compiler: 'bun',
159
+ compilerArguments: {
160
+ target: ['bun-win-x64'],
161
+ }
162
+ }),
163
+ ])
164
+
165
+ ```
166
+
167
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
168
+
169
+ <h2 id="createesplugin">CreateESPlugin</h2>
170
+
171
+
172
+ #### reference:`CreateESPlugin`
173
+ - typed esbuild Plugin generator;
174
+
175
+ ```js
176
+ /**
177
+ * @param {string} name
178
+ * @param {import('esbuild').Plugin["setup"]} setup
179
+ * @returns {import('esbuild').Plugin}
180
+ */
181
+ ```
182
+ - <i>example</i>:
183
+ ```js
184
+ import { CreateESPlugin } from 'vivth';
185
+
186
+ export const pluginAddCopyRight = CreateESPlugin(
187
+ 'MyCopyrightDeclaration',
188
+ async (build) => {
189
+ // build script;
190
+ }
191
+ );
113
192
 
114
193
  ```
115
194
 
@@ -127,18 +206,21 @@ npm i vivth
127
206
  * @param {Object} options
128
207
  * @param {string} options.content
129
208
  * - the code can also uses composites from the result from multiple readFiles;
130
- * - the import statements on the content should use absolute path from project root, prefixed with forward slash;
131
- * @param {string} options.extension
132
- * @param {boolean} [options.asBinary]
133
- * @param {Omit<Parameters<build>[0], 'entryPoints'|'bundle'|'write'|'format'|'sourcemap'|'external'|'stdin'>} [esbuildOptions]
134
- * @returns {Promise<ReturnType<typeof TryAsync<string>>>}
209
+ * @param {string} options.root
210
+ * - use dirname of said fileString path;
211
+ * @param {'.mts'|'.ts'|'.mjs'} options.extension
212
+ * @param {boolean} [options.withBinHeader]
213
+ * @param {Omit<Parameters<build>[0],
214
+ * 'entryPoints'|'bundle'|'write'|'sourcemap'>
215
+ * } [esbuildOptions]
216
+ * @returns {ReturnType<typeof TryAsync<string>>}
135
217
  */
136
218
  ```
137
219
  - <i>example</i>:
138
220
  ```js
139
221
  import { EsBundler } from 'vivth';
140
222
 
141
- const bundledString = EsBundler(,
223
+ const bundledString = EsBundler(
142
224
  {
143
225
  content: ``,
144
226
  extension: '.mts',
@@ -152,11 +234,104 @@ npm i vivth
152
234
 
153
235
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
154
236
 
237
+ <h2 id="fsinline">FSInline</h2>
238
+
239
+
240
+ #### reference:`FSInline`
241
+ - class helper to inline file;
242
+ - use only if you are planning to use [CompileJS](#compilejs);
243
+
244
+
245
+ #### reference:`FSInline.vivthFSInlineFile`
246
+ - declare entrypoint of file inlining;
247
+ >- on the dev time, it's just regullar `readFile` from `node:fs/promises`;
248
+ >- on the compiled, it will read file from `FSInline.vivthFSInlinelists`
249
+
250
+ ```js
251
+ /**
252
+ * @param {string} filePathFromProject
253
+ * - doesn't require prefix;
254
+ * @returns {Promise<Buffer<ArrayBuffer>>}
255
+ */
256
+ ```
257
+ - <i>example</i>:
258
+ ```js
259
+ import { FSInline } from 'vivth';
260
+
261
+ (await FSInline.vivthFSInlineFile('/assets/text.txt')).toString('utf-8');
262
+
263
+ ```
264
+
265
+ #### reference:`FSInline.vivthFSInlineDir`
266
+ - declare entrypoint of file inlining, include all files on `dir` and `subdir` that match the `fileRule`;
267
+
268
+ ```js
269
+ /**
270
+ * @param {string} dirPathFromProject
271
+ * - doesn't require prefix;
272
+ * @param {RegExp} fileRule
273
+ * @returns {Promise<typeof FSInline["vivthFSInlineFile"]>}
274
+ */
275
+ ```
276
+ - <i>example</i>:
277
+ ```js
278
+ import { FSInline } from 'vivth';
279
+
280
+ export const pngAssets = await FSInline.vivthFSInlineDir('/assets', /.png$/g);
281
+
282
+ ```
283
+
284
+ #### reference:`FSInline.vivthFSInlinelists`
285
+ - placeholder for FSInline;
286
+ - it's remain publicly accessible so it doesn't mess with regex analyze on bundle;
287
+ - shouldn't be manually accessed;
288
+ >- access via `FSInline.vivthFSInlineFile` or `FSInline.vivthFSInlineDir`;
289
+
290
+ ```js
291
+ /**
292
+ * @type {Record<string, Buffer<ArrayBuffer>>}
293
+ */
294
+ ```
295
+
296
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
297
+
298
+ <h2 id="fsinlineanalyzer">FSInlineAnalyzer</h2>
299
+
300
+
301
+ #### reference:`FSInlineAnalyzer`
302
+ - collections of static method to analyze content for `FSInline`;
303
+
304
+
305
+ #### reference:`FSInlineAnalyzer.finalContent`
306
+ - to be used on bundled content;
307
+
308
+ ```js
309
+ /**
310
+ * @param {string} content
311
+ * @param {'cjs'|'esm'} format
312
+ * @returns {ReturnType<typeof TryAsync<string>>}
313
+ */
314
+ ```
315
+ - <i>example</i>:
316
+ ```js
317
+ import { readFile } from 'node:fs/promises';
318
+
319
+ import { FSInlineAnalyzer } from 'vivth';
320
+
321
+ const [resultFinalContent, errorFinalContent] = await FSInlineAnalyzer.finalContent(
322
+ await readFile('./resultESBunlded.mjs', {encoding: 'utf-8'}),
323
+ 'esm'
324
+ );
325
+
326
+ ```
327
+
328
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
329
+
155
330
  <h2 id="console">Console</h2>
156
331
 
157
332
 
158
333
  #### reference:`Console`
159
- - class with static methods to print to standard console with added style;
334
+ - class with static methods to print to standard console with bare minimum ANSI styles;
160
335
 
161
336
 
162
337
  #### reference:`Console.log`
@@ -165,8 +340,17 @@ npm i vivth
165
340
  ```js
166
341
  /**
167
342
  * @param {any} data
168
- * @returns {void}
343
+ * @returns {void}
169
344
  */
345
+ ```
346
+ - <i>example</i>:
347
+ ```js
348
+ import { Console } from 'vivth';
349
+
350
+ Console.log({
351
+ hello: 'world!!',
352
+ });
353
+
170
354
  ```
171
355
 
172
356
  #### reference:`Console.info`
@@ -175,8 +359,17 @@ npm i vivth
175
359
  ```js
176
360
  /**
177
361
  * @param {any} data
178
- * @returns {void}
362
+ * @returns {void}
179
363
  */
364
+ ```
365
+ - <i>example</i>:
366
+ ```js
367
+ import { Console } from 'vivth';
368
+
369
+ Console.info({
370
+ hello: 'world!!',
371
+ });
372
+
180
373
  ```
181
374
 
182
375
  #### reference:`Console.warn`
@@ -185,8 +378,17 @@ npm i vivth
185
378
  ```js
186
379
  /**
187
380
  * @param {any} data
188
- * @returns {void}
381
+ * @returns {void}
189
382
  */
383
+ ```
384
+ - <i>example</i>:
385
+ ```js
386
+ import { Console } from 'vivth';
387
+
388
+ Console.warn({
389
+ hello: 'world!!',
390
+ });
391
+
190
392
  ```
191
393
 
192
394
  #### reference:`Console.error`
@@ -195,8 +397,17 @@ npm i vivth
195
397
  ```js
196
398
  /**
197
399
  * @param {any} data
198
- * @returns {void}
400
+ * @returns {void}
199
401
  */
402
+ ```
403
+ - <i>example</i>:
404
+ ```js
405
+ import { Console } from 'vivth';
406
+
407
+ Console.error({
408
+ hello: 'world!!',
409
+ });
410
+
200
411
  ```
201
412
 
202
413
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
@@ -209,8 +420,8 @@ npm i vivth
209
420
 
210
421
  ```js
211
422
  /**
212
- * @template V
213
- * @extends Signal<V>
423
+ * @template VALUE
424
+ * @extends Signal<VALUE>
214
425
  */
215
426
  ```
216
427
 
@@ -219,7 +430,9 @@ npm i vivth
219
430
 
220
431
  ```js
221
432
  /**
222
- * @param {(effectInstanceOptions:Effect["options"])=>Promise<V>} derivedFunction
433
+ * @param {(effectInstanceOptions:Omit<Effect["options"] &
434
+ * Derived["options"], unwrapLazy>) =>
435
+ * Promise<VALUE>} derivedFunction
223
436
  */
224
437
  ```
225
438
  - <i>example</i>:
@@ -241,13 +454,50 @@ npm i vivth
241
454
 
242
455
  ```
243
456
 
457
+ #### reference:`Derived_instance.options`
458
+ - additional helper to be accessed on effect;
459
+
460
+
461
+ #### reference:`Derived_instance.options.dontUpdate`
462
+ - return this value tandem with `isLastCalled`, to not to update the value of this instance, even when returning early;
463
+
464
+ ```js
465
+ /**
466
+ * @type {Object}
467
+ */
468
+ ```
469
+ - <i>example</i>:
470
+ ```js
471
+ import { Signal, Derived } from 'vivth';
472
+
473
+ const count = new Signal(0);
474
+ const double = new Derived(async({
475
+ subscribe,
476
+ dontUpdate,
477
+ isLastCalled,
478
+ }) => {
479
+ const currentValue = subscribe(count).value;
480
+ if (!(await isLastCalled(10))) {
481
+ return dontUpdate;
482
+ }
483
+ const res = await fetch(`some/path/${curentValue.toString()}`);
484
+ if (!(await isLastCalled())) {
485
+ return dontUpdate; // this will prevent race condition, even if the earlier fetch return late;
486
+ }
487
+ return res;
488
+ });
489
+
490
+ count.value++;
491
+
492
+ ```
493
+
244
494
  #### reference:`Derived_instance.value:getter`
245
495
  - the most recent value of the instance
246
496
  - can be turn into reactive with Effect or Derived instantiation;
247
497
 
248
498
  ```js
249
499
  /**
250
- * @type {V}
500
+ * @returns {VALUE}
251
501
  */
252
502
  ```
253
503
 
@@ -258,7 +508,7 @@ npm i vivth
258
508
  ```js
259
509
  /**
260
510
  * @private
261
- * @type {V}
511
+ * @type {VALUE}
262
512
  */
263
513
  ```
264
514
 
@@ -276,29 +526,37 @@ npm i vivth
276
526
  >- now can dynamically subscribes to signal, even on conditionals, that are not run during first run;
277
527
 
278
528
 
279
- #### reference:`new Effect`
529
+ #### reference:`Effect_instance.options`
530
+ - collections of lazy methods to handle effect calls of this instance;
531
+
532
+
533
+ #### reference:`Effect_instance.options.isLastCalled:getter`
280
534
 
281
535
 
282
536
  ```js
283
537
  /**
284
- * @param {(arg0:Effect["options"])=>Promise<void>} effect
538
+ * @returns {(timeoutMS?:number)=>Promise<boolean>}
539
+ * - timeoutMS only necessary if the operation doesn't naturally await;
540
+ * - if it's operation such as `fetch`, you can just leave it blank;
285
541
  */
286
542
  ```
287
543
  - <i>example</i>:
288
- ```js
289
- import { Signal, Derived, Effect, Console } from 'vivth';
290
-
291
- const count = new Signal(0);
292
- const double = new Derived( async({$}) => $(count).value * 2); // double listen to count changes
293
- new Effect(async ({
294
- subscribe, // : registrar callback for this effect instance, immediately return the signal instance
295
- removeEffect, // : disable this effect instance from reacting to dependency changes;
296
- }) => {
297
- Console.log(subscribe(double).value); // effect listen to double changes
298
- const a = double.value; // no need to wrap double twice with $
299
- })
300
-
301
- count.value++;
544
+ ```js
545
+
546
+ import { Effect } from 'vivth';
547
+
548
+ const effect = new Effect(async ({ isLastCalled }) => {
549
+ if (!(await isLastCalled(100))) {
550
+ return;
551
+ }
552
+ // OR
553
+ const res = await fetch('some/path');
554
+ if (!(await isLastCalled(
555
+ // no need to add timeoutMS argument, as fetch are naturally add delay;
556
+ ))) {
557
+ return;
558
+ }
559
+ })
302
560
 
303
561
  ```
304
562
 
@@ -307,16 +565,18 @@ npm i vivth
307
565
 
308
566
  ```js
309
567
  /**
310
- * @template {Signal} S
311
- * @param {S} signal
312
- * @returns {S}
568
+ * @template {Signal} SIGNAL
569
+ * @param {SIGNAL} signal
570
+ * @returns {SIGNAL}
313
571
  */
314
572
  ```
315
573
  - <i>example</i>:
316
- ```js
317
- const effect = new Effect(async () => {
318
- // code
319
- })
574
+ ```js
575
+ import { Effect } from 'vivth';
576
+
577
+ const effect = new Effect(async () => {
578
+ // code
579
+ })
320
580
  effect.options.subscribe(signalInstance);
321
581
 
322
582
  ```
@@ -326,18 +586,50 @@ npm i vivth
326
586
 
327
587
  ```js
328
588
  /**
329
- * @type {()=>void}
589
+ * @type {()=>void}
330
590
  */
331
591
  ```
332
592
  - <i>example</i>:
333
- ```js
334
- const effect = new Effect(async () => {
335
- // code
336
- })
593
+ ```js
594
+ import { Effect } from 'vivth';
595
+
596
+ const effect = new Effect(async () => {
597
+ // code
598
+ })
337
599
  effect.options.removeEffect();
338
600
 
339
601
  ```
340
602
 
603
+ #### reference:`new Effect`
604
+
605
+
606
+ ```js
607
+ /**
608
+ * @param {( arg0:
609
+ * Omit<Effect["options"], typeof unwrapLazy>
610
+ * ) =>
611
+ * Promise<void>} effect
612
+ */
613
+ ```
614
+ - <i>example</i>:
615
+ ```js
616
+ import { Signal, Derived, Effect, Console } from 'vivth';
617
+
618
+ const count = new Signal(0);
619
+ const double = new Derived( async({$}) => $(count).value * 2); // double listen to count changes
620
+ new Effect(async ({
621
+ subscribe, // : registrar callback for this effect instance, immediately return the signal instance
622
+ removeEffect, // : disable this effect instance from reacting to dependency changes;
623
+ isLastCalled, // : check whether this callback run is this instant last called effect;
624
+ }) => {
625
+ Console.log(subscribe(double).value); // effect listen to double changes
626
+ const a = double.value; // no need to wrap double twice with $
627
+ })
628
+
629
+ count.value++;
630
+
631
+ ```
632
+
341
633
  #### reference:`Effect_instance.run`
342
634
  - normally is to let to be automatically run when dependency signals changes, however it's also accessible as instance method;
343
635
 
@@ -348,6 +640,8 @@ npm i vivth
348
640
  ```
349
641
  - <i>example</i>:
350
642
  ```js
643
+ import { Effect } from 'vivth';
644
+
351
645
  const effect = new Effect(async ()=>{
352
646
  // code
353
647
  })
@@ -366,7 +660,7 @@ npm i vivth
366
660
 
367
661
  ```js
368
662
  /**
369
- * @template V
663
+ * @template VALUE
370
664
  */
371
665
  ```
372
666
 
@@ -375,7 +669,7 @@ npm i vivth
375
669
 
376
670
  ```js
377
671
  /**
378
- * @param {V} initialValue
672
+ * @param {VALUE} initialValue
379
673
  */
380
674
  ```
381
675
 
@@ -384,7 +678,7 @@ npm i vivth
384
678
 
385
679
  ```js
386
680
  /**
387
- * @type {Derived<V>}
681
+ * @type {Derived<VALUE>}
388
682
  */
389
683
  ```
390
684
  - <i>example</i>:
@@ -405,7 +699,7 @@ npm i vivth
405
699
 
406
700
  ```js
407
701
  /**
408
- * @param {V} correctedValue
702
+ * @param {VALUE} correctedValue
409
703
  * @returns {void}
410
704
  */
411
705
  ```
@@ -428,11 +722,12 @@ npm i vivth
428
722
 
429
723
 
430
724
  #### reference:`EventSignal`
431
- - Signal implementation for `CustomEvent`, to dispatch and listen;
725
+ - Signal implementation for `CustomEvent`, to dispatch and listen;
726
+ - it's based on string as key, so it can be listened/dispatched even without direct instance reference;
432
727
 
433
728
  ```js
434
729
  /**
435
- * @template {IsListSignal} isList
730
+ * @template {IsListSignal} ISLIST
436
731
  * - boolean;
437
732
  */
438
733
  ```
@@ -473,8 +768,22 @@ npm i vivth
473
768
 
474
769
  ```js
475
770
  /**
476
- * @type {Signal|ListSignal}
771
+ * @type {Signal|ListSignal}
477
772
  */
773
+ ```
774
+ - <i>example</i>:
775
+ ```js
776
+ import { EventSignal, Effect, Console } from 'vivth';
777
+
778
+ const myEventSignal = await EventSignal.get('dataEvent', false);
779
+
780
+ new Effect(({ subscribe })=>{
781
+ const listenValue = subscribe(myEventSignal.dispatch).value;
782
+ // dispatch can be used as two way communication;
783
+ Console.log({ listenValue });
784
+ })
785
+ myEventSignal.dispatch.value = 'hey';
786
+
478
787
  ```
479
788
 
480
789
  #### reference:`EventSignal_instance.listen`
@@ -484,8 +793,22 @@ npm i vivth
484
793
 
485
794
  ```js
486
795
  /**
487
- * @type {Derived|ListDerived}
796
+ * @type {Derived|ListDerived}
488
797
  */
798
+ ```
799
+ - <i>example</i>:
800
+ ```js
801
+ import { EventSignal, Effect, Console } from 'vivth';
802
+
803
+ const myEventSignal = await EventSignal.get('dataEvent', false);
804
+
805
+ new Effect(({ subscribe })=>{
806
+ const listenValue = subscribe(myEventSignal.listen).value;
807
+ // listen can be used only as listener for one way communication;
808
+ Console.log({ listenValue });
809
+ })
810
+ myEventSignal.dispatch.value = 'hey';
811
+
489
812
  ```
490
813
 
491
814
  #### reference:`EventSignal.remove`
@@ -507,7 +830,7 @@ npm i vivth
507
830
  ```js
508
831
  import { EventSignal } from 'vivth';
509
832
 
510
- EventSignal.remove.subscriber('yourEventSignalName', yourEffectInstance);
833
+ EventSignal.remove.subscriber('yourEventSignalName', myEffectInstance);
511
834
 
512
835
  ```
513
836
 
@@ -556,7 +879,16 @@ npm i vivth
556
879
  ```
557
880
  - <i>example</i>:
558
881
  ```js
559
- eventSignal_instance.remove.subscriber(yourEffectInstance);
882
+ import { EventSignal, Effect, Console } from 'vivth';
883
+
884
+ const myEventSignal = await EventSignal.get('dataEvent', false);
885
+
886
+ const myEffectInstance = new Effect(({ subscribe })=>{
887
+ const listenValue = subscribe(myEventSignal.dispatch).value;
888
+ Console.log({ listenValue });
889
+ })
890
+ myEventSignal.dispatch.value = 'hey';
891
+ eventSignal_instance.remove.subscriber(myEffectInstance);
560
892
 
561
893
  ```
562
894
 
@@ -570,6 +902,15 @@ npm i vivth
570
902
  ```
571
903
  - <i>example</i>:
572
904
  ```js
905
+ import { EventSignal, Effect, Console } from 'vivth';
906
+
907
+ const myEventSignal = await EventSignal.get('dataEvent', false);
908
+
909
+ const myEffectInstance = new Effect(({ subscribe })=>{
910
+ const listenValue = subscribe(myEventSignal.dispatch).value;
911
+ Console.log({ listenValue });
912
+ })
913
+ myEventSignal.dispatch.value = 'hey';
573
914
  eventSignal_instance.remove.allSubscribers();
574
915
 
575
916
  ```
@@ -584,12 +925,135 @@ npm i vivth
584
925
  ```
585
926
  - <i>example</i>:
586
927
  ```js
928
+ import { EventSignal, Effect, Console } from 'vivth';
929
+
930
+ const myEventSignal = await EventSignal.get('dataEvent', false);
931
+
932
+ const myEffectInstance = new Effect(({ subscribe })=>{
933
+ const listenValue = subscribe(myEventSignal.dispatch).value;
934
+ Console.log({ listenValue });
935
+ });
936
+
587
937
  eventSignal_instance.remove.ref();
588
938
 
589
939
  ```
590
940
 
591
941
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
592
942
 
943
+ <h2 id="filesafe">FileSafe</h2>
944
+
945
+
946
+ #### reference:`FileSafe`
947
+ - collection of static methods of file access with added safety to mkdir before proceeding;
948
+
949
+
950
+ #### reference:`FileSafe.write`
951
+ - method to create file safely by recursively mkdir the dirname of the outFile;
952
+ - also returning promise of result & error as value;
953
+
954
+ ```js
955
+ /**
956
+ * @param {Parameters<writeFile>[0]} outFile
957
+ * @param {Parameters<writeFile>[1]} content
958
+ * @param {Parameters<writeFile>[2]} [options]
959
+ * @returns {ReturnType<typeof TryAsync<void>>}
960
+ */
961
+ ```
962
+ - <i>example</i>:
963
+ ```js
964
+ import { join } from 'node:path';
965
+ import { FileSafe, Paths } from 'vivth';
966
+
967
+ const [, errorWrite] = await FileSafe.write(
968
+ join(Paths.root, '/some/path.mjs'),
969
+ `console.log("hello-world!!");`,
970
+ { encoding: 'utf-8' }
971
+ );
972
+
973
+ ```
974
+
975
+ #### reference:`FileSafe.copy`
976
+ - method to copy file/dir safely by recursively mkdir the dirname of the dest;
977
+ - also returning promise of result & error as value;
978
+
979
+ ```js
980
+ /**
981
+ * @param {Parameters<typeof copyFile>[0]} sourceFile
982
+ * @param {Parameters<typeof copyFile>[1]} destinationFile
983
+ * @param {Parameters<typeof copyFile>[2]} mode
984
+ * @returns {ReturnType<typeof TryAsync<void>>}
985
+ */
986
+ ```
987
+ - <i>example</i>:
988
+ ```js
989
+ import { join } from 'node:path';
990
+ import { FileSafe, Paths } from 'vivth';
991
+
992
+ const [, errorWrite] = await FileSafe.copy(
993
+ join(Paths.root, '/some/path.mjs'),
994
+ join(Paths.root, '/other/path.copy.mjs'),
995
+ { encoding: 'utf-8' }
996
+ );
997
+
998
+ ```
999
+
1000
+ #### reference:`FileSafe.rename`
1001
+ - method to rename file/dir safely by recursively mkdir the dirname of the dest;
1002
+ - also returning promise of result & error as value;
1003
+
1004
+ ```js
1005
+ /**
1006
+ * @param {Parameters<typeof rename>[0]} oldPath
1007
+ * @param {Parameters<typeof rename>[0]} newPath
1008
+ * @returns {ReturnType<typeof TryAsync<void>>}
1009
+ */
1010
+ ```
1011
+ - <i>example</i>:
1012
+ ```js
1013
+ import { join } from 'node:path';
1014
+ import { FileSafe, Paths } from 'vivth';
1015
+
1016
+ const [, errorRename] = await FileSafe.rename(
1017
+ join(Paths.root, 'some/path'),
1018
+ join(Paths.root, 'other/path'),
1019
+ );
1020
+
1021
+ ```
1022
+
1023
+ #### reference:`FileSafe.rm`
1024
+ - function to remove dir and file;
1025
+ - also returning promise of result & error as value;
1026
+
1027
+ ```js
1028
+ /**
1029
+ * @param {Parameters<rm>[0]} path
1030
+ * @param {Parameters<rm>[1]} [rmOptions]
1031
+ * @returns {ReturnType<typeof TryAsync<void>>}
1032
+ */
1033
+ ```
1034
+
1035
+ #### reference:`FileSafe.mkdir`
1036
+ - create directory recursively;
1037
+ - also returning promise of result & error as value;
1038
+
1039
+ ```js
1040
+ /**
1041
+ * @param {Parameters<mkdir>[0]} outDir
1042
+ * - absolute path
1043
+ * @returns {ReturnType<typeof TryAsync<string>>}
1044
+ */
1045
+ ```
1046
+ - <i>example</i>:
1047
+ ```js
1048
+ import { join } from 'node:path';
1049
+ import { FileSafe, Paths } from 'vivth';
1050
+
1051
+ const [str, errorMkDir] = await FileSafe.mkdir(join(Paths.root, '/some/path/example'));
1052
+
1053
+ ```
1054
+
1055
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1056
+
593
1057
  <h2 id="listderived">ListDerived</h2>
594
1058
 
595
1059
 
@@ -600,8 +1064,8 @@ npm i vivth
600
1064
 
601
1065
  ```js
602
1066
  /**
603
- * @template {ListArg} LA
604
- * @extends {Derived<LA[]>}
1067
+ * @template {ListArg} LISTARG
1068
+ * @extends {Derived<LISTARG[]>}
605
1069
  */
606
1070
  ```
607
1071
 
@@ -610,7 +1074,9 @@ npm i vivth
610
1074
 
611
1075
  ```js
612
1076
  /**
613
- * @param {(effectInstanceOptions:Effect["options"])=>Promise<LA[]>} derivedFunction
1077
+ * @param {(effectInstanceOptions:Omit<Effect["options"],
1078
+ * unwrapLazy>)=>
1079
+ * Promise<LISTARG[]>} derivedFunction
614
1080
  */
615
1081
  ```
616
1082
  - <i>example</i>:
@@ -642,8 +1108,8 @@ npm i vivth
642
1108
 
643
1109
  ```js
644
1110
  /**
645
- * @template {import('../types/ListArg.mjs').ListArg} LA
646
- * @extends {Signal<LA[]>}
1111
+ * @template {import('../types/ListArg.mjs').ListArg} LISTARG
1112
+ * @extends {Signal<LISTARG[]>}
647
1113
  */
648
1114
  ```
649
1115
 
@@ -663,7 +1129,7 @@ npm i vivth
663
1129
 
664
1130
  ```js
665
1131
  /**
666
- * @param {LA[]} [value]
1132
+ * @param {LISTARG[]} [value]
667
1133
  */
668
1134
  ```
669
1135
  - <i>example</i>:
@@ -682,7 +1148,7 @@ npm i vivth
682
1148
 
683
1149
  ```js
684
1150
  /**
685
- * @type {LA[]}
1151
+ * @returns {LISTARG[]}
686
1152
  */
687
1153
  ```
688
1154
 
@@ -692,7 +1158,7 @@ npm i vivth
692
1158
  ```js
693
1159
  /**
694
1160
  * @private
695
- * @type {LA[]}
1161
+ * @type {LISTARG[]}
696
1162
  */
697
1163
  ```
698
1164
 
@@ -707,7 +1173,7 @@ npm i vivth
707
1173
 
708
1174
  ```js
709
1175
  /**
710
- * @type {Array<LA>}
1176
+ * @returns {Array<LISTARG>}
711
1177
  */
712
1178
  ```
713
1179
 
@@ -716,7 +1182,7 @@ npm i vivth
716
1182
 
717
1183
  ```js
718
1184
  /**
719
- * @param {...LA} listArg
1185
+ * @param {...LISTARG} listArg
720
1186
  * @returns {void}
721
1187
  */
722
1188
  ```
@@ -735,7 +1201,7 @@ npm i vivth
735
1201
 
736
1202
  ```js
737
1203
  /**
738
- * @param {...LA} listArg
1204
+ * @param {...LISTARG} listArg
739
1205
  * @returns {void}
740
1206
  */
741
1207
  ```
@@ -758,7 +1224,7 @@ npm i vivth
758
1224
 
759
1225
  ```js
760
1226
  /**
761
- * @param {LA[]} listArgs
1227
+ * @param {LISTARG[]} listArgs
762
1228
  * - new array in place of the deleted array.
763
1229
  * @returns {void}
764
1230
  */
@@ -773,60 +1239,267 @@ npm i vivth
773
1239
  * - The zero-based location in the data from which to start removing elements.
774
1240
  * @param {number} deleteCount
775
1241
  * -The number of elements to remove.
776
- * @param {...LA} listArg
1242
+ * @param {...LISTARG} listArg
777
1243
  * - new data in place of the deleted data.
778
1244
  * @returns {void}
779
1245
  */
780
1246
  ```
781
1247
 
782
- #### reference:`ListSignal_instance.arrayMethods.swap`
783
- - swap `List` data between two indexes;
1248
+ #### reference:`ListSignal_instance.arrayMethods.swap`
1249
+ - swap `List` data between two indexes;
1250
+
1251
+ ```js
1252
+ /**
1253
+ * @param {number} indexA
1254
+ * @param {number} indexB
1255
+ * @returns {void}
1256
+ */
1257
+ ```
1258
+
1259
+ #### reference:`ListSignal_instance.arrayMethods.modify`
1260
+ - modify `List` element at specific index;
1261
+
1262
+ ```js
1263
+ /**
1264
+ * @param {number} index
1265
+ * @param {Partial<LISTARG>} listArg
1266
+ * @returns {void}
1267
+ */
1268
+ ```
1269
+
1270
+ #### reference:`ListSignal_instance.arrayMethods.remove`
1271
+ - remove `List` element at specific index;
1272
+
1273
+ ```js
1274
+ /**
1275
+ * @param {number} index
1276
+ * @returns {void}
1277
+ */
1278
+ ```
1279
+
1280
+ #### reference:`ListSignal_instance.arrayMethods.reverse`
1281
+ - reverses the elements in an `List` in place.
1282
+
1283
+ ```js
1284
+ /**
1285
+ * @returns {void}
1286
+ */
1287
+ ```
1288
+
1289
+ #### reference:`ListSignal_instance.arrayMethods.pop`
1290
+ - removes the last element;
1291
+
1292
+ ```js
1293
+ /**
1294
+ * @returns {void}
1295
+ */
1296
+ ```
1297
+
1298
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1299
+
1300
+ <h2 id="litexp">LitExp</h2>
1301
+
1302
+
1303
+ #### reference:`LitExp`
1304
+ - class helper to created opionated regex helper;
1305
+ - named capture uses `es6+` feature, you might need to add polyfill to target extremely old browser;
1306
+ - class name refer to `Literal Expression`;
1307
+ - please be patient when using this class;
1308
+ >- destructuring is meant for extensive typehelper;
1309
+ >- and destructuring can lead to unhandled error here and there;
1310
+ >- therefore error as value is introduced to help to prevent error on runtime;
784
1311
 
785
1312
  ```js
786
1313
  /**
787
- * @param {number} indexA
788
- * @param {number} indexB
789
- * @returns {void}
1314
+ * @template {LitExpKeyType} KEYS
790
1315
  */
791
1316
  ```
792
1317
 
793
- #### reference:`ListSignal_instance.arrayMethods.modify`
794
- - modify `List` element at specific index;
1318
+ #### reference:`LitExp.prepare`
1319
+ - constructor helper;
1320
+ - under the hood it is an abstraction of `RegExp`, with more template literal touch;
1321
+ >- you can apply inline `RegExp` features on the string template literal(as constructor RegExp arg0);
1322
+ >>- by doing so you are opting in to make:
1323
+ >>>- your regex detection more robust; but
1324
+ >>>- `litExp_instance.make.string` to be `unusable`;
1325
+ >>- also mind the needs of escape for special characters;
795
1326
 
796
1327
  ```js
797
1328
  /**
798
- * @param {number} index
799
- * @param {Partial<LA>} listArg
800
- * @returns {void}
1329
+ * @template {LitExpKeyType} KEYS
1330
+ * @param {KEYS} keysAndDefaultValuePair
1331
+ * - keys and whether to override regex detection;
1332
+ * >- example:
1333
+ * ```js
1334
+ * myKey: /myCustomCapture/ // all flags will be stripped;
1335
+ * ```
1336
+ * - default value === `false` is "[\\s\\S]
1337
+ *?", as in whiteSpace and nonWhiteSpace 0 to more occurence;
1338
+ * @returns {ReturnType<typeof TrySync<(templateStringArray:TemplateStringsArray,
1339
+ * ...values:(keyof KEYS)[]
1340
+ * )=>LitExp<KEYS>>>}
1341
+ * - placement of `key` will determine the named capture group will be placed in the template literal;
1342
+ * - it is recomended to not end template literal with any of the `key`s as the regex detection might failed to detects the boundary of the end of matched string of that capture group;
801
1343
  */
1344
+ ```
1345
+ - <i>example</i>:
1346
+ ```js
1347
+ import { LitExp } from 'vivth';
1348
+
1349
+ (()=>{
1350
+ const [liteal, errorPrep] = LitExp.prepare({
1351
+ myKey: /myCustomCapture/, // is placed on (?<myKey>myCustomCapture)
1352
+ // use false to place "[\\s\\S]*?" instead;
1353
+ ...keyCaptureLogicPair
1354
+ })
1355
+ if (errorPrep) {
1356
+ console.error(error);
1357
+ return;
1358
+ }
1359
+ const litExp_instance = liteal`templateLiteral:${'myKey'};`
1360
+ // recommended to end the template literal with any string but `key`;
1361
+ })()
1362
+
802
1363
  ```
803
1364
 
804
- #### reference:`ListSignal_instance.arrayMethods.remove`
805
- - remove `List` element at specific index;
1365
+ #### reference:`LitExp_instance.make`
1366
+ - instance methods for generating things;
1367
+
1368
+
1369
+ #### reference:`LitExp_instance.make.string`
1370
+ - to make string based on the template literal;
806
1371
 
807
1372
  ```js
808
1373
  /**
809
- * @param {number} index
810
- * @returns {void}
1374
+ * @param {Partial<ReturnType<LitExp<KEYS>["evaluate"]["execGroups"]>>[0]["result"]} overrides
1375
+ * @returns {string}
811
1376
  */
1377
+ ```
1378
+ - <i>example</i>:
1379
+ ```js
1380
+ import { LitExp } from 'vivth';
1381
+
1382
+ const [literal, errorPreparing] = LitExp.prepare({
1383
+ myKey: false,
1384
+ ...keyCaptureLogicPair
1385
+ })
1386
+
1387
+ // asuming no error
1388
+ litExp_instance = `templateLiteral:${'myKey'};`;
1389
+ const [result, error] = litExp_instance.make.string({
1390
+ myKey: 'actualvalue',
1391
+ });
1392
+
1393
+ console.log(result); // "templateLiteral:actualvalue;"
1394
+
812
1395
  ```
813
1396
 
814
- #### reference:`ListSignal_instance.arrayMethods.reverse`
815
- - reverses the elements in an `List` in place.
1397
+ #### reference:`LitExp_instance.evaluate`
1398
+ - methods collections to evaluate string with `Literal Expression`;
1399
+
1400
+
1401
+ #### reference:`LitExp_instance.evaluate.execGroups`
1402
+ - to exec and grouped based on `key`;
816
1403
 
817
1404
  ```js
818
1405
  /**
819
- * @returns {void}
1406
+ * @param {string} string
1407
+ * @param {Object} options
1408
+ * @param {ConstructorParameters<typeof RegExp>[1]} options.flags
1409
+ * @param {boolean} options.whiteSpaceSensitive
1410
+ * - true: leave any whitespace as is to be used as regex detection;
1411
+ * - false: convert all whitespace to `\s+`;
1412
+ * @param {boolean} options.absoluteLeadAndFollowing
1413
+ * - false: standard capture;
1414
+ * - true: add `^` and `<h2 id="litexp">LitExp</h2>
1415
+
1416
+ to capture definition:
1417
+ * >- meaning string will have to match starting and end of line from capture definition;
1418
+ * @returns {ReturnType<typeof TrySync<{
1419
+ * result:{ whole:string, named: Record<keyof KEYS, string>},
1420
+ * regexp:RegExp}>>
1421
+ * }
820
1422
  */
1423
+ ```
1424
+ - <i>example</i>:
1425
+ ```js
1426
+ import { LitExp } from 'vivth';
1427
+
1428
+ const [literal, errorPreparing] = LitExp.prepare({
1429
+ myKey: false,
1430
+ ...keyCaptureLogicPair
1431
+ })
1432
+
1433
+ // asuming no eror
1434
+ const litExp_instance = literal`templateLiteral:${'myKey'};`
1435
+
1436
+ const [{
1437
+ result:{ // asuming there's no error
1438
+ named: { myKey },
1439
+ whole,
1440
+ },
1441
+ regex, // for reference
1442
+ }, error] = litExp_instance.evaluate.execGroups(
1443
+ `templateLiteral:Something;`,
1444
+ { ...options }
1445
+ )
1446
+
1447
+ console.log(whole); // "templateLiteral:Something;"
1448
+ console.log(myKey); // "Something"
1449
+
821
1450
  ```
822
1451
 
823
- #### reference:`ListSignal_instance.arrayMethods.pop`
824
- - removes the last element;
1452
+ #### reference:`LitExp_instance.evaluate.matchedAllAndGrouped`
1453
+ - to match all and grouped based on `key`;
825
1454
 
826
1455
  ```js
827
1456
  /**
828
- * @returns {void}
1457
+ * @param {Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[0]} string
1458
+ * @param {Omit<Parameters<LitExp<KEYS>["evaluate"]["execGroups"]>[1], 'absoluteLeadAndFollowing'>} options
1459
+ * @returns {ReturnType<typeof TrySync<{result:{whole:string[], named:Array<Record<keyof KEYS, string>>},
1460
+ * regexp: RegExp}>>
1461
+ * }
829
1462
  */
1463
+ ```
1464
+ - <i>example</i>:
1465
+ ```js
1466
+ import { LitExp, Console } from 'vivth';
1467
+
1468
+ const [literal, errorPreparing] = LitExp.prepare({
1469
+ myKey: false,
1470
+ ...keyCaptureLogicPair
1471
+ })
1472
+
1473
+ // asuming no error;
1474
+ litExp_instance = literal`templateLiteral:${'myKey'};`
1475
+
1476
+ const [resultOfMatchedAllAndGrouped, error] = litExp_instance.evaluate.matchedAllAndGrouped(
1477
+ `templateLiteral:Something;
1478
+ templateLiteral:SomethingElse;`,
1479
+ { ...options }
1480
+ )
1481
+ (()=>{
1482
+ if (error) {
1483
+ Console.error(error);
1484
+ return;
1485
+ }
1486
+ const {
1487
+ result: {
1488
+ whole: [whole0, whole1],
1489
+ named: [
1490
+ { myKey: myKeyExec0, },
1491
+ { myKey: myKeyExec1, },
1492
+ ],
1493
+ },
1494
+ regexp
1495
+ } = resultOfMatchedAllAndGrouped;
1496
+
1497
+ console.log(whole0); // "templateLiteral:Something;"
1498
+ console.log(whole1); // "templateLiteral:SomethingElse;"
1499
+ console.log(myKeyExec0); // "Something"
1500
+ console.log(myKeyExec1); // "SomethingElse"
1501
+ })()
1502
+
830
1503
  ```
831
1504
 
832
1505
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
@@ -836,7 +1509,8 @@ npm i vivth
836
1509
 
837
1510
  #### reference:`Paths`
838
1511
  - class helpers to define pathReference;
839
- - is a singleton;
1512
+ - is a singleton;
1513
+ - most of functionality need to access `Paths.root`, if you get warning, you can instantiate `Paths` before running anything;
840
1514
 
841
1515
 
842
1516
  #### reference:`new Paths`
@@ -858,6 +1532,10 @@ npm i vivth
858
1532
  * ```js
859
1533
  * Deno.env.get("INIT_CWD") ?? Deno.cwd()
860
1534
  * ```
1535
+ * - pkg:
1536
+ * ```js
1537
+ * __dirname
1538
+ * ```
861
1539
  * - other: you need to check your JSRuntime for the rootPath reference;
862
1540
  */
863
1541
  ```
@@ -896,7 +1574,25 @@ npm i vivth
896
1574
  ```js
897
1575
  import { Paths } from 'vivth';
898
1576
 
899
- Paths.normalize('file:\\D:\\myFile.mjs'); // return 'file://D://myFile.mjs'
1577
+ Paths.normalize('file:\\D:\\myFile.mjs'); // "file://D://myFile.mjs"
1578
+
1579
+ ```
1580
+
1581
+ #### reference:`Paths.normalizesForRoot`
1582
+ - normalize path separator to forward slash `/`;
1583
+ - then starts with forward slash `/`;
1584
+
1585
+ ```js
1586
+ /**
1587
+ * @param {string} path_
1588
+ * @returns {`/${string}`}
1589
+ */
1590
+ ```
1591
+ - <i>example</i>:
1592
+ ```js
1593
+ import { Paths } from 'vivth';
1594
+
1595
+ Paths.normalizesForRoot('path\\myFile.mjs'); // "/path/myFile.mjs"
900
1596
 
901
1597
  ```
902
1598
 
@@ -910,7 +1606,7 @@ npm i vivth
910
1606
 
911
1607
  ```js
912
1608
  /**
913
- * @template {AnyButUndefined} T
1609
+ * @template {AnyButUndefined} DEFINEDANY
914
1610
  */
915
1611
  ```
916
1612
 
@@ -921,8 +1617,16 @@ npm i vivth
921
1617
  /**
922
1618
  * @param {Map<AnyButUndefined, [Promise<any>, {}]>} uniqueMap
923
1619
  * @returns {typeof QChannel}
924
- * - usefull for Queue primitive on multiple library but single reference, like the Web by making the `Map` on `window` object;
1620
+ * - usefull for Queue primitive on multiple library but single reference, like the Web by making the `Map` on `window` object;
925
1621
  */
1622
+ ```
1623
+ - <i>example</i>:
1624
+ ```js
1625
+ import { QChannel } from 'vivth';
1626
+
1627
+ const myMappedQref = (window['myMappedQref'] = new Map());
1628
+ export const MyQClass = QChannel.makeQClass(myMappedQref);
1629
+
926
1630
  ```
927
1631
 
928
1632
  #### reference:`QChannel.fifo`
@@ -950,9 +1654,9 @@ npm i vivth
950
1654
 
951
1655
  ```js
952
1656
  /**
953
- * @template ResultType
954
- * @param {()=>Promise<ResultType>} asyncCallback
955
- * @returns {Promise<[ResultType|undefined, Error|undefined]>}
1657
+ * @template RESULT
1658
+ * @param {()=>Promise<RESULT>} asyncCallback
1659
+ * @returns {Promise<[RESULT|undefined, Error|undefined]>}
956
1660
  */
957
1661
  ```
958
1662
  - <i>example</i>:
@@ -963,9 +1667,19 @@ npm i vivth
963
1667
 
964
1668
  ```
965
1669
 
966
- #### reference:`QChannel_instance.clear`
967
- - clear up all queued on the instance;
968
- - only clear up the reference, the already called will not be stoped;
1670
+ #### reference:`QChannel_instance.close`
1671
+ - disable queue;
1672
+ - when `closed`, `isLastOnQ` will allways return `false`;
1673
+
1674
+ ```js
1675
+ /**
1676
+ * @returns {void}
1677
+ */
1678
+ ```
1679
+
1680
+ #### reference:`QChannel_instance.open`
1681
+ - enable queue;
1682
+ - when `opened`, `isLastOnQ` will evaluate whether calls are actually the last of queue;
969
1683
 
970
1684
  ```js
971
1685
  /**
@@ -981,16 +1695,16 @@ npm i vivth
981
1695
 
982
1696
  ```js
983
1697
  /**
984
- * @param {T} keyID
1698
+ * @param {DEFINEDANY} keyID
985
1699
  * @returns {Promise<QCBReturn>}
986
1700
  */
987
1701
  ```
988
1702
  - <i>example</i>:
989
1703
  ```js
990
- const q = new QChannel();
1704
+ const q = new QChannel('channel name');
991
1705
  const handler = async () => {
992
1706
  const { resume, isLastOnQ } = await q.key(keyID);
993
- // if (!isLastOnQ) { // imperative debounce if needed
1707
+ // if (!isLastOnQ()) { // imperative debounce if needed
994
1708
  // resume();
995
1709
  // return;
996
1710
  // }
@@ -1011,17 +1725,19 @@ npm i vivth
1011
1725
 
1012
1726
  ```js
1013
1727
  /**
1014
- * @template ResultType
1015
- * @param {T} keyID
1016
- * @param {(options:Omit<QCBReturn, "resume">)=>Promise<ResultType>} asyncCallback
1017
- * @returns {Promise<[ResultType|undefined, Error|undefined]>}
1728
+ * @template RESULT
1729
+ * @param {DEFINEDANY} keyID
1730
+ * @param {(options:Omit<QCBReturn,
1731
+ * "resume">) =>
1732
+ * Promise<RESULT>} asyncCallback
1733
+ * @returns {ReturnType<typeof TryAsync<RESULT>>}
1018
1734
  */
1019
1735
  ```
1020
1736
  - <i>example</i>:
1021
1737
  ```js
1022
- const q = new QChannel();
1738
+ const q = new QChannel('channel name');
1023
1739
  const [result, error] = await q.callback(keyID, async ({ isLastOnQ }) = > {
1024
- // if (!isLastOnQ) { // imperative debounce if needed
1740
+ // if (!isLastOnQ()) { // imperative debounce if needed
1025
1741
  // return;
1026
1742
  // }
1027
1743
  // code
@@ -1036,13 +1752,9 @@ npm i vivth
1036
1752
 
1037
1753
  #### reference:`SafeExit`
1038
1754
  - class helper for describing how to Safely Response on exit events
1039
- - singleton;
1755
+ - singleton;
1756
+ - most of functionality might need to access `SafeExit.instance.exiting`, if you get warning, you can instantiate `SafeExit` before running anything;
1040
1757
 
1041
- ```js
1042
- /**
1043
- * @template {[string, ...string[]]} eventNames
1044
- */
1045
- ```
1046
1758
 
1047
1759
  #### reference:`SafeExit.instance`
1048
1760
  - only accessible after instantiation;
@@ -1059,7 +1771,13 @@ npm i vivth
1059
1771
  ```js
1060
1772
  /**
1061
1773
  * @param {Object} options
1062
- * @param {eventNames} options.eventNames
1774
+ * @param {[string, ...string[]]} options.eventNames
1775
+ * - eventNames are blank by default, you need to manually name them all;
1776
+ * - 'exit' will be omited, as it might cause async callbacks failed to execute;
1777
+ * - example:
1778
+ * ```js
1779
+ * ['SIGINT', 'SIGTERM']
1780
+ * ```
1063
1781
  * @param {()=>void} options.terminator
1064
1782
  * - standard node/bun:
1065
1783
  * ```js
@@ -1079,6 +1797,17 @@ npm i vivth
1079
1797
  * });
1080
1798
  * };
1081
1799
  * ```
1800
+ * - example Deno:
1801
+ * ```js
1802
+ * (eventName) => {
1803
+ * const sig = Deno.signal(eventName);
1804
+ * for await (const _ of sig) {
1805
+ * exiting.correction(true);
1806
+ * sig.dispose();
1807
+ * Console.log(`safe exit via "${eventName}"`);
1808
+ * }
1809
+ * }
1810
+ * ```
1082
1811
  * - if your exit callback doesn't uses `process` global object you need to input on the SafeExit instantiation
1083
1812
  */
1084
1813
  ```
@@ -1087,12 +1816,10 @@ npm i vivth
1087
1816
  import { SafeExit, Console } from 'vivth';
1088
1817
 
1089
1818
  new SafeExit({
1090
- // eventNames are blank by default, you need to manually name them all;
1091
- // 'exit' will be omited, as it might cause async callbacks failed to execute;
1092
1819
  eventNames: ['SIGINT', 'SIGTERM', ...eventNames],
1093
- terminator = () => process.exit(0), // OR on deno () => Deno.exit(0),
1820
+ terminator : () => process.exit(0), // OR on deno () => Deno.exit(0),
1094
1821
  // optional deno example
1095
- listener = (eventName) => {
1822
+ listener : (eventName) => {
1096
1823
  const sig = Deno.signal(eventName);
1097
1824
  for await (const _ of sig) {
1098
1825
  exiting.correction(true);
@@ -1189,9 +1916,10 @@ npm i vivth
1189
1916
  - <i>example</i>:
1190
1917
  ```js
1191
1918
  import { Setup } from 'vivth';
1919
+ import { Worker } from 'node:worker_threads';
1192
1920
 
1193
1921
  Setup.workerMain({
1194
- workerClass: async () => await (import('worker_threads')).Worker,
1922
+ workerClass: Worker,
1195
1923
  basePath: 'public/assets/js/workers',
1196
1924
  pathValidator: async (workerPath, root, base) => {
1197
1925
  const res = await fetch(`${root}/${base}/${workerPath}`);
@@ -1203,14 +1931,16 @@ npm i vivth
1203
1931
  ```
1204
1932
 
1205
1933
  #### reference:`Setup.workerThread`
1206
- - correct `parentPort` reference when needed;
1934
+ - correct `parentPort` reference when needed;
1935
+ - export to create new reference to be use to create new WorkerThread instance;
1207
1936
 
1208
1937
 
1209
1938
  - <i>example</i>:
1210
1939
  ```js
1211
1940
  import { Setup } from 'vivth';
1941
+ import { parentPort } from 'node:worker_threads';
1212
1942
 
1213
- Setup.workerThread({ parentPort: async () => (await import('node:worker_threads')).parentPort });
1943
+ export const MyWorkerThreadRef = Setup.workerThread({parentPort});
1214
1944
  // that is the default value, if your parentPort/equivalent API is not that;
1215
1945
  // you need to call this method;
1216
1946
 
@@ -1226,8 +1956,24 @@ npm i vivth
1226
1956
 
1227
1957
  ```js
1228
1958
  /**
1229
- * @template Value
1959
+ * @template VALUE
1960
+ */
1961
+ ```
1962
+
1963
+ #### reference:`new Signal`
1964
+ - create a `Signal`;
1965
+
1966
+ ```js
1967
+ /**
1968
+ * @param {VALUE} value
1230
1969
  */
1970
+ ```
1971
+ - <i>example</i>:
1972
+ ```js
1973
+ import { Signal, Effect } from 'vivth';
1974
+
1975
+ const count = new Signal(0);
1976
+
1231
1977
  ```
1232
1978
 
1233
1979
  #### reference:`Signal_instance.subscribers`
@@ -1248,20 +1994,20 @@ npm i vivth
1248
1994
 
1249
1995
  ```js
1250
1996
  /**
1251
- * @param {(options:{signalInstance:Signal<Value>})=>Promise<void>} [callback]
1997
+ * @param {(options:{signalInstance:Signal<VALUE>})=>Promise<void>} [callback]
1252
1998
  * @returns {void}
1253
1999
  */
1254
2000
  ```
1255
2001
  - <i>example</i>:
1256
2002
  ```js
1257
- // for deep signal like array or object you can:
2003
+ import { Signal } from 'vivth';
1258
2004
 
2005
+ // for deep signal like array or object you can:
1259
2006
  const arraySignal = new Signal([1,2]);
1260
2007
  arraySignal.value.push(3);
1261
2008
  arraySignal.subscribers.notify();
1262
2009
 
1263
2010
  // OR for more complex mutation:
1264
-
1265
2011
  const objectSignal = new Signal({a:'test', b:'test'});
1266
2012
  objectSignal.subscribers.notify(async ({ signalInstance }) => {
1267
2013
  signalInstance.value['c'] = 'testc';
@@ -1302,28 +2048,12 @@ npm i vivth
1302
2048
  */
1303
2049
  ```
1304
2050
 
1305
- #### reference:`new Signal`
1306
-
1307
-
1308
- ```js
1309
- /**
1310
- * @param {Value} value
1311
- */
1312
- ```
1313
- - <i>example</i>:
1314
- ```js
1315
- import { Signal, Effect } from 'vivth';
1316
-
1317
- const count = new Signal(0);
1318
-
1319
- ```
1320
-
1321
2051
  #### reference:`Signal_instance.prev:getter`
1322
2052
  - value before change;
1323
2053
 
1324
2054
  ```js
1325
2055
  /**
1326
- * @type {Value}
2056
+ * @returns {VALUE}
1327
2057
  */
1328
2058
  ```
1329
2059
 
@@ -1332,7 +2062,7 @@ npm i vivth
1332
2062
 
1333
2063
  ```js
1334
2064
  /**
1335
- * @type {Value}
2065
+ * @returns {VALUE}
1336
2066
  */
1337
2067
  ```
1338
2068
  - <i>example</i>:
@@ -1345,7 +2075,7 @@ npm i vivth
1345
2075
  new Effect(async ({ subscribe }) =>{
1346
2076
  const countValue = subscribe(count).value; // reactive
1347
2077
  })
1348
- const oneMoreThanCount = new Effect(async ({ subscribe }) =>{
2078
+ const oneMoreThanCount = new Derived(async ({ subscribe }) =>{
1349
2079
  return subscribe(count).value + 1; // reactive
1350
2080
  })
1351
2081
 
@@ -1356,7 +2086,7 @@ npm i vivth
1356
2086
 
1357
2087
  ```js
1358
2088
  /**
1359
- * @type {Value}
2089
+ * @type {VALUE}
1360
2090
  */
1361
2091
  ```
1362
2092
  - <i>example</i>:
@@ -1376,7 +2106,8 @@ npm i vivth
1376
2106
 
1377
2107
 
1378
2108
  #### reference:`WorkerMainThread`
1379
- - class helper to create `Worker` instance;
2109
+ - class helper to create `Worker` instance;
2110
+ - before any `Worker` functionaily to be used, you need to setup it with `WorkerThread.setup` and `WorkerMainThread.setup` before runing anytyhing;
1380
2111
 
1381
2112
  ```js
1382
2113
  /**
@@ -1393,13 +2124,14 @@ npm i vivth
1393
2124
  * @param {typeof WorkerMainThread["workerClass"]} param0.workerClass
1394
2125
  * - example:
1395
2126
  * ```js
1396
- * async () => await (import('worker_threads')).Worker
2127
+ * import { Worker } from 'node:worker_threads';
1397
2128
  * ```
1398
2129
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
1399
2130
  * - example:
1400
2131
  * ```js
1401
2132
  * async (workerPath, root, base) => {
1402
- * const res = await fetch(`${root}/${base}/${workerPath}`);
2133
+ * const truePathCheck = `${root}/${base}/${workerPath}`;
2134
+ * const res = await fetch(truePathCheck);
1403
2135
  * // might also check wheter it need base or not
1404
2136
  * return await res.ok;
1405
2137
  * }
@@ -1411,10 +2143,11 @@ npm i vivth
1411
2143
  ```
1412
2144
  - <i>example</i>:
1413
2145
  ```js
2146
+ import { Worker } from 'node:worker_threads';
1414
2147
  import { WorkerMainThread } from 'vivth';
1415
2148
 
1416
2149
  WorkerMainThread.setup({
1417
- workerClass: async () => await (import('worker_threads')).Worker,
2150
+ workerClass: Worker,
1418
2151
  basePath: 'public/assets/js/workers',
1419
2152
  pathValidator: async (workerPath, root, base) => {
1420
2153
  const res = await fetch(`${root}/${base}/${workerPath}`);
@@ -1431,7 +2164,7 @@ npm i vivth
1431
2164
 
1432
2165
  ```js
1433
2166
  /**
1434
- * @type {()=>Promise<typeof Worker|typeof import('worker_threads').Worker>}
2167
+ * @type {typeof Worker|typeof import('worker_threads').Worker}
1435
2168
  */
1436
2169
  ```
1437
2170
 
@@ -1441,218 +2174,82 @@ npm i vivth
1441
2174
 
1442
2175
  ```js
1443
2176
  /**
1444
- * @type {string}
1445
- */
1446
- ```
1447
-
1448
- #### reference:`WorkerMainThread.pathValidator`
1449
- - reference for validating path;
1450
- - edit via `setup`;
1451
-
1452
- ```js
1453
- /**
1454
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
1455
- */
1456
- ```
1457
-
1458
- #### reference:`new WorkerMainThread`
1459
- - create Worker_instance;
1460
-
1461
- ```js
1462
- /**
1463
- * @param {string} handler
1464
- * - if `isInline` === `false`, `handler` should be:
1465
- * >- pointing to worker thread file; WHICH
1466
- * >- the path must be relative to `projectRoot`;
1467
- * - if `isInline` === `true`, `handler` should be
1468
- * >- string literal of prebundled worker thread script; OR
1469
- * >- manually made string literal of worker thread script;
1470
- * @param {Omit<WorkerOptions|import('worker_threads').WorkerOptions, 'eval'|'type'>} [options]
1471
- * @param {boolean} [isInline]
1472
- */
1473
- ```
1474
- - <i>example</i>:
1475
- ```js
1476
- import { WorkerMainThread } from 'vivth';
1477
-
1478
- export const myDoubleWorker = new WorkerMainThread('./doubleWorkerThread.mjs');
1479
-
1480
- ```
1481
-
1482
- #### reference:`WorkerMainThread.isBrowser:getter`
1483
- - check whether js run in browser
1484
-
1485
- ```js
1486
- /**
1487
- * @type {boolean}
1488
- */
1489
- ```
1490
-
1491
- #### reference:`WorkerMainThread_instance.terminate`
1492
- - terminate all signals that are used on this instance;
1493
-
1494
- ```js
1495
- /**
1496
- * @type {()=>void}
1497
- */
1498
- ```
1499
-
1500
- #### reference:`WorkerMainThread_instance.receiverSignal`
1501
- - result signal of the processed message;
1502
-
1503
- ```js
1504
- /**
1505
- * @type {Derived<WorkerResult<WT["Post"]>>}
1506
- */
1507
- ```
1508
- - <i>example</i>:
1509
- ```js
1510
- import { Effect } from 'vivth';
1511
- import { myDoubleWorker } from './myDoubleWorker.mjs';
1512
-
1513
- const doubleReceiverSignal = myDoubleWorker.receiverSignal;
1514
- new Effect(async({ subscribe }) => {
1515
- const value = subscribe(doubleReceiverSignal).value;
1516
- // code
1517
- })
1518
-
1519
- ```
1520
-
1521
- #### reference:`WorkerMainThread_instance.postMessage`
1522
- - callback to send message to the worker thread;
1523
-
1524
- ```js
1525
- /**
1526
- * @type {(event: WT["Receive"])=>void}
1527
- */
1528
- ```
1529
- - <i>example</i>:
1530
- ```js
1531
- import { myDoubleWorker } from './myDoubleWorker.mjs';
1532
-
1533
- myDoubleWorker.postMessage(90);
1534
-
1535
- ```
1536
-
1537
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1538
-
1539
- <h2 id="workerresult">WorkerResult</h2>
1540
-
1541
-
1542
- #### reference:`WorkerResult`
1543
- - typeHelper for `Worker` message passing;
1544
- - uses error as value instead;
1545
-
1546
- ```js
1547
- /**
1548
- * @template POST
1549
- */
1550
- ```
1551
-
1552
- #### reference:`WorkerResult_instance.data`
1553
- - result value;
1554
-
1555
- ```js
1556
- /**
1557
- * @type {POST}
1558
- */
1559
- ```
1560
-
1561
- #### reference:`WorkerResult_instance.error`
1562
- - error value;
1563
-
1564
- ```js
1565
- /**
1566
- * @type {Error|string|undefined}
1567
- */
1568
- ```
1569
-
1570
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1571
-
1572
- <h2 id="workerthread">WorkerThread</h2>
1573
-
1574
-
1575
- #### reference:`WorkerThread`
1576
- - class helper for `WorkerThread` creation;
1577
-
1578
- ```js
1579
- /**
1580
- * @template Receive
1581
- * @template Post
2177
+ * @type {string}
1582
2178
  */
1583
2179
  ```
1584
2180
 
1585
- #### reference:`WorkerThread.setup`
1586
- - need to be called and exported as new `WorkerThread` class reference;
2181
+ #### reference:`WorkerMainThread.pathValidator`
2182
+ - reference for validating path;
2183
+ - edit via `setup`;
1587
2184
 
1588
2185
  ```js
1589
2186
  /**
1590
- * @template Receive_
1591
- * @template Post_
1592
- * @param {{parentPort:()=>Promise<any>}} parentPortRef
1593
- * - correct parentPort reference, example:
1594
- * ```js
1595
- * async () => (await import('node:worker_threads')).parentPort
1596
- * ```
1597
- * @returns {typeof WorkerThread<Receive_, Post_>}
2187
+ * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
1598
2188
  */
1599
- ```
1600
- - <i>example</i>:
1601
- ```js
1602
- import { WorkerThread } from 'vivth';
1603
-
1604
- WorkerThread.setup({ parentPort: async () => (await import('node:worker_threads')).parentPort });
1605
- // that is the default value, if your parentPort/equivalent API is not that;
1606
- // you need to call this method;
1607
-
1608
2189
  ```
1609
2190
 
1610
- #### reference:`new WorkerThread`
1611
- - instantiate via created class from `setup` static method;
2191
+ #### reference:`WorkerMainThread.newVivthWorker`
2192
+ - create Worker_instance;
1612
2193
 
1613
2194
  ```js
1614
2195
  /**
1615
- * @param {WorkerThread["handler"]} handler
2196
+ * @param {string} handler
2197
+ * @param {Omit<WorkerOptions|import('worker_threads').WorkerOptions, 'eval'|'type'>} [options]
2198
+ * @returns {WorkerMainThread<WT>}
1616
2199
  */
1617
2200
  ```
1618
2201
  - <i>example</i>:
1619
2202
  ```js
1620
- import { MyWorkerThread } from './MyWorkerThread.mjs';
2203
+ import { WorkerMainThread } from 'vivth';
1621
2204
 
1622
- const doubleWorker = new MyWorkerThread((ev, isLastOnQ) => {
1623
- // if(!isLastOnQ) {
1624
- // return null; // can be used for imperative debouncing;
1625
- // }
1626
- return ev = ev * 2;
1627
- });
2205
+ export const myDoubleWorker = WorkerMainThread.newVivthWorker('./doubleWorkerThread.mjs');
1628
2206
 
1629
2207
  ```
1630
2208
 
1631
- #### reference:`WorkerThread_instance.handler`
1632
- - type helper;
2209
+ #### reference:`WorkerMainThread_instance.terminate`
2210
+ - terminate all signals that are used on this instance;
1633
2211
 
1634
2212
  ```js
1635
2213
  /**
1636
- * @type {(ev: Receive, isLastOnQ:boolean) => Post}
2214
+ * @type {()=>void}
1637
2215
  */
1638
2216
  ```
1639
2217
 
1640
- #### reference:`WorkerThread_instance.Receive`
1641
- - helper type, hold no actual value;
2218
+ #### reference:`WorkerMainThread_instance.receiverSignal`
2219
+ - result signal of the processed message;
1642
2220
 
1643
2221
  ```js
1644
2222
  /**
1645
- * @type {Receive}
2223
+ * @type {Derived<WorkerResult<WT["POST"]>>}
1646
2224
  */
2225
+ ```
2226
+ - <i>example</i>:
2227
+ ```js
2228
+ import { Effect } from 'vivth';
2229
+ import { myDoubleWorker } from './myDoubleWorker.mjs';
2230
+
2231
+ const doubleReceiverSignal = myDoubleWorker.receiverSignal;
2232
+ new Effect(async({ subscribe }) => {
2233
+ const value = subscribe(doubleReceiverSignal).value;
2234
+ // code
2235
+ })
2236
+
1647
2237
  ```
1648
2238
 
1649
- #### reference:`WorkerThread_instance.Post`
1650
- - helper type, hold no actual value;
2239
+ #### reference:`WorkerMainThread_instance.postMessage`
2240
+ - callback to send message to the worker thread;
1651
2241
 
1652
2242
  ```js
1653
2243
  /**
1654
- * @type {Post}
2244
+ * @type {(event: WT["RECEIVE"])=>void}
1655
2245
  */
2246
+ ```
2247
+ - <i>example</i>:
2248
+ ```js
2249
+ import { myDoubleWorker } from './myDoubleWorker.mjs';
2250
+
2251
+ myDoubleWorker.postMessage(90);
2252
+
1656
2253
  ```
1657
2254
 
1658
2255
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
@@ -1671,13 +2268,18 @@ npm i vivth
1671
2268
  * @param {string} mimeType
1672
2269
  * @param {(string:string)=>string} btoaFunction
1673
2270
  * - check your js runtime `btoa`;
1674
- * @returns {string}
2271
+ * - node compatible:
2272
+ * ```js
2273
+ * (str, prevBufferEncoding) =>
2274
+ * Buffer.from(str, prevBufferEncoding).toString('base64')
2275
+ * ```
2276
+ * @returns {Base64URLString}
1675
2277
  */
1676
2278
  ```
1677
2279
  - <i>example</i>:
1678
2280
  ```js
1679
2281
  import { Base64URL } from 'vivth'
1680
- import { fileString } from './fileString.mjs';
2282
+ import fileString from './fileString.mjs';
1681
2283
 
1682
2284
  Base64URL(fileString, 'application/javascript', btoa);
1683
2285
 
@@ -1685,6 +2287,33 @@ npm i vivth
1685
2287
 
1686
2288
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1687
2289
 
2290
+ <h2 id="base64urlfromfile">Base64URLFromFile</h2>
2291
+
2292
+
2293
+ #### reference:`Base64URLFromFile`
2294
+ - create inline base64 url;
2295
+ - usage:
2296
+ >- can be extremely usefull to display file on desktop app webview, without exposing http server;
2297
+ >- when using `FSInline`, use [Base64URL](#base64url) instead;
2298
+
2299
+ ```js
2300
+ /**
2301
+ * @param {string} filePath
2302
+ * @returns {Promise<Base64URLString>}
2303
+ */
2304
+ ```
2305
+ - <i>example</i>:
2306
+ ```js
2307
+ import { join } from 'node:path'
2308
+
2309
+ import { Base64URLFromFile, Paths } from 'vivth'
2310
+
2311
+ await Base64URLFromFile(join(Paths.root, '/path/to/file'));
2312
+
2313
+ ```
2314
+
2315
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2316
+
1688
2317
  <h2 id="eventnamespace">EventNameSpace</h2>
1689
2318
 
1690
2319
 
@@ -1717,7 +2346,7 @@ npm i vivth
1717
2346
  >>- `"at"description` are treated as plain `markdown`;
1718
2347
  >>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
1719
2348
  >>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
1720
- >>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` is documentation/generation results;
2349
+ >>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
1721
2350
 
1722
2351
 
1723
2352
  #### reference:`new JSautoDOC`
@@ -1741,25 +2370,9 @@ npm i vivth
1741
2370
  ```
1742
2371
  - <i>example</i>:
1743
2372
  ```js
1744
- import { Console, Setup, JSautoDOC } from 'vivth';
1745
-
1746
- const { paths, safeExit } = Setup;
1747
-
1748
- new paths({
1749
- root: process?.env?.INIT_CWD ?? process?.cwd(),
1750
- });
1751
-
1752
- new safeExit({
1753
- exitEventNames: ['SIGINT', 'SIGTERM', 'exit'],
1754
- exitCallbackListeners: (eventName) => {
1755
- process.once(eventName, function () {
1756
- safeExit.instance.exiting.correction(true);
1757
- Console.log(`safe exit via "${eventName}"`);
1758
- });
1759
- },
1760
- });
2373
+ import { JSautoDOC } from 'vivth';
1761
2374
 
1762
- new JSautoDOC({
2375
+ new JSautoDOC({
1763
2376
  paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
1764
2377
  copyright: 'this library is made and distributed under MIT license;',
1765
2378
  tableOfContentTitle: 'list of exported API and typehelpers',
@@ -1779,14 +2392,14 @@ npm i vivth
1779
2392
 
1780
2393
  ```js
1781
2394
  /**
1782
- * @template {Object} P
1783
- * @template {Object} O
2395
+ * @template {Object} PARENT
2396
+ * @template {Object} OBJECT
1784
2397
  * @param {string} keyName
1785
- * @param {P} parent
1786
- * @param {(this:P)=>O} object
2398
+ * @param {PARENT} parent
2399
+ * @param {(this:PARENT)=>OBJECT} object
1787
2400
  * @param {Object} [options]
1788
2401
  * @param {boolean} [options.lazy]
1789
- * @return {O}
2402
+ * @return {OBJECT}
1790
2403
  */
1791
2404
  ```
1792
2405
  - <i>example</i>:
@@ -1841,9 +2454,9 @@ npm i vivth
1841
2454
 
1842
2455
  ```js
1843
2456
  /**
1844
- * @template {string} N
1845
- * @param {N} name
1846
- * @returns {{[EventNameSpace]: N}}
2457
+ * @template {string} NAME
2458
+ * @param {NAME} name
2459
+ * @returns {{[EventNameSpace]: NAME}}
1847
2460
  */
1848
2461
  ```
1849
2462
  - <i>example</i>:
@@ -1860,6 +2473,27 @@ npm i vivth
1860
2473
 
1861
2474
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
1862
2475
 
2476
+ <h2 id="getruntime">GetRuntime</h2>
2477
+
2478
+
2479
+ #### reference:`GetRuntime`
2480
+ - detects the current JavaScript runtime;
2481
+
2482
+ ```js
2483
+ /**
2484
+ * @type {()=>Runtime}
2485
+ */
2486
+ ```
2487
+ - <i>example</i>:
2488
+ ```js
2489
+ import { GetRuntime } form 'vivth';
2490
+
2491
+ const runtime = GetRuntime();
2492
+
2493
+ ```
2494
+
2495
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2496
+
1863
2497
  <h2 id="isasync">IsAsync</h2>
1864
2498
 
1865
2499
 
@@ -1899,17 +2533,18 @@ npm i vivth
1899
2533
 
1900
2534
  ```js
1901
2535
  /**
1902
- * @template T
1903
- * @param {() => T} factory
1904
- * @returns {T & {[unwrapLazy]: string}}
2536
+ * @template FACTORY
2537
+ * @param {() => FACTORY} factory
2538
+ * @returns {FACTORY & {[unwrapLazy]: ()=> FACTORY}}
1905
2539
  * - the unwrapLazy prop can be accessed to force instatiation/call;
1906
2540
  * >- `unwrapLazy` prop name can be checked by checking the list of possible prop, from your ide;
1907
- * >- as of version 1.0.0, value is `vivth:unwrapLazy;`;
2541
+ * >- as of version `1.0.0`, value is `vivth:unwrapLazy;`;
1908
2542
  */
1909
2543
  ```
1910
2544
  - <i>example</i>:
1911
2545
  ```js
1912
2546
  import { LazyFactory } from 'vivth';
2547
+
1913
2548
  class MyClass{
1914
2549
  constructor() {
1915
2550
  this.myProp = 1; // will only available when accessed;
@@ -1926,7 +2561,9 @@ npm i vivth
1926
2561
  import { myInstance } from './myInstance.mjs';
1927
2562
 
1928
2563
  const a = myInstance; // not yet initiated;
1929
- const b = a.myProp // imediately initiated;
2564
+ const b = a.myProp // imediately initiated;
2565
+ // OR
2566
+ myInstance["vivth:unwrapLazy;"]() // forcefully call the callback;
1930
2567
 
1931
2568
  ```
1932
2569
 
@@ -1972,15 +2609,15 @@ npm i vivth
1972
2609
 
1973
2610
  ```js
1974
2611
  /**
1975
- * @template {string} Key
1976
- * @template ReturnType_
2612
+ * @template {string} KEY
2613
+ * @template RETURNTYPE
1977
2614
  * @template {Record<
1978
- * Key,
1979
- * () => Promise<ReturnType_>
2615
+ * KEY,
2616
+ * (err:{prevError:undefined|Error}) => Promise<RETURNTYPE>
1980
2617
  * >} RecordTryType
1981
2618
  * @param {RecordTryType} tryRecord
1982
2619
  * @returns {Promise<
1983
- * [[keyof RecordTryType, ReturnType_], undefined]
2620
+ * [[keyof RecordTryType, RETURNTYPE], undefined]
1984
2621
  * | [[undefined, undefined], Error]
1985
2622
  * >}
1986
2623
  */
@@ -1990,13 +2627,13 @@ npm i vivth
1990
2627
  import { Try } from 'vivth';
1991
2628
 
1992
2629
  const [[key, result], error] = await Try({
1993
- someRuntime: async () => {
2630
+ someRuntime: async ( prevError ) => {
1994
2631
  // asuming on this one doesn't naturally throw error,
1995
2632
  // yet you need to continue to next key,
1996
2633
  // instead of returning,
1997
2634
  // you should throw new Error(something);
1998
2635
  },
1999
- browser: async () => {
2636
+ browser: async ( prevError ) => {
2000
2637
  return location?.origin;
2001
2638
  // if no error, stop other key function from running;
2002
2639
  // key = 'browser'
@@ -2005,7 +2642,7 @@ npm i vivth
2005
2642
  // if error;
2006
2643
  // run nodeOrBun;
2007
2644
  },
2008
- nodeOrBun: async () => {
2645
+ nodeOrBun: async ( prevError ) => {
2009
2646
  return process?.env?.INIT_CWD ?? process?.cwd();
2010
2647
  // if no error;
2011
2648
  // key = 'nodeOrBun'
@@ -2030,9 +2667,9 @@ npm i vivth
2030
2667
 
2031
2668
  ```js
2032
2669
  /**
2033
- * @template ResultType
2034
- * @param {()=>Promise<ResultType>} asyncFunction_
2035
- * @returns {Promise<[ResultType|undefined, Error|undefined]>}
2670
+ * @template RESULT
2671
+ * @param {()=>Promise<RESULT>} asyncFunction_
2672
+ * @returns {Promise<[RESULT|undefined, Error|undefined]>}
2036
2673
  */
2037
2674
  ```
2038
2675
  - <i>example</i>:
@@ -2063,9 +2700,9 @@ npm i vivth
2063
2700
 
2064
2701
  ```js
2065
2702
  /**
2066
- * @template ResultType
2067
- * @param {()=>ResultType} function_
2068
- * @returns {[ResultType|undefined, Error|undefined]}
2703
+ * @template RESULT
2704
+ * @param {()=>RESULT} function_
2705
+ * @returns {[RESULT|undefined, Error|undefined]}
2069
2706
  */
2070
2707
  ```
2071
2708
  - <i>example</i>:
@@ -2092,6 +2729,7 @@ npm i vivth
2092
2729
  ```js
2093
2730
  /**
2094
2731
  * @param {string} path_
2732
+ * - path from `Paths.root`;
2095
2733
  * @param {Object} [options]
2096
2734
  * @param {string} [options.overrideDir]
2097
2735
  * - default: write conversion to same directory;
@@ -2111,37 +2749,6 @@ npm i vivth
2111
2749
 
2112
2750
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2113
2751
 
2114
- <h2 id="writefilesafe">WriteFileSafe</h2>
2115
-
2116
-
2117
- #### reference:`WriteFileSafe`
2118
- - function to create file by recursively mkdir the dirname of the outFile;
2119
- - also returing promise of result & error as value;
2120
-
2121
- ```js
2122
- /**
2123
- * @param {string} outFile
2124
- * @param {string} content
2125
- * @param {import('node:fs').WriteFileOptions} options
2126
- * @returns {Promise<ReturnType<typeof TryAsync<void>>>}
2127
- */
2128
- ```
2129
- - <i>example</i>:
2130
- ```js
2131
- import { WriteFileSafe } from 'vivth';
2132
-
2133
- const [_, writeError] = await TryAsync(async () => {
2134
- return await WriteFileSafe(
2135
- '/some/path.mjs',
2136
- 'console.log("hello-world!!");',
2137
- { encoding: 'utf-8' }
2138
- );
2139
- });
2140
-
2141
- ```
2142
-
2143
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2144
-
2145
2752
  <h2 id="anybutundefined">AnyButUndefined</h2>
2146
2753
 
2147
2754
  - jsdoc types:
@@ -2190,6 +2797,17 @@ npm i vivth
2190
2797
  ```
2191
2798
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2192
2799
 
2800
+ <h2 id="litexpkeytype">LitExpKeyType</h2>
2801
+
2802
+ - jsdoc types:
2803
+
2804
+ ```js
2805
+ /**
2806
+ * @typedef {Record<string, RegExp|false>} LitExpKeyType
2807
+ */
2808
+ ```
2809
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2810
+
2193
2811
  <h2 id="mutationtype">MutationType</h2>
2194
2812
 
2195
2813
  - jsdoc types:
@@ -2223,7 +2841,171 @@ npm i vivth
2223
2841
  ```js
2224
2842
  /**
2225
2843
  * - return type of Q callback;
2226
- * @typedef {{resume:()=>void, isLastOnQ:boolean}} QCBReturn
2844
+ * @typedef {{resume:()=>void, isLastOnQ:()=>boolean}} QCBReturn
2845
+ */
2846
+ ```
2847
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2848
+
2849
+ <h2 id="runtime">Runtime</h2>
2850
+
2851
+ - jsdoc types:
2852
+
2853
+ ```js
2854
+ /**
2855
+ * @description
2856
+ * - for popular runtimes check;
2857
+ * @typedef {'node' | 'bun' | 'deno' | 'browser' | 'unknown'} Runtime
2858
+ */
2859
+ ```
2860
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2861
+
2862
+ <h2 id="workerresult">WorkerResult</h2>
2863
+
2864
+
2865
+ #### reference:`WorkerResult`
2866
+ - typeHelper for `Worker` message passing;
2867
+ - uses error as value instead;
2868
+
2869
+ ```js
2870
+ /**
2871
+ * @template POST
2872
+ */
2873
+ ```
2874
+
2875
+ #### reference:`WorkerResult_instance.data`
2876
+ - result value;
2877
+
2878
+ ```js
2879
+ /**
2880
+ * @type {POST}
2881
+ */
2882
+ ```
2883
+
2884
+ #### reference:`WorkerResult_instance.error`
2885
+ - error value;
2886
+
2887
+ ```js
2888
+ /**
2889
+ * @type {Error|string|undefined}
2890
+ */
2891
+ ```
2892
+
2893
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2894
+
2895
+ <h2 id="workerthread">WorkerThread</h2>
2896
+
2897
+
2898
+ #### reference:`WorkerThread`
2899
+ - class helper for `WorkerThread` creation;
2900
+ - before any `Worker` functionaily to be used, you need to setup it with `WorkerThread.setup` and `WorkerMainThread.setup` before runing anytyhing;
2901
+
2902
+ ```js
2903
+ /**
2904
+ * @template RECEIVE
2905
+ * @template POST
2906
+ */
2907
+ ```
2908
+
2909
+ #### reference:`WorkerThread.setup`
2910
+ - need to be called and exported as new `WorkerThread` class reference;
2911
+
2912
+ ```js
2913
+ /**
2914
+ * @template RECEIVE
2915
+ * @template POST
2916
+ * @param {{parentPort:import('worker_threads')["parentPort"]}} refs
2917
+ * -example:
2918
+ * ```js
2919
+ * import { parentPort } from 'node:worker_threads';
2920
+ * ```
2921
+ * @returns {typeof WorkerThread<RECEIVE, POST>}
2922
+ */
2923
+ ```
2924
+ - <i>example</i>:
2925
+ ```js
2926
+ import { WorkerThread } from 'vivth';
2927
+ import { parentPort } from 'node:worker_threads';
2928
+
2929
+ export const MyWorkerThreadRef = WorkerThread.setup({ parentPort });
2930
+
2931
+ ```
2932
+
2933
+ #### reference:`new WorkerThread`
2934
+ - instantiate via created class from `setup` static method;
2935
+
2936
+ ```js
2937
+ /**
2938
+ * @param {WorkerThread["handler"]} handler
2939
+ */
2940
+ ```
2941
+ - <i>example</i>:
2942
+ ```js
2943
+ import { MyWorkerThread } from './MyWorkerThread.mjs';
2944
+
2945
+ const doubleWorker = new MyWorkerThread((ev, isLastOnQ) => {
2946
+ // if(!isLastOnQ()) {
2947
+ // return null; // can be used for imperative debouncing;
2948
+ // }
2949
+ // await fetch('some/path')
2950
+ // if(!isLastOnQ()) {
2951
+ // return;
2952
+ // }
2953
+ return ev = ev * 2;
2954
+ });
2955
+
2956
+ ```
2957
+
2958
+ #### reference:`WorkerThread_instance.handler`
2959
+ - type helper;
2960
+
2961
+ ```js
2962
+ /**
2963
+ * @type {(ev: RECEIVE, isLastOnQ:QCBReturn["isLastOnQ"]) => POST}
2964
+ */
2965
+ ```
2966
+
2967
+ #### reference:`WorkerThread_instance.RECEIVE`
2968
+ - helper type, hold no actual value;
2969
+
2970
+ ```js
2971
+ /**
2972
+ * @type {RECEIVE}
2973
+ */
2974
+ ```
2975
+
2976
+ #### reference:`WorkerThread_instance.POST`
2977
+ - helper type, hold no actual value;
2978
+
2979
+ ```js
2980
+ /**
2981
+ * @type {POST}
2227
2982
  */
2228
2983
  ```
2984
+
2985
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2986
+
2987
+ <h2 id="tobundledjsplugin">ToBundledJSPlugin</h2>
2988
+
2989
+
2990
+ #### reference:`ToBundledJSPlugin`
2991
+ - generate `esbuild.Plugin` for changing dev time file into runtime file;
2992
+ - on using esbuild with this plugin, it will replace any module that have similiar file name but ended with Bundled(before extname);
2993
+ >- works on `.mts`|`.ts`|`.mjs`|`.cjs`|`.js`;
2994
+ >- `anyFileName.mjs` -> seek for and use `anyFileNameBundled.mjs`, if not found use `anyFileName.mjs`;
2995
+
2996
+ ```js
2997
+ /**
2998
+ * @param {string} includedInPath
2999
+ * - is generalized, you can freely uses forward or backward slash;
3000
+ * @returns {ReturnType<CreateESPlugin>}
3001
+ */
3002
+ ```
3003
+ - <i>example</i>:
3004
+ ```js
3005
+ import { ToBundledJSPlugin } from 'vivth';
3006
+
3007
+ export const myBundledPlugin = ToBundledJSPlugin('/myProjectName/src/');
3008
+
3009
+ ```
3010
+
2229
3011
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>