@atlaspack/workers 2.14.5-canary.17 → 2.14.5-canary.171

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 (51) hide show
  1. package/CHANGELOG.md +210 -0
  2. package/index.d.ts +96 -3
  3. package/lib/Handle.js +0 -3
  4. package/lib/Worker.js +7 -1
  5. package/lib/WorkerFarm.js +15 -7
  6. package/lib/backend.js +5 -1
  7. package/lib/bus.js +1 -1
  8. package/lib/child.js +11 -4
  9. package/lib/cpuCount.js +6 -2
  10. package/lib/process/ProcessChild.js +6 -1
  11. package/lib/process/ProcessWorker.js +9 -2
  12. package/lib/threads/ThreadsChild.js +3 -0
  13. package/lib/threads/ThreadsWorker.js +10 -2
  14. package/lib/types/Handle.d.ts +19 -0
  15. package/lib/types/Worker.d.ts +40 -0
  16. package/lib/types/WorkerFarm.d.ts +93 -0
  17. package/lib/types/backend.d.ts +4 -0
  18. package/lib/types/bus.d.ts +6 -0
  19. package/lib/types/child.d.ts +43 -0
  20. package/lib/types/childState.d.ts +3 -0
  21. package/lib/types/cpuCount.d.ts +2 -0
  22. package/lib/types/index.d.ts +6 -0
  23. package/lib/types/process/ProcessChild.d.ts +9 -0
  24. package/lib/types/process/ProcessWorker.d.ts +16 -0
  25. package/lib/types/threads/ThreadsChild.d.ts +8 -0
  26. package/lib/types/threads/ThreadsWorker.d.ts +15 -0
  27. package/lib/types/types.d.ts +52 -0
  28. package/lib/types/web/WebChild.d.ts +8 -0
  29. package/lib/types/web/WebWorker.d.ts +15 -0
  30. package/lib/web/WebChild.js +6 -1
  31. package/lib/web/WebWorker.js +20 -4
  32. package/package.json +15 -18
  33. package/src/{Handle.js → Handle.ts} +11 -11
  34. package/src/{Worker.js → Worker.ts} +66 -54
  35. package/src/{WorkerFarm.js → WorkerFarm.ts} +196 -141
  36. package/src/{backend.js → backend.ts} +6 -3
  37. package/src/{bus.js → bus.ts} +2 -3
  38. package/src/{child.js → child.ts} +55 -43
  39. package/src/{childState.js → childState.ts} +1 -2
  40. package/src/{cpuCount.js → cpuCount.ts} +10 -7
  41. package/src/{index.js → index.ts} +0 -1
  42. package/src/process/{ProcessChild.js → ProcessChild.ts} +5 -3
  43. package/src/process/{ProcessWorker.js → ProcessWorker.ts} +10 -7
  44. package/src/threads/{ThreadsChild.js → ThreadsChild.ts} +2 -2
  45. package/src/threads/{ThreadsWorker.js → ThreadsWorker.ts} +14 -8
  46. package/src/{types.js → types.ts} +34 -35
  47. package/src/web/{WebChild.js → WebChild.ts} +6 -2
  48. package/src/web/{WebWorker.js → WebWorker.ts} +19 -7
  49. package/test/{cpuCount.test.js → cpuCount.test.ts} +0 -1
  50. package/test/{workerfarm.test.cjs → workerfarm.test.js} +9 -2
  51. package/tsconfig.json +4 -0
@@ -1,9 +1,11 @@
1
1
  // NOTE: @atlaspack/logger exports object instances from the module.
2
2
  // If there are issues, check all imports are using the same module instance/path
3
+ //
4
+ // NOTE2: @atlaspack/babel-register needs to run on the fixtures under ./integration
5
+ // otherwise the fixtures will import "package.json#main" files rather than "package.json#source"
3
6
  const Logger = require('@atlaspack/logger').default;
4
7
  const assert = require('assert');
5
- // eslint-disable-next-line @atlaspack/no-self-package-imports
6
- const WorkerFarm = require('@atlaspack/workers').default;
8
+ const WorkerFarm = require('../src/index.ts').default;
7
9
 
8
10
  describe('WorkerFarm', function () {
9
11
  this.timeout(30000);
@@ -292,6 +294,7 @@ describe('WorkerFarm', function () {
292
294
  await dispose();
293
295
  result = await workerfarm.run(ref);
294
296
  assert.equal(result, 'Shared reference does not exist');
297
+ await workerfarm.end();
295
298
  });
296
299
 
297
300
  it('Should resolve shared references in workers', async () => {
@@ -311,6 +314,7 @@ describe('WorkerFarm', function () {
311
314
 
312
315
  await dispose();
313
316
  assert(workerfarm.workerApi.resolveSharedReference(sharedValue) == null);
317
+ await workerfarm.end();
314
318
  });
315
319
 
316
320
  it('Should support shared references in local worker', async () => {
@@ -329,6 +333,7 @@ describe('WorkerFarm', function () {
329
333
  await dispose();
330
334
  result = await workerfarm.run(ref);
331
335
  assert.equal(result, 'Shared reference does not exist');
336
+ await workerfarm.end();
332
337
  });
333
338
 
334
339
  it('should resolve shared references in local worker', async () => {
@@ -348,6 +353,7 @@ describe('WorkerFarm', function () {
348
353
 
349
354
  await dispose();
350
355
  assert(workerfarm.workerApi.resolveSharedReference(sharedValue) == null);
356
+ await workerfarm.end();
351
357
  });
352
358
 
353
359
  it('Should dispose of shared references when ending', async () => {
@@ -361,5 +367,6 @@ describe('WorkerFarm', function () {
361
367
  assert.equal(workerfarm.sharedReferences.size, 1);
362
368
  await workerfarm.end();
363
369
  assert.equal(workerfarm.sharedReferences.size, 0);
370
+ await workerfarm.end();
364
371
  });
365
372
  });
package/tsconfig.json ADDED
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "../../../tsconfig.json",
3
+ "include": ["src"]
4
+ }