zkcloudworker 0.1.0 → 0.1.2
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 +18 -0
- package/lib/ts/src/api/api.js +25 -0
- package/lib/ts/src/api/client-api.d.ts +147 -0
- package/lib/ts/src/api/client-api.js +122 -0
- package/lib/ts/src/config.js +2 -2
- package/lib/ts/src/index.d.ts +1 -0
- package/lib/ts/src/index.js +3 -1
- package/lib/ts/tsconfig.tsbuildinfo +1 -1
- package/lib/web/src/api/api.d.ts +18 -0
- package/lib/web/src/api/api.js +27 -0
- package/lib/web/src/api/api.js.map +1 -1
- package/lib/web/src/api/client-api.d.ts +147 -0
- package/lib/web/src/api/client-api.js +134 -0
- package/lib/web/src/api/client-api.js.map +1 -0
- package/lib/web/src/cloud/cloud.js.map +1 -1
- package/lib/web/src/config.js +2 -2
- package/lib/web/src/config.js.map +1 -1
- package/lib/web/src/index.d.ts +1 -0
- package/lib/web/src/index.js +1 -0
- package/lib/web/src/index.js.map +1 -1
- package/lib/web/tsconfig.web.tsbuildinfo +1 -1
- package/package.json +1 -1
package/lib/web/src/api/api.js
CHANGED
@@ -74,6 +74,33 @@ export class zkCloudWorker {
|
|
74
74
|
};
|
75
75
|
});
|
76
76
|
}
|
77
|
+
/**
|
78
|
+
* Gets the result of the job using serverless api call
|
79
|
+
* @param data the data for the deploy call
|
80
|
+
* @param data.packageName the name of the zip file with the code to be deployed
|
81
|
+
* @returns { success: boolean, error?: string, result?: any }
|
82
|
+
* where result is the result of the job
|
83
|
+
* if the job is not finished yet, the result will be undefined
|
84
|
+
* if the job failed, the result will be undefined and error will be set
|
85
|
+
* if the job is finished, the result will be set and error will be undefined
|
86
|
+
* if the job is not found, the result will be undefined and error will be set
|
87
|
+
*/
|
88
|
+
deploy(data) {
|
89
|
+
return __awaiter(this, void 0, void 0, function* () {
|
90
|
+
const result = yield this.apiHub("deploy", data);
|
91
|
+
if (result.data === "error")
|
92
|
+
return {
|
93
|
+
success: false,
|
94
|
+
error: result.error,
|
95
|
+
};
|
96
|
+
else
|
97
|
+
return {
|
98
|
+
success: result.success,
|
99
|
+
jobId: result.data,
|
100
|
+
error: result.error,
|
101
|
+
};
|
102
|
+
});
|
103
|
+
}
|
77
104
|
/**
|
78
105
|
* Gets the billing report for the jobs sent using JWT
|
79
106
|
* @returns { success: boolean, error?: string, result?: any }
|
@@ -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,MAAM,SAAS,CAAC;AAChC,OAAO,MAAM,MAAM,WAAW,CAAC;AAC/B,MAAM,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAAC;AAEzD;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAIxB;;;OAGG;IACH,YAAY,GAAW;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,QAAQ,GAAG,iBAAiB,CAAC;IACpC,CAAC;IAED;;;;;;;;;;;;OAYG;IACU,SAAS,CAAC,IAMtB;;YAKC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACpD,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO;gBACzB,OAAO;oBACL,OAAO,EAAE,KAAK;oBACd,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAC;;gBAEF,OAAO;oBACL,OAAO,EAAE,MAAM,CAAC,OAAO;oBACvB,KAAK,EAAE,MAAM,CAAC,IAAI;oBAClB,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB,CAAC;QACN,CAAC;KAAA;IAED;;;;;;;;;;OAUG;IACU,SAAS,CAAC,IAAuB;;YAM5C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC;YACpD,IAAI,IAAI,CAAC,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AAE,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC;YAChD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;gBAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;YAC1C,CAAC;QACH,CAAC;KAAA;IAED,8DAA8D;IACtD,OAAO,CAAC,IAAS;QACvB,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,IAAI,CAAC;QAClC,IAAI,CAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,SAAS,MAAK,QAAQ;YAAE,OAAO,IAAI,CAAC;QAC9C,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC;YACpE,OAAO,IAAI,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
@@ -0,0 +1,147 @@
|
|
1
|
+
/**
|
2
|
+
* Client API for calling the zkCloudWorker
|
3
|
+
*/
|
4
|
+
export { TxnPayload, IsError, SerializedTxn, SignedSerializedTxn, TxnResult, JobPayload, JobResult, zkCloudWorkerAPI, };
|
5
|
+
interface TxnPayload {
|
6
|
+
data: object;
|
7
|
+
options?: object;
|
8
|
+
}
|
9
|
+
interface IsError {
|
10
|
+
code: number;
|
11
|
+
message: string;
|
12
|
+
exception: any;
|
13
|
+
}
|
14
|
+
interface SerializedTxn {
|
15
|
+
hash: string | null;
|
16
|
+
transaction: any | null;
|
17
|
+
error: IsError | null;
|
18
|
+
}
|
19
|
+
interface SignedSerializedTxn {
|
20
|
+
hash: string | null;
|
21
|
+
transaction: any | null;
|
22
|
+
error: IsError | null;
|
23
|
+
}
|
24
|
+
interface TxnResult {
|
25
|
+
hash: string | null;
|
26
|
+
data: any | null;
|
27
|
+
error: IsError | null;
|
28
|
+
}
|
29
|
+
interface JobPayload {
|
30
|
+
data: object;
|
31
|
+
options?: object;
|
32
|
+
}
|
33
|
+
interface JobResult {
|
34
|
+
data: any | null;
|
35
|
+
error: IsError | null;
|
36
|
+
}
|
37
|
+
declare class zkCloudWorkerAPI {
|
38
|
+
private API_KEY;
|
39
|
+
constructor(apiKey: string);
|
40
|
+
/**
|
41
|
+
* prove() sign() and send()
|
42
|
+
*
|
43
|
+
* The called cloud worker is expected to compile the needed Contract,
|
44
|
+
* create the transaction, prove it and send it back serialized.
|
45
|
+
*
|
46
|
+
* Then the serialized transaction can be signed locally using AuroWallet
|
47
|
+
* and finally send it to MINA using the cloud worker.
|
48
|
+
*
|
49
|
+
* IMPORTANT: the transaction fee will be paid by the local sender, using
|
50
|
+
* the Auro Wallet at the moment of signing the serialized transaction.
|
51
|
+
*
|
52
|
+
* We only need the sender public key to create and prove the transaction.
|
53
|
+
* The sender private key NEVER leaves the local wallet.
|
54
|
+
*
|
55
|
+
* Example:
|
56
|
+
* ~~~
|
57
|
+
* let zkWorker = new ZKRunner(API_KEY);
|
58
|
+
*
|
59
|
+
* let serializedTxn = await zkWorker.prove('batch-voting-...', {
|
60
|
+
* data: {
|
61
|
+
* claimUid: '012345...789',
|
62
|
+
* // ...
|
63
|
+
* },
|
64
|
+
* options: {
|
65
|
+
* senderAddress: 'B62...',
|
66
|
+
* fee: MIN_FEE // MAX_FEE | AUTO_FEE | number
|
67
|
+
* }
|
68
|
+
* });
|
69
|
+
* if (serializedTxn.error)
|
70
|
+
* // treat error here
|
71
|
+
*
|
72
|
+
* let signedTxn = await zkWorker.sign(signerAddress, serializedTxn);
|
73
|
+
* if (signedTxn.error)
|
74
|
+
* // treat error here
|
75
|
+
*
|
76
|
+
* let txnResult = await zkWorker.send(signedTxn) ;
|
77
|
+
* if (txnResult.error)
|
78
|
+
* // treat error here
|
79
|
+
* ~~~
|
80
|
+
*/
|
81
|
+
prove(jobName: string, payload: TxnPayload): Promise<void>;
|
82
|
+
sign(signerAddress: string, serializedTxn: SerializedTxn): Promise<void>;
|
83
|
+
send(txn: SignedSerializedTxn): Promise<void>;
|
84
|
+
/**
|
85
|
+
* proveAndSend()
|
86
|
+
*
|
87
|
+
* The called cloud worker is expected to do all: compile the needed Contract,
|
88
|
+
* create the transaction, prove it, sign it using one of the available
|
89
|
+
* fee payers, and finally send it to MINA.
|
90
|
+
*
|
91
|
+
* IMPORTANT: the transaction fee will be paid by the first fee payer
|
92
|
+
* available from the list of fee payers provided by the ZKRunner service.
|
93
|
+
* Also the fee will be set by the cloud worker using some optimal algorithm
|
94
|
+
* that minimizes fees.
|
95
|
+
*
|
96
|
+
* In this case the sender public key to create and prove the transaction
|
97
|
+
* will be the selected ZKRunner fee payer previously mentioned.
|
98
|
+
*
|
99
|
+
* Example:
|
100
|
+
* ~~~
|
101
|
+
* let zkWorker = new ZKRunner(API_KEY);
|
102
|
+
*
|
103
|
+
* let txnResult = await zkWorker.proveAndSend('batch-voting-...', {
|
104
|
+
* data: {
|
105
|
+
* claimUid: '012345...789',
|
106
|
+
* // ...
|
107
|
+
* }
|
108
|
+
* });
|
109
|
+
*
|
110
|
+
* if (txnResult.error)
|
111
|
+
* // treat error here
|
112
|
+
* ~~~
|
113
|
+
*/
|
114
|
+
proveAndSend(jobName: string, payload: TxnPayload): Promise<void>;
|
115
|
+
/**
|
116
|
+
* runJob()
|
117
|
+
*
|
118
|
+
* The called cloud worker can also be used to easily run jobs not related to
|
119
|
+
* a MINA transaction, and will act just like any serverless function.
|
120
|
+
*
|
121
|
+
* This "generic" job can benefit from the easy to use deploy and call service
|
122
|
+
* already implemented for cloud proving without no extra costs.
|
123
|
+
*
|
124
|
+
* IMPORTANT: there will be a small fee that needs to be paid for service usage,
|
125
|
+
* but no MINA fees need to be paid.
|
126
|
+
*
|
127
|
+
* Example:
|
128
|
+
* ~~~
|
129
|
+
* let zkWorker = new ZKRunner(API_KEY);
|
130
|
+
*
|
131
|
+
* let jobResult = await zkWorker.runJob('send-email-to-judges', {
|
132
|
+
* data: {
|
133
|
+
* judges: [
|
134
|
+
* // ...
|
135
|
+
* ],
|
136
|
+
* },
|
137
|
+
* options: {
|
138
|
+
* // ...
|
139
|
+
* }
|
140
|
+
* });
|
141
|
+
*
|
142
|
+
* if (txnResult.error)
|
143
|
+
* // treat error here
|
144
|
+
* ~~~
|
145
|
+
*/
|
146
|
+
runJob(jobName: string, payload: JobPayload): Promise<void>;
|
147
|
+
}
|
@@ -0,0 +1,134 @@
|
|
1
|
+
import { __awaiter } from "tslib";
|
2
|
+
/**
|
3
|
+
* Client API for calling the zkCloudWorker
|
4
|
+
*/
|
5
|
+
export { zkCloudWorkerAPI, };
|
6
|
+
class zkCloudWorkerAPI {
|
7
|
+
constructor(apiKey) {
|
8
|
+
this.API_KEY = "";
|
9
|
+
this.API_KEY = apiKey;
|
10
|
+
}
|
11
|
+
/**
|
12
|
+
* prove() sign() and send()
|
13
|
+
*
|
14
|
+
* The called cloud worker is expected to compile the needed Contract,
|
15
|
+
* create the transaction, prove it and send it back serialized.
|
16
|
+
*
|
17
|
+
* Then the serialized transaction can be signed locally using AuroWallet
|
18
|
+
* and finally send it to MINA using the cloud worker.
|
19
|
+
*
|
20
|
+
* IMPORTANT: the transaction fee will be paid by the local sender, using
|
21
|
+
* the Auro Wallet at the moment of signing the serialized transaction.
|
22
|
+
*
|
23
|
+
* We only need the sender public key to create and prove the transaction.
|
24
|
+
* The sender private key NEVER leaves the local wallet.
|
25
|
+
*
|
26
|
+
* Example:
|
27
|
+
* ~~~
|
28
|
+
* let zkWorker = new ZKRunner(API_KEY);
|
29
|
+
*
|
30
|
+
* let serializedTxn = await zkWorker.prove('batch-voting-...', {
|
31
|
+
* data: {
|
32
|
+
* claimUid: '012345...789',
|
33
|
+
* // ...
|
34
|
+
* },
|
35
|
+
* options: {
|
36
|
+
* senderAddress: 'B62...',
|
37
|
+
* fee: MIN_FEE // MAX_FEE | AUTO_FEE | number
|
38
|
+
* }
|
39
|
+
* });
|
40
|
+
* if (serializedTxn.error)
|
41
|
+
* // treat error here
|
42
|
+
*
|
43
|
+
* let signedTxn = await zkWorker.sign(signerAddress, serializedTxn);
|
44
|
+
* if (signedTxn.error)
|
45
|
+
* // treat error here
|
46
|
+
*
|
47
|
+
* let txnResult = await zkWorker.send(signedTxn) ;
|
48
|
+
* if (txnResult.error)
|
49
|
+
* // treat error here
|
50
|
+
* ~~~
|
51
|
+
*/
|
52
|
+
prove(jobName, payload //: Promise < SerializedTxn > {
|
53
|
+
) {
|
54
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
55
|
+
}
|
56
|
+
sign(signerAddress, serializedTxn //: Promise<SignedSerializedTxn> {
|
57
|
+
) {
|
58
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
59
|
+
}
|
60
|
+
send(txn //: Promise<TxnResult> {
|
61
|
+
) {
|
62
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
63
|
+
}
|
64
|
+
/**
|
65
|
+
* proveAndSend()
|
66
|
+
*
|
67
|
+
* The called cloud worker is expected to do all: compile the needed Contract,
|
68
|
+
* create the transaction, prove it, sign it using one of the available
|
69
|
+
* fee payers, and finally send it to MINA.
|
70
|
+
*
|
71
|
+
* IMPORTANT: the transaction fee will be paid by the first fee payer
|
72
|
+
* available from the list of fee payers provided by the ZKRunner service.
|
73
|
+
* Also the fee will be set by the cloud worker using some optimal algorithm
|
74
|
+
* that minimizes fees.
|
75
|
+
*
|
76
|
+
* In this case the sender public key to create and prove the transaction
|
77
|
+
* will be the selected ZKRunner fee payer previously mentioned.
|
78
|
+
*
|
79
|
+
* Example:
|
80
|
+
* ~~~
|
81
|
+
* let zkWorker = new ZKRunner(API_KEY);
|
82
|
+
*
|
83
|
+
* let txnResult = await zkWorker.proveAndSend('batch-voting-...', {
|
84
|
+
* data: {
|
85
|
+
* claimUid: '012345...789',
|
86
|
+
* // ...
|
87
|
+
* }
|
88
|
+
* });
|
89
|
+
*
|
90
|
+
* if (txnResult.error)
|
91
|
+
* // treat error here
|
92
|
+
* ~~~
|
93
|
+
*/
|
94
|
+
proveAndSend(jobName, payload //: Promise<TxnResult> {
|
95
|
+
) {
|
96
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
97
|
+
}
|
98
|
+
/**
|
99
|
+
* runJob()
|
100
|
+
*
|
101
|
+
* The called cloud worker can also be used to easily run jobs not related to
|
102
|
+
* a MINA transaction, and will act just like any serverless function.
|
103
|
+
*
|
104
|
+
* This "generic" job can benefit from the easy to use deploy and call service
|
105
|
+
* already implemented for cloud proving without no extra costs.
|
106
|
+
*
|
107
|
+
* IMPORTANT: there will be a small fee that needs to be paid for service usage,
|
108
|
+
* but no MINA fees need to be paid.
|
109
|
+
*
|
110
|
+
* Example:
|
111
|
+
* ~~~
|
112
|
+
* let zkWorker = new ZKRunner(API_KEY);
|
113
|
+
*
|
114
|
+
* let jobResult = await zkWorker.runJob('send-email-to-judges', {
|
115
|
+
* data: {
|
116
|
+
* judges: [
|
117
|
+
* // ...
|
118
|
+
* ],
|
119
|
+
* },
|
120
|
+
* options: {
|
121
|
+
* // ...
|
122
|
+
* }
|
123
|
+
* });
|
124
|
+
*
|
125
|
+
* if (txnResult.error)
|
126
|
+
* // treat error here
|
127
|
+
* ~~~
|
128
|
+
*/
|
129
|
+
runJob(jobName, payload //: Promise<JobResult> {
|
130
|
+
) {
|
131
|
+
return __awaiter(this, void 0, void 0, function* () { });
|
132
|
+
}
|
133
|
+
}
|
134
|
+
//# sourceMappingURL=client-api.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"client-api.js","sourceRoot":"","sources":["../../../../../src/api/client-api.ts"],"names":[],"mappings":";AAAA;;GAEG;AACH,OAAO,EAQL,gBAAgB,GACjB,CAAC;AAyCF,MAAM,gBAAgB;IAGpB,YAAY,MAAc;QAFlB,YAAO,GAAW,EAAE,CAAC;QAG3B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;IACxB,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAwCG;IACG,KAAK,CACT,OAAe,EACf,OAAmB,CAAC,+BAA+B;;8DAClD,CAAC;KAAA;IAEE,IAAI,CACR,aAAqB,EACrB,aAA4B,CAAC,kCAAkC;;8DAC9D,CAAC;KAAA;IAEE,IAAI,CACR,GAAwB,CAAC,wBAAwB;;8DAChD,CAAC;KAAA;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACG,YAAY,CAChB,OAAe,EACf,OAAmB,CAAC,wBAAwB;;8DAC3C,CAAC;KAAA;IAEJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8BG;IACG,MAAM,CACV,OAAe,EACf,OAAmB,CAAC,wBAAwB;;8DAC3C,CAAC;KAAA;CACL"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,KAAK;IAEzB,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;
|
1
|
+
{"version":3,"file":"cloud.js","sourceRoot":"","sources":["../../../../../src/cloud/cloud.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,KAAK;IAEzB,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CASF"}
|
package/lib/web/src/config.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
const config = {
|
2
2
|
MINAFEE: "200000000",
|
3
|
-
ZKCLOUDWORKER_AUTH: "
|
4
|
-
ZKCLOUDWORKER_API: "https://n1zjzclr99.execute-api.eu-west-1.amazonaws.com/dev/
|
3
|
+
ZKCLOUDWORKER_AUTH: "M6t4jtbBAFFXhLERHQWyEB9JA9xi4cWqmYduaCXtbrFjb7yaY7TyaXDunKDJNiUTBEcyUomNXJgC",
|
4
|
+
ZKCLOUDWORKER_API: "https://n1zjzclr99.execute-api.eu-west-1.amazonaws.com/dev/zkcloudworker",
|
5
5
|
};
|
6
6
|
export default config;
|
7
7
|
//# sourceMappingURL=config.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,WAAW;IACpB,kBAAkB,EAChB,
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../../src/config.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,OAAO,EAAE,WAAW;IACpB,kBAAkB,EAChB,8EAA8E;IAChF,iBAAiB,EACf,0EAA0E;CAC7E,CAAC;AAEF,eAAe,MAAM,CAAC"}
|
package/lib/web/src/index.d.ts
CHANGED
@@ -3,3 +3,4 @@ export { Cloud } from "./cloud/cloud";
|
|
3
3
|
export { blockchain, initBlockchain, Memory, makeString, sleep, accountBalance, accountBalanceMina, formatTime, MinaNetwork, } from "./mina";
|
4
4
|
export { fee } from "./fee";
|
5
5
|
export { MinaNetworkURL, Berkeley, Lightnet, TestWorld2 } from "./networks";
|
6
|
+
export { TxnPayload, IsError, SerializedTxn, SignedSerializedTxn, TxnResult, JobPayload, JobResult, zkCloudWorkerAPI, } from "./api/client-api";
|
package/lib/web/src/index.js
CHANGED
@@ -3,4 +3,5 @@ export { Cloud } from "./cloud/cloud";
|
|
3
3
|
export { initBlockchain, Memory, makeString, sleep, accountBalance, accountBalanceMina, formatTime, } from "./mina";
|
4
4
|
export { fee } from "./fee";
|
5
5
|
export { Berkeley, Lightnet, TestWorld2 } from "./networks";
|
6
|
+
export { zkCloudWorkerAPI, } from "./api/client-api";
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/lib/web/src/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAEL,cAAc,EACd,MAAM,EACN,UAAU,EACV,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,GAEX,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAkB,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC"}
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAEL,cAAc,EACd,MAAM,EACN,UAAU,EACV,KAAK,EACL,cAAc,EACd,kBAAkB,EAClB,UAAU,GAEX,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,GAAG,EAAE,MAAM,OAAO,CAAC;AAC5B,OAAO,EAAkB,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC5E,OAAO,EAQL,gBAAgB,GACjB,MAAM,kBAAkB,CAAC"}
|