@atlaspack/workers 2.14.21-typescript-1fd1095e8.0 → 2.14.21-typescript-b27501580.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaspack/workers",
3
- "version": "2.14.21-typescript-1fd1095e8.0",
3
+ "version": "2.14.21-typescript-b27501580.0",
4
4
  "description": "Blazing fast, zero configuration web application bundler",
5
5
  "license": "(MIT OR Apache-2.0)",
6
6
  "publishConfig": {
@@ -10,19 +10,19 @@
10
10
  "type": "git",
11
11
  "url": "https://github.com/atlassian-labs/atlaspack.git"
12
12
  },
13
- "main": "lib/index.js",
14
- "source": "src/index.ts",
15
- "types": "index.d.ts",
13
+ "main": "./lib/index.js",
14
+ "source": "./src/index.ts",
15
+ "types": "./lib/index.d.ts",
16
16
  "engines": {
17
17
  "node": ">= 16.0.0"
18
18
  },
19
19
  "dependencies": {
20
- "@atlaspack/build-cache": "2.13.4-typescript-1fd1095e8.0",
21
- "@atlaspack/diagnostic": "2.14.2-typescript-1fd1095e8.0",
22
- "@atlaspack/logger": "2.14.14-typescript-1fd1095e8.0",
23
- "@atlaspack/profiler": "2.14.18-typescript-1fd1095e8.0",
24
- "@atlaspack/types-internal": "2.15.3-typescript-1fd1095e8.0",
25
- "@atlaspack/utils": "2.17.3-typescript-1fd1095e8.0",
20
+ "@atlaspack/build-cache": "2.13.4-typescript-b27501580.0",
21
+ "@atlaspack/diagnostic": "2.14.2-typescript-b27501580.0",
22
+ "@atlaspack/logger": "2.14.14-typescript-b27501580.0",
23
+ "@atlaspack/profiler": "2.14.18-typescript-b27501580.0",
24
+ "@atlaspack/types-internal": "2.15.3-typescript-b27501580.0",
25
+ "@atlaspack/utils": "2.17.3-typescript-b27501580.0",
26
26
  "nullthrows": "^1.1.1"
27
27
  },
28
28
  "browser": {
@@ -31,7 +31,7 @@
31
31
  },
32
32
  "type": "commonjs",
33
33
  "scripts": {
34
- "check-ts": "tsc --noEmit"
34
+ "check-ts": "tsc --emitDeclarationOnly --rootDir src"
35
35
  },
36
- "gitHead": "1fd1095e86da1e50d6c7819c0f132ce09a2bf396"
37
- }
36
+ "gitHead": "b275015805a058452afb6fb48c078ecd4de925f2"
37
+ }
package/lib/Handle.js DELETED
@@ -1,42 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- function _buildCache() {
8
- const data = require("@atlaspack/build-cache");
9
- _buildCache = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- var _package = _interopRequireDefault(require("../package.json"));
15
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- let HANDLE_ID = 0;
17
- const handleById = new Map();
18
- class Handle {
19
- constructor(opts) {
20
- this.id = opts.id ?? ++HANDLE_ID;
21
- this.fn = opts.fn;
22
- this.childId = opts.childId;
23
- handleById.set(this.id, this);
24
- }
25
- dispose() {
26
- handleById.delete(this.id);
27
- }
28
- serialize() {
29
- return {
30
- id: this.id,
31
- childId: this.childId
32
- };
33
- }
34
- static deserialize(opts) {
35
- return new Handle(opts);
36
- }
37
- }
38
-
39
- // Register the Handle as a serializable class so that it will properly be deserialized
40
- // by anything that uses WorkerFarm.
41
- exports.default = Handle;
42
- (0, _buildCache().registerSerializableClass)(`${_package.default.version}:Handle`, Handle);
package/lib/Worker.js DELETED
@@ -1,194 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
- function _nullthrows() {
8
- const data = _interopRequireDefault(require("nullthrows"));
9
- _nullthrows = function () {
10
- return data;
11
- };
12
- return data;
13
- }
14
- function _events() {
15
- const data = _interopRequireDefault(require("events"));
16
- _events = function () {
17
- return data;
18
- };
19
- return data;
20
- }
21
- function _diagnostic() {
22
- const data = _interopRequireDefault(require("@atlaspack/diagnostic"));
23
- _diagnostic = function () {
24
- return data;
25
- };
26
- return data;
27
- }
28
- var _backend = require("./backend");
29
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
- let WORKER_ID = 0;
31
- class Worker extends _events().default {
32
- // @ts-expect-error TS2564
33
-
34
- id = WORKER_ID++;
35
- sentSharedReferences = new Set();
36
- calls = new Map();
37
- exitCode = null;
38
- callId = 0;
39
- ready = false;
40
- stopped = false;
41
- isStopping = false;
42
- constructor(options) {
43
- super();
44
- this.options = options;
45
- }
46
- async fork(forkModule) {
47
- let filteredArgs = [];
48
- if (process.execArgv) {
49
- filteredArgs = process.execArgv.filter(v => !/^--(debug|inspect|no-opt|max-old-space-size=|max-semi-space-size=|expose-gc)/.test(v));
50
- for (let i = 0; i < filteredArgs.length; i++) {
51
- let arg = filteredArgs[i];
52
- let isArgWithParam = (arg === '-r' || arg === '--require') && filteredArgs[i + 1] === '@atlaspack/register' || arg === '--title';
53
- if (isArgWithParam) {
54
- filteredArgs.splice(i, 2);
55
- i--;
56
- }
57
- }
58
- }
59
-
60
- // Workaround for https://github.com/nodejs/node/issues/29117
61
- if (process.env.NODE_OPTIONS) {
62
- // arg parsing logic adapted from https://stackoverflow.com/a/46946420/2352201
63
- let opts = [''];
64
- let quote = false;
65
- for (let c of (0, _nullthrows().default)(process.env.NODE_OPTIONS.match(/.|^$/g))) {
66
- if (c === '"') {
67
- quote = !quote;
68
- } else if (!quote && c === ' ') {
69
- opts.push('');
70
- } else {
71
- opts[opts.length - 1] += c.replace(/\\(.)/, '$1');
72
- }
73
- }
74
- for (let i = 0; i < opts.length; i++) {
75
- let opt = opts[i];
76
- if (opt === '-r' || opt === '--require') {
77
- filteredArgs.push(opt, opts[i + 1]);
78
- i++;
79
- }
80
- }
81
- }
82
- let onMessage = data => this.receive(data);
83
- let onExit = code => {
84
- this.exitCode = code;
85
- this.emit('exit', code);
86
- };
87
- let onError = err => {
88
- this.emit('error', err);
89
- };
90
- let WorkerBackend = (0, _backend.getWorkerBackend)(this.options.backend);
91
- this.worker = new WorkerBackend(filteredArgs, onMessage, onError, onExit);
92
- await this.worker.start();
93
- await new Promise((resolve, reject) => {
94
- this.call({
95
- method: 'childInit',
96
- args: [forkModule, {
97
- shouldPatchConsole: !!this.options.shouldPatchConsole,
98
- shouldTrace: !!this.options.shouldTrace
99
- }],
100
- retries: 0,
101
- skipReadyCheck: true,
102
- resolve,
103
- reject
104
- });
105
- });
106
- let sharedRefs = this.options.sharedReferences;
107
- let refsShared = new Set();
108
- // in case more refs are created while initial refs are sending
109
- while (refsShared.size < sharedRefs.size) {
110
- await Promise.all([...sharedRefs]
111
- // @ts-expect-error TS2769
112
- .filter(([ref]) => !refsShared.has(ref)).map(async ([ref, value]) => {
113
- await this.sendSharedReference(ref, value);
114
- refsShared.add(ref);
115
- }));
116
- }
117
- this.ready = true;
118
- this.emit('ready');
119
- }
120
- sendSharedReference(ref, value) {
121
- this.sentSharedReferences.add(ref);
122
- return new Promise((resolve, reject) => {
123
- this.call({
124
- method: 'createSharedReference',
125
- args: [ref, value],
126
- resolve,
127
- reject,
128
- retries: 0,
129
- skipReadyCheck: true
130
- });
131
- });
132
- }
133
- send(data) {
134
- this.worker.send(data);
135
- }
136
- call(call) {
137
- if (this.stopped || this.isStopping) {
138
- return;
139
- }
140
- let idx = this.callId++;
141
- this.calls.set(idx, call);
142
- let msg = {
143
- type: 'request',
144
- idx: idx,
145
- child: this.id,
146
- handle: call.handle,
147
- method: call.method,
148
- args: call.args
149
- };
150
- if (this.ready || call.skipReadyCheck === true) {
151
- // @ts-expect-error TS2345
152
- this.send(msg);
153
- } else {
154
- // @ts-expect-error TS2345
155
- this.once('ready', () => this.send(msg));
156
- }
157
- }
158
- receive(message) {
159
- if (this.stopped || this.isStopping) {
160
- return;
161
- }
162
- if (message.type === 'request') {
163
- this.emit('request', message);
164
- } else if (message.type === 'response') {
165
- let idx = message.idx;
166
- if (idx == null) {
167
- return;
168
- }
169
- let call = this.calls.get(idx);
170
- if (!call) {
171
- // Return for unknown calls, these might accur if a third party process uses workers
172
- return;
173
- }
174
- if (message.contentType === 'error') {
175
- call.reject(new (_diagnostic().default)({
176
- diagnostic: message.content
177
- }));
178
- } else {
179
- call.resolve(message.content);
180
- }
181
- this.calls.delete(idx);
182
- this.emit('response', message);
183
- }
184
- }
185
- async stop() {
186
- if (!this.stopped) {
187
- this.stopped = true;
188
- if (this.worker) {
189
- await this.worker.stop();
190
- }
191
- }
192
- }
193
- }
194
- exports.default = Worker;