@andersbakken/fisk 3.4.104 → 3.5.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 (48) hide show
  1. package/builder/VM.js +5 -7
  2. package/builder/client.js +8 -10
  3. package/builder/fisk-builder.js +22 -15
  4. package/builder/server.js +19 -9
  5. package/package.json +1 -1
  6. package/scheduler/server.js +19 -23
  7. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/6f3d6f00c1fec0eb44ef1d4d65edf1506dc3d824 +0 -1
  8. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/9b50cb3b165351cfaf3a84c7452b5625a53982bd +0 -1
  9. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/a187396d7c2e3dc16e77ed1dfd8e1c1ef0e486ee +0 -1
  10. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/aa48bf61fe6d1e09d8e2088e7174bd3cc665486b +0 -1
  11. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/ab0db788eb4ffd1406d5c967b8d8a1f9c4f872a1 +0 -1
  12. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/c437c9f3ca4fe26852e48992562e8f625e6eb3d5 +0 -1
  13. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/code/cache/feb4835b4c3c5ca207c3adaeba3bf7d539d598a4 +0 -1
  14. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/6f3d6f00c1fec0eb44ef1d4d65edf1506dc3d824 +0 -1
  15. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/9b50cb3b165351cfaf3a84c7452b5625a53982bd +0 -1
  16. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/a187396d7c2e3dc16e77ed1dfd8e1c1ef0e486ee +0 -1
  17. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/aa48bf61fe6d1e09d8e2088e7174bd3cc665486b +0 -1
  18. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/ab0db788eb4ffd1406d5c967b8d8a1f9c4f872a1 +0 -1
  19. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/c437c9f3ca4fe26852e48992562e8f625e6eb3d5 +0 -1
  20. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/semanticDiagnostics/cache/feb4835b4c3c5ca207c3adaeba3bf7d539d598a4 +0 -1
  21. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/6f3d6f00c1fec0eb44ef1d4d65edf1506dc3d824 +0 -1
  22. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/9b50cb3b165351cfaf3a84c7452b5625a53982bd +0 -1
  23. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/a187396d7c2e3dc16e77ed1dfd8e1c1ef0e486ee +0 -1
  24. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/aa48bf61fe6d1e09d8e2088e7174bd3cc665486b +0 -1
  25. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/ab0db788eb4ffd1406d5c967b8d8a1f9c4f872a1 +0 -1
  26. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/c437c9f3ca4fe26852e48992562e8f625e6eb3d5 +0 -1
  27. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/syntacticDiagnostics/cache/feb4835b4c3c5ca207c3adaeba3bf7d539d598a4 +0 -1
  28. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/0633edb60fd6a23c41b4a3ecd6745d0918ddc443 +0 -0
  29. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/0fbe0fd936446971be562f345406924c189b440d +0 -0
  30. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/1460dbc1a06c23e1b35a5ea7503af46ecf64a3d7 +0 -0
  31. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/275df2f723ff5eb991b1f1314c27d5ee8f368d0f +0 -0
  32. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/442395a1e95b214924378140af2474e7dcabc38a +0 -0
  33. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/4cf155d27ec97f64a8625356918240d54b7b648e +0 -0
  34. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/6abbc694eb7c9915d4bc616b87ec96a7f1beabe8 +0 -0
  35. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/6ddcf876c72761cf72ce026ac36e5a85a3fef426 +0 -0
  36. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/8171e95e73521604a2d9dee15217d199330f4207 +0 -0
  37. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/9d464c7351b779db405539ce4295a3fb9d80f181 +0 -0
  38. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/aeb253b245b256f7f45a7a4d8ecba39abe53b421 +0 -0
  39. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/bb509537d07eafe005fa7dbf3251e24a71d7d073 +0 -0
  40. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/be48c1dd473009fceabbbd08c8bf0dde615280b3 +0 -0
  41. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/c6ab093e229a9a7d7442ac43d8b832c68f454faa +0 -0
  42. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/d7129ca09c222bcedabe550058a1dc00f770a7bb +0 -0
  43. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/da2cdf367b48c84adc1c966cb1aaa0115a2ba25e +0 -0
  44. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/da7a45624ab6c7901cf496b81a9f7d6beb85516c +0 -0
  45. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/db2a6425476330dda1162995f162ab52f3438f8b +0 -0
  46. package/.cache/rpt2_5ee3bf3b1ea0871757cf6d9c5526a3abe9b0a81c/types/cache/e0f94621f43e73a1c561c1b7610a95ed6d54ee78 +0 -0
  47. package/dist/fisk-daemon.js +0 -4159
  48. package/dist/fisk-daemon.js.map +0 -1
package/builder/VM.js CHANGED
@@ -28,15 +28,13 @@ class CompileJob extends EventEmitter
28
28
  }
29
29
  }
30
30
 
31
- feed(data, last) {
31
+ feed(data) {
32
32
  fs.writeSync(this.fd, data);
33
33
  this.cppSize += data.length;
34
- if (last) {
35
- this.startCompile = Date.now();
36
- fs.close(this.fd);
37
- this.fd = undefined;
38
- this.vm.child.send({ type: "compile", commandLine: this.commandLine, argv0: this.argv0, id: this.id, dir: this.vmDir}, this.sendCallback.bind(this));
39
- }
34
+ this.startCompile = Date.now();
35
+ fs.close(this.fd);
36
+ this.fd = undefined;
37
+ this.vm.child.send({ type: "compile", commandLine: this.commandLine, argv0: this.argv0, id: this.id, dir: this.vmDir}, this.sendCallback.bind(this));
40
38
  }
41
39
 
42
40
  cancel() {
package/builder/client.js CHANGED
@@ -121,18 +121,16 @@ class Client extends EventEmitter {
121
121
  error("No data in buffer");
122
122
  return;
123
123
  }
124
- if (remaining) {
125
- // more data
126
- if (msg.length > remaining) {
127
- // woops
128
- error(`length ${msg.length} > ${remaining}`);
129
- return;
130
- }
131
- remaining -= msg.length;
132
- this.emit("data", { data: msg, last: !remaining });
133
- } else {
124
+ if (!remaining) {
134
125
  error(`Unexpected binary message of length: ${msg.length}`);
126
+ return;
127
+ } else if (msg.length !== remaining) {
128
+ // woops
129
+ error(`length ${msg.length} !== ${remaining}`);
130
+ return;
135
131
  }
132
+ remaining = 0;
133
+ this.emit("data", { data: msg });
136
134
  } else {
137
135
  error("Unexpected object");
138
136
  }
@@ -21,6 +21,7 @@ const VM = require("./VM");
21
21
  const load = require("./load");
22
22
  const ObjectCache = require("./objectcache");
23
23
  const quitOnError = require("./quit-on-error")(option);
24
+ const zlib = require("zlib");
24
25
 
25
26
  if (process.getuid() !== 0) {
26
27
  console.error("fisk builder needs to run as root to be able to chroot");
@@ -652,7 +653,7 @@ server.on("job", job => {
652
653
  aborted: false,
653
654
  started: false,
654
655
  heartbeatTimer: undefined,
655
- buffers: [],
656
+ buffer: undefined,
656
657
  stdout: "",
657
658
  stderr: "",
658
659
  start: function() {
@@ -713,11 +714,13 @@ server.on("job", job => {
713
714
 
714
715
  console.log("Starting job", j.id, job.sourceFile, "for", job.ip, job.name, "wait", job.wait);
715
716
  j.op = vm.startCompile(job.commandLine, job.argv0, job.id);
716
- j.buffers.forEach(data => j.op.feed(data.data, data.last));
717
+ if (j.buffer) {
718
+ j.op.feed(j.buffer);
719
+ j.buffer = undefined;
720
+ }
717
721
  if (job.wait) {
718
722
  job.send("resume", {});
719
723
  }
720
- delete j.buffers;
721
724
  j.op.on("stdout", data => { j.stdout += data; }); // ### is there ever any stdout? If there is, does the order matter for stdout vs stderr?
722
725
  j.op.on("stderr", data => { j.stderr += data; });
723
726
  j.op.on("finished", event => {
@@ -735,7 +738,11 @@ server.on("job", job => {
735
738
  }
736
739
 
737
740
  // this can't be async, the directory is removed after the event is fired
738
- let contents = event.files.map(f => { return { contents: fs.readFileSync(f.absolute), path: f.path }; });
741
+ const forCache = event.files.map(f => ({ contents: fs.readFileSync(f.absolute), path: f.path }));
742
+ const contents = !j.job.compressed ? forCache : forCache.map(x => ({
743
+ path: x.path,
744
+ contents: x.contents.byteLength ? zlib.gzipSync(x.contents) : x.contents
745
+ }));
739
746
  let response = {
740
747
  type: "response",
741
748
  index: contents.map(item => { return { path: item.path, bytes: item.contents.length }; }),
@@ -755,13 +762,14 @@ server.on("job", job => {
755
762
  response.sourceFile = job.sourceFile;
756
763
  response.commandLine = job.commandLine;
757
764
  response.environment = job.hash;
758
- objectCache.add(response, contents);
765
+ objectCache.add(response, forCache);
759
766
  }
760
767
 
761
- for (let i=0; i<contents.length; ++i) {
762
- job.send(contents[i].contents);
763
- }
764
- // job.close();
768
+ contents.forEach(x => {
769
+ if (x.contents.byteLength) {
770
+ job.send(x.contents);
771
+ }
772
+ });
765
773
  // console.log("GOT ID", j);
766
774
  if (event.success) {
767
775
  client.send("jobFinished", {
@@ -822,14 +830,13 @@ server.on("job", job => {
822
830
  });
823
831
 
824
832
  job.on("data", data => {
825
- // console.log("got data", this.id, data.last, typeof j.op);
826
- if (data.last)
827
- uploadDuration = Date.now() - jobStartTime;
833
+ // console.log("got data", this.id, typeof j.op);
834
+ uploadDuration = Date.now() - jobStartTime;
828
835
  if (!j.op) {
829
- j.buffers.push(data);
830
- console.log("buffering...", j.buffers.length);
836
+ j.buffer = data.data;
837
+ console.log("buffering...", j.buffer.byteLength);
831
838
  } else {
832
- j.op.feed(data.data, data.last);
839
+ j.op.feed(data.data);
833
840
  }
834
841
  });
835
842
 
package/builder/server.js CHANGED
@@ -1,15 +1,14 @@
1
-
2
1
  const EventEmitter = require("events");
3
2
  const WebSocket = require("ws");
4
3
  const Url = require("url");
5
4
  const http = require("http");
6
5
  const express = require("express");
6
+ const zlib = require("zlib");
7
7
 
8
8
  class Job extends EventEmitter {
9
9
  constructor(data) {
10
10
  super();
11
- for (let key in data)
12
- this[key] = data[key];
11
+ Object.assign(this, data);
13
12
  }
14
13
 
15
14
  send(type, msg) {
@@ -154,6 +153,7 @@ class Server extends EventEmitter {
154
153
  return;
155
154
  }
156
155
  bytes = json.bytes;
156
+ client.compressed = json.compressed;
157
157
  client.commandLine = json.commandLine;
158
158
  client.argv0 = json.argv0;
159
159
  client.connectTime = connectTime;
@@ -166,21 +166,31 @@ class Server extends EventEmitter {
166
166
  // console.log("Got binary", msg.length, bytes);
167
167
  if (!msg.length) {
168
168
  // no data?
169
- console.error("No data in buffer");
169
+ error("No data in buffer");
170
170
  return;
171
171
  }
172
172
  if (!bytes) {
173
173
  error("Got binary message without a preceeding json message describing the data");
174
174
  return;
175
175
  }
176
- if (msg.length > bytes) {
176
+ if (msg.length !== bytes) {
177
177
  // woops
178
- error(`length ${msg.length} > ${bytes}`);
178
+ error(`length ${msg.length} !== ${bytes}`);
179
179
  return;
180
180
  }
181
- bytes -= msg.length;
182
- // console.log("Emitting", "data", { data: msg.length, last: !bytes });
183
- client.emit("data", { data: msg, last: !bytes });
181
+ bytes = 0;
182
+ // console.log("GOT DATA", client.compressed, msg.length);
183
+ if (client.compressed) {
184
+ zlib.gunzip(msg, (err, data) => {
185
+ if (err) {
186
+ error(`Got error inflating data ${err}`);
187
+ } else {
188
+ client.emit("data", { data });
189
+ }
190
+ });
191
+ } else {
192
+ client.emit("data", { data: msg });
193
+ }
184
194
  }
185
195
  break;
186
196
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andersbakken/fisk",
3
- "version": "3.4.104",
3
+ "version": "3.5.0",
4
4
  "description": "Fisk, a distributed compile system",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
@@ -10,7 +10,7 @@ class Client extends EventEmitter {
10
10
  constructor(object) {
11
11
  super();
12
12
  this.created = new Date();
13
- this.assign(object);
13
+ Object.assign(this, object);
14
14
  this.pingSent = undefined;
15
15
  this.ws.on("pong", () => {
16
16
  // console.log("got pong", this.name);
@@ -18,12 +18,6 @@ class Client extends EventEmitter {
18
18
  });
19
19
  }
20
20
 
21
- assign(object) {
22
- for (let key in object) {
23
- this[key] = object[key];
24
- }
25
- }
26
-
27
21
  send(type, msg) {
28
22
  try {
29
23
  if (msg === undefined) {
@@ -188,7 +182,7 @@ class Server extends EventEmitter {
188
182
  const clientHostname = req.headers["x-fisk-client-hostname"];
189
183
  if (clientHostname)
190
184
  data.hostname = clientHostname;
191
- client.assign(data);
185
+ Object.assign(client, data);
192
186
  this.emit("compile", client);
193
187
  let remaining = { bytes: undefined, type: undefined };
194
188
  client.ws.on("close", (status, reason) => client.emit("close", status, reason));
@@ -315,20 +309,22 @@ class Server extends EventEmitter {
315
309
  if (env)
316
310
  environments[env] = true;
317
311
  });
318
- client.assign({ port: port,
319
- name: name,
320
- labels: labels,
321
- slots: slots,
322
- jobsPerformed: 0,
323
- jobsScheduled: 0,
324
- totalCompileSpeed: 0,
325
- totalUploadSpeed: 0,
326
- lastJob: 0,
327
- load: 0,
328
- npmVersion: npmVersion,
329
- hostname: hostname,
330
- environments: environments,
331
- system: system });
312
+ Object.assign(client, {
313
+ port: port,
314
+ name: name,
315
+ labels: labels,
316
+ slots: slots,
317
+ jobsPerformed: 0,
318
+ jobsScheduled: 0,
319
+ totalCompileSpeed: 0,
320
+ totalUploadSpeed: 0,
321
+ lastJob: 0,
322
+ load: 0,
323
+ npmVersion: npmVersion,
324
+ hostname: hostname,
325
+ environments: environments,
326
+ system: system
327
+ });
332
328
  client.ws.on("message", msg => {
333
329
  // console.log("Got message from builder", typeof msg, msg.length);
334
330
  switch (typeof msg) {
@@ -375,7 +371,7 @@ class Server extends EventEmitter {
375
371
  }
376
372
 
377
373
  _handleClientVerify(req, client) {
378
- client.assign({npmVersion: req.headers["x-fisk-npm-version"] });
374
+ Object.assign(client, {npmVersion: req.headers["x-fisk-npm-version"] });
379
375
  this.emit("clientVerify", client);
380
376
  client.ws.on("close", (code, reason) => {
381
377
  client.ws.removeAllListeners();
@@ -1 +0,0 @@
1
- {"code":"export const Constants = {\n // client codes\n get AcquireCppSlot() {\n return 1;\n },\n get AcquireCompileSlot() {\n return 2;\n },\n get ReleaseCppSlot() {\n return 3;\n },\n get ReleaseCompileSlot() {\n return 4;\n },\n get JSON() {\n return 5;\n },\n // daemon codes\n get CppSlotAcquired() {\n return 10;\n },\n get CompileSlotAcquired() {\n return 11;\n },\n get JSONResponse() {\n return 12;\n }\n};\n//# sourceMappingURL=constants.js.map","references":[],"map":"{\"version\":3,\"file\":\"constants.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../daemon/constants.ts\"],\"names\":[],\"mappings\":\"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG;IACrB,eAAe;IACf,IAAI,cAAc;QACd,OAAO,CAAC,CAAC;IACb,CAAC;IACD,IAAI,kBAAkB;QAClB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,IAAI,cAAc;QACd,OAAO,CAAC,CAAC;IACb,CAAC;IACD,IAAI,kBAAkB;QAClB,OAAO,CAAC,CAAC;IACb,CAAC;IACD,IAAI,IAAI;QACJ,OAAO,CAAC,CAAC;IACb,CAAC;IAED,eAAe;IACf,IAAI,eAAe;QACf,OAAO,EAAE,CAAC;IACd,CAAC;IACD,IAAI,mBAAmB;QACnB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,IAAI,YAAY;QACZ,OAAO,EAAE,CAAC;IACd,CAAC;CACJ,CAAC\"}"}
@@ -1 +0,0 @@
1
- {"code":"import EventEmitter from \"events\";\nimport assert from \"assert\";\nclass Slots extends EventEmitter {\n constructor(count, name, debug) {\n super();\n this.count = count;\n this.name = name;\n this.used = new Map();\n this.debug = debug;\n this.pending = new Map();\n if (this.debug) {\n console.log(\"Slots created\", this.toString());\n }\n }\n acquire(id, data, cb) {\n if (this.used.size < this.count) {\n this.used.set(id, data);\n if (this.debug) {\n console.log(\"acquired slot\", id, data, this.toString());\n }\n cb();\n }\n else {\n if (this.debug) {\n console.log(\"pending slot\", id, this.toString());\n }\n this.pending.set(id, { data: data, cb: cb });\n }\n }\n release(id) {\n this.pending.delete(id);\n if (this.used.has(id)) {\n const data = this.used.get(id);\n this.used.delete(id);\n assert(this.used.size < this.count);\n assert(this.used.size + 1 === this.count || this.pending.size === 0);\n if (this.debug) {\n console.log(\"released\", id, data, this.toString());\n }\n // eslint-disable-next-line no-unreachable-loop\n for (const p of this.pending) {\n this.used.set(p[0], p[1].data);\n this.pending.delete(p[0]);\n p[1].cb();\n break;\n }\n }\n }\n toString() {\n return `${this.name} ${this.used.size}/${this.count}`;\n }\n dump() {\n const pending = {}, used = {};\n for (const p of this.pending) {\n pending[p[0]] = p[1].data;\n }\n for (const p of this.used) {\n used[p[0]] = p[1];\n }\n return { pending: pending, capacity: this.count, used: this.used.size };\n }\n}\nexport { Slots };\n//# sourceMappingURL=slots.js.map","references":[],"map":"{\"version\":3,\"file\":\"slots.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../daemon/slots.ts\"],\"names\":[],\"mappings\":\"AAAA,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAQ5B,MAAM,KAAM,SAAQ,YAAY;IAO5B,YAAY,KAAa,EAAE,IAAY,EAAE,KAAc;QACnD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAA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AAC,IAAI,EAAE,CAAC;IAC5E,CAAC;CACJ;AAED,OAAO,EAAE,KAAK,EAAE,CAAC\"}"}
@@ -1 +0,0 @@
1
- {"code":"// #!/usr/bin/env node\nimport { Constants } from \"./constants\";\nimport { Server } from \"./server\";\nimport { Slots } from \"./slots\";\nimport Common from \"../common\";\nimport assert from \"assert\";\nimport options from \"@jhanssen/options\";\nimport os from \"os\";\nconst option = options({\n prefix: \"fisk/daemon\",\n noApplicationPath: true,\n additionalFiles: [\"fisk/daemon.conf.override\"]\n});\nconst common = Common(option);\nconst debug = Boolean(option(\"debug\"));\nprocess.on(\"unhandledRejection\", (reason, p) => {\n console.log(\"Unhandled Rejection at: Promise\", p, \"reason:\", reason.stack);\n process.exit();\n // if (client)\n // client.send('log', { message: `Unhandled Rejection at: Promise ${p}, reason: ${reason.stack}` });\n});\nprocess.on(\"uncaughtException\", (err) => {\n console.error(\"Uncaught exception\", err);\n process.exit();\n // if (client)\n // client.send('log', { message: `Uncaught exception ${err.toString()} ${err.stack}` });\n});\nconst server = new Server(option, common);\nserver.listen().then(() => {\n console.log(\"listening on\", server.file);\n});\n// server.on(\"message\nserver.on(\"error\", (err) => {\n console.error(\"server error\", err);\n});\nconst cppSlots = new Slots(option.int(\"cpp-slots\", Math.max(os.cpus().length * 2, 1)), \"cpp\", debug);\nconst compileSlots = new Slots(option.int(\"slots\", Math.max(os.cpus().length, 1)), \"compile\", debug);\nserver.on(\"compile\", (compile) => {\n compile.on(\"dumpSlots\", () => {\n const ret = { cpp: cppSlots.dump(), compile: compileSlots.dump() };\n if (debug) {\n console.log(\"sending dump\", ret);\n }\n compile.send(ret);\n });\n let requestedCppSlot = false;\n compile.on(\"acquireCppSlot\", () => {\n if (debug) {\n console.log(\"acquireCppSlot\");\n }\n assert(!requestedCppSlot);\n requestedCppSlot = true;\n cppSlots.acquire(compile.id, { pid: compile.pid }, () => {\n // compile.send({ type: 'cppSlotAcquired' });\n compile.send(Constants.CppSlotAcquired);\n });\n });\n compile.on(\"releaseCppSlot\", () => {\n if (debug) {\n console.log(\"releaseCppSlot\");\n }\n assert(requestedCppSlot);\n if (requestedCppSlot) {\n requestedCppSlot = false;\n cppSlots.release(compile.id);\n }\n });\n let requestedCompileSlot = false;\n compile.on(\"acquireCompileSlot\", () => {\n if (debug) {\n console.log(\"acquireCompileSlot\");\n }\n assert(!requestedCompileSlot);\n requestedCompileSlot = true;\n compileSlots.acquire(compile.id, { pid: compile.pid }, () => {\n // compile.send({ type: 'compileSlotAcquired' });\n compile.send(Constants.CompileSlotAcquired);\n });\n });\n compile.on(\"releaseCompileSlot\", () => {\n if (debug) {\n console.log(\"releaseCompileSlot\");\n }\n assert(requestedCompileSlot);\n if (requestedCompileSlot) {\n requestedCompileSlot = false;\n compileSlots.release(compile.id);\n }\n });\n compile.on(\"error\", (err) => {\n if (debug) {\n console.error(\"Got error from fiskc\", compile.id, compile.pid, err);\n }\n if (requestedCppSlot) {\n requestedCppSlot = false;\n cppSlots.release(compile.id);\n }\n if (requestedCompileSlot) {\n requestedCompileSlot = false;\n compileSlots.release(compile.id);\n }\n });\n compile.on(\"end\", () => {\n if (debug) {\n console.log(\"got end from\", compile.id, compile.pid);\n }\n if (requestedCppSlot) {\n requestedCppSlot = false;\n cppSlots.release(compile.id);\n }\n if (requestedCompileSlot) {\n requestedCompileSlot = false;\n compileSlots.release(compile.id);\n }\n });\n});\nprocess.on(\"exit\", () => {\n server.close();\n});\nprocess.on(\"SIGINT\", () => {\n server.close();\n process.exit();\n});\n/*\n const client = new Client(option, common.Version);\n\nlet connectInterval;\nclient.on('quit', message => {\n process.exit(message.code);\n});\n\nclient.on('connect', () => {\n console.log('connected');\n if (connectInterval) {\n clearInterval(connectInterval);\n connectInterval = undefined;\n }\n});\n\nclient.on('error', err => {\n console.error('client error', err);\n});\n\nclient.on('close', () => {\n console.log('client closed');\n if (!connectInterval) {\n connectInterval = setInterval(() => {\n console.log('Reconnecting...');\n client.connect();\n }, 1000);\n }\n});\n*/\n//# sourceMappingURL=fisk-daemon.js.map","references":["/home/abakken/dev/fisk/daemon/constants.ts","/home/abakken/dev/fisk/daemon/server.ts","/home/abakken/dev/fisk/daemon/slots.ts","/home/abakken/dev/fisk/common/index.ts","/home/abakken/dev/fisk/node_modules/@jhanssen/options/index.d.ts"],"map":"{\"version\":3,\"file\":\"fisk-daemon.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../daemon/fisk-daemon.ts\"],\"names\":[],\"mappings\":\"AAAA,sBAAsB;AAEtB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,OAAO,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,MAAM,MAAM,GAAG,OAAO,CAAC;IACnB,MAAM,EAAE,aAAa;IACrB,iBAAiB,EAAE,IAAI;IACvB,eAAe,EAAE,CAAC,2BAA2B,CAAC;CACjD,CAAC,CAAC;AACH,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;AAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;AAEvC,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAa,EAAE,CAAC,EAAE,EAAE;IAClD,OAAO,CAAC,GAAG,CAAC,iCAAiC,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAC3E,OAAO,CAAC,IAAI,EAAE,CAAC;IACf,cAAc;IACd,wGAAwG;AAC5G,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;IACpC,OAAO,CAAC,KAAK,CAAC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O,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SAChC;QACD,IAAI,oBAAoB,EAAE;YACtB,oBAAoB,GAAG,KAAK,CAAC;YAC7B,YAAY,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;SACpC;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE;IACpB,MAAM,CAAC,KAAK,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;IACtB,MAAM,CAAC,KAAK,EAAE,CAAC;IACf,OAAO,CAAC,IAAI,EAAE,CAAC;AACnB,CAAC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA6BE\"}"}
@@ -1 +0,0 @@
1
- {"code":"import fs from \"fs-extra\";\nimport os from \"os\";\nimport path from \"path\";\nconst Version = 5;\nfunction cacheDir(option) {\n let dir = option(\"cache-dir\");\n if (!dir) {\n // @ts-ignore\n dir = path.join(os.homedir(), \".cache\", \"fisk\", path.basename(option.prefix));\n }\n return String(dir);\n}\nfunction validateCache(option) {\n const dir = cacheDir(option);\n const file = path.join(dir, \"version\");\n // console.log(dir);\n let version;\n try {\n version = fs.readFileSync(file);\n if (version.readUInt32BE() === Version) {\n return;\n }\n }\n catch (err) {\n /* */\n }\n if (version) {\n console.log(`Wrong version. Destroying cache ${dir}`);\n }\n fs.removeSync(dir);\n fs.mkdirpSync(dir);\n const buf = Buffer.allocUnsafe(4);\n buf.writeUInt32BE(Version);\n fs.writeFileSync(file, buf);\n}\nexport default function (option) {\n validateCache(option);\n return {\n cacheDir: cacheDir.bind(undefined, option),\n Version\n };\n}\n//# sourceMappingURL=index.js.map","references":["/home/abakken/dev/fisk/node_modules/@jhanssen/options/index.d.ts","/home/abakken/dev/fisk/node_modules/@types/fs-extra/index.d.ts"],"map":"{\"version\":3,\"file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C,OAAO,CAAC,CAAC;IAC3B,EAAE,CAAC,aAAa,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;AAChC,CAAC;AAID,MAAM,CAAC,OAAO,WAAW,MAAsB;IAC3C,aAAa,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO;QACH,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,MAAM,CAAC;QAC1C,OAAO;KACV,CAAC;AACN,CAAC\"}"}
@@ -1 +0,0 @@
1
- {"code":"import { ClientBuffer } from \"./clientbuffer\";\nimport { Constants } from \"./constants\";\nimport EventEmitter from \"events\";\nclass Compile extends EventEmitter {\n constructor(conn, id, option) {\n super();\n this.debug = Boolean(option(\"debug\"));\n this.id = id;\n this.connection = conn;\n this.buffer = new ClientBuffer();\n this.messageLength = 0;\n this.pid = undefined;\n this.connection.on(\"data\", this._onData.bind(this));\n this.connection.on(\"end\", () => {\n // console.log(\"connection ended\", id);\n this.emit(\"end\");\n });\n this.connection.on(\"error\", (err) => {\n // console.log(\"connection error\", id, err);\n this.emit(\"error\", err);\n });\n }\n send(message) {\n if (this.debug) {\n console.log(\"Compile::send\", message);\n }\n try {\n if (typeof message === \"number\") {\n this.connection.write(Buffer.from([message]));\n }\n else {\n const msg = Buffer.from(JSON.stringify(message), \"utf8\");\n const header = Buffer.allocUnsafe(5);\n header.writeUInt8(Constants.JSONResponse, 0);\n header.writeUInt32BE(msg.length, 1);\n if (this.debug) {\n console.log(\"Compile::send header\", header, Constants.JSONResponse);\n }\n this.connection.write(header);\n this.connection.write(msg);\n }\n }\n catch (err) {\n console.error(\"Got error sending message\", err);\n }\n }\n _onData(data) {\n // console.log(\"got data\", data.length);\n this.buffer.write(data);\n let available = this.buffer.available;\n if (this.debug) {\n console.log(\"Compile::_onData\", \"id\", this.id, \"pid\", this.pid, data, \"available\", available, this.messageLength);\n }\n if (!this.pid) {\n if (available < 4) {\n return;\n }\n const pidBuffer = this.buffer.read(4);\n available -= 4;\n this.pid = pidBuffer.readUInt32BE();\n if (this.debug) {\n console.log(\"Compile::_onData got pid\", \"id\", this.id, \"pid\", this.pid);\n }\n }\n const emit = (type) => {\n if (this.debug) {\n console.log(\"Compile::_onData::emit\", type, available);\n }\n const read = this.buffer.read(1);\n if (this.debug) {\n console.log(\"Discarded\", read);\n }\n --available;\n this.emit(type);\n };\n while (available) {\n if (!this.messageLength) {\n if (this.debug) {\n console.log(\"peeking\", this.buffer.peek());\n }\n switch (this.buffer.peek()) {\n case Constants.AcquireCppSlot:\n emit(\"acquireCppSlot\");\n continue;\n case Constants.AcquireCompileSlot:\n emit(\"acquireCompileSlot\");\n continue;\n case Constants.ReleaseCppSlot:\n emit(\"releaseCppSlot\");\n continue;\n case Constants.ReleaseCompileSlot:\n emit(\"releaseCompileSlot\");\n continue;\n case Constants.JSON:\n if (available < 5) {\n break;\n }\n this.buffer.read(1);\n this.messageLength = this.buffer.read(4).readUInt32BE();\n available -= 5;\n break;\n default:\n console.error(\"Bad data\", this.buffer.peek(), \"available\", available);\n throw new Error(\"Got unexpected type \" + this.buffer.peek());\n }\n }\n if (!this.messageLength || this.messageLength > available) {\n // console.log(\"Still waiting on data\", this.messageLength, this.buffer.available);\n break;\n }\n const raw = this.buffer.read(this.messageLength);\n available -= this.messageLength;\n this.messageLength = 0;\n try {\n const msg = JSON.parse(raw.toString(\"utf8\"));\n if (this.debug) {\n console.log(\"Got json message\", msg);\n }\n // console.log(\"Got message\", msg);\n this.emit(msg.type, msg);\n }\n catch (err) {\n console.error(\"Bad JSON received\", err);\n this.connection.destroy();\n break;\n }\n }\n }\n}\nexport { Compile };\n//# sourceMappingURL=compile.js.map","references":["/home/abakken/dev/fisk/daemon/clientbuffer.ts","/home/abakken/dev/fisk/daemon/constants.ts","/home/abakken/dev/fisk/node_modules/@jhanssen/options/index.d.ts"],"map":"{\"version\":3,\"file\":\"compile.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../daemon/compile.ts\"],\"names\":[],\"mappings\":\"AAAA,OAAO,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AC5B;YAAC,OAAO,GAAG,EAAE;gBACV,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;gBACxC,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;gBAC1B,MAAM;aACT;SACJ;IACL,CAAC;CACJ;AAED,OAAO,EAAE,OAAO,EAAE,CAAC\"}"}
@@ -1 +0,0 @@
1
- {"code":"import { Compile } from \"./compile\";\nimport EventEmitter from \"events\";\nimport fs from \"fs-extra\";\nimport net from \"net\";\nimport path from \"path\";\nclass Server extends EventEmitter {\n constructor(option, common) {\n super();\n this.debug = Boolean(option(\"debug\"));\n this.file = String(option(\"socket\", path.join(common.cacheDir(), \"socket\")));\n this.server = undefined;\n this.option = option;\n this._connections = {};\n this._connectionId = 0;\n }\n close() {\n if (this.debug) {\n console.log(\"Server::close\");\n }\n if (this.server) {\n this.server.close();\n }\n try {\n fs.unlinkSync(this.file);\n }\n catch (err) {\n /* */\n }\n }\n listen() {\n try {\n fs.unlinkSync(this.file); // this should be more\n // complicated with attempts to\n // cleanly shut down and whatnot\n }\n catch (err) {\n /* */\n }\n return new Promise((resolve) => {\n let connected = false;\n this.server = net.createServer(this._onConnection.bind(this)).listen(this.file, () => {\n fs.chmodSync(this.file, \"777\");\n connected = true;\n resolve();\n });\n this.server.on(\"error\", (err) => {\n if (!connected) {\n console.error(\"Got server error\", err);\n setTimeout(this.listen.bind(this), 1000);\n }\n });\n this.server.on(\"close\", (err) => {\n if (!connected) {\n console.error(\"Got server error\", err);\n setTimeout(this.listen.bind(this), 1000);\n }\n });\n });\n }\n _onConnection(conn) {\n const compile = new Compile(conn, ++this._connectionId, this.option);\n if (this.debug) {\n console.log(\"Server::_onConnection\", compile.id);\n }\n if (this._connectionId === Math.pow(2, 31) - 1) {\n this._connectionId = 0;\n }\n this._connections[compile.id] = conn;\n compile.on(\"end\", () => {\n if (this.debug) {\n console.log(\"Compile::end\");\n }\n delete this._connections[compile.id];\n });\n this.emit(\"compile\", compile);\n }\n}\nexport { Server };\n//# sourceMappingURL=server.js.map","references":["/home/abakken/dev/fisk/common/index.ts","/home/abakken/dev/fisk/daemon/compile.ts","/home/abakken/dev/fisk/node_modules/@jhanssen/options/index.d.ts","/home/abakken/dev/fisk/node_modules/@types/fs-extra/index.d.ts"],"map":"{\"version\":3,\"file\":\"server.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../daemon/server.ts\"],\"names\":[],\"mappings\":\"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,YAAY,MAAM,QAAQ,CAAC;AAClC,OAAO,EAAE,MAAM,UAAU,CAAC;AAC1B,OAAO,GAAe,MAAM,KAAK,CAAC;AAClC,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,MAAM,MAAO,SAAQ,YAAY;IAS7B,YAAY,MAAsB,EAAE,MAAc;QAC9C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC7E,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,KAAK;QACD,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;SAChC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACb,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;SACvB;QACD,IAAI;YACA,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC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,CAAC,CAAC,CAAC;IACP,CAAC;IACD,aAAa,CAAC,IAAY;QACtB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;QACrE,IAAI,IAAI,CAAC,KAAK,EAAE;YACZ,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;SACpD;QACD,IAAI,IAAI,CAAC,aAAa,KAAK,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE;YAC5C,IAAI,CAAC,aAAa,GAAG,CAAC,CAAC;SAC1B;QACD,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QACrC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE;YACnB,IAAI,IAAI,CAAC,KAAK,EAAE;gBACZ,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;aAC/B;YAED,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAClC,CAAC;CACJ;AAED,OAAO,EAAE,MAAM,EAAE,CAAC\"}"}
@@ -1 +0,0 @@
1
- {"code":"class ClientBuffer {\n constructor() {\n this.buffers = [];\n this.offset = 0;\n }\n write(buffer) {\n this.buffers.push(buffer);\n // console.log(\"write\", buffer.length, this.buffers.length, this.available);\n }\n peek() {\n if (!this.available) {\n throw new Error(\"No data available\");\n }\n return this.buffers[0][this.offset];\n }\n read(len) {\n if (!len) {\n throw new Error(\"Don't be a tool\");\n }\n if (len > this.available) {\n throw new Error(\"We don't have this many bytes available \" + len + \">\" + this.available);\n }\n // console.log(\"read\", len, this.available);\n let ret;\n if (this.buffers[0].length - this.offset >= len) {\n // buffers[0] is enough\n const buf = this.buffers[0];\n if (buf.length - this.offset === len) {\n ret = this.offset ? buf.slice(this.offset) : buf;\n this.offset = 0;\n this.buffers.splice(0, 1);\n return ret;\n }\n ret = buf.slice(this.offset, this.offset + len);\n this.offset += len;\n return ret;\n }\n ret = Buffer.allocUnsafe(len);\n let retOffset = 0;\n this.buffers[0].copy(ret, 0, this.offset);\n retOffset += this.buffers[0].length - this.offset;\n this.offset = 0;\n this.buffers.splice(0, 1);\n while (retOffset < len) {\n const needed = len - retOffset;\n const buf = this.buffers[0];\n if (buf.length <= needed) {\n this.buffers[0].copy(ret, retOffset);\n retOffset += this.buffers[0].length;\n this.buffers.splice(0, 1);\n }\n else {\n this.buffers[0].copy(ret, retOffset, 0, needed);\n retOffset += needed;\n this.offset = needed;\n }\n }\n return ret;\n }\n get available() {\n return this.buffers.reduce((total, buf) => total + buf.length, 0) - this.offset;\n }\n}\nexport { ClientBuffer };\n//# sourceMappingURL=clientbuffer.js.map","references":[],"map":"{\"version\":3,\"file\":\"clientbuffer.js\",\"sourceRoot\":\"\",\"sources\":[\"../../../daemon/clientbuffer.ts\"],\"names\":[],\"mappings\":\"AAAA,MAAM,YAAY;IAId;QACI,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IACpB,CAAC;IAED,KAAK,CAAC,MAAc;QAChB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC1B,4EAA4E;IAChF,CAAC;IAED,IAAI;QACA,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAC;SACxC;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;IAED,IAAI,CAAC,GAAW;QACZ,IAAI,CAAC,GAAG,EAAE;YACN,MAAM,IAAI,KAAK,CAAC,iBAAi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