@helios-lang/contract-utils 0.1.0 → 0.1.1
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 +1 -1
- package/src/hl2ts.js +5 -1
- package/src/lib/Lib.js +13 -0
- package/src/lib/Libg_v0_16.js +22 -0
- package/src/lib/index.js +1 -0
- package/src/lib/load.js +37 -0
package/package.json
CHANGED
package/src/hl2ts.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
import { loadLibrary } from "./lib/index.js"
|
|
4
|
+
|
|
3
5
|
async function main() {
|
|
4
6
|
console.log("hl2ts")
|
|
5
7
|
|
|
6
|
-
|
|
8
|
+
const lib = await loadLibrary()
|
|
9
|
+
|
|
10
|
+
console.log(lib.version)
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
main()
|
package/src/lib/Lib.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import("./Lib.js").Lib} Lib
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @implements {Lib}
|
|
7
|
+
*/
|
|
8
|
+
export class Lib_v0_16 {
|
|
9
|
+
/**
|
|
10
|
+
* @param {any} lib
|
|
11
|
+
*/
|
|
12
|
+
constructor(lib) {
|
|
13
|
+
this.lib = lib
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @type {string}
|
|
18
|
+
*/
|
|
19
|
+
get version() {
|
|
20
|
+
return this.lib.VERSION
|
|
21
|
+
}
|
|
22
|
+
}
|
package/src/lib/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { loadLibrary } from "./load.js"
|
package/src/lib/load.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getVersion } from "./Lib.js"
|
|
2
|
+
import { Lib_v0_16 } from "./Libg_v0_16.js"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* @typedef {import("./Lib.js").Lib} Lib
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const packageNames = [
|
|
9
|
+
"@hyperionbt/helios"
|
|
10
|
+
]
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @returns {Promise<Lib>}
|
|
14
|
+
*/
|
|
15
|
+
export async function loadLibrary() {
|
|
16
|
+
for (let packageName of packageNames) {
|
|
17
|
+
try {
|
|
18
|
+
const lib = await eval(`import("${packageName}")`)
|
|
19
|
+
|
|
20
|
+
const [major, minor] = getVersion(lib)
|
|
21
|
+
|
|
22
|
+
switch(major) {
|
|
23
|
+
case 0:
|
|
24
|
+
switch (minor) {
|
|
25
|
+
case 16:
|
|
26
|
+
return new Lib_v0_16(lib)
|
|
27
|
+
}
|
|
28
|
+
default:
|
|
29
|
+
throw new Error(`compiler version ${lib.VERSION} not supported`)
|
|
30
|
+
}
|
|
31
|
+
} catch(_e) {
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
throw new Error("compiler not installed")
|
|
37
|
+
}
|