@helios-lang/contract-utils 0.2.73 → 0.2.74
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 +7 -1
- package/src/context/ContractContextCache.js +0 -89
- package/src/context/index.js +1 -1
- package/src/context/set-fs-build-cache.js +81 -0
- package/types/context/ContractContextCache.d.ts +0 -8
- package/types/context/ContractContextCache.d.ts.map +1 -1
- package/types/context/index.d.ts +1 -1
- package/types/context/index.d.ts.map +1 -1
- package/types/context/set-fs-build-cache.d.ts +2 -0
- package/types/context/set-fs-build-cache.d.ts.map +1 -0
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@helios-lang/contract-utils",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.74",
|
|
4
4
|
"description": "Convenience and type-safety utilities for using Helios validators from within Typescript",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./set-fs-build-cache": "./src/context/set-fs-build-cache.js"
|
|
9
|
+
},
|
|
10
|
+
"sideEffects": [
|
|
11
|
+
"./src/context/set-fs-build-cache.js"
|
|
12
|
+
],
|
|
7
13
|
"type": "module",
|
|
8
14
|
"bin": {
|
|
9
15
|
"hl2ts": "src/hl2ts.js"
|
|
@@ -153,92 +153,3 @@ class ContractContextCache {
|
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
export const contractContextCache = new ContractContextCache()
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* @typedef {"fs"} BuildCacheKind
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @param {BuildCacheKind} kind
|
|
163
|
-
*/
|
|
164
|
-
export function setBuildCache(kind) {
|
|
165
|
-
if (kind === "fs") {
|
|
166
|
-
contractContextCache.explicitCache = new FileSystemCache()
|
|
167
|
-
} else {
|
|
168
|
-
throw new Error("invalid build cache props")
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
// uses same storage strategy as esbuild-plugin
|
|
173
|
-
/**
|
|
174
|
-
* @implements {ExplicitCache}
|
|
175
|
-
*/
|
|
176
|
-
class FileSystemCache {
|
|
177
|
-
/**
|
|
178
|
-
* @private
|
|
179
|
-
* @type {typeof import("node:fs")}
|
|
180
|
-
*/
|
|
181
|
-
fs
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* @private
|
|
185
|
-
* @type {typeof import("node:os")}
|
|
186
|
-
*/
|
|
187
|
-
os
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* @private
|
|
191
|
-
* @type {typeof import("node:path")}
|
|
192
|
-
*/
|
|
193
|
-
path
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* @private
|
|
197
|
-
* @type {string}
|
|
198
|
-
*/
|
|
199
|
-
cacheDir
|
|
200
|
-
|
|
201
|
-
constructor() {
|
|
202
|
-
this.fs = require("node:fs")
|
|
203
|
-
this.os = require("node:os")
|
|
204
|
-
this.path = require("node:path")
|
|
205
|
-
this.cacheDir = this.path.join(this.os.tmpdir(), "helios-cache")
|
|
206
|
-
|
|
207
|
-
if (!this.fs.existsSync(this.cacheDir)) {
|
|
208
|
-
this.fs.mkdirSync(this.cacheDir, {
|
|
209
|
-
recursive: true
|
|
210
|
-
})
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/**
|
|
215
|
-
* @private
|
|
216
|
-
* @param {string} key
|
|
217
|
-
*/
|
|
218
|
-
genPath(key) {
|
|
219
|
-
return this.path.join(this.cacheDir, key + ".json")
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* @param {string} key
|
|
224
|
-
*/
|
|
225
|
-
has(key) {
|
|
226
|
-
return this.fs.existsSync(this.genPath(key))
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* @param {string} key
|
|
231
|
-
* @returns {JsonSafe}
|
|
232
|
-
*/
|
|
233
|
-
get(key) {
|
|
234
|
-
return JSON.parse(this.fs.readFileSync(this.genPath(key)).toString())
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* @param {string} key
|
|
239
|
-
* @param {JsonSafe} obj
|
|
240
|
-
*/
|
|
241
|
-
set(key, obj) {
|
|
242
|
-
this.fs.writeFileSync(this.genPath(key), JSON.stringify(obj))
|
|
243
|
-
}
|
|
244
|
-
}
|
package/src/context/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ContractContextBuilder } from "./ContractContextBuilder.js"
|
|
2
|
-
export { contractContextCache
|
|
2
|
+
export { contractContextCache } from "./ContractContextCache.js"
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @template {{[name: string]: import("../codegen/index.js").LoadedValidator}} Vs
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { contractContextCache } from "./ContractContextCache.js"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @typedef {import("./ContractContextCache.js").ExplicitCache} ExplicitCache
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
// uses same storage strategy as esbuild-plugin
|
|
8
|
+
/**
|
|
9
|
+
* @implements {ExplicitCache}
|
|
10
|
+
*/
|
|
11
|
+
class FileSystemCache {
|
|
12
|
+
/**
|
|
13
|
+
* @private
|
|
14
|
+
* @type {typeof import("node:fs")}
|
|
15
|
+
*/
|
|
16
|
+
fs
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @private
|
|
20
|
+
* @type {typeof import("node:os")}
|
|
21
|
+
*/
|
|
22
|
+
os
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @private
|
|
26
|
+
* @type {typeof import("node:path")}
|
|
27
|
+
*/
|
|
28
|
+
path
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @private
|
|
32
|
+
* @type {string}
|
|
33
|
+
*/
|
|
34
|
+
cacheDir
|
|
35
|
+
|
|
36
|
+
constructor() {
|
|
37
|
+
this.fs = require("node:fs")
|
|
38
|
+
this.os = require("node:os")
|
|
39
|
+
this.path = require("node:path")
|
|
40
|
+
this.cacheDir = this.path.join(this.os.tmpdir(), "helios-cache")
|
|
41
|
+
|
|
42
|
+
if (!this.fs.existsSync(this.cacheDir)) {
|
|
43
|
+
this.fs.mkdirSync(this.cacheDir, {
|
|
44
|
+
recursive: true
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* @private
|
|
51
|
+
* @param {string} key
|
|
52
|
+
*/
|
|
53
|
+
genPath(key) {
|
|
54
|
+
return this.path.join(this.cacheDir, key + ".json")
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} key
|
|
59
|
+
*/
|
|
60
|
+
has(key) {
|
|
61
|
+
return this.fs.existsSync(this.genPath(key))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @param {string} key
|
|
66
|
+
* @returns {JsonSafe}
|
|
67
|
+
*/
|
|
68
|
+
get(key) {
|
|
69
|
+
return JSON.parse(this.fs.readFileSync(this.genPath(key)).toString())
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @param {string} key
|
|
74
|
+
* @param {JsonSafe} obj
|
|
75
|
+
*/
|
|
76
|
+
set(key, obj) {
|
|
77
|
+
this.fs.writeFileSync(this.genPath(key), JSON.stringify(obj))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
contractContextCache.explicitCache = new FileSystemCache()
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @typedef {"fs"} BuildCacheKind
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* @param {BuildCacheKind} kind
|
|
6
|
-
*/
|
|
7
|
-
export function setBuildCache(kind: BuildCacheKind): void;
|
|
8
1
|
export const contractContextCache: ContractContextCache;
|
|
9
|
-
export type BuildCacheKind = "fs";
|
|
10
2
|
export type UplcData = import("@helios-lang/uplc").UplcData;
|
|
11
3
|
export type UplcProgram = import("@helios-lang/uplc").UplcProgram;
|
|
12
4
|
export type LoadedModule = import("../codegen/LoadedModule.js").LoadedModule;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractContextCache.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextCache.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ContractContextCache.d.ts","sourceRoot":"","sources":["../../src/context/ContractContextCache.js"],"names":[],"mappings":"AA0JA,wDAA8D;uBApJjD,OAAO,mBAAmB,EAAE,QAAQ;0BACpC,OAAO,mBAAmB,EAAE,WAAW;2BACvC,OAAO,4BAA4B,EAAE,YAAY;8BACjD,OAAO,+BAA+B,EAAE,eAAe;yBACvD,OAAO,iBAAiB,EAAE,UAAU;6BACpC,OAAO,iBAAiB,EAAE,cAAc;sCACxC,OAAO,iBAAiB,EAAE,uBAAuB;uCACjD,OAAO,iBAAiB,EAAE,wBAAwB;4BAIlD;IACR,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;IACzB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,QAAQ,CAAA;IAC1B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,CAAA;CACxC;AAhBJ;;;;;;;;;GASG;AAEH;;;;;;GAMG;AAEH;IACI;;;;OAIG;IACH,wBAAe;IAEf;;;;OAIG;IACH,eAFU,MAAM,CAAC,aAAa,CAAC,CAElB;IAEb;;;;OAIG;IACH,UAAC;IAED;;;OAGG;IACH,gBAAO;IAQP,eAEC;IAED;;;;;;;;;;;OAWG;IACH,mBAVW;QACN,OAAO,EAAE,MAAM,CAAA;QACf,KAAK,EAAE,OAAO,CAAA;QACd,SAAS,EAAE,OAAO,CAAA;QAClB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;QAC3C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAA;QACrC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;KACrC,GACS,MAAM,CA0BlB;IAED;;OAEG;IACH,WAFW,cAAc,EAAE,QAI1B;IAED;;;OAGG;IACH,SAHW,MAAM,SACN,UAAU,QAQpB;IAED;;;OAGG;IACH,SAHW,MAAM,GACJ,MAAM,CAAC,UAAU,CAAC,CAuB9B;IAED;;OAEG;IACH,UAFY,cAAc,EAAE,CAI3B;CACJ"}
|
package/types/context/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export { ContractContextBuilder } from "./ContractContextBuilder.js";
|
|
2
|
+
export { contractContextCache } from "./ContractContextCache.js";
|
|
2
3
|
export type ContractContext<Vs extends {
|
|
3
4
|
[name: string]: import("../codegen/index.js").LoadedValidator;
|
|
4
5
|
}, Ms extends {
|
|
5
6
|
[name: string]: import("../codegen/index.js").LoadedModule;
|
|
6
7
|
}> = import("./ContractContext.js").ContractContext<Vs, Ms>;
|
|
7
|
-
export { contractContextCache, setBuildCache } from "./ContractContextCache.js";
|
|
8
8
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/context/index.js"],"names":[],"mappings":";;4BAI+E,EAAE,SAApE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,qBAAqB,EAAE,eAAe,CAAA;CAAE,EACF,EAAE,SAAjE;IAAE,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,qBAAqB,EAAE,YAAY,CAAA;CAAE,IAC9D,OAAO,sBAAsB,EAAE,eAAe,CAAC,EAAE,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"set-fs-build-cache.d.ts","sourceRoot":"","sources":["../../src/context/set-fs-build-cache.js"],"names":[],"mappings":"4BAGa,OAAO,2BAA2B,EAAE,aAAa"}
|