@atlaspack/workers 2.14.5-canary.44 → 2.14.5-canary.442

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 (68) hide show
  1. package/CHANGELOG.md +493 -0
  2. package/dist/Handle.js +33 -0
  3. package/dist/Worker.js +180 -0
  4. package/dist/WorkerFarm.js +539 -0
  5. package/dist/backend.js +34 -0
  6. package/dist/bus.js +24 -0
  7. package/dist/child.js +290 -0
  8. package/dist/childState.js +11 -0
  9. package/dist/cpuCount.js +72 -0
  10. package/dist/index.js +44 -0
  11. package/dist/process/ProcessChild.js +48 -0
  12. package/dist/process/ProcessWorker.js +68 -0
  13. package/dist/threads/ThreadsChild.js +31 -0
  14. package/dist/threads/ThreadsWorker.js +47 -0
  15. package/dist/types.js +2 -0
  16. package/dist/web/WebChild.js +34 -0
  17. package/dist/web/WebWorker.js +70 -0
  18. package/index.d.ts +96 -3
  19. package/lib/Handle.js +0 -3
  20. package/lib/Worker.js +7 -1
  21. package/lib/WorkerFarm.js +12 -7
  22. package/lib/backend.js +5 -1
  23. package/lib/bus.js +1 -1
  24. package/lib/child.js +11 -4
  25. package/lib/cpuCount.js +6 -2
  26. package/lib/process/ProcessChild.js +6 -1
  27. package/lib/process/ProcessWorker.js +9 -2
  28. package/lib/threads/ThreadsChild.js +3 -0
  29. package/lib/threads/ThreadsWorker.js +10 -2
  30. package/lib/types/Handle.d.ts +19 -0
  31. package/lib/types/Worker.d.ts +40 -0
  32. package/lib/types/WorkerFarm.d.ts +93 -0
  33. package/lib/types/backend.d.ts +4 -0
  34. package/lib/types/bus.d.ts +6 -0
  35. package/lib/types/child.d.ts +43 -0
  36. package/lib/types/childState.d.ts +3 -0
  37. package/lib/types/cpuCount.d.ts +2 -0
  38. package/lib/types/index.d.ts +6 -0
  39. package/lib/types/process/ProcessChild.d.ts +9 -0
  40. package/lib/types/process/ProcessWorker.d.ts +16 -0
  41. package/lib/types/threads/ThreadsChild.d.ts +8 -0
  42. package/lib/types/threads/ThreadsWorker.d.ts +15 -0
  43. package/lib/types/types.d.ts +52 -0
  44. package/lib/types/web/WebChild.d.ts +8 -0
  45. package/lib/types/web/WebWorker.d.ts +15 -0
  46. package/lib/web/WebChild.js +6 -1
  47. package/lib/web/WebWorker.js +19 -4
  48. package/package.json +15 -19
  49. package/src/{Handle.js → Handle.ts} +11 -11
  50. package/src/{Worker.js → Worker.ts} +66 -54
  51. package/src/{WorkerFarm.js → WorkerFarm.ts} +195 -142
  52. package/src/{backend.js → backend.ts} +6 -3
  53. package/src/{bus.js → bus.ts} +2 -3
  54. package/src/{child.js → child.ts} +55 -43
  55. package/src/{childState.js → childState.ts} +1 -2
  56. package/src/{cpuCount.js → cpuCount.ts} +10 -7
  57. package/src/{index.js → index.ts} +0 -1
  58. package/src/process/{ProcessChild.js → ProcessChild.ts} +5 -3
  59. package/src/process/{ProcessWorker.js → ProcessWorker.ts} +10 -7
  60. package/src/threads/{ThreadsChild.js → ThreadsChild.ts} +2 -2
  61. package/src/threads/{ThreadsWorker.js → ThreadsWorker.ts} +14 -8
  62. package/src/{types.js → types.ts} +34 -35
  63. package/src/web/{WebChild.js → WebChild.ts} +6 -2
  64. package/src/web/{WebWorker.js → WebWorker.ts} +19 -7
  65. package/test/{cpuCount.test.js → cpuCount.test.ts} +0 -1
  66. package/test/{workerfarm.test.cjs → workerfarm.test.js} +9 -2
  67. package/tsconfig.json +27 -0
  68. package/tsconfig.tsbuildinfo +1 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,498 @@
1
1
  # @atlaspack/workers
2
2
 
3
+ ## 2.14.56
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies []:
8
+ - @atlaspack/logger@2.14.48
9
+ - @atlaspack/utils@3.3.8
10
+ - @atlaspack/types-internal@2.24.1
11
+ - @atlaspack/profiler@2.15.17
12
+
13
+ ## 2.14.55
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [[`857962a`](https://github.com/atlassian-labs/atlaspack/commit/857962a352bb0aebaf74a8765e8c44d7e875a4e9)]:
18
+ - @atlaspack/types-internal@2.24.0
19
+ - @atlaspack/logger@2.14.47
20
+ - @atlaspack/utils@3.3.7
21
+ - @atlaspack/build-cache@2.13.13
22
+ - @atlaspack/profiler@2.15.16
23
+
24
+ ## 2.14.54
25
+
26
+ ### Patch Changes
27
+
28
+ - Updated dependencies [[`d8e984b`](https://github.com/atlassian-labs/atlaspack/commit/d8e984b7f6d04fa03707fa299bfd8b8bf9f58280)]:
29
+ - @atlaspack/utils@3.3.6
30
+ - @atlaspack/logger@2.14.46
31
+ - @atlaspack/build-cache@2.13.12
32
+ - @atlaspack/types-internal@2.23.2
33
+ - @atlaspack/profiler@2.15.15
34
+
35
+ ## 2.14.53
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies []:
40
+ - @atlaspack/logger@2.14.45
41
+ - @atlaspack/utils@3.3.5
42
+ - @atlaspack/build-cache@2.13.11
43
+ - @atlaspack/types-internal@2.23.1
44
+ - @atlaspack/profiler@2.15.14
45
+
46
+ ## 2.14.52
47
+
48
+ ### Patch Changes
49
+
50
+ - Updated dependencies [[`e058f0e`](https://github.com/atlassian-labs/atlaspack/commit/e058f0e7a0423ba9373e85a7dbd5c1dd43b47916)]:
51
+ - @atlaspack/types-internal@2.23.0
52
+ - @atlaspack/logger@2.14.44
53
+ - @atlaspack/profiler@2.15.13
54
+ - @atlaspack/utils@3.3.4
55
+ - @atlaspack/build-cache@2.13.10
56
+
57
+ ## 2.14.51
58
+
59
+ ### Patch Changes
60
+
61
+ - Updated dependencies []:
62
+ - @atlaspack/logger@2.14.43
63
+ - @atlaspack/utils@3.3.3
64
+ - @atlaspack/profiler@2.15.12
65
+ - @atlaspack/types-internal@2.22.8
66
+
67
+ ## 2.14.50
68
+
69
+ ### Patch Changes
70
+
71
+ - Updated dependencies []:
72
+ - @atlaspack/logger@2.14.42
73
+ - @atlaspack/utils@3.3.2
74
+ - @atlaspack/build-cache@2.13.9
75
+ - @atlaspack/types-internal@2.22.7
76
+ - @atlaspack/profiler@2.15.11
77
+
78
+ ## 2.14.49
79
+
80
+ ### Patch Changes
81
+
82
+ - Updated dependencies []:
83
+ - @atlaspack/logger@2.14.41
84
+ - @atlaspack/utils@3.3.1
85
+ - @atlaspack/build-cache@2.13.8
86
+ - @atlaspack/types-internal@2.22.6
87
+ - @atlaspack/profiler@2.15.10
88
+
89
+ ## 2.14.48
90
+
91
+ ### Patch Changes
92
+
93
+ - Updated dependencies [[`47aa84e`](https://github.com/atlassian-labs/atlaspack/commit/47aa84e44c61066072a5bf3d57678565b9d2c5a3), [`565bab3`](https://github.com/atlassian-labs/atlaspack/commit/565bab3771cc334659d873cabff4cdfac0860cc7)]:
94
+ - @atlaspack/utils@3.3.0
95
+ - @atlaspack/build-cache@2.13.7
96
+ - @atlaspack/profiler@2.15.9
97
+ - @atlaspack/logger@2.14.40
98
+ - @atlaspack/types-internal@2.22.5
99
+
100
+ ## 2.14.47
101
+
102
+ ### Patch Changes
103
+
104
+ - Updated dependencies []:
105
+ - @atlaspack/logger@2.14.39
106
+ - @atlaspack/utils@3.2.8
107
+ - @atlaspack/profiler@2.15.8
108
+ - @atlaspack/types-internal@2.22.4
109
+
110
+ ## 2.14.46
111
+
112
+ ### Patch Changes
113
+
114
+ - Updated dependencies [[`02cc8b3`](https://github.com/atlassian-labs/atlaspack/commit/02cc8b32c06ca6b51806b33f6f707ca06e55e957)]:
115
+ - @atlaspack/types-internal@2.22.3
116
+ - @atlaspack/logger@2.14.38
117
+ - @atlaspack/utils@3.2.7
118
+ - @atlaspack/profiler@2.15.7
119
+
120
+ ## 2.14.45
121
+
122
+ ### Patch Changes
123
+
124
+ - Updated dependencies []:
125
+ - @atlaspack/types-internal@2.22.2
126
+ - @atlaspack/utils@3.2.6
127
+ - @atlaspack/logger@2.14.37
128
+ - @atlaspack/profiler@2.15.6
129
+
130
+ ## 2.14.44
131
+
132
+ ### Patch Changes
133
+
134
+ - Updated dependencies []:
135
+ - @atlaspack/logger@2.14.36
136
+ - @atlaspack/utils@3.2.5
137
+ - @atlaspack/types-internal@2.22.1
138
+ - @atlaspack/profiler@2.15.5
139
+
140
+ ## 2.14.43
141
+
142
+ ### Patch Changes
143
+
144
+ - Updated dependencies [[`00fa643`](https://github.com/atlassian-labs/atlaspack/commit/00fa6433202bfd3311479f6314c9ec878a789f2c)]:
145
+ - @atlaspack/types-internal@2.22.0
146
+ - @atlaspack/logger@2.14.35
147
+ - @atlaspack/profiler@2.15.4
148
+ - @atlaspack/utils@3.2.4
149
+
150
+ ## 2.14.42
151
+
152
+ ### Patch Changes
153
+
154
+ - Updated dependencies []:
155
+ - @atlaspack/logger@2.14.34
156
+ - @atlaspack/utils@3.2.3
157
+ - @atlaspack/types-internal@2.21.3
158
+ - @atlaspack/profiler@2.15.3
159
+
160
+ ## 2.14.41
161
+
162
+ ### Patch Changes
163
+
164
+ - Updated dependencies []:
165
+ - @atlaspack/logger@2.14.33
166
+ - @atlaspack/utils@3.2.2
167
+ - @atlaspack/types-internal@2.21.2
168
+ - @atlaspack/profiler@2.15.2
169
+
170
+ ## 2.14.40
171
+
172
+ ### Patch Changes
173
+
174
+ - Updated dependencies []:
175
+ - @atlaspack/logger@2.14.32
176
+ - @atlaspack/utils@3.2.1
177
+ - @atlaspack/types-internal@2.21.1
178
+ - @atlaspack/profiler@2.15.1
179
+
180
+ ## 2.14.39
181
+
182
+ ### Patch Changes
183
+
184
+ - Updated dependencies [[`8eb84ee`](https://github.com/atlassian-labs/atlaspack/commit/8eb84ee61a42bfe87c58079b610802b07a6a13e4), [`73168c2`](https://github.com/atlassian-labs/atlaspack/commit/73168c275a5d9abff9907bcf536b340bca1ed5f0), [`617a318`](https://github.com/atlassian-labs/atlaspack/commit/617a318ddc9419b38360257353fec50b9051ee13)]:
185
+ - @atlaspack/types-internal@2.21.0
186
+ - @atlaspack/utils@3.2.0
187
+ - @atlaspack/profiler@2.15.0
188
+ - @atlaspack/logger@2.14.31
189
+
190
+ ## 2.14.38
191
+
192
+ ### Patch Changes
193
+
194
+ - Updated dependencies [[`7d7a55d`](https://github.com/atlassian-labs/atlaspack/commit/7d7a55dd6395ec391a2e4c33b3dec0d1ea477d4c)]:
195
+ - @atlaspack/utils@3.1.2
196
+ - @atlaspack/types-internal@2.20.8
197
+ - @atlaspack/logger@2.14.30
198
+ - @atlaspack/profiler@2.14.35
199
+
200
+ ## 2.14.37
201
+
202
+ ### Patch Changes
203
+
204
+ - Updated dependencies []:
205
+ - @atlaspack/logger@2.14.29
206
+ - @atlaspack/utils@3.1.1
207
+ - @atlaspack/types-internal@2.20.7
208
+ - @atlaspack/profiler@2.14.34
209
+
210
+ ## 2.14.36
211
+
212
+ ### Patch Changes
213
+
214
+ - Updated dependencies [[`5776be2`](https://github.com/atlassian-labs/atlaspack/commit/5776be21f70a3f2b9471ba33da3ba1a883f21f1a)]:
215
+ - @atlaspack/utils@3.1.0
216
+ - @atlaspack/logger@2.14.28
217
+ - @atlaspack/types-internal@2.20.6
218
+ - @atlaspack/profiler@2.14.33
219
+
220
+ ## 2.14.35
221
+
222
+ ### Patch Changes
223
+
224
+ - Updated dependencies [[`c372f3f`](https://github.com/atlassian-labs/atlaspack/commit/c372f3fd6fce8200d5cf47f41bc7895c6cbb5558), [`17dfea9`](https://github.com/atlassian-labs/atlaspack/commit/17dfea9e9f3169807808520df9c09ebf70dc8b10)]:
225
+ - @atlaspack/types-internal@2.20.5
226
+ - @atlaspack/utils@3.0.3
227
+ - @atlaspack/logger@2.14.27
228
+ - @atlaspack/profiler@2.14.32
229
+
230
+ ## 2.14.34
231
+
232
+ ### Patch Changes
233
+
234
+ - [#782](https://github.com/atlassian-labs/atlaspack/pull/782) [`25cbee6`](https://github.com/atlassian-labs/atlaspack/commit/25cbee625fb47ac20423fe34ff37bc818a807245) Thanks [@yamadapc](https://github.com/yamadapc)! - Initial atlaspack-inspector release
235
+
236
+ - Updated dependencies []:
237
+ - @atlaspack/types-internal@2.20.4
238
+ - @atlaspack/utils@3.0.2
239
+ - @atlaspack/logger@2.14.26
240
+ - @atlaspack/profiler@2.14.31
241
+
242
+ ## 2.14.33
243
+
244
+ ### Patch Changes
245
+
246
+ - Updated dependencies [[`236e546`](https://github.com/atlassian-labs/atlaspack/commit/236e5465863dca6044a7191e05260a5b924c342e)]:
247
+ - @atlaspack/utils@3.0.1
248
+ - @atlaspack/types-internal@2.20.3
249
+ - @atlaspack/logger@2.14.25
250
+ - @atlaspack/profiler@2.14.30
251
+
252
+ ## 2.14.32
253
+
254
+ ### Patch Changes
255
+
256
+ - Updated dependencies [[`1180103`](https://github.com/atlassian-labs/atlaspack/commit/118010351ed444f8178988afb3f77807154dd933)]:
257
+ - @atlaspack/utils@3.0.0
258
+ - @atlaspack/types-internal@2.20.2
259
+ - @atlaspack/logger@2.14.24
260
+ - @atlaspack/profiler@2.14.29
261
+
262
+ ## 2.14.31
263
+
264
+ ### Patch Changes
265
+
266
+ - [#785](https://github.com/atlassian-labs/atlaspack/pull/785) [`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922) Thanks [@matt-koko](https://github.com/matt-koko)! - We need to re-publish every package in Atlaspack with the corrected types field.
267
+
268
+ - Updated dependencies [[`0e7dd5e`](https://github.com/atlassian-labs/atlaspack/commit/0e7dd5ec6fbe05aa9e0bb5775a9d0975f206a922)]:
269
+ - @atlaspack/build-cache@2.13.6
270
+ - @atlaspack/diagnostic@2.14.4
271
+ - @atlaspack/logger@2.14.23
272
+ - @atlaspack/profiler@2.14.28
273
+ - @atlaspack/types-internal@2.20.1
274
+ - @atlaspack/utils@2.19.3
275
+
276
+ ## 2.14.30
277
+
278
+ ### Patch Changes
279
+
280
+ - Updated dependencies [[`eedcbc4`](https://github.com/atlassian-labs/atlaspack/commit/eedcbc408fc1e86a2a8e25f1a41c57146d8529e1), [`f6532d7`](https://github.com/atlassian-labs/atlaspack/commit/f6532d7a4f7f007bd4e5e36af04dd466f0b9f572)]:
281
+ - @atlaspack/types-internal@2.20.0
282
+ - @atlaspack/utils@2.19.2
283
+ - @atlaspack/logger@2.14.22
284
+ - @atlaspack/profiler@2.14.27
285
+
286
+ ## 2.14.29
287
+
288
+ ### Patch Changes
289
+
290
+ - Updated dependencies []:
291
+ - @atlaspack/types-internal@2.19.5
292
+ - @atlaspack/utils@2.19.1
293
+ - @atlaspack/logger@2.14.21
294
+ - @atlaspack/profiler@2.14.26
295
+
296
+ ## 2.14.28
297
+
298
+ ### Patch Changes
299
+
300
+ - Updated dependencies [[`f0349a6`](https://github.com/atlassian-labs/atlaspack/commit/f0349a6b9b04755088f121095ca6301a2ada3767)]:
301
+ - @atlaspack/utils@2.19.0
302
+ - @atlaspack/types-internal@2.19.4
303
+ - @atlaspack/logger@2.14.20
304
+ - @atlaspack/profiler@2.14.25
305
+
306
+ ## 2.14.27
307
+
308
+ ### Patch Changes
309
+
310
+ - Updated dependencies []:
311
+ - @atlaspack/types-internal@2.19.3
312
+ - @atlaspack/utils@2.18.4
313
+ - @atlaspack/logger@2.14.19
314
+ - @atlaspack/profiler@2.14.24
315
+
316
+ ## 2.14.26
317
+
318
+ ### Patch Changes
319
+
320
+ - [#742](https://github.com/atlassian-labs/atlaspack/pull/742) [`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd) Thanks [@yamadapc](https://github.com/yamadapc)! - Internal changes and bug fixes to environmentDeduplication flag
321
+
322
+ - Updated dependencies [[`ee040bb`](https://github.com/atlassian-labs/atlaspack/commit/ee040bb6428f29b57d892ddd8107e29077d08ffd), [`889c65c`](https://github.com/atlassian-labs/atlaspack/commit/889c65cd25b811045e26a117e7404f694dde77a2)]:
323
+ - @atlaspack/types-internal@2.19.2
324
+ - @atlaspack/build-cache@2.13.5
325
+ - @atlaspack/diagnostic@2.14.3
326
+ - @atlaspack/profiler@2.14.23
327
+ - @atlaspack/logger@2.14.18
328
+ - @atlaspack/utils@2.18.3
329
+
330
+ ## 2.14.25
331
+
332
+ ### Patch Changes
333
+
334
+ - Updated dependencies []:
335
+ - @atlaspack/types-internal@2.19.1
336
+ - @atlaspack/utils@2.18.2
337
+ - @atlaspack/logger@2.14.17
338
+ - @atlaspack/profiler@2.14.22
339
+
340
+ ## 2.14.24
341
+
342
+ ### Patch Changes
343
+
344
+ - Updated dependencies [[`7f5841c`](https://github.com/atlassian-labs/atlaspack/commit/7f5841c39df049f9546cccbeea2a7337e0337b45)]:
345
+ - @atlaspack/types-internal@2.19.0
346
+ - @atlaspack/logger@2.14.16
347
+ - @atlaspack/utils@2.18.1
348
+ - @atlaspack/profiler@2.14.21
349
+
350
+ ## 2.14.23
351
+
352
+ ### Patch Changes
353
+
354
+ - Updated dependencies [[`23d561e`](https://github.com/atlassian-labs/atlaspack/commit/23d561e51e68b0c38fd1ff4e4fb173e5e7b01cf2)]:
355
+ - @atlaspack/utils@2.18.0
356
+ - @atlaspack/types-internal@2.18.0
357
+ - @atlaspack/logger@2.14.15
358
+ - @atlaspack/profiler@2.14.20
359
+
360
+ ## 2.14.22
361
+
362
+ ### Patch Changes
363
+
364
+ - [#720](https://github.com/atlassian-labs/atlaspack/pull/720) [`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94) Thanks [@alshdavid](https://github.com/alshdavid)! - Migrate to TypeScript
365
+
366
+ - Updated dependencies [[`d2fd849`](https://github.com/atlassian-labs/atlaspack/commit/d2fd849770fe6305e9c694bd97b1bd905abd9d94), [`43fdd22`](https://github.com/atlassian-labs/atlaspack/commit/43fdd223860fbc97af17d68c65419b97412cb888)]:
367
+ - @atlaspack/types-internal@2.17.0
368
+ - @atlaspack/build-cache@2.13.4
369
+ - @atlaspack/diagnostic@2.14.2
370
+ - @atlaspack/profiler@2.14.19
371
+ - @atlaspack/logger@2.14.14
372
+ - @atlaspack/utils@2.17.4
373
+
374
+ ## 2.14.21
375
+
376
+ ### Patch Changes
377
+
378
+ - Updated dependencies [[`069de47`](https://github.com/atlassian-labs/atlaspack/commit/069de478e64fb5889f6f2ce023eb510782767fbd)]:
379
+ - @atlaspack/types-internal@2.16.0
380
+ - @atlaspack/profiler@2.14.18
381
+ - @atlaspack/utils@2.17.3
382
+
383
+ ## 2.14.20
384
+
385
+ ### Patch Changes
386
+
387
+ - Updated dependencies []:
388
+ - @atlaspack/types-internal@2.15.2
389
+ - @atlaspack/utils@2.17.2
390
+ - @atlaspack/profiler@2.14.17
391
+
392
+ ## 2.14.19
393
+
394
+ ### Patch Changes
395
+
396
+ - Updated dependencies []:
397
+ - @atlaspack/types-internal@2.15.1
398
+ - @atlaspack/utils@2.17.1
399
+ - @atlaspack/profiler@2.14.16
400
+
401
+ ## 2.14.18
402
+
403
+ ### Patch Changes
404
+
405
+ - Updated dependencies [[`dbb4072`](https://github.com/atlassian-labs/atlaspack/commit/dbb40721ebeb45990a14ba04e6b44e7f836fb32d), [`de23e0c`](https://github.com/atlassian-labs/atlaspack/commit/de23e0ce49d5504fe3947ac26640a3d951087da3), [`18a57cf`](https://github.com/atlassian-labs/atlaspack/commit/18a57cf8a4789b2de5ad8e2676f317a26cc91417), [`a5ed1b4`](https://github.com/atlassian-labs/atlaspack/commit/a5ed1b414498560f393ff491af4da25b6e8dde56)]:
406
+ - @atlaspack/utils@2.17.0
407
+ - @atlaspack/types-internal@2.15.0
408
+ - @atlaspack/logger@2.14.13
409
+ - @atlaspack/profiler@2.14.15
410
+
411
+ ## 2.14.17
412
+
413
+ ### Patch Changes
414
+
415
+ - Updated dependencies []:
416
+ - @atlaspack/logger@2.14.12
417
+ - @atlaspack/utils@2.16.1
418
+
419
+ ## 2.14.16
420
+
421
+ ### Patch Changes
422
+
423
+ - Updated dependencies [[`30ee2cf`](https://github.com/atlassian-labs/atlaspack/commit/30ee2cfcd34cf2646ded0eda13fdb80a2a5de529)]:
424
+ - @atlaspack/utils@2.16.0
425
+ - @atlaspack/types-internal@2.14.14
426
+ - @atlaspack/profiler@2.14.14
427
+
428
+ ## 2.14.15
429
+
430
+ ### Patch Changes
431
+
432
+ - Updated dependencies []:
433
+ - @atlaspack/types-internal@2.14.13
434
+ - @atlaspack/utils@2.15.3
435
+ - @atlaspack/profiler@2.14.13
436
+
437
+ ## 2.14.14
438
+
439
+ ### Patch Changes
440
+
441
+ - Updated dependencies []:
442
+ - @atlaspack/types-internal@2.14.12
443
+ - @atlaspack/utils@2.15.2
444
+ - @atlaspack/profiler@2.14.12
445
+
446
+ ## 2.14.13
447
+
448
+ ### Patch Changes
449
+
450
+ - [#650](https://github.com/atlassian-labs/atlaspack/pull/650) [`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb) Thanks [@alshdavid](https://github.com/alshdavid)! - Remove package.json#exports
451
+
452
+ - Updated dependencies [[`ef3d622`](https://github.com/atlassian-labs/atlaspack/commit/ef3d6228f4e006702198a19c61e051d194d325cb)]:
453
+ - @atlaspack/logger@2.14.11
454
+ - @atlaspack/utils@2.15.1
455
+ - @atlaspack/types-internal@2.14.11
456
+ - @atlaspack/profiler@2.14.11
457
+
458
+ ## 2.14.12
459
+
460
+ ### Patch Changes
461
+
462
+ - Updated dependencies [[`e39c6cf`](https://github.com/atlassian-labs/atlaspack/commit/e39c6cf05f7e95ce5420dbcea66f401b1cbd397c)]:
463
+ - @atlaspack/utils@2.15.0
464
+ - @atlaspack/types-internal@2.14.10
465
+ - @atlaspack/profiler@2.14.10
466
+
467
+ ## 2.14.11
468
+
469
+ ### Patch Changes
470
+
471
+ - Updated dependencies []:
472
+ - @atlaspack/types-internal@2.14.9
473
+ - @atlaspack/utils@2.14.11
474
+ - @atlaspack/profiler@2.14.9
475
+
476
+ ## 2.14.10
477
+
478
+ ### Patch Changes
479
+
480
+ - Updated dependencies [[`51aba5f`](https://github.com/atlassian-labs/atlaspack/commit/51aba5fc0e49235ee06bbc3c376f48c3e7da5c4b)]:
481
+ - @atlaspack/types-internal@2.14.8
482
+ - @atlaspack/profiler@2.14.8
483
+ - @atlaspack/logger@2.14.10
484
+ - @atlaspack/utils@2.14.10
485
+
486
+ ## 2.14.9
487
+
488
+ ### Patch Changes
489
+
490
+ - Updated dependencies []:
491
+ - @atlaspack/logger@2.14.9
492
+ - @atlaspack/utils@2.14.9
493
+ - @atlaspack/types-internal@2.14.7
494
+ - @atlaspack/profiler@2.14.7
495
+
3
496
  ## 2.14.8
4
497
 
5
498
  ### Patch Changes
package/dist/Handle.js ADDED
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const build_cache_1 = require("@atlaspack/build-cache");
7
+ const package_json_1 = __importDefault(require("../package.json"));
8
+ let HANDLE_ID = 0;
9
+ const handleById = new Map();
10
+ class Handle {
11
+ constructor(opts) {
12
+ this.id = opts.id ?? ++HANDLE_ID;
13
+ this.fn = opts.fn;
14
+ this.childId = opts.childId;
15
+ handleById.set(this.id, this);
16
+ }
17
+ dispose() {
18
+ handleById.delete(this.id);
19
+ }
20
+ serialize() {
21
+ return {
22
+ id: this.id,
23
+ childId: this.childId,
24
+ };
25
+ }
26
+ static deserialize(opts) {
27
+ return new Handle(opts);
28
+ }
29
+ }
30
+ exports.default = Handle;
31
+ // Register the Handle as a serializable class so that it will properly be deserialized
32
+ // by anything that uses WorkerFarm.
33
+ (0, build_cache_1.registerSerializableClass)(`${package_json_1.default.version}:Handle`, Handle);
package/dist/Worker.js ADDED
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const nullthrows_1 = __importDefault(require("nullthrows"));
7
+ const events_1 = __importDefault(require("events"));
8
+ const diagnostic_1 = __importDefault(require("@atlaspack/diagnostic"));
9
+ const backend_1 = require("./backend");
10
+ let WORKER_ID = 0;
11
+ class Worker extends events_1.default {
12
+ constructor(options) {
13
+ super();
14
+ this.id = WORKER_ID++;
15
+ this.sentSharedReferences = new Set();
16
+ this.calls = new Map();
17
+ this.exitCode = null;
18
+ this.callId = 0;
19
+ this.ready = false;
20
+ this.stopped = false;
21
+ this.isStopping = false;
22
+ this.options = options;
23
+ }
24
+ async fork(forkModule) {
25
+ let filteredArgs = [];
26
+ if (process.execArgv) {
27
+ filteredArgs = process.execArgv.filter((v) => !/^--(debug|inspect|no-opt|max-old-space-size=|max-semi-space-size=|expose-gc)/.test(v));
28
+ for (let i = 0; i < filteredArgs.length; i++) {
29
+ let arg = filteredArgs[i];
30
+ let isArgWithParam = ((arg === '-r' || arg === '--require') &&
31
+ filteredArgs[i + 1] === '@atlaspack/register') ||
32
+ arg === '--title';
33
+ if (isArgWithParam) {
34
+ filteredArgs.splice(i, 2);
35
+ i--;
36
+ }
37
+ }
38
+ }
39
+ // Workaround for https://github.com/nodejs/node/issues/29117
40
+ if (process.env.NODE_OPTIONS) {
41
+ // arg parsing logic adapted from https://stackoverflow.com/a/46946420/2352201
42
+ let opts = [''];
43
+ let quote = false;
44
+ for (let c of (0, nullthrows_1.default)(process.env.NODE_OPTIONS.match(/.|^$/g))) {
45
+ if (c === '"') {
46
+ quote = !quote;
47
+ }
48
+ else if (!quote && c === ' ') {
49
+ opts.push('');
50
+ }
51
+ else {
52
+ opts[opts.length - 1] += c.replace(/\\(.)/, '$1');
53
+ }
54
+ }
55
+ for (let i = 0; i < opts.length; i++) {
56
+ let opt = opts[i];
57
+ if (opt === '-r' || opt === '--require') {
58
+ filteredArgs.push(opt, opts[i + 1]);
59
+ i++;
60
+ }
61
+ }
62
+ }
63
+ let onMessage = (data) => this.receive(data);
64
+ let onExit = (code) => {
65
+ this.exitCode = code;
66
+ this.emit('exit', code);
67
+ };
68
+ let onError = (err) => {
69
+ this.emit('error', err);
70
+ };
71
+ let WorkerBackend = (0, backend_1.getWorkerBackend)(this.options.backend);
72
+ this.worker = new WorkerBackend(filteredArgs, onMessage, onError, onExit);
73
+ await this.worker.start();
74
+ await new Promise((resolve, reject) => {
75
+ this.call({
76
+ method: 'childInit',
77
+ args: [
78
+ forkModule,
79
+ {
80
+ shouldPatchConsole: !!this.options.shouldPatchConsole,
81
+ shouldTrace: !!this.options.shouldTrace,
82
+ },
83
+ ],
84
+ retries: 0,
85
+ skipReadyCheck: true,
86
+ resolve,
87
+ reject,
88
+ });
89
+ });
90
+ let sharedRefs = this.options.sharedReferences;
91
+ let refsShared = new Set();
92
+ // in case more refs are created while initial refs are sending
93
+ while (refsShared.size < sharedRefs.size) {
94
+ await Promise.all([...sharedRefs]
95
+ // @ts-expect-error TS2769
96
+ .filter(([ref]) => !refsShared.has(ref))
97
+ .map(async ([ref, value]) => {
98
+ await this.sendSharedReference(ref, value);
99
+ refsShared.add(ref);
100
+ }));
101
+ }
102
+ this.ready = true;
103
+ this.emit('ready');
104
+ }
105
+ sendSharedReference(ref, value) {
106
+ this.sentSharedReferences.add(ref);
107
+ return new Promise((resolve, reject) => {
108
+ this.call({
109
+ method: 'createSharedReference',
110
+ args: [ref, value],
111
+ resolve,
112
+ reject,
113
+ retries: 0,
114
+ skipReadyCheck: true,
115
+ });
116
+ });
117
+ }
118
+ send(data) {
119
+ this.worker.send(data);
120
+ }
121
+ call(call) {
122
+ if (this.stopped || this.isStopping) {
123
+ return;
124
+ }
125
+ let idx = this.callId++;
126
+ this.calls.set(idx, call);
127
+ let msg = {
128
+ type: 'request',
129
+ idx: idx,
130
+ child: this.id,
131
+ handle: call.handle,
132
+ method: call.method,
133
+ args: call.args,
134
+ };
135
+ if (this.ready || call.skipReadyCheck === true) {
136
+ // @ts-expect-error TS2345
137
+ this.send(msg);
138
+ }
139
+ else {
140
+ // @ts-expect-error TS2345
141
+ this.once('ready', () => this.send(msg));
142
+ }
143
+ }
144
+ receive(message) {
145
+ if (this.stopped || this.isStopping) {
146
+ return;
147
+ }
148
+ if (message.type === 'request') {
149
+ this.emit('request', message);
150
+ }
151
+ else if (message.type === 'response') {
152
+ let idx = message.idx;
153
+ if (idx == null) {
154
+ return;
155
+ }
156
+ let call = this.calls.get(idx);
157
+ if (!call) {
158
+ // Return for unknown calls, these might accur if a third party process uses workers
159
+ return;
160
+ }
161
+ if (message.contentType === 'error') {
162
+ call.reject(new diagnostic_1.default({ diagnostic: message.content }));
163
+ }
164
+ else {
165
+ call.resolve(message.content);
166
+ }
167
+ this.calls.delete(idx);
168
+ this.emit('response', message);
169
+ }
170
+ }
171
+ async stop() {
172
+ if (!this.stopped) {
173
+ this.stopped = true;
174
+ if (this.worker) {
175
+ await this.worker.stop();
176
+ }
177
+ }
178
+ }
179
+ }
180
+ exports.default = Worker;