vivth 1.2.0 → 1.2.2

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 CHANGED
@@ -62,7 +62,6 @@ npm i vivth
62
62
  - [Base64URL](#base64url)
63
63
  - [Base64URLFromFile](#base64urlfromfile)
64
64
  - [EventNameSpace](#eventnamespace)
65
- - [JSautoDOC](#jsautodoc)
66
65
  - [CreateImmutable](#createimmutable)
67
66
  - [EventCheck](#eventcheck)
68
67
  - [EventObject](#eventobject)
@@ -74,6 +73,7 @@ npm i vivth
74
73
  - [TryAsync](#tryasync)
75
74
  - [TrySync](#trysync)
76
75
  - [TsToMjs](#tstomjs)
76
+ - [JSautoDOC](#jsautodoc)
77
77
  - [AnyButUndefined](#anybutundefined)
78
78
  - [ExtnameType](#extnametype)
79
79
  - [IsListSignal](#islistsignal)
@@ -2129,16 +2129,13 @@ npm i vivth
2129
2129
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
2130
2130
  * - example:
2131
2131
  * ```js
2132
- * async (workerPath, root, base) => {
2132
+ * async (workerPath, root) => {
2133
2133
  * const truePathCheck = `${root}/${base}/${workerPath}`;
2134
2134
  * const res = await fetch(truePathCheck);
2135
2135
  * // might also check wheter it need base or not
2136
2136
  * return await res.ok;
2137
2137
  * }
2138
2138
  * ```
2139
- * @param {typeof WorkerMainThread["basePath"]} [param0.basePath]
2140
- * - additonal realtivePath from rootPath;
2141
- * - default: '';
2142
2139
  */
2143
2140
  ```
2144
2141
  - <i>example</i>:
@@ -2148,11 +2145,15 @@ npm i vivth
2148
2145
 
2149
2146
  WorkerMainThread.setup({
2150
2147
  workerClass: Worker,
2151
- basePath: 'public/assets/js/workers',
2152
- pathValidator: async (workerPath, root, base) => {
2153
- const res = await fetch(`${root}/${base}/${workerPath}`);
2154
- // might also check wheter it need base or not
2155
- return await res.ok;
2148
+ pathValidator: async ({worker, root}) => {
2149
+ const res = await fetch(`${root}/${worker}`);
2150
+ if (res.ok) {
2151
+ return res
2152
+ }
2153
+ const res2 = await fetch(`${root}/someAdditionalPath/${worker}`);
2154
+ if (res2.ok) {
2155
+ return res2
2156
+ }
2156
2157
  },
2157
2158
  });
2158
2159
 
@@ -2168,23 +2169,13 @@ npm i vivth
2168
2169
  */
2169
2170
  ```
2170
2171
 
2171
- #### reference:`WorkerMainThread.basePath`
2172
- - reference for worker file `basePath`;
2173
- - edit via `setup`;
2174
-
2175
- ```js
2176
- /**
2177
- * @type {string}
2178
- */
2179
- ```
2180
-
2181
2172
  #### reference:`WorkerMainThread.pathValidator`
2182
2173
  - reference for validating path;
2183
2174
  - edit via `setup`;
2184
2175
 
2185
2176
  ```js
2186
2177
  /**
2187
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
2178
+ * @type {(paths:{worker: string, root:string})=>Promise<string>}
2188
2179
  */
2189
2180
  ```
2190
2181
 
@@ -2328,60 +2319,6 @@ npm i vivth
2328
2319
 
2329
2320
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2330
2321
 
2331
- <h2 id="jsautodoc">JSautoDOC</h2>
2332
-
2333
-
2334
- #### reference:`JSautoDOC`
2335
- - class for auto documenting mjs package/project, using jsdoc;
2336
- - this autodocumenter uses [chokidar](https://npmjs.com/package/chokidar) under the hood;
2337
- - this class also is used to generate this `README.md`;
2338
- - behaviours:
2339
- >1) add `"at"noautodoc` on self closing jsdoc comment to opt out from generating documentation on said file;
2340
- >>- auto export must follows the following rules, and there's no way to override;
2341
- >2) export all named exported 'const'|'function'|'async function'|'class', alphanumeric name, started with Capital letter, same name with fileName on `options.pahts.file`;
2342
- >3) declare typedef of existing typedef with alphanumeric name, started with Capital letter, same name with fileName, and have no valid export like on point <sup>1</sup> on `options.pahts.file`;
2343
- >4) create `README.md` based on, `options.paths.dir` and `README.src.md`;
2344
- >5) extract `"at"description` jsdoc:
2345
- >>- on static/prop that have depths, all of children should have `"at"static`/`"at"instance` `nameOfImmediateParent`, same block but before `"at"description` comment line;
2346
- >>- `"at"description` are treated as plain `markdown`;
2347
- >>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
2348
- >>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
2349
- >>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
2350
-
2351
-
2352
- #### reference:`new JSautoDOC`
2353
-
2354
-
2355
- ```js
2356
- /**
2357
- * @param {Object} [options]
2358
- * @param {Object} [options.paths]
2359
- * @param {string} [options.paths.file]
2360
- * - entry point;
2361
- * @param {string} [options.paths.readMe]
2362
- * - readme target;
2363
- * @param {string} [options.paths.dir]
2364
- * - source directory;
2365
- * @param {string} [options.copyright]
2366
- * @param {string} [options.tableOfContentTitle]
2367
- * @param {import('chokidar').ChokidarOptions} [options.option]
2368
- * - ChokidarOptions;
2369
- */
2370
- ```
2371
- - <i>example</i>:
2372
- ```js
2373
- import { JSautoDOC } from 'vivth';
2374
-
2375
- new JSautoDOC({
2376
- paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
2377
- copyright: 'this library is made and distributed under MIT license;',
2378
- tableOfContentTitle: 'list of exported API and typehelpers',
2379
- });
2380
-
2381
- ```
2382
-
2383
- *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2384
-
2385
2322
  <h2 id="createimmutable">CreateImmutable</h2>
2386
2323
 
2387
2324
 
@@ -2749,6 +2686,60 @@ npm i vivth
2749
2686
 
2750
2687
  *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2751
2688
 
2689
+ <h2 id="jsautodoc">JSautoDOC</h2>
2690
+
2691
+
2692
+ #### reference:`JSautoDOC`
2693
+ - class for auto documenting mjs package/project, using jsdoc;
2694
+ - this autodocumenter uses [chokidar](https://npmjs.com/package/chokidar) under the hood;
2695
+ - this class also is used to generate this `README.md`;
2696
+ - behaviours:
2697
+ >1) add `"at"noautodoc` on self closing jsdoc comment to opt out from generating documentation on said file;
2698
+ >>- auto export must follows the following rules, and there's no way to override;
2699
+ >2) export all named exported 'const'|'function'|'async function'|'class', alphanumeric name, started with Capital letter, same name with fileName on `options.pahts.file`;
2700
+ >3) declare typedef of existing typedef with alphanumeric name, started with Capital letter, same name with fileName, and have no valid export like on point <sup>1</sup> on `options.pahts.file`;
2701
+ >4) create `README.md` based on, `options.paths.dir` and `README.src.md`;
2702
+ >5) extract `"at"description` jsdoc:
2703
+ >>- on static/prop that have depths, all of children should have `"at"static`/`"at"instance` `nameOfImmediateParent`, same block but before `"at"description` comment line;
2704
+ >>- `"at"description` are treated as plain `markdown`;
2705
+ >>- first `"at"${string}` after `"at"description` until `"at"example` will be treated as `javascript` comment block on the `markdown`;
2706
+ >>- `"at"example` are treated as `javascript` block on the `markdown` file, and should be placed last on the same comment block;
2707
+ >>- you can always look at `vivth/src` files to check how the source, and the `README.md` and `index.mjs` documentation/generation results;
2708
+
2709
+
2710
+ #### reference:`new JSautoDOC`
2711
+
2712
+
2713
+ ```js
2714
+ /**
2715
+ * @param {Object} [options]
2716
+ * @param {Object} [options.paths]
2717
+ * @param {string} [options.paths.file]
2718
+ * - entry point;
2719
+ * @param {string} [options.paths.readMe]
2720
+ * - readme target;
2721
+ * @param {string} [options.paths.dir]
2722
+ * - source directory;
2723
+ * @param {string} [options.copyright]
2724
+ * @param {string} [options.tableOfContentTitle]
2725
+ * @param {import('chokidar').ChokidarOptions} [options.option]
2726
+ * - ChokidarOptions;
2727
+ */
2728
+ ```
2729
+ - <i>example</i>:
2730
+ ```js
2731
+ import { JSautoDOC } from 'vivth';
2732
+
2733
+ new JSautoDOC({
2734
+ paths: { dir: 'src', file: 'index.mjs', readMe: 'README.md' },
2735
+ copyright: 'this library is made and distributed under MIT license;',
2736
+ tableOfContentTitle: 'list of exported API and typehelpers',
2737
+ });
2738
+
2739
+ ```
2740
+
2741
+ *) <sub>[go to list of exported API and typehelpers](#list-of-exported-api-and-typehelpers)</sub>
2742
+
2752
2743
  <h2 id="anybutundefined">AnyButUndefined</h2>
2753
2744
 
2754
2745
  - jsdoc types:
package/index.mjs CHANGED
@@ -29,7 +29,6 @@ export { WorkerMainThread } from './src/class/WorkerMainThread.mjs';
29
29
  export { Base64URL } from './src/common/Base64URL.mjs';
30
30
  export { Base64URLFromFile } from './src/common/Base64URLFromFile.mjs';
31
31
  export { EventNameSpace } from './src/common/EventNameSpace.mjs';
32
- export { JSautoDOC } from './src/doc/JSautoDOC.mjs';
33
32
  export { CreateImmutable } from './src/function/CreateImmutable.mjs';
34
33
  export { EventCheck } from './src/function/EventCheck.mjs';
35
34
  export { EventObject } from './src/function/EventObject.mjs';
@@ -41,6 +40,7 @@ export { Try } from './src/function/Try.mjs';
41
40
  export { TryAsync } from './src/function/TryAsync.mjs';
42
41
  export { TrySync } from './src/function/TrySync.mjs';
43
42
  export { TsToMjs } from './src/function/TsToMjs.mjs';
43
+ export { JSautoDOC } from './src/doc/JSautoDOC.mjs';
44
44
  export { WorkerResult } from './src/class/WorkerResult.mjs';
45
45
  export { WorkerThread } from './src/class/WorkerThread.mjs';
46
46
  export { ToBundledJSPlugin } from './src/bundler/adds/ToBundledJSPlugin.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vivth",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "library primitives",
5
5
  "main": "index.mjs",
6
6
  "types": "./types/index.d.mts",
@@ -43,31 +43,32 @@ export class WorkerMainThread {
43
43
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
44
44
  * - example:
45
45
  * ```js
46
- * async (workerPath, root, base) => {
46
+ * async (workerPath, root) => {
47
47
  * const truePathCheck = `${root}/${base}/${workerPath}`;
48
48
  * const res = await fetch(truePathCheck);
49
49
  * // might also check wheter it need base or not
50
50
  * return await res.ok;
51
51
  * }
52
52
  * ```
53
- * @param {typeof WorkerMainThread["basePath"]} [param0.basePath]
54
- * - additonal realtivePath from rootPath;
55
- * - default: '';
56
53
  * @example
57
54
  * import { Worker } from 'node:worker_threads';
58
55
  * import { WorkerMainThread } from 'vivth';
59
56
  *
60
57
  * WorkerMainThread.setup({
61
58
  * workerClass: Worker,
62
- * basePath: 'public/assets/js/workers',
63
- * pathValidator: async (workerPath, root, base) => {
64
- * const res = await fetch(`${root}/${base}/${workerPath}`);
65
- * // might also check wheter it need base or not
66
- * return await res.ok;
59
+ * pathValidator: async ({worker, root}) => {
60
+ * const res = await fetch(`${root}/${worker}`);
61
+ * if (res.ok) {
62
+ * return res
63
+ * }
64
+ * const res2 = await fetch(`${root}/someAdditionalPath/${worker}`);
65
+ * if (res2.ok) {
66
+ * return res2
67
+ * }
67
68
  * },
68
69
  * });
69
70
  */
70
- static setup = ({ workerClass, pathValidator, basePath = '' }) => {
71
+ static setup = ({ workerClass, pathValidator }) => {
71
72
  if (!Paths.root) {
72
73
  return;
73
74
  }
@@ -78,7 +79,6 @@ export class WorkerMainThread {
78
79
  WorkerMainThread.#isRegistered = true;
79
80
  WorkerMainThread.workerClass = workerClass;
80
81
  WorkerMainThread.pathValidator = pathValidator;
81
- WorkerMainThread.basePath = basePath;
82
82
  };
83
83
  /**
84
84
  * @description
@@ -87,18 +87,11 @@ export class WorkerMainThread {
87
87
  * @type {typeof Worker|typeof import('worker_threads').Worker}
88
88
  */
89
89
  static workerClass;
90
- /**
91
- * @description
92
- * - reference for worker file `basePath`;
93
- * - edit via `setup`;
94
- * @type {string}
95
- */
96
- static basePath;
97
90
  /**
98
91
  * @description
99
92
  * - reference for validating path;
100
93
  * - edit via `setup`;
101
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
94
+ * @type {(paths:{worker: string, root:string})=>Promise<string>}
102
95
  */
103
96
  static pathValidator;
104
97
  static #options = /** @type {import('worker_threads').WorkerOptions & { type?: 'module' }} */ ({
@@ -157,7 +150,6 @@ export class WorkerMainThread {
157
150
  return await pathValidator({
158
151
  worker: handler,
159
152
  root: Paths.root,
160
- base: WorkerMainThread.basePath,
161
153
  });
162
154
  });
163
155
  if (error) {
@@ -33,9 +33,8 @@ export class WorkerMainThread {
33
33
  * @param {Object} param0
34
34
  * @param {typeof WorkerMainThread["workerClass"]} param0.workerClass
35
35
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
36
- * @param {typeof WorkerMainThread["basePath"]} [param0.basePath]
37
36
  */
38
- static setup = ({ workerClass, pathValidator, basePath = '' }) => {
37
+ static setup = ({ workerClass, pathValidator }) => {
39
38
  if (!Paths.root) {
40
39
  return;
41
40
  }
@@ -46,18 +45,13 @@ export class WorkerMainThread {
46
45
  WorkerMainThread.#isRegistered = true;
47
46
  WorkerMainThread.workerClass = workerClass;
48
47
  WorkerMainThread.pathValidator = pathValidator;
49
- WorkerMainThread.basePath = basePath;
50
48
  };
51
49
  /**
52
50
  * @type {typeof Worker|typeof import('worker_threads').Worker}
53
51
  */
54
52
  static workerClass;
55
53
  /**
56
- * @type {string}
57
- */
58
- static basePath;
59
- /**
60
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
54
+ * @type {(paths:{worker: string, root:string})=>Promise<string>}
61
55
  */
62
56
  static pathValidator;
63
57
  static #options = /** @type {import('worker_threads').WorkerOptions & { type?: 'module' }} */ ({
package/types/index.d.mts CHANGED
@@ -21,7 +21,6 @@ export { WorkerMainThread } from "./src/class/WorkerMainThread.mjs";
21
21
  export { Base64URL } from "./src/common/Base64URL.mjs";
22
22
  export { Base64URLFromFile } from "./src/common/Base64URLFromFile.mjs";
23
23
  export { EventNameSpace } from "./src/common/EventNameSpace.mjs";
24
- export { JSautoDOC } from "./src/doc/JSautoDOC.mjs";
25
24
  export { CreateImmutable } from "./src/function/CreateImmutable.mjs";
26
25
  export { EventCheck } from "./src/function/EventCheck.mjs";
27
26
  export { EventObject } from "./src/function/EventObject.mjs";
@@ -33,6 +32,7 @@ export { Try } from "./src/function/Try.mjs";
33
32
  export { TryAsync } from "./src/function/TryAsync.mjs";
34
33
  export { TrySync } from "./src/function/TrySync.mjs";
35
34
  export { TsToMjs } from "./src/function/TsToMjs.mjs";
35
+ export { JSautoDOC } from "./src/doc/JSautoDOC.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";
@@ -54,10 +54,9 @@ export class Setup {
54
54
  * },
55
55
  * });
56
56
  */
57
- static workerMain: ({ workerClass, pathValidator, basePath }: {
57
+ static workerMain: ({ workerClass, pathValidator }: {
58
58
  workerClass: (typeof WorkerMainThread)["workerClass"];
59
59
  pathValidator: (typeof WorkerMainThread)["pathValidator"];
60
- basePath?: (typeof WorkerMainThread)["basePath"];
61
60
  }) => void;
62
61
  /**
63
62
  * @description
@@ -29,34 +29,34 @@ export class WorkerMainThread<WT extends WorkerThread> {
29
29
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
30
30
  * - example:
31
31
  * ```js
32
- * async (workerPath, root, base) => {
32
+ * async (workerPath, root) => {
33
33
  * const truePathCheck = `${root}/${base}/${workerPath}`;
34
34
  * const res = await fetch(truePathCheck);
35
35
  * // might also check wheter it need base or not
36
36
  * return await res.ok;
37
37
  * }
38
38
  * ```
39
- * @param {typeof WorkerMainThread["basePath"]} [param0.basePath]
40
- * - additonal realtivePath from rootPath;
41
- * - default: '';
42
39
  * @example
43
40
  * import { Worker } from 'node:worker_threads';
44
41
  * import { WorkerMainThread } from 'vivth';
45
42
  *
46
43
  * WorkerMainThread.setup({
47
44
  * workerClass: Worker,
48
- * basePath: 'public/assets/js/workers',
49
- * pathValidator: async (workerPath, root, base) => {
50
- * const res = await fetch(`${root}/${base}/${workerPath}`);
51
- * // might also check wheter it need base or not
52
- * return await res.ok;
45
+ * pathValidator: async ({worker, root}) => {
46
+ * const res = await fetch(`${root}/${worker}`);
47
+ * if (res.ok) {
48
+ * return res
49
+ * }
50
+ * const res2 = await fetch(`${root}/someAdditionalPath/${worker}`);
51
+ * if (res2.ok) {
52
+ * return res2
53
+ * }
53
54
  * },
54
55
  * });
55
56
  */
56
- static setup: ({ workerClass, pathValidator, basePath }: {
57
+ static setup: ({ workerClass, pathValidator }: {
57
58
  workerClass: (typeof WorkerMainThread)["workerClass"];
58
59
  pathValidator: (typeof WorkerMainThread)["pathValidator"];
59
- basePath?: (typeof WorkerMainThread)["basePath"];
60
60
  }) => void;
61
61
  /**
62
62
  * @description
@@ -65,23 +65,15 @@ export class WorkerMainThread<WT extends WorkerThread> {
65
65
  * @type {typeof Worker|typeof import('worker_threads').Worker}
66
66
  */
67
67
  static workerClass: typeof Worker | typeof import("worker_threads").Worker;
68
- /**
69
- * @description
70
- * - reference for worker file `basePath`;
71
- * - edit via `setup`;
72
- * @type {string}
73
- */
74
- static basePath: string;
75
68
  /**
76
69
  * @description
77
70
  * - reference for validating path;
78
71
  * - edit via `setup`;
79
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
72
+ * @type {(paths:{worker: string, root:string})=>Promise<string>}
80
73
  */
81
74
  static pathValidator: (paths: {
82
75
  worker: string;
83
76
  root: string;
84
- base: string;
85
77
  }) => Promise<string>;
86
78
  static #options: import("worker_threads").WorkerOptions & {
87
79
  type?: "module";
@@ -18,28 +18,21 @@ export class WorkerMainThread<WT extends WorkerThread> {
18
18
  * @param {Object} param0
19
19
  * @param {typeof WorkerMainThread["workerClass"]} param0.workerClass
20
20
  * @param {typeof WorkerMainThread["pathValidator"]} param0.pathValidator
21
- * @param {typeof WorkerMainThread["basePath"]} [param0.basePath]
22
21
  */
23
- static setup: ({ workerClass, pathValidator, basePath }: {
22
+ static setup: ({ workerClass, pathValidator }: {
24
23
  workerClass: (typeof WorkerMainThread)["workerClass"];
25
24
  pathValidator: (typeof WorkerMainThread)["pathValidator"];
26
- basePath?: (typeof WorkerMainThread)["basePath"];
27
25
  }) => void;
28
26
  /**
29
27
  * @type {typeof Worker|typeof import('worker_threads').Worker}
30
28
  */
31
29
  static workerClass: typeof Worker | typeof import("worker_threads").Worker;
32
30
  /**
33
- * @type {string}
34
- */
35
- static basePath: string;
36
- /**
37
- * @type {(paths:{worker: string, root:string, base: string})=>Promise<string>}
31
+ * @type {(paths:{worker: string, root:string})=>Promise<string>}
38
32
  */
39
33
  static pathValidator: (paths: {
40
34
  worker: string;
41
35
  root: string;
42
- base: string;
43
36
  }) => Promise<string>;
44
37
  static #options: import("worker_threads").WorkerOptions & {
45
38
  type?: "module";
@@ -1,35 +0,0 @@
1
- ## HOW TO INSTALL
2
-
3
- - example uses `npm`, you can allways use your own favourite package manager;
4
-
5
- ```shell
6
- npm i vivth
7
- ```
8
-
9
- ## vivth
10
-
11
- - `vivth` are intended to be a collections of usefull `primitives`, and not to be directly used as
12
- underlying framework;
13
- - completely `JSruntime` agnostic:
14
- > - instead of `vivth` trying to guess, all runtime specific API should be provided by dev;
15
- - contains helpers to help you write data driven javascript program, including:
16
- > - collections of extremely ⚡ performant `signal` classes;
17
- > > - `vivth` deliberately take away `auto-subscription`:
18
- > > > - and introducing more imperative way of subsrciption yet still simple enough, which in
19
- > > > turn, it completely removes total code blocking on previously needed auto subsrciption
20
- > > > process on first run;
21
- > > > - and also make previously unthinkable dynamic subscription on conditionals that runs
22
- > > > outside first run, now completely possible;
23
- > - collections of `queue-helper` classes;
24
- > - fully typed `worker-threads` abstraction;
25
- > - ` error as value` function helper;
26
- > - opionated `autoDocumentation`;
27
- > - opionated `bundler`;
28
-
29
- ## versions:
30
-
31
- - `1.0.0+:b`:
32
- > - beta release;
33
- > - checking edge cases;
34
- > - stable API, the exposed API access are highly unlikely to changes, only the underlying code
35
- > might changes for improving performance;