reflected 0.1.1 → 0.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reflected",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "A primitive to allow workers to call synchronously any functionality exposed on the main thread.",
5
5
  "exports": {
6
6
  ".": {
package/src/ffi/main.js CHANGED
@@ -4,22 +4,27 @@ import main from '../index.js';
4
4
 
5
5
  const { assign } = Object;
6
6
 
7
+ /**
8
+ * @param {string} url
9
+ * @param {import('../index.js').MainOptions & import('reflected-ffi/local').LocalOptions} options
10
+ */
7
11
  export default async (url, options) => {
8
12
  const ffi = local({
9
13
  timeout: 0,
10
14
  buffer: true,
11
15
  ...options,
16
+ // @ts-ignore
12
17
  reflect: (...args) => worker.send(args),
13
18
  });
14
19
 
15
- const worker = await main(
20
+ const worker = /** @type {Worker} */(await main(
16
21
  url,
17
22
  {
18
23
  ...options,
19
24
  // @ts-ignore
20
25
  onsync: args => ffi.reflect(...args),
21
26
  }
22
- );
27
+ ));
23
28
 
24
29
  const { terminate } = worker;
25
30
  return assign(worker, {
package/src/ffi/worker.js CHANGED
@@ -2,6 +2,9 @@ import remote from 'reflected-ffi/remote';
2
2
 
3
3
  import worker from '../index.js';
4
4
 
5
+ /**
6
+ * @param {import('../index.js').WorkerOptions & import('reflected-ffi/remote').RemoteOptions} options
7
+ */
5
8
  export default async options => {
6
9
  const reflected = await worker({
7
10
  ...options,
@@ -1,2 +1,18 @@
1
- declare function _default(url: any, options: any): Promise<any>;
1
+ declare function _default(url: string, options: import("../index.js").MainOptions & import("reflected-ffi/local").LocalOptions): Promise<Worker & {
2
+ ffi: {
3
+ assign: {
4
+ <T extends {}, U>(target: T, source: U): T & U;
5
+ <T extends {}, U, V>(target: T, source1: U, source2: V): T & U & V;
6
+ <T extends {}, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
7
+ (target: object, ...sources: any[]): any;
8
+ };
9
+ gather: (target: any, ...keys: (string | symbol)[][]) => any[];
10
+ query: (target: any, path: string) => any;
11
+ direct<T extends WeakKey>(value: T): T;
12
+ evaluate: (callback: Function, ...args: any[]) => any;
13
+ reflect(method: number, uid: number | null, ...args: any[]): any;
14
+ terminate(): void;
15
+ };
16
+ terminate(): void;
17
+ }>;
2
18
  export default _default;
@@ -1,4 +1,4 @@
1
- declare function _default(options: any): Promise<{
1
+ declare function _default(options: import("../index.js").WorkerOptions & import("reflected-ffi/remote").RemoteOptions): Promise<{
2
2
  global: unknown;
3
3
  isProxy: (value: any) => boolean;
4
4
  assign<T extends {}, U>(target: T, source: U): T & U;