zkcloudworker 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/ts/src/api/api.d.ts +2 -2
- package/lib/ts/src/api/api.js +26 -6
- package/lib/ts/src/cloud/cloud.d.ts +22 -1
- package/lib/ts/src/cloud/cloud.js +3 -1
- package/lib/ts/src/cloud/local.d.ts +26 -1
- package/lib/ts/src/cloud/local.js +138 -1
- package/lib/ts/src/cloud/task.d.ts +10 -0
- package/lib/ts/src/cloud/task.js +2 -0
- package/lib/ts/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/api/api.d.ts +2 -2
- package/lib/web/src/api/api.js +26 -6
- package/lib/web/src/api/api.js.map +1 -1
- package/lib/web/src/cloud/cloud.d.ts +22 -1
- package/lib/web/src/cloud/cloud.js +4 -2
- package/lib/web/src/cloud/cloud.js.map +1 -1
- package/lib/web/src/cloud/local.d.ts +26 -1
- package/lib/web/src/cloud/local.js +142 -1
- package/lib/web/src/cloud/local.js.map +1 -1
- package/lib/web/src/cloud/task.d.ts +10 -0
- package/lib/web/src/cloud/task.js +2 -0
- package/lib/web/src/cloud/task.js.map +1 -0
- package/lib/web/tsconfig.web.tsbuildinfo +1 -1
- package/package.json +1 -1
package/lib/web/src/api/api.d.ts
CHANGED
@@ -9,7 +9,7 @@ export declare class zkCloudWorkerClient {
|
|
9
9
|
readonly jwt: string;
|
10
10
|
readonly endpoint: string;
|
11
11
|
readonly chain: blockchain;
|
12
|
-
readonly localWorker
|
12
|
+
readonly localWorker?: (cloud: Cloud) => Promise<zkCloudWorker>;
|
13
13
|
/**
|
14
14
|
* Constructor for the API class
|
15
15
|
* @param jwt The jwt token for authentication, get it at https://t.me/minanft_bot?start=auth
|
@@ -63,7 +63,7 @@ export declare class zkCloudWorkerClient {
|
|
63
63
|
execute(data: {
|
64
64
|
developer: string;
|
65
65
|
repo: string;
|
66
|
-
task
|
66
|
+
task: string;
|
67
67
|
userId?: string;
|
68
68
|
args?: string;
|
69
69
|
metadata?: string;
|
package/lib/web/src/api/api.js
CHANGED
@@ -233,6 +233,8 @@ export class zkCloudWorkerClient {
|
|
233
233
|
return __awaiter(this, void 0, void 0, function* () {
|
234
234
|
var _a;
|
235
235
|
if (this.jwt === "local") {
|
236
|
+
if (this.localWorker === undefined)
|
237
|
+
throw new Error("localWorker is undefined");
|
236
238
|
switch (command) {
|
237
239
|
case "recursiveProof": {
|
238
240
|
console.log("calculating recursive proof locally...");
|
@@ -255,7 +257,11 @@ export class zkCloudWorkerClient {
|
|
255
257
|
jobStatus: "started",
|
256
258
|
maxAttempts: 0,
|
257
259
|
};
|
258
|
-
const cloud = new LocalCloud({
|
260
|
+
const cloud = new LocalCloud({
|
261
|
+
job,
|
262
|
+
chain: this.chain,
|
263
|
+
localWorker: this.localWorker,
|
264
|
+
});
|
259
265
|
const worker = yield this.localWorker(cloud);
|
260
266
|
if (worker === undefined)
|
261
267
|
throw new Error("worker is undefined");
|
@@ -264,9 +270,14 @@ export class zkCloudWorkerClient {
|
|
264
270
|
data,
|
265
271
|
});
|
266
272
|
job.timeFinished = Date.now();
|
267
|
-
job.jobStatus = "finished";
|
268
|
-
job.result = proof;
|
269
273
|
job.maxAttempts = 1;
|
274
|
+
if (proof !== undefined) {
|
275
|
+
job.jobStatus = "finished";
|
276
|
+
job.result = proof;
|
277
|
+
}
|
278
|
+
else {
|
279
|
+
job.jobStatus = "failed";
|
280
|
+
}
|
270
281
|
LocalStorage.jobs[jobId] = job;
|
271
282
|
return {
|
272
283
|
success: true,
|
@@ -293,15 +304,24 @@ export class zkCloudWorkerClient {
|
|
293
304
|
jobStatus: "started",
|
294
305
|
maxAttempts: 0,
|
295
306
|
};
|
296
|
-
const cloud = new LocalCloud({
|
307
|
+
const cloud = new LocalCloud({
|
308
|
+
job,
|
309
|
+
chain: this.chain,
|
310
|
+
localWorker: this.localWorker,
|
311
|
+
});
|
297
312
|
const worker = yield this.localWorker(cloud);
|
298
313
|
if (worker === undefined)
|
299
314
|
throw new Error("worker is undefined");
|
300
315
|
const result = yield worker.execute();
|
301
316
|
job.timeFinished = Date.now();
|
302
|
-
job.jobStatus = "finished";
|
303
|
-
job.result = result;
|
304
317
|
job.maxAttempts = 1;
|
318
|
+
if (result !== undefined) {
|
319
|
+
job.jobStatus = "finished";
|
320
|
+
job.result = result;
|
321
|
+
}
|
322
|
+
else {
|
323
|
+
job.jobStatus = "failed";
|
324
|
+
}
|
305
325
|
LocalStorage.jobs[jobId] = job;
|
306
326
|
return {
|
307
327
|
success: true,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../../../src/api/api.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,MAAM,MAAM,WAAW,CAAC;AAI/B,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;AAEzD;;;;GAIG;AACH,MAAM,OAAO,mBAAmB;IAM9B;;;OAGG;IACH,YAAY,MAIX;QACC,MAAM,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;QAC7C,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,UAAU,CAAC;QACjC,IAAI,GAAG,KAAK,OAAO,EAAE,CAAC;YACpB,IAAI,aAAa,KAAK,SAAS;gBAC7B,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC;QACnC,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACU,cAAc,CAAC,IAQ3B;;YAKC,MAAM,MAAM,GAAG,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CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,aAAa;QACnB,OAAO,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,GAAG,GAAG,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;IACjE,CAAC;CACF"}
|
@@ -38,6 +38,27 @@ export declare abstract class Cloud {
|
|
38
38
|
abstract saveFile(filename: string, value: Buffer): Promise<void>;
|
39
39
|
abstract loadFile(filename: string): Promise<Buffer | undefined>;
|
40
40
|
abstract loadEnvironment(password: string): Promise<void>;
|
41
|
+
abstract recursiveProof(data: {
|
42
|
+
transactions: string[];
|
43
|
+
task?: string;
|
44
|
+
userId?: string;
|
45
|
+
args?: string;
|
46
|
+
metadata?: string;
|
47
|
+
}): Promise<string>;
|
48
|
+
abstract execute(data: {
|
49
|
+
task: string;
|
50
|
+
userId?: string;
|
51
|
+
args?: string;
|
52
|
+
metadata?: string;
|
53
|
+
}): Promise<string>;
|
54
|
+
abstract addTask(data: {
|
55
|
+
task: string;
|
56
|
+
userId?: string;
|
57
|
+
args?: string;
|
58
|
+
metadata?: string;
|
59
|
+
}): Promise<string>;
|
60
|
+
abstract deleteTask(taskId: string): Promise<void>;
|
61
|
+
abstract processTasks(): Promise<void>;
|
41
62
|
}
|
42
63
|
export interface CloudTransaction {
|
43
64
|
txId: string;
|
@@ -52,5 +73,5 @@ export declare abstract class zkCloudWorker {
|
|
52
73
|
merge(proof1: string, proof2: string): Promise<string | undefined>;
|
53
74
|
execute(): Promise<string | undefined>;
|
54
75
|
processTransactions(transactions: CloudTransaction[]): Promise<void>;
|
55
|
-
task(
|
76
|
+
task(): Promise<string | undefined>;
|
56
77
|
}
|
@@ -47,8 +47,10 @@ export class zkCloudWorker {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () { });
|
48
48
|
}
|
49
49
|
// process the task defined by the developer
|
50
|
-
task(
|
51
|
-
return __awaiter(this, void 0, void 0, function* () {
|
50
|
+
task() {
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
52
|
+
return undefined;
|
53
|
+
});
|
52
54
|
}
|
53
55
|
}
|
54
56
|
//# sourceMappingURL=cloud.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":";AAQA,MAAM,OAAgB,KAAK;IAazB,YAAY,MAYX;QACC,MAAM,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,GACN,GAAG,MAAM,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":";AAQA,MAAM,OAAgB,KAAK;IAazB,YAAY,MAYX;QACC,MAAM,EACJ,KAAK,EACL,MAAM,EACN,KAAK,EACL,SAAS,EACT,IAAI,EACJ,IAAI,EACJ,MAAM,EACN,IAAI,EACJ,QAAQ,EACR,YAAY,EACZ,KAAK,GACN,GAAG,MAAM,CAAC;QACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,KAAK,CAAC;QAC1C,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CA+BF;AAQD,MAAM,OAAgB,aAAa;IAGjC,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,mCAAmC;IAC7B,iBAAiB;;YACrB,OAAO,EAAE,CAAC;QACZ,CAAC;KAAA;IAED,wEAAwE;IAClE,MAAM,CAAC,WAAmB;;YAC9B,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;IAEK,KAAK,CAAC,MAAc,EAAE,MAAc;;YACxC,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;IAED,+EAA+E;IACzE,OAAO;;YACX,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;IAED,iDAAiD;IAC3C,mBAAmB,CAAC,YAAgC;8DAAkB,CAAC;KAAA;IAE7E,4CAA4C;IACtC,IAAI;;YACR,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;CACF"}
|
@@ -2,13 +2,16 @@
|
|
2
2
|
import { Cache, PrivateKey } from "o1js";
|
3
3
|
import { Cloud, zkCloudWorker } from "./cloud";
|
4
4
|
import { JobData } from "./job";
|
5
|
+
import { TaskData } from "./task";
|
5
6
|
import { blockchain } from "../networks";
|
6
7
|
export declare class LocalCloud extends Cloud {
|
8
|
+
readonly localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
7
9
|
constructor(params: {
|
8
10
|
job: JobData;
|
9
11
|
chain: blockchain;
|
10
12
|
cache?: Cache;
|
11
13
|
stepId?: string;
|
14
|
+
localWorker: (cloud: Cloud) => Promise<zkCloudWorker>;
|
12
15
|
});
|
13
16
|
getDeployer(): Promise<PrivateKey>;
|
14
17
|
log(msg: string): Promise<void>;
|
@@ -17,6 +20,28 @@ export declare class LocalCloud extends Cloud {
|
|
17
20
|
saveFile(filename: string, value: Buffer): Promise<void>;
|
18
21
|
loadFile(filename: string): Promise<Buffer | undefined>;
|
19
22
|
loadEnvironment(password: string): Promise<void>;
|
23
|
+
private generateId;
|
24
|
+
recursiveProof(data: {
|
25
|
+
transactions: string[];
|
26
|
+
task?: string;
|
27
|
+
userId?: string;
|
28
|
+
args?: string;
|
29
|
+
metadata?: string;
|
30
|
+
}): Promise<string>;
|
31
|
+
execute(data: {
|
32
|
+
task: string;
|
33
|
+
userId?: string;
|
34
|
+
args?: string;
|
35
|
+
metadata?: string;
|
36
|
+
}): Promise<string>;
|
37
|
+
addTask(data: {
|
38
|
+
task: string;
|
39
|
+
userId?: string;
|
40
|
+
args?: string;
|
41
|
+
metadata?: string;
|
42
|
+
}): Promise<string>;
|
43
|
+
deleteTask(taskId: string): Promise<void>;
|
44
|
+
processTasks(): Promise<void>;
|
20
45
|
static sequencer(params: {
|
21
46
|
worker: zkCloudWorker;
|
22
47
|
data: {
|
@@ -44,7 +69,7 @@ export declare class LocalStorage {
|
|
44
69
|
};
|
45
70
|
};
|
46
71
|
static tasks: {
|
47
|
-
[key: string]:
|
72
|
+
[key: string]: TaskData;
|
48
73
|
};
|
49
74
|
static saveData(name: string): Promise<void>;
|
50
75
|
static loadData(name: string): Promise<void>;
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import { __awaiter } from "tslib";
|
2
2
|
import { Cache } from "o1js";
|
3
3
|
import { Cloud } from "./cloud";
|
4
|
+
import { makeString } from "../mina";
|
4
5
|
import { saveFile, loadFile, saveBinaryFile, loadBinaryFile } from "./files";
|
5
6
|
export class LocalCloud extends Cloud {
|
6
7
|
constructor(params) {
|
7
|
-
const { job, chain, cache, stepId } = params;
|
8
|
+
const { job, chain, cache, stepId, localWorker } = params;
|
8
9
|
const { jobId, developer, repo, task, userId, args, metadata } = job;
|
9
10
|
super({
|
10
11
|
jobId: jobId,
|
@@ -19,6 +20,7 @@ export class LocalCloud extends Cloud {
|
|
19
20
|
isLocalCloud: true,
|
20
21
|
chain,
|
21
22
|
});
|
23
|
+
this.localWorker = localWorker;
|
22
24
|
}
|
23
25
|
getDeployer() {
|
24
26
|
return __awaiter(this, void 0, void 0, function* () {
|
@@ -57,6 +59,145 @@ export class LocalCloud extends Cloud {
|
|
57
59
|
throw new Error("Method not implemented.");
|
58
60
|
});
|
59
61
|
}
|
62
|
+
generateId() {
|
63
|
+
return "local." + Date.now().toString() + "." + makeString(32);
|
64
|
+
}
|
65
|
+
recursiveProof(data) {
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
67
|
+
console.log("calculating recursive proof locally...");
|
68
|
+
const timeCreated = Date.now();
|
69
|
+
const jobId = this.generateId();
|
70
|
+
const job = {
|
71
|
+
id: "local",
|
72
|
+
jobId: jobId,
|
73
|
+
developer: this.developer,
|
74
|
+
repo: this.repo,
|
75
|
+
task: data.task,
|
76
|
+
userId: data.userId,
|
77
|
+
args: data.args,
|
78
|
+
metadata: data.metadata,
|
79
|
+
filename: "recursiveProof.json",
|
80
|
+
txNumber: data.transactions.length,
|
81
|
+
timeCreated,
|
82
|
+
timeCreatedString: new Date(timeCreated).toISOString(),
|
83
|
+
timeStarted: timeCreated,
|
84
|
+
jobStatus: "started",
|
85
|
+
maxAttempts: 0,
|
86
|
+
};
|
87
|
+
const cloud = new LocalCloud({
|
88
|
+
job,
|
89
|
+
chain: this.chain,
|
90
|
+
localWorker: this.localWorker,
|
91
|
+
});
|
92
|
+
const worker = yield this.localWorker(cloud);
|
93
|
+
if (worker === undefined)
|
94
|
+
throw new Error("worker is undefined");
|
95
|
+
const proof = yield LocalCloud.sequencer({
|
96
|
+
worker,
|
97
|
+
data: Object.assign(Object.assign({}, data), { developer: this.developer, repo: this.repo }),
|
98
|
+
});
|
99
|
+
job.timeFinished = Date.now();
|
100
|
+
job.jobStatus = "finished";
|
101
|
+
job.result = proof;
|
102
|
+
job.maxAttempts = 1;
|
103
|
+
LocalStorage.jobs[jobId] = job;
|
104
|
+
return jobId;
|
105
|
+
});
|
106
|
+
}
|
107
|
+
execute(data) {
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
109
|
+
console.log("executing locally...");
|
110
|
+
const timeCreated = Date.now();
|
111
|
+
const jobId = this.generateId();
|
112
|
+
const job = {
|
113
|
+
id: "local",
|
114
|
+
jobId: jobId,
|
115
|
+
developer: this.developer,
|
116
|
+
repo: this.repo,
|
117
|
+
task: data.task,
|
118
|
+
userId: data.userId,
|
119
|
+
args: data.args,
|
120
|
+
metadata: data.metadata,
|
121
|
+
txNumber: 1,
|
122
|
+
timeCreated,
|
123
|
+
timeCreatedString: new Date(timeCreated).toISOString(),
|
124
|
+
timeStarted: timeCreated,
|
125
|
+
jobStatus: "started",
|
126
|
+
maxAttempts: 0,
|
127
|
+
};
|
128
|
+
const cloud = new LocalCloud({
|
129
|
+
job,
|
130
|
+
chain: this.chain,
|
131
|
+
localWorker: this.localWorker,
|
132
|
+
});
|
133
|
+
const worker = yield this.localWorker(cloud);
|
134
|
+
if (worker === undefined)
|
135
|
+
throw new Error("worker is undefined");
|
136
|
+
const result = yield worker.execute();
|
137
|
+
job.timeFinished = Date.now();
|
138
|
+
job.jobStatus = "finished";
|
139
|
+
job.result = result;
|
140
|
+
job.maxAttempts = 1;
|
141
|
+
LocalStorage.jobs[jobId] = job;
|
142
|
+
return jobId;
|
143
|
+
});
|
144
|
+
}
|
145
|
+
addTask(data) {
|
146
|
+
return __awaiter(this, void 0, void 0, function* () {
|
147
|
+
const taskId = this.generateId();
|
148
|
+
LocalStorage.tasks[taskId] = Object.assign(Object.assign({}, data), { id: "local", taskId, developer: this.developer, repo: this.repo });
|
149
|
+
return taskId;
|
150
|
+
});
|
151
|
+
}
|
152
|
+
deleteTask(taskId) {
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
154
|
+
delete LocalStorage.tasks[taskId];
|
155
|
+
});
|
156
|
+
}
|
157
|
+
processTasks() {
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
159
|
+
for (const taskId in LocalStorage.tasks) {
|
160
|
+
const data = LocalStorage.tasks[taskId];
|
161
|
+
const jobId = this.generateId();
|
162
|
+
const timeCreated = Date.now();
|
163
|
+
const job = {
|
164
|
+
id: "local",
|
165
|
+
jobId: jobId,
|
166
|
+
developer: this.developer,
|
167
|
+
repo: this.repo,
|
168
|
+
task: data.task,
|
169
|
+
userId: data.userId,
|
170
|
+
args: data.args,
|
171
|
+
metadata: data.metadata,
|
172
|
+
txNumber: 1,
|
173
|
+
timeCreated: timeCreated,
|
174
|
+
timeCreatedString: new Date(timeCreated).toISOString(),
|
175
|
+
timeStarted: Date.now(),
|
176
|
+
jobStatus: "started",
|
177
|
+
maxAttempts: 0,
|
178
|
+
};
|
179
|
+
const cloud = new LocalCloud({
|
180
|
+
job,
|
181
|
+
chain: this.chain,
|
182
|
+
localWorker: this.localWorker,
|
183
|
+
});
|
184
|
+
const worker = yield this.localWorker(cloud);
|
185
|
+
console.log("Executing task", { taskId, data });
|
186
|
+
const result = yield worker.task();
|
187
|
+
job.timeFinished = Date.now();
|
188
|
+
job.maxAttempts = 1;
|
189
|
+
job.billedDuration = job.timeFinished - timeCreated;
|
190
|
+
if (result !== undefined) {
|
191
|
+
job.jobStatus = "finished";
|
192
|
+
job.result = result;
|
193
|
+
}
|
194
|
+
else {
|
195
|
+
job.jobStatus = "failed";
|
196
|
+
}
|
197
|
+
LocalStorage.jobs[jobId] = job;
|
198
|
+
}
|
199
|
+
});
|
200
|
+
}
|
60
201
|
static sequencer(params) {
|
61
202
|
return __awaiter(this, void 0, void 0, function* () {
|
62
203
|
const { worker, data } = params;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../../src/cloud/local.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,MAAM,OAAO,UAAW,SAAQ,KAAK;
|
1
|
+
{"version":3,"file":"local.js","sourceRoot":"","sources":["../../../../../src/cloud/local.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAc,MAAM,MAAM,CAAC;AACzC,OAAO,EAAE,KAAK,EAAiB,MAAM,SAAS,CAAC;AAG/C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAErC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE7E,MAAM,OAAO,UAAW,SAAQ,KAAK;IAEnC,YAAY,MAMX;QACC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,GAAG,MAAM,CAAC;QAE1D,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC;QACrE,KAAK,CAAC;YACJ,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,QAAQ;YAC1B,KAAK,EAAE,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,KAAK,CAAC,UAAU,CAAC,SAAS,CAAC;YAC3C,SAAS,EAAE,SAAS;YACpB,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