@hyperbridge/sdk 1.3.0 → 1.3.2
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/dist/browser/index.d.ts +62 -22
- package/dist/browser/index.js +223 -100
- package/dist/browser/index.js.map +1 -1
- package/dist/node/index.d.ts +62 -22
- package/dist/node/index.js +223 -100
- package/dist/node/index.js.map +1 -1
- package/package.json +1 -1
- package/plugins/vite.js +52 -39
package/package.json
CHANGED
package/plugins/vite.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import path from "node:path"
|
|
2
1
|
import { copyFile } from "node:fs/promises"
|
|
2
|
+
import path from "node:path"
|
|
3
3
|
import { colorize } from "consola/utils"
|
|
4
4
|
|
|
5
5
|
const logMessage = (message) => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
const time = new Date().toLocaleTimeString([], {
|
|
7
|
+
hour: "2-digit",
|
|
8
|
+
minute: "2-digit",
|
|
9
|
+
second: "2-digit",
|
|
10
|
+
hour12: true,
|
|
11
|
+
})
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const timestamp = colorize("dim", time)
|
|
14
|
+
const tag = colorize("bold", colorize("magenta", "[hyperbridge]"))
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
return console.log(timestamp, tag, message)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
@@ -21,35 +21,48 @@ const logMessage = (message) => {
|
|
|
21
21
|
* @returns {Plugin}
|
|
22
22
|
*/
|
|
23
23
|
const copyWasm = () => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
24
|
+
let is_dev_server = false
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
name: "@hyperbridge/vite:wasm-deps",
|
|
28
|
+
configResolved(config) {
|
|
29
|
+
if (config.command === "serve") {
|
|
30
|
+
is_dev_server = true
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
buildStart: async function makeCopy() {
|
|
34
|
+
if (!is_dev_server) {
|
|
35
|
+
logMessage("⏭️ Skipping wasm dependency. No neccessary in build step");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// @todo: Add monorepo support
|
|
40
|
+
|
|
41
|
+
// Get path to the consuming project's node_modules
|
|
42
|
+
const projectNodeModules = path.resolve(process.cwd(), "node_modules")
|
|
43
|
+
|
|
44
|
+
// Find the @hyperbridge/sdk package in node_modules
|
|
45
|
+
const source = path.resolve(
|
|
46
|
+
projectNodeModules,
|
|
47
|
+
"@hyperbridge/sdk/dist/browser/web_bg.wasm",
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
// Destination in the Vite cache directory
|
|
51
|
+
const destDir = path.resolve(projectNodeModules, ".vite/deps")
|
|
52
|
+
const dest = path.resolve(destDir, "web_bg.wasm")
|
|
53
|
+
|
|
54
|
+
// Wait for .vite folder to exist
|
|
55
|
+
setTimeout(async () => {
|
|
56
|
+
try {
|
|
57
|
+
logMessage("📦 Copying wasm dependency")
|
|
58
|
+
await copyFile(source, dest)
|
|
59
|
+
logMessage("✅ Copy complete")
|
|
60
|
+
} catch (error) {
|
|
61
|
+
logMessage(`❌ Error copying wasm file: ${error?.message}`)
|
|
62
|
+
}
|
|
63
|
+
}, 2000)
|
|
64
|
+
},
|
|
65
|
+
}
|
|
53
66
|
}
|
|
54
67
|
|
|
55
68
|
export default copyWasm
|