@anonaddy/omni-worker 0.1.0 → 0.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 (127) hide show
  1. package/README.md +22 -14
  2. package/dist/cjs/helpers/builder.js +22 -0
  3. package/dist/cjs/helpers/builder.js.map +1 -0
  4. package/dist/cjs/helpers/pool.js +9 -0
  5. package/dist/cjs/helpers/pool.js.map +1 -0
  6. package/dist/cjs/node/builder/helpers.js +14 -28
  7. package/dist/cjs/node/builder/helpers.js.map +1 -1
  8. package/dist/cjs/node/builder/index.js +2 -1
  9. package/dist/cjs/node/builder/index.js.map +1 -1
  10. package/dist/cjs/node/index.js +110 -51
  11. package/dist/cjs/node/index.js.map +1 -1
  12. package/dist/cjs/node/pool.js +131 -73
  13. package/dist/cjs/node/pool.js.map +1 -1
  14. package/dist/cjs/node.js +6 -0
  15. package/dist/cjs/node.js.map +1 -0
  16. package/dist/cjs/types/helpers.js +11 -0
  17. package/dist/cjs/types/helpers.js.map +1 -0
  18. package/dist/cjs/types/node-omni-worker.js +3 -0
  19. package/dist/cjs/types/node-omni-worker.js.map +1 -0
  20. package/dist/cjs/types/web-omni-worker.js +3 -0
  21. package/dist/cjs/types/web-omni-worker.js.map +1 -0
  22. package/dist/cjs/web/builder/helpers.js +9 -0
  23. package/dist/cjs/web/builder/helpers.js.map +1 -0
  24. package/dist/cjs/{node/builder/node.js → web/builder/index.js} +10 -17
  25. package/dist/cjs/web/builder/index.js.map +1 -0
  26. package/dist/cjs/web/builder/model.js +3 -0
  27. package/dist/cjs/web/builder/model.js.map +1 -0
  28. package/dist/cjs/web/index.js +156 -0
  29. package/dist/cjs/web/index.js.map +1 -0
  30. package/dist/cjs/web/pool.js +143 -0
  31. package/dist/cjs/web/pool.js.map +1 -0
  32. package/dist/cjs/web/provider/helpers.js +9 -0
  33. package/dist/cjs/web/provider/helpers.js.map +1 -0
  34. package/dist/cjs/web/provider/index.js +69 -0
  35. package/dist/cjs/web/provider/index.js.map +1 -0
  36. package/dist/cjs/web/provider/model.js +3 -0
  37. package/dist/cjs/web/provider/model.js.map +1 -0
  38. package/dist/cjs/web.js +8 -0
  39. package/dist/cjs/web.js.map +1 -0
  40. package/dist/mjs/helpers/builder.js +16 -0
  41. package/dist/mjs/helpers/builder.js.map +1 -0
  42. package/dist/mjs/helpers/pool.js +6 -0
  43. package/dist/mjs/helpers/pool.js.map +1 -0
  44. package/dist/mjs/node/builder/helpers.js +14 -27
  45. package/dist/mjs/node/builder/helpers.js.map +1 -1
  46. package/dist/mjs/node/builder/index.js +4 -3
  47. package/dist/mjs/node/builder/index.js.map +1 -1
  48. package/dist/mjs/node/index.js +111 -51
  49. package/dist/mjs/node/index.js.map +1 -1
  50. package/dist/mjs/node/pool.js +132 -73
  51. package/dist/mjs/node/pool.js.map +1 -1
  52. package/dist/mjs/node.js +2 -0
  53. package/dist/mjs/node.js.map +1 -0
  54. package/dist/mjs/types/helpers.js +8 -0
  55. package/dist/mjs/types/helpers.js.map +1 -0
  56. package/dist/mjs/types/node-omni-worker.js +2 -0
  57. package/dist/mjs/types/node-omni-worker.js.map +1 -0
  58. package/dist/mjs/types/web-omni-worker.js +2 -0
  59. package/dist/mjs/types/web-omni-worker.js.map +1 -0
  60. package/dist/mjs/web/builder/helpers.js +6 -0
  61. package/dist/mjs/web/builder/helpers.js.map +1 -0
  62. package/dist/mjs/web/builder/index.js +10 -0
  63. package/dist/mjs/web/builder/index.js.map +1 -0
  64. package/dist/mjs/web/builder/model.js +2 -0
  65. package/dist/mjs/web/builder/model.js.map +1 -0
  66. package/dist/mjs/web/index.js +120 -0
  67. package/dist/mjs/web/index.js.map +1 -0
  68. package/dist/mjs/web/pool.js +140 -0
  69. package/dist/mjs/web/pool.js.map +1 -0
  70. package/dist/mjs/web/provider/helpers.js +6 -0
  71. package/dist/mjs/web/provider/helpers.js.map +1 -0
  72. package/dist/mjs/web/provider/index.js +32 -0
  73. package/dist/mjs/web/provider/index.js.map +1 -0
  74. package/dist/mjs/web/provider/model.js +2 -0
  75. package/dist/mjs/web/provider/model.js.map +1 -0
  76. package/dist/mjs/web.js +3 -0
  77. package/dist/mjs/web.js.map +1 -0
  78. package/dist/types/helpers/builder.d.ts +2 -0
  79. package/dist/types/helpers/builder.d.ts.map +1 -0
  80. package/dist/types/helpers/pool.d.ts +2 -0
  81. package/dist/types/helpers/pool.d.ts.map +1 -0
  82. package/dist/types/node/builder/helpers.d.ts +0 -1
  83. package/dist/types/node/builder/helpers.d.ts.map +1 -1
  84. package/dist/types/node/builder/index.d.ts +2 -2
  85. package/dist/types/node/builder/index.d.ts.map +1 -1
  86. package/dist/types/node/index.d.ts +15 -13
  87. package/dist/types/node/index.d.ts.map +1 -1
  88. package/dist/types/node/pool.d.ts +4 -3
  89. package/dist/types/node/pool.d.ts.map +1 -1
  90. package/dist/types/node.d.ts +3 -0
  91. package/dist/types/node.d.ts.map +1 -0
  92. package/dist/types/types/helpers.d.ts +6 -0
  93. package/dist/types/types/helpers.d.ts.map +1 -0
  94. package/dist/types/types/node-omni-worker.d.ts +90 -0
  95. package/dist/types/types/node-omni-worker.d.ts.map +1 -0
  96. package/dist/types/types/web-omni-worker.d.ts +103 -0
  97. package/dist/types/types/web-omni-worker.d.ts.map +1 -0
  98. package/dist/types/web/builder/helpers.d.ts +3 -0
  99. package/dist/types/web/builder/helpers.d.ts.map +1 -0
  100. package/dist/types/web/builder/index.d.ts +8 -0
  101. package/dist/types/web/builder/index.d.ts.map +1 -0
  102. package/dist/types/web/builder/model.d.ts +11 -0
  103. package/dist/types/web/builder/model.d.ts.map +1 -0
  104. package/dist/types/web/index.d.ts +35 -0
  105. package/dist/types/web/index.d.ts.map +1 -0
  106. package/dist/types/web/pool.d.ts +31 -0
  107. package/dist/types/web/pool.d.ts.map +1 -0
  108. package/dist/types/web/provider/helpers.d.ts +2 -0
  109. package/dist/types/web/provider/helpers.d.ts.map +1 -0
  110. package/dist/types/web/provider/index.d.ts +16 -0
  111. package/dist/types/web/provider/index.d.ts.map +1 -0
  112. package/dist/types/web/provider/model.d.ts +7 -0
  113. package/dist/types/web/provider/model.d.ts.map +1 -0
  114. package/dist/types/web.d.ts +4 -0
  115. package/dist/types/web.d.ts.map +1 -0
  116. package/package.json +23 -9
  117. package/dist/cjs/index.js +0 -8
  118. package/dist/cjs/index.js.map +0 -1
  119. package/dist/cjs/node/builder/node.js.map +0 -1
  120. package/dist/mjs/index.js +0 -3
  121. package/dist/mjs/index.js.map +0 -1
  122. package/dist/mjs/node/builder/node.js +0 -14
  123. package/dist/mjs/node/builder/node.js.map +0 -1
  124. package/dist/types/index.d.ts +0 -4
  125. package/dist/types/index.d.ts.map +0 -1
  126. package/dist/types/node/builder/node.d.ts +0 -7
  127. package/dist/types/node/builder/node.d.ts.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EAClB,MAAM,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function getCallerDir(): string;
2
+ //# sourceMappingURL=builder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../../src/helpers/builder.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,WAa3B"}
@@ -0,0 +1,2 @@
1
+ export declare function doYield(): Promise<unknown>;
2
+ //# sourceMappingURL=pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/helpers/pool.ts"],"names":[],"mappings":"AAAA,wBAAgB,OAAO,qBAItB"}
@@ -1,3 +1,2 @@
1
- export declare function getCallerDir(): string;
2
1
  export declare function buildWorkerCode(entryFile: string): Promise<string>;
3
2
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/node/builder/helpers.ts"],"names":[],"mappings":"AAWA,wBAAgB,YAAY,WAa3B;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,mBAoChD"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/node/builder/helpers.ts"],"names":[],"mappings":"AAWA,wBAAgB,eAAe,CAAC,SAAS,EAAE,MAAM,mBAoChD"}
@@ -1,8 +1,8 @@
1
1
  import Comlink from 'comlink';
2
- import { Worker } from 'worker_threads';
2
+ import { Worker as ThreadWorker } from 'worker_threads';
3
3
  export declare const genWorkerCodeFromFile: (workerPath: string) => Promise<string>;
4
4
  export declare const buildNodeApiAndWorkerFromCode: <T>(code: string) => {
5
- worker: Worker;
5
+ worker: ThreadWorker;
6
6
  api: Comlink.RemoteObject<T>;
7
7
  };
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAKxC,eAAO,MAAM,qBAAqB,eACpB,MAAM,KACjB,OAAO,CAAC,MAAM,CAKhB,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,CAAC,QACvC,MAAM,KACX;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;CAMhD,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/node/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAMxD,eAAO,MAAM,qBAAqB,eACpB,MAAM,KACjB,OAAO,CAAC,MAAM,CAKhB,CAAA;AAED,eAAO,MAAM,6BAA6B,GAAI,CAAC,QACvC,MAAM,KACX;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;CAMtD,CAAA"}
@@ -1,27 +1,29 @@
1
- import { IOmniWorker } from '../types/index.d';
1
+ import { IOmniWorker, IPoolable } from '../types/node-omni-worker';
2
2
  import Comlink from 'comlink';
3
- import { IPoolable } from '../types/pool.d';
3
+ /**
4
+ * OmniWorker for NodeJS
5
+ */
4
6
  export declare class NodeOmniWorker<T> implements IOmniWorker<T>, IPoolable<T> {
5
- private _api;
6
- private _worker;
7
7
  private _code;
8
+ private _worker;
9
+ private _api;
8
10
  private constructor();
9
11
  /**
10
12
  * Expose the functions inside the worker to the rest of the application.
11
13
  * After having exposed the functions, the build step can be initiated.
12
- * @param functions An object with functions inside the worker to be exposed to
13
- * the rest of the application.
14
+ * @param exposable A class, object with functions or a single function to be
15
+ * exposed to the main thread.
14
16
  */
15
- static expose: <T_1 extends object>(functions: T_1) => void;
17
+ static expose: <T_1>(exposable: T_1) => void;
16
18
  /**
17
- * Build the OmniWorker from a worker file. Please note that the functions
18
- * on the worker file need to first be exposed using the expose({ <functions> })
19
- * functions, in order to start this build step.
19
+ * Handles the building of the necessary resources for an OmniWorker to function.
20
+ * This usually means, building from the consumer's code, creating the comlink
21
+ * interface between the worker and the main thread as well as the worker itself.
20
22
  *
21
- * @param path The relative path to where the worker module is located
22
- * @returns A new Node OmniWorker
23
+ * @param path Relative path FROM YOUR PROJECT's ROOT to the file to be the worker
24
+ * @returns An OmniWorker
23
25
  */
24
- static build<T extends object>(path: string): Promise<NodeOmniWorker<T>>;
26
+ static build<T>(path: string): Promise<NodeOmniWorker<T>>;
25
27
  isInitialized: () => boolean;
26
28
  use: () => Comlink.RemoteObject<T>;
27
29
  clone: (numOfTimes: number) => NodeOmniWorker<T>[];
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/node/index.ts"],"names":[],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,CAEhC;IAEK,GAAG,gCAOT;IAEM,KAAK,eAAgB,MAAM,yBAQjC;IAEM,OAAO,sBAEb;CACF"}
@@ -1,4 +1,5 @@
1
- import { IOmniWorkerPool, IOmniWorkerPoolOptions } from "../types/pool.d";
1
+ import { NodeOmniWorker } from ".";
2
+ import { IOmniWorkerPool, IOmniWorkerPoolOptions } from "../types/node-omni-worker";
2
3
  export declare class NodeOmniWorkerPool<T> implements IOmniWorkerPool<T> {
3
4
  private _pool;
4
5
  private _from;
@@ -11,13 +12,13 @@ export declare class NodeOmniWorkerPool<T> implements IOmniWorkerPool<T> {
11
12
  * @param from The (relative) file path from your project's root to the worker .ts file
12
13
  * @param options (Optional) Options object for launching the pool
13
14
  */
14
- static buildAndLaunch<T extends object>(from: string, options?: IOmniWorkerPoolOptions): Promise<NodeOmniWorkerPool<T>>;
15
+ static buildAndLaunch<T>(from: string, options?: IOmniWorkerPoolOptions): Promise<NodeOmniWorkerPool<T>>;
15
16
  /**
16
17
  * Launches a new NodeOmniWorker pool according to the options provided
17
18
  * @param worker An already built NodeOmniWorker
18
19
  * @returns A newly created pool
19
20
  */
20
- private static launch;
21
+ static launch<T>(worker: NodeOmniWorker<T>, options?: IOmniWorkerPoolOptions): NodeOmniWorkerPool<T>;
21
22
  /**
22
23
  * Applies the options provided
23
24
  */
@@ -1 +1 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/node/pool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE1E,qBAAa,kBAAkB,CAAC,CAAC,CAAE,YAAW,eAAe,CAAC,CAAC,CAAC;IAE9D,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO;IASP;;;;OAIG;WACiB,cAAc,CAAC,CAAC,SAAS,MAAM,EACjD,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,sBAAsB,GAC/B,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAMjC;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,MAAM;IAQrB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBb,aAAa,gBAAyB;IAEtC,eAAe,eAAqB;IAEpC,GAAG,0CAoBT;IAEM,OAAO,sBASb;CACF"}
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/node/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,GAAG,CAAC;AAEnC,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAe,MAAM,2BAA2B,CAAC;AAEjG,qBACa,kBAAkB,CAAC,CAAC,CAAE,YAAW,eAAe,CAAC,CAAC,CAAC;IAE9D,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO;IASP;;;;OAIG;WACiB,cAAc,CAAC,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,sBAER,GACA,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC;IAMjC;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EACb,MAAM,EAAE,cAAc,CAAC,CAAC,CAAC,EACzB,OAAO,GAAE,sBAER,GACA,kBAAkB,CAAC,CAAC,CAAC;IAKxB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBb,aAAa,gBAAyB;IAEtC,eAAe,eAAqB;IAEpC,GAAG,0CAoBT;IAEM,OAAO,sBASb;CACF"}
@@ -0,0 +1,3 @@
1
+ export { IOmniWorker, IOmniWorkerPool, IOmniWorkerPoolOptions } from './types/node-omni-worker';
2
+ export { NodeOmniWorker } from './node/index';
3
+ //# sourceMappingURL=node.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,cAAc,EACf,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Applies an interface with static function definitions
3
+ * @returns The constructor of class T
4
+ */
5
+ export declare function staticImplements<T>(): <U extends T>(constructor: U) => void;
6
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/types/helpers.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,MACtB,CAAC,SAAS,CAAC,eAAe,CAAC,UACtC"}
@@ -0,0 +1,90 @@
1
+ import { RemoteObject } from 'comlink/dist/umd/comlink';
2
+ /**
3
+ * The base Interface for all workers
4
+ */
5
+ export interface IOmniWorker<T> {
6
+ /**
7
+ * Use this function to see if the worker(pool) was successfully initialized
8
+ *
9
+ * @returns A boolean on whether or not the OmniWorker was successfully initialized
10
+ */
11
+ isInitialized: () => boolean;
12
+ /**
13
+ * Will let you use the worker functions that were exposed from inside the worker(pool).
14
+ * Please not that since using the worker, all your functions will now return
15
+ * asynchronously (Promise<T>).
16
+ *
17
+ * @returns An object with the worker functions that were exposed from the worker
18
+ */
19
+ use: () => RemoteObject<T>;
20
+ /**
21
+ * Terminates the underlying worker(s)
22
+ */
23
+ destroy: () => Promise<void>;
24
+ }
25
+ /**
26
+ * Defines whether the class is buildable, meaning that class can be made into
27
+ * a NodeOmniWorker type.
28
+ */
29
+ export interface IBuildable {
30
+ build: <T>(path: string) => Promise<IOmniWorker<T>>;
31
+ }
32
+ /**
33
+ * Defines whether the class can expose code from the module user to the main thread.
34
+ */
35
+ export interface IExposable {
36
+ expose: <T>(exposable: T) => void;
37
+ }
38
+ /**
39
+ * A pool with multiple OmniWorkers
40
+ */
41
+ export interface IOmniWorkerPool<T> extends IOmniWorker<T> {
42
+ /**
43
+ * Retrieves the number of workers that were initialized for the pool
44
+ */
45
+ getNumOfWorkers: () => number;
46
+ }
47
+ /**
48
+ * Determines whether an OmniWorker pool is able to build and launch
49
+ * OmniWorkers
50
+ */
51
+ export interface ILaunchable {
52
+ /**
53
+ * First builds the OmniWorkers and then launches a new OmniWorker pool
54
+ * @param from The (relative) file path from your project's root to the worker .ts file
55
+ * @param options (Optional) Options object for launching the pool
56
+ */
57
+ buildAndLaunch<T>(from: string, options?: IOmniWorkerPoolOptions): Promise<IOmniWorkerPool<T>>;
58
+ /**
59
+ * Launches a new OmniWorker pool according to the options provided
60
+ * @param worker An already built OmniWorker
61
+ * @returns A newly created pool
62
+ */
63
+ launch<T extends object>(worker: IOmniWorker<T>, options?: IOmniWorkerPoolOptions): IOmniWorkerPool<T>;
64
+ }
65
+ /**
66
+ * Whether an IOmniWorker is able to be pooled
67
+ */
68
+ export interface IPoolable<T> {
69
+ /**
70
+ * Clone an OmniWorker as many times as specified
71
+ * @param numOfTimes how many times the item should be cloned
72
+ * @returns a collection of OmniWorkers
73
+ */
74
+ clone: (numOfTimes: number) => IOmniWorker<T>[];
75
+ }
76
+ /**
77
+ * Options for instantiation of a OmniWorkerPool
78
+ */
79
+ export interface IPoolOptions {
80
+ /**
81
+ * The desired number of workers to be launched
82
+ */
83
+ numOfWorkers?: number;
84
+ }
85
+ /**
86
+ * The options for instantiating an OmniWorker pool
87
+ */
88
+ export interface IOmniWorkerPoolOptions extends IPoolOptions {
89
+ }
90
+ //# sourceMappingURL=node-omni-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"node-omni-worker.d.ts","sourceRoot":"","sources":["../../../src/types/node-omni-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAA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AY,CAAC,EAAE,MAAM,CAAA;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,YAAY;CAAI"}
@@ -0,0 +1,103 @@
1
+ import { RemoteObject } from 'comlink/dist/esm/comlink';
2
+ /**
3
+ * The base Interface for all workers
4
+ */
5
+ export interface IOmniWorker<T> {
6
+ /**
7
+ * Use this function to see if the worker(pool) was successfully initialized
8
+ *
9
+ * @returns A boolean on whether or not the OmniWorker was successfully initialized
10
+ */
11
+ isInitialized: () => boolean;
12
+ /**
13
+ * Will let you use the worker functions that were exposed from inside the worker(pool).
14
+ * Please not that since using the worker, all your functions will now return
15
+ * asynchronously (Promise<T>).
16
+ *
17
+ * @returns An object with the worker functions that were exposed from the worker
18
+ */
19
+ use: () => RemoteObject<T>;
20
+ /**
21
+ * Terminates the underlying worker(s)
22
+ */
23
+ destroy: () => Promise<void>;
24
+ }
25
+ /**
26
+ * Defines whether the class is buildable, meaning that class can be made into
27
+ * a OmniWorker type.
28
+ */
29
+ export interface IBuildable {
30
+ build: <T>(url: URL, options: IWebOmniWorkerBuilderOptions) => Promise<IOmniWorker<T>>;
31
+ }
32
+ /**
33
+ * Defines whether the class can expose code from the module user to the main thread.
34
+ */
35
+ export interface IExposable {
36
+ expose: <T>(exposable: T) => void;
37
+ }
38
+ /**
39
+ * A pool with multiple OmniWorkers
40
+ */
41
+ export interface IOmniWorkerPool<T> extends IOmniWorker<T> {
42
+ /**
43
+ * Retrieves the number of workers that were initialized for the pool
44
+ */
45
+ getNumOfWorkers: () => number;
46
+ }
47
+ /**
48
+ * Determines whether an OmniWorker pool is able to build and launch
49
+ * OmniWorkers
50
+ */
51
+ export interface ILaunchable {
52
+ /**
53
+ * First builds the OmniWorkers and then launches a new OmniWorker pool
54
+ * @param from The (relative) file path from your project's root to the worker .ts file
55
+ * @param options (Optional) Options object for launching the pool
56
+ */
57
+ buildAndLaunch<T>(url: URL, options?: IWebOmniWorkerBuilderOptions & IOmniWorkerPoolOptions): Promise<IOmniWorkerPool<T>>;
58
+ /**
59
+ * Launches a new OmniWorker pool according to the options provided
60
+ * @param worker An already built OmniWorker
61
+ * @returns A newly created pool
62
+ */
63
+ launch<T extends object>(worker: IOmniWorker<T>, options?: IOmniWorkerPoolOptions): IOmniWorkerPool<T>;
64
+ }
65
+ /**
66
+ * Whether an IOmniWorker is able to be pooled
67
+ */
68
+ export interface IPoolable<T> {
69
+ /**
70
+ * Clone an OmniWorker as many times as specified
71
+ * @param numOfTimes how many times the item should be cloned
72
+ * @returns a collection of OmniWorkers
73
+ */
74
+ clone: (numOfTimes: number) => IOmniWorker<T>[];
75
+ }
76
+ /**
77
+ * Options for instantiation of a OmniWorkerPool
78
+ */
79
+ export interface IPoolOptions {
80
+ /**
81
+ * The desired number of workers to be launched
82
+ */
83
+ numOfWorkers?: number;
84
+ }
85
+ /**
86
+ * The options for instantiating an OmniWorker pool
87
+ */
88
+ export interface IOmniWorkerPoolOptions extends IPoolOptions {
89
+ }
90
+ /**
91
+ * JS Extension types
92
+ */
93
+ export type JsExtension = '.cjs' | '.mjs' | '.js';
94
+ /**
95
+ * The options provided to the `provideWorker(url, options)` function
96
+ */
97
+ export interface IWebOmniWorkerBuilderOptions {
98
+ /**
99
+ * The bundler's target extension (defaults to .js)
100
+ */
101
+ extension?: JsExtension;
102
+ }
103
+ //# sourceMappingURL=web-omni-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web-omni-worker.d.ts","sourceRoot":"","sources":["../../../src/types/web-omni-worker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;EAEE;AACF,MAAM,WAAW,WAAW,CAAC,CAAC;IAC5B;;;;OAIG;IACH,aAAa,EAAE,MAAM,OAAO,CAAA;IAE5B;;;;;;OAMG;IACH,GAAG,EAAE,MAAM,YAAY,CAAC,CAAC,CAAC,CAAA;IAE1B;;OAEG;IACH,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAA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IAC3C;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAA;CACxB"}
@@ -0,0 +1,3 @@
1
+ import { JsExtension } from "../../types/web-omni-worker";
2
+ export declare function convertToJsUrl(tsUrl: URL, extension: JsExtension): URL;
3
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/web/builder/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAE1D,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,WAAW,GAAG,GAAG,CAItE"}
@@ -0,0 +1,8 @@
1
+ import * as Comlink from 'comlink/dist/esm/comlink';
2
+ import { IWebOmniWorkerBuilderOptions } from '../../types/web-omni-worker';
3
+ export declare const buildWebApiAndWorker: <T>(tsUrl: URL, options: IWebOmniWorkerBuilderOptions) => {
4
+ jsUrl: URL;
5
+ worker: Worker;
6
+ api: Comlink.RemoteObject<T>;
7
+ };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/builder/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AAEpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,6BAA6B,CAAC;AAE3E,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAC7B,GAAG,WACD,4BAA4B,KACpC;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAA;CAS5D,CAAA"}
@@ -0,0 +1,11 @@
1
+ export type JsExtension = '.cjs' | '.mjs' | '.js';
2
+ /**
3
+ * The options provided to the `provideWorker(url, options)` function
4
+ */
5
+ export interface WebOmniWorkerBuilderOptions {
6
+ /**
7
+ * The bundler's target extension (defaults to .js)
8
+ */
9
+ extension?: JsExtension;
10
+ }
11
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/web/builder/model.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAElD;;GAEG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,SAAS,CAAC,EAAE,WAAW,CAAA;CACxB"}
@@ -0,0 +1,35 @@
1
+ import { IOmniWorker, IPoolable } from "../types/web-omni-worker";
2
+ import * as Comlink from 'comlink/dist/esm/comlink';
3
+ import { IWebOmniWorkerBuilderOptions } from "../web";
4
+ /**
5
+ * OmniWorker for the web
6
+ */
7
+ export declare class WebOmniWorker<T> implements IOmniWorker<T>, IPoolable<T> {
8
+ private _url;
9
+ private _options;
10
+ private _worker;
11
+ private _api;
12
+ constructor(url: URL, options: IWebOmniWorkerBuilderOptions, worker: Worker, api: Comlink.RemoteObject<T>);
13
+ /**
14
+ * Expose the functions inside the worker to the rest of the application.
15
+ * After having exposed the functions, the build step can be initiated.
16
+ * @param exposable A class, object with functions or a single function to be
17
+ * exposed to the main thread.
18
+ */
19
+ static expose: <T_1>(exposable: T_1) => void;
20
+ /**
21
+ * Handles the building of the necessary resources for an OmniWorker to function.
22
+ * This usually means, building from the consumer's code, creating the comlink
23
+ * interface between the worker and the main thread as well as the worker itself.
24
+ *
25
+ * @param tsUrl A URL object linking to the worker .ts file
26
+ * @param options Builder options
27
+ * @returns A WebOmniWorker
28
+ */
29
+ static build<T>(tsUrl: URL, options?: IWebOmniWorkerBuilderOptions): Promise<WebOmniWorker<T>>;
30
+ isInitialized: () => boolean;
31
+ use: () => Comlink.RemoteObject<T>;
32
+ destroy: () => Promise<void>;
33
+ clone: (numOfTimes: number) => WebOmniWorker<T>[];
34
+ }
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0B,WAAW,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAC1F,OAAO,KAAK,OAAO,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EAAE,4BAA4B,EAAE,MAAM,QAAQ,CAAC;AAEtD;;GAEG;AACH,qBAEa,aAAa,CAAC,CAAC,CAAE,YAAW,WAAW,CAAC,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IACnE,OAAO,CAAC,IAAI,CAAM;IAClB,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,IAAI,CAA0B;gBAGpC,GAAG,EAAE,GAAG,EACR,OAAO,EAAE,4BAA4B,EACrC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC;IAS9B;;;;;OAKG;IACH,OAAc,MAAM,mBAAkB,GAAC,KAAG,IAAI,CAE7C;IAED;;;;;;;;OAQG;WACiB,KAAK,CAAC,CAAC,EACzB,KAAK,EAAE,GAAG,EACV,OAAO,GAAE,4BAER,GACA,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;IAK5B,aAAa,gBAAiC;IAE9C,GAAG,gCAOF;IAED,OAAO,sBAEL;IAEF,KAAK,eAAgB,MAAM,wBASzB;CACH"}
@@ -0,0 +1,31 @@
1
+ import { WebOmniWorker } from ".";
2
+ import { IOmniWorkerPool, IOmniWorkerPoolOptions, IWebOmniWorkerBuilderOptions } from "../types/web-omni-worker";
3
+ export declare class WebOmniWorkerPool<T> implements IOmniWorkerPool<T> {
4
+ private _pool;
5
+ private _from;
6
+ private _options;
7
+ private _count;
8
+ private _lastUseIdx;
9
+ private constructor();
10
+ /**
11
+ * First builds the OmniWorkers and then launches a new WebOmniWorker pool
12
+ * @param url A URL with the relative file path to the worker .ts file
13
+ * @param options (Optional) Options object for launching the pool
14
+ */
15
+ static buildAndLaunch<T>(url: URL, options?: IWebOmniWorkerBuilderOptions & IOmniWorkerPoolOptions): Promise<WebOmniWorkerPool<T>>;
16
+ /**
17
+ * Launches a new WebOmniWorker pool according to the options provided
18
+ * @param worker An already built WebOmniWorker
19
+ * @returns A newly created pool
20
+ */
21
+ static launch<T>(worker: WebOmniWorker<T>, options?: IWebOmniWorkerBuilderOptions & IOmniWorkerPoolOptions): WebOmniWorkerPool<T>;
22
+ /**
23
+ * Applies the options provided
24
+ */
25
+ private applyOptions;
26
+ isInitialized: () => boolean;
27
+ getNumOfWorkers: () => number;
28
+ use: () => import("comlink/dist/esm/comlink").RemoteObject<T>;
29
+ destroy: () => Promise<void>;
30
+ }
31
+ //# sourceMappingURL=pool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../../src/web/pool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,GAAG,CAAC;AAElC,OAAO,EAAe,eAAe,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAE9H,qBACa,iBAAiB,CAAC,CAAC,CAAE,YAAW,eAAe,CAAC,CAAC,CAAC;IAE7D,OAAO,CAAC,KAAK,CAA0B;IACvC,OAAO,CAAC,KAAK,CAAmB;IAChC,OAAO,CAAC,QAAQ,CAAwD;IACxE,OAAO,CAAC,MAAM,CAAa;IAC3B,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO;IASP;;;;OAIG;WACiB,cAAc,CAAC,CAAC,EAClC,GAAG,EAAE,GAAG,EACR,OAAO,GAAE,4BAA4B,GAAG,sBAGvC,GACA,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;IAMhC;;;;OAIG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EACb,MAAM,EAAE,aAAa,CAAC,CAAC,CAAC,EACxB,OAAO,CAAC,EAAE,4BAA4B,GAAG,sBAAsB,GAC9D,iBAAiB,CAAC,CAAC,CAAC;IAKvB;;OAEG;IACH,OAAO,CAAC,YAAY;IAmBb,aAAa,gBAAyB;IAEtC,eAAe,eAAqB;IAEpC,GAAG,2DAoBT;IAEM,OAAO,sBASb;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare function convertToJsUrl(tsUrl: URL, extension?: string): URL;
2
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/web/provider/helpers.ts"],"names":[],"mappings":"AAAA,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,SAAQ,GAAG,GAAG,CAIjE"}
@@ -0,0 +1,16 @@
1
+ import { WorkerProviderOptions } from "./model";
2
+ /**
3
+ * This provider is needed, since most bundlers will "tree shake"
4
+ * out worker files that are not imported. The reason for that,
5
+ * is that worker files aren't supposed to be imported.
6
+ * This wrapper function quickly imports the worker, before building
7
+ * it.
8
+ *
9
+ * @param tsUrl A URL object linking a worker .ts file, created using
10
+ * new URL('/path/to/your/file.ts', import.meta.url)
11
+ * @param options Optional options for the provisioning
12
+ * @returns A callback function, returning the the .js URL for building
13
+ * the worker
14
+ */
15
+ export declare const provideWorker: (tsUrl: URL, options?: WorkerProviderOptions) => () => URL;
16
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/provider/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,aAAa,UACjB,GAAG,YACD,qBAAqB,WAOnB,GAWZ,CAAA"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The options provided to the `provideWorker(url, options)` function
3
+ */
4
+ export interface WorkerProviderOptions {
5
+ extension?: '.cjs' | '.mjs' | '.js';
6
+ }
7
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../src/web/provider/model.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,KAAK,CAAA;CACpC"}
@@ -0,0 +1,4 @@
1
+ export { IOmniWorker, IOmniWorkerPool, IOmniWorkerPoolOptions, IWebOmniWorkerBuilderOptions } from './types/web-omni-worker';
2
+ export { WebOmniWorker } from './web/index';
3
+ export { WebOmniWorkerPool } from './web/pool';
4
+ //# sourceMappingURL=web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,sBAAsB,EACtB,4BAA4B,EAC7B,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,aAAa,EACd,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,iBAAiB,EAClB,MAAM,YAAY,CAAC"}
package/package.json CHANGED
@@ -1,19 +1,31 @@
1
1
  {
2
2
  "name": "@anonaddy/omni-worker",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Run your code including all imports inside workers on either the web or on NodeJS!",
5
- "main": "dist/cjs/index.js",
6
- "module": "dist/mjs/index.js",
5
+ "main": "dist/cjs/node.js",
6
+ "types": "dist/types/node.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "require": "./dist/cjs/index.js",
10
- "import": "./dist/mjs/index.js"
9
+ "node": {
10
+ "types": "./dist/types/node.d.ts",
11
+ "require": "./dist/cjs/node.js",
12
+ "import": "./dist/mjs/node.js"
13
+ },
14
+ "browser": {
15
+ "types": "./dist/types/web.d.ts",
16
+ "import": "./dist/mjs/web.js"
17
+ },
18
+ "default": {
19
+ "types": "./dist/types/web.d.ts",
20
+ "import": "./dist/mjs/web.js"
21
+ }
11
22
  },
12
23
  "./package.json": "./package.json"
13
24
  },
14
- "types": "dist/types/index.d.ts",
15
25
  "scripts": {
16
26
  "build": "tsc -p tsconfig.cjs.json && tsc -p tsconfig.mjs.json",
27
+ "prepack": "npm run build",
28
+ "pack": "npm pack --silent",
17
29
  "test:dom": "vitest --config vite.config.dom.ts",
18
30
  "test:node": "vitest --config vite.config.node.ts",
19
31
  "prepare": "npm run build"
@@ -39,20 +51,22 @@
39
51
  "@types/lodash": "^4.17.15",
40
52
  "@types/memory-fs": "^0.3.7",
41
53
  "@types/webpack-node-externals": "^3.0.4",
54
+ "jsdom": "^26.0.0",
42
55
  "lodash": "^4.17.21",
43
56
  "swisseph": "^0.5.17",
44
57
  "ts-node": "^10.9.2",
45
58
  "typescript": "^5.0.0",
46
59
  "vitest": "^3.0.5"
47
60
  },
48
- "dependencies": {
61
+ "peerDependencies": {
49
62
  "@babel/plugin-transform-modules-commonjs": "^7.26.3",
63
+ "@babel/plugin-proposal-decorators": "^7.25.9",
50
64
  "@babel/preset-env": "^7.26.8",
51
65
  "@babel/preset-typescript": "^7.26.0",
52
66
  "babel-loader": "^9.2.1",
53
- "comlink": "^4.4.2",
54
67
  "terser-webpack-plugin": "^5.3.11",
55
68
  "webpack": "^5.97.1",
56
- "webpack-node-externals": "^3.0.0"
69
+ "webpack-node-externals": "^3.0.0",
70
+ "comlink": "^4.4.2"
57
71
  }
58
72
  }
package/dist/cjs/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NodeOmniWorkerPool = exports.NodeOmniWorker = void 0;
4
- var node_1 = require("./node");
5
- Object.defineProperty(exports, "NodeOmniWorker", { enumerable: true, get: function () { return node_1.NodeOmniWorker; } });
6
- var pool_1 = require("./node/pool");
7
- Object.defineProperty(exports, "NodeOmniWorkerPool", { enumerable: true, get: function () { return pool_1.NodeOmniWorkerPool; } });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAKA,+BAEgB;AADd,sGAAA,cAAc,OAAA;AAGhB,oCAEqB;AADnB,0GAAA,kBAAkB,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../../src/node/builder/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAmC;AACnC,mDAAwC;AACxC,uFAA4D;AAC5D,uCAA0D;AAC1D,gDAAwB;AAEjB,MAAM,YAAY,GAAG,KAAK,EAC/B,UAAkB,EACkC,EAAE;IAEtD,MAAM,SAAS,GAAG,IAAA,sBAAY,GAAE,CAAC;IACjC,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IAEzD,MAAM,EAAE,GAAG,MAAM,IAAA,yBAAe,EAAC,YAAY,CAAC,CAAC;IAE/C,MAAM,MAAM,GAAG,IAAI,uBAAM,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAI,IAAA,yBAAY,EAAC,MAAM,CAAC,CAAC,CAAC;IAElD,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC;AACzB,CAAC,CAAA;AAbY,QAAA,YAAY,gBAaxB"}
package/dist/mjs/index.js DELETED
@@ -1,3 +0,0 @@
1
- export { NodeOmniWorker } from './node';
2
- export { NodeOmniWorkerPool } from './node/pool';
3
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,cAAc,EACf,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,kBAAkB,EACnB,MAAM,aAAa,CAAC"}