@holochain/hc-spin 0.200.0
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/.editorconfig +9 -0
- package/.eslintignore +4 -0
- package/.eslintrc +31 -0
- package/.prettierignore +6 -0
- package/.prettierrc.yaml +3 -0
- package/.vscode/extensions.json +3 -0
- package/.vscode/launch.json +39 -0
- package/.vscode/settings.json +12 -0
- package/.yarnrc.yml +1 -0
- package/README.md +48 -0
- package/build/entitlements.mac.plist +12 -0
- package/build/icon.icns +0 -0
- package/build/icon.ico +0 -0
- package/build/icon.png +0 -0
- package/cli/cli.js +18 -0
- package/dist/cli.js +18 -0
- package/dist/main/index.js +13513 -0
- package/dist/preload/index.js +5 -0
- package/dist/renderer/assets/renderer-2UdJ5Bnz.js +1 -0
- package/dist/renderer/index.html +44 -0
- package/dist/renderer/indexNotFound1.html +44 -0
- package/dist/renderer/indexNotFound2.html +44 -0
- package/docs/DEVSETUP.md +36 -0
- package/electron.vite.config.ts +22 -0
- package/package.json +51 -0
- package/resources/icon.png +0 -0
- package/rust-utils/.yarnrc.yml +1 -0
- package/rust-utils/Cargo.toml +44 -0
- package/rust-utils/build.rs +5 -0
- package/rust-utils/index.d.ts +33 -0
- package/rust-utils/index.js +258 -0
- package/rust-utils/package.json +31 -0
- package/rust-utils/src/decode_webhapp.rs +112 -0
- package/rust-utils/src/lib.rs +7 -0
- package/rust-utils/src/types.rs +52 -0
- package/rust-utils/src/utils.rs +4 -0
- package/rust-utils/src/zome_call_signer.rs +99 -0
- package/src/main/index.ts +305 -0
- package/src/main/validateArgs.ts +90 -0
- package/src/main/windows.ts +178 -0
- package/src/preload/index.ts +8 -0
- package/src/renderer/index.html +44 -0
- package/src/renderer/indexNotFound1.html +44 -0
- package/src/renderer/indexNotFound2.html +44 -0
- package/src/renderer/src/renderer.ts +1 -0
- package/tsconfig.json +4 -0
- package/tsconfig.node.json +8 -0
- package/tsconfig.web.json +7 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
console.error("index.html not found.");
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>Holochain dev CLI</title>
|
|
6
|
+
<meta
|
|
7
|
+
http-equiv="Content-Security-Policy"
|
|
8
|
+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
|
|
9
|
+
/>
|
|
10
|
+
<script type="module" crossorigin src="./assets/renderer-2UdJ5Bnz.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div class="container">
|
|
15
|
+
<h1>index.html not found.</h1>
|
|
16
|
+
<div style="margin-bottom: 100px">
|
|
17
|
+
Is your dev server running at the port specified with the
|
|
18
|
+
<span class="code">--ui-port</span> option?
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
23
|
+
<style>
|
|
24
|
+
body {
|
|
25
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.container {
|
|
30
|
+
display: flex;
|
|
31
|
+
height: 100vh;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.code {
|
|
40
|
+
background-color: lightgray;
|
|
41
|
+
border-radius: 3px;
|
|
42
|
+
padding: 1px 3px;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>Holochain dev CLI</title>
|
|
6
|
+
<meta
|
|
7
|
+
http-equiv="Content-Security-Policy"
|
|
8
|
+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
|
|
9
|
+
/>
|
|
10
|
+
<script type="module" crossorigin src="./assets/renderer-2UdJ5Bnz.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div class="container">
|
|
15
|
+
<h1>index.html not found.</h1>
|
|
16
|
+
<div style="margin-bottom: 100px">
|
|
17
|
+
Make sure the UI assets in your .webhapp file contain an index.html file at the asset
|
|
18
|
+
folder's root level.
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
23
|
+
<style>
|
|
24
|
+
body {
|
|
25
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.container {
|
|
30
|
+
display: flex;
|
|
31
|
+
height: 100vh;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.code {
|
|
40
|
+
background-color: lightgray;
|
|
41
|
+
border-radius: 3px;
|
|
42
|
+
padding: 1px 3px;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<title>Holochain dev CLI</title>
|
|
6
|
+
<meta
|
|
7
|
+
http-equiv="Content-Security-Policy"
|
|
8
|
+
content="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'"
|
|
9
|
+
/>
|
|
10
|
+
<script type="module" crossorigin src="./assets/renderer-2UdJ5Bnz.js"></script>
|
|
11
|
+
</head>
|
|
12
|
+
|
|
13
|
+
<body>
|
|
14
|
+
<div class="container">
|
|
15
|
+
<h1>index.html not found.</h1>
|
|
16
|
+
<div style="margin-bottom: 100px">
|
|
17
|
+
Make sure that the path you provided via the <span class="code">--ui-path</span> option
|
|
18
|
+
contains an index.html file.
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
</body>
|
|
22
|
+
</html>
|
|
23
|
+
<style>
|
|
24
|
+
body {
|
|
25
|
+
font-family: Arial, Helvetica, sans-serif;
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.container {
|
|
30
|
+
display: flex;
|
|
31
|
+
height: 100vh;
|
|
32
|
+
margin: 0;
|
|
33
|
+
padding: 0;
|
|
34
|
+
flex-direction: column;
|
|
35
|
+
align-items: center;
|
|
36
|
+
justify-content: center;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.code {
|
|
40
|
+
background-color: lightgray;
|
|
41
|
+
border-radius: 3px;
|
|
42
|
+
padding: 1px 3px;
|
|
43
|
+
}
|
|
44
|
+
</style>
|
package/docs/DEVSETUP.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
## Dev Setup
|
|
2
|
+
|
|
3
|
+
To setup the development environment to develop on the CLI itself:
|
|
4
|
+
|
|
5
|
+
1. Install dependencies:
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
2. Build Rust node add-ons (requires Rust + Go installed)
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
yarn setup
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
3. Run the CLI in development mode
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
yarn dev -- -- [your CLI arguments here]
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
for example
|
|
25
|
+
|
|
26
|
+
```
|
|
27
|
+
yarn dev -- -- --help
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
to invoke the help menu showing the available CLI arguments and options.
|
|
31
|
+
|
|
32
|
+
4. Building the CLI:
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
yarn build
|
|
36
|
+
```
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { defineConfig, externalizeDepsPlugin } from 'electron-vite';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
export default defineConfig({
|
|
5
|
+
main: {
|
|
6
|
+
plugins: [externalizeDepsPlugin({ exclude: ['@holochain/client', 'nanoid', 'get-port'] })],
|
|
7
|
+
},
|
|
8
|
+
preload: {
|
|
9
|
+
plugins: [externalizeDepsPlugin()],
|
|
10
|
+
},
|
|
11
|
+
renderer: {
|
|
12
|
+
build: {
|
|
13
|
+
rollupOptions: {
|
|
14
|
+
input: {
|
|
15
|
+
admin: path.resolve(__dirname, 'src/renderer/index.html'),
|
|
16
|
+
splashscreen: path.resolve(__dirname, 'src/renderer/indexNotFound1.html'),
|
|
17
|
+
selectmediasource: path.resolve(__dirname, 'src/renderer/indexNotFound2.html'),
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@holochain/hc-spin",
|
|
3
|
+
"version": "0.200.0",
|
|
4
|
+
"description": "CLI to run Holochain aps during development.",
|
|
5
|
+
"author": "matthme",
|
|
6
|
+
"homepage": "https://developer.holochain.org",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "out/main/index.js",
|
|
9
|
+
"bin": {
|
|
10
|
+
"hc-spin": "./dist/cli.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"format": "prettier --write .",
|
|
14
|
+
"lint": "eslint . --ext .js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix",
|
|
15
|
+
"typecheck:node": "tsc --noEmit -p tsconfig.node.json --composite false",
|
|
16
|
+
"typecheck:web": "tsc --noEmit -p tsconfig.web.json --composite false",
|
|
17
|
+
"typecheck": "npm run typecheck:node && npm run typecheck:web",
|
|
18
|
+
"start": "electron-vite preview",
|
|
19
|
+
"dev": "electron-vite dev",
|
|
20
|
+
"build": "rimraf dist && npm run typecheck && electron-vite build && mv ./out ./dist && cp ./cli/cli.js ./dist/cli.js",
|
|
21
|
+
"setup": "cd rust-utils && yarn && yarn build && cd .."
|
|
22
|
+
},
|
|
23
|
+
"dependencies": {
|
|
24
|
+
"@electron-toolkit/preload": "^3.0.0",
|
|
25
|
+
"@electron-toolkit/utils": "^3.0.0",
|
|
26
|
+
"@holochain/client": "^0.16.3",
|
|
27
|
+
"commander": "11.1.0",
|
|
28
|
+
"electron": "^28.1.1",
|
|
29
|
+
"electron-context-menu": "3.6.1",
|
|
30
|
+
"get-port": "7.0.0",
|
|
31
|
+
"hc-spin-rust-utils": "file:./rust-utils/dist",
|
|
32
|
+
"nanoid": "5.0.4",
|
|
33
|
+
"split": "1.0.1"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@electron-toolkit/eslint-config-prettier": "^2.0.0",
|
|
37
|
+
"@electron-toolkit/eslint-config-ts": "^1.0.1",
|
|
38
|
+
"@electron-toolkit/tsconfig": "^1.0.1",
|
|
39
|
+
"@types/node": "^18.19.5",
|
|
40
|
+
"bufferutil": "4.0.8",
|
|
41
|
+
"electron-builder": "^24.9.1",
|
|
42
|
+
"electron-vite": "https://github.com/matthme/electron-vite.git#forward-cli-args-dist",
|
|
43
|
+
"eslint": "^8.56.0",
|
|
44
|
+
"prettier": "^3.1.1",
|
|
45
|
+
"rimraf": "5.0.5",
|
|
46
|
+
"typescript": "^5.3.3",
|
|
47
|
+
"utf-8-validate": "^6.0.3",
|
|
48
|
+
"vite": "^5.0.11"
|
|
49
|
+
},
|
|
50
|
+
"packageManager": "yarn@1.22.19"
|
|
51
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nodeLinker: node-modules
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
[package]
|
|
2
|
+
edition = "2021"
|
|
3
|
+
name = "hc-spin-rust-utils"
|
|
4
|
+
version = "0.0.0"
|
|
5
|
+
|
|
6
|
+
[workspace]
|
|
7
|
+
|
|
8
|
+
[lib]
|
|
9
|
+
crate-type = ["cdylib"]
|
|
10
|
+
|
|
11
|
+
[dependencies]
|
|
12
|
+
# We keep those holochain dependencies separate from the root project to avoid irrelevant incompatibilities
|
|
13
|
+
holochain_client = "0.4.5-rc.0"
|
|
14
|
+
holochain_conductor_api = "0.2.4"
|
|
15
|
+
holochain_integrity_types = "0.2.4"
|
|
16
|
+
holochain_types = "0.2.4"
|
|
17
|
+
holochain_zome_types = "0.2.4"
|
|
18
|
+
holo_hash = "0.2.4"
|
|
19
|
+
kitsune_p2p_timestamp = "0.2.4"
|
|
20
|
+
lair_keystore_api = "0.3.0"
|
|
21
|
+
|
|
22
|
+
hex = "0.4.3"
|
|
23
|
+
futures = "0.3"
|
|
24
|
+
nanoid = "0.4.0"
|
|
25
|
+
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
26
|
+
napi = { version = "2.12.2", default-features = false, features = [
|
|
27
|
+
"napi4",
|
|
28
|
+
"tokio_rt",
|
|
29
|
+
"async",
|
|
30
|
+
"serde-json",
|
|
31
|
+
] }
|
|
32
|
+
napi-derive = "2.12.2"
|
|
33
|
+
serde = { version = "1.0", features = ["derive"] }
|
|
34
|
+
serde_yaml = "0.8"
|
|
35
|
+
sodoken = "0.0.9"
|
|
36
|
+
url = "2.2"
|
|
37
|
+
url2 = "0.0.6"
|
|
38
|
+
zip = "0.5.0"
|
|
39
|
+
|
|
40
|
+
[build-dependencies]
|
|
41
|
+
napi-build = "2.0.1"
|
|
42
|
+
|
|
43
|
+
[profile.release]
|
|
44
|
+
lto = true
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
export function saveHappOrWebhapp(happOrWebHappPath: string, appId: string, uisDir: string, happsDir: string): Promise<void>
|
|
7
|
+
export interface ZomeCallUnsignedNapi {
|
|
8
|
+
cellId: Array<Array<number>>
|
|
9
|
+
zomeName: string
|
|
10
|
+
fnName: string
|
|
11
|
+
payload: Array<number>
|
|
12
|
+
capSecret?: Array<number>
|
|
13
|
+
provenance: Array<number>
|
|
14
|
+
nonce: Array<number>
|
|
15
|
+
expiresAt: number
|
|
16
|
+
}
|
|
17
|
+
export interface ZomeCallNapi {
|
|
18
|
+
cellId: Array<Array<number>>
|
|
19
|
+
zomeName: string
|
|
20
|
+
fnName: string
|
|
21
|
+
payload: Array<number>
|
|
22
|
+
capSecret?: Array<number>
|
|
23
|
+
provenance: Array<number>
|
|
24
|
+
nonce: Array<number>
|
|
25
|
+
expiresAt: number
|
|
26
|
+
signature: Array<number>
|
|
27
|
+
}
|
|
28
|
+
export type JsZomeCallSigner = ZomeCallSigner
|
|
29
|
+
export class ZomeCallSigner {
|
|
30
|
+
constructor()
|
|
31
|
+
static connect(connectionUrl: string, passphrase: string): Promise<ZomeCallSigner>
|
|
32
|
+
signZomeCall(zomeCallUnsignedJs: ZomeCallUnsignedNapi): Promise<ZomeCallNapi>
|
|
33
|
+
}
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/* prettier-ignore */
|
|
4
|
+
|
|
5
|
+
/* auto-generated by NAPI-RS */
|
|
6
|
+
|
|
7
|
+
const { existsSync, readFileSync } = require('fs')
|
|
8
|
+
const { join } = require('path')
|
|
9
|
+
|
|
10
|
+
const { platform, arch } = process
|
|
11
|
+
|
|
12
|
+
let nativeBinding = null
|
|
13
|
+
let localFileExisted = false
|
|
14
|
+
let loadError = null
|
|
15
|
+
|
|
16
|
+
function isMusl() {
|
|
17
|
+
// For Node 10
|
|
18
|
+
if (!process.report || typeof process.report.getReport !== 'function') {
|
|
19
|
+
try {
|
|
20
|
+
const lddPath = require('child_process').execSync('which ldd').toString().trim()
|
|
21
|
+
return readFileSync(lddPath, 'utf8').includes('musl')
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return true
|
|
24
|
+
}
|
|
25
|
+
} else {
|
|
26
|
+
const { glibcVersionRuntime } = process.report.getReport().header
|
|
27
|
+
return !glibcVersionRuntime
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
switch (platform) {
|
|
32
|
+
case 'android':
|
|
33
|
+
switch (arch) {
|
|
34
|
+
case 'arm64':
|
|
35
|
+
localFileExisted = existsSync(join(__dirname, 'hc-we-rust-utils.android-arm64.node'))
|
|
36
|
+
try {
|
|
37
|
+
if (localFileExisted) {
|
|
38
|
+
nativeBinding = require('./hc-we-rust-utils.android-arm64.node')
|
|
39
|
+
} else {
|
|
40
|
+
nativeBinding = require('hc-spin-rust-utils-android-arm64')
|
|
41
|
+
}
|
|
42
|
+
} catch (e) {
|
|
43
|
+
loadError = e
|
|
44
|
+
}
|
|
45
|
+
break
|
|
46
|
+
case 'arm':
|
|
47
|
+
localFileExisted = existsSync(join(__dirname, 'hc-we-rust-utils.android-arm-eabi.node'))
|
|
48
|
+
try {
|
|
49
|
+
if (localFileExisted) {
|
|
50
|
+
nativeBinding = require('./hc-we-rust-utils.android-arm-eabi.node')
|
|
51
|
+
} else {
|
|
52
|
+
nativeBinding = require('hc-spin-rust-utils-android-arm-eabi')
|
|
53
|
+
}
|
|
54
|
+
} catch (e) {
|
|
55
|
+
loadError = e
|
|
56
|
+
}
|
|
57
|
+
break
|
|
58
|
+
default:
|
|
59
|
+
throw new Error(`Unsupported architecture on Android ${arch}`)
|
|
60
|
+
}
|
|
61
|
+
break
|
|
62
|
+
case 'win32':
|
|
63
|
+
switch (arch) {
|
|
64
|
+
case 'x64':
|
|
65
|
+
localFileExisted = existsSync(
|
|
66
|
+
join(__dirname, 'hc-we-rust-utils.win32-x64-msvc.node')
|
|
67
|
+
)
|
|
68
|
+
try {
|
|
69
|
+
if (localFileExisted) {
|
|
70
|
+
nativeBinding = require('./hc-we-rust-utils.win32-x64-msvc.node')
|
|
71
|
+
} else {
|
|
72
|
+
nativeBinding = require('hc-spin-rust-utils-win32-x64-msvc')
|
|
73
|
+
}
|
|
74
|
+
} catch (e) {
|
|
75
|
+
loadError = e
|
|
76
|
+
}
|
|
77
|
+
break
|
|
78
|
+
case 'ia32':
|
|
79
|
+
localFileExisted = existsSync(
|
|
80
|
+
join(__dirname, 'hc-we-rust-utils.win32-ia32-msvc.node')
|
|
81
|
+
)
|
|
82
|
+
try {
|
|
83
|
+
if (localFileExisted) {
|
|
84
|
+
nativeBinding = require('./hc-we-rust-utils.win32-ia32-msvc.node')
|
|
85
|
+
} else {
|
|
86
|
+
nativeBinding = require('hc-spin-rust-utils-win32-ia32-msvc')
|
|
87
|
+
}
|
|
88
|
+
} catch (e) {
|
|
89
|
+
loadError = e
|
|
90
|
+
}
|
|
91
|
+
break
|
|
92
|
+
case 'arm64':
|
|
93
|
+
localFileExisted = existsSync(
|
|
94
|
+
join(__dirname, 'hc-we-rust-utils.win32-arm64-msvc.node')
|
|
95
|
+
)
|
|
96
|
+
try {
|
|
97
|
+
if (localFileExisted) {
|
|
98
|
+
nativeBinding = require('./hc-we-rust-utils.win32-arm64-msvc.node')
|
|
99
|
+
} else {
|
|
100
|
+
nativeBinding = require('hc-spin-rust-utils-win32-arm64-msvc')
|
|
101
|
+
}
|
|
102
|
+
} catch (e) {
|
|
103
|
+
loadError = e
|
|
104
|
+
}
|
|
105
|
+
break
|
|
106
|
+
default:
|
|
107
|
+
throw new Error(`Unsupported architecture on Windows: ${arch}`)
|
|
108
|
+
}
|
|
109
|
+
break
|
|
110
|
+
case 'darwin':
|
|
111
|
+
localFileExisted = existsSync(join(__dirname, 'hc-we-rust-utils.darwin-universal.node'))
|
|
112
|
+
try {
|
|
113
|
+
if (localFileExisted) {
|
|
114
|
+
nativeBinding = require('./hc-we-rust-utils.darwin-universal.node')
|
|
115
|
+
} else {
|
|
116
|
+
nativeBinding = require('hc-spin-rust-utils-darwin-universal')
|
|
117
|
+
}
|
|
118
|
+
break
|
|
119
|
+
} catch {}
|
|
120
|
+
switch (arch) {
|
|
121
|
+
case 'x64':
|
|
122
|
+
localFileExisted = existsSync(join(__dirname, 'hc-we-rust-utils.darwin-x64.node'))
|
|
123
|
+
try {
|
|
124
|
+
if (localFileExisted) {
|
|
125
|
+
nativeBinding = require('./hc-we-rust-utils.darwin-x64.node')
|
|
126
|
+
} else {
|
|
127
|
+
nativeBinding = require('hc-spin-rust-utils-darwin-x64')
|
|
128
|
+
}
|
|
129
|
+
} catch (e) {
|
|
130
|
+
loadError = e
|
|
131
|
+
}
|
|
132
|
+
break
|
|
133
|
+
case 'arm64':
|
|
134
|
+
localFileExisted = existsSync(
|
|
135
|
+
join(__dirname, 'hc-we-rust-utils.darwin-arm64.node')
|
|
136
|
+
)
|
|
137
|
+
try {
|
|
138
|
+
if (localFileExisted) {
|
|
139
|
+
nativeBinding = require('./hc-we-rust-utils.darwin-arm64.node')
|
|
140
|
+
} else {
|
|
141
|
+
nativeBinding = require('hc-spin-rust-utils-darwin-arm64')
|
|
142
|
+
}
|
|
143
|
+
} catch (e) {
|
|
144
|
+
loadError = e
|
|
145
|
+
}
|
|
146
|
+
break
|
|
147
|
+
default:
|
|
148
|
+
throw new Error(`Unsupported architecture on macOS: ${arch}`)
|
|
149
|
+
}
|
|
150
|
+
break
|
|
151
|
+
case 'freebsd':
|
|
152
|
+
if (arch !== 'x64') {
|
|
153
|
+
throw new Error(`Unsupported architecture on FreeBSD: ${arch}`)
|
|
154
|
+
}
|
|
155
|
+
localFileExisted = existsSync(join(__dirname, 'hc-we-rust-utils.freebsd-x64.node'))
|
|
156
|
+
try {
|
|
157
|
+
if (localFileExisted) {
|
|
158
|
+
nativeBinding = require('./hc-we-rust-utils.freebsd-x64.node')
|
|
159
|
+
} else {
|
|
160
|
+
nativeBinding = require('hc-spin-rust-utils-freebsd-x64')
|
|
161
|
+
}
|
|
162
|
+
} catch (e) {
|
|
163
|
+
loadError = e
|
|
164
|
+
}
|
|
165
|
+
break
|
|
166
|
+
case 'linux':
|
|
167
|
+
switch (arch) {
|
|
168
|
+
case 'x64':
|
|
169
|
+
if (isMusl()) {
|
|
170
|
+
localFileExisted = existsSync(
|
|
171
|
+
join(__dirname, 'hc-we-rust-utils.linux-x64-musl.node')
|
|
172
|
+
)
|
|
173
|
+
try {
|
|
174
|
+
if (localFileExisted) {
|
|
175
|
+
nativeBinding = require('./hc-we-rust-utils.linux-x64-musl.node')
|
|
176
|
+
} else {
|
|
177
|
+
nativeBinding = require('hc-spin-rust-utils-linux-x64-musl')
|
|
178
|
+
}
|
|
179
|
+
} catch (e) {
|
|
180
|
+
loadError = e
|
|
181
|
+
}
|
|
182
|
+
} else {
|
|
183
|
+
localFileExisted = existsSync(
|
|
184
|
+
join(__dirname, 'hc-we-rust-utils.linux-x64-gnu.node')
|
|
185
|
+
)
|
|
186
|
+
try {
|
|
187
|
+
if (localFileExisted) {
|
|
188
|
+
nativeBinding = require('./hc-we-rust-utils.linux-x64-gnu.node')
|
|
189
|
+
} else {
|
|
190
|
+
nativeBinding = require('hc-spin-rust-utils-linux-x64-gnu')
|
|
191
|
+
}
|
|
192
|
+
} catch (e) {
|
|
193
|
+
loadError = e
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
break
|
|
197
|
+
case 'arm64':
|
|
198
|
+
if (isMusl()) {
|
|
199
|
+
localFileExisted = existsSync(
|
|
200
|
+
join(__dirname, 'hc-we-rust-utils.linux-arm64-musl.node')
|
|
201
|
+
)
|
|
202
|
+
try {
|
|
203
|
+
if (localFileExisted) {
|
|
204
|
+
nativeBinding = require('./hc-we-rust-utils.linux-arm64-musl.node')
|
|
205
|
+
} else {
|
|
206
|
+
nativeBinding = require('hc-spin-rust-utils-linux-arm64-musl')
|
|
207
|
+
}
|
|
208
|
+
} catch (e) {
|
|
209
|
+
loadError = e
|
|
210
|
+
}
|
|
211
|
+
} else {
|
|
212
|
+
localFileExisted = existsSync(
|
|
213
|
+
join(__dirname, 'hc-we-rust-utils.linux-arm64-gnu.node')
|
|
214
|
+
)
|
|
215
|
+
try {
|
|
216
|
+
if (localFileExisted) {
|
|
217
|
+
nativeBinding = require('./hc-we-rust-utils.linux-arm64-gnu.node')
|
|
218
|
+
} else {
|
|
219
|
+
nativeBinding = require('hc-spin-rust-utils-linux-arm64-gnu')
|
|
220
|
+
}
|
|
221
|
+
} catch (e) {
|
|
222
|
+
loadError = e
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'arm':
|
|
227
|
+
localFileExisted = existsSync(
|
|
228
|
+
join(__dirname, 'hc-we-rust-utils.linux-arm-gnueabihf.node')
|
|
229
|
+
)
|
|
230
|
+
try {
|
|
231
|
+
if (localFileExisted) {
|
|
232
|
+
nativeBinding = require('./hc-we-rust-utils.linux-arm-gnueabihf.node')
|
|
233
|
+
} else {
|
|
234
|
+
nativeBinding = require('hc-spin-rust-utils-linux-arm-gnueabihf')
|
|
235
|
+
}
|
|
236
|
+
} catch (e) {
|
|
237
|
+
loadError = e
|
|
238
|
+
}
|
|
239
|
+
break
|
|
240
|
+
default:
|
|
241
|
+
throw new Error(`Unsupported architecture on Linux: ${arch}`)
|
|
242
|
+
}
|
|
243
|
+
break
|
|
244
|
+
default:
|
|
245
|
+
throw new Error(`Unsupported OS: ${platform}, architecture: ${arch}`)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (!nativeBinding) {
|
|
249
|
+
if (loadError) {
|
|
250
|
+
throw loadError
|
|
251
|
+
}
|
|
252
|
+
throw new Error(`Failed to load native binding`)
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const { saveHappOrWebhapp, ZomeCallSigner } = nativeBinding
|
|
256
|
+
|
|
257
|
+
module.exports.saveHappOrWebhapp = saveHappOrWebhapp
|
|
258
|
+
module.exports.ZomeCallSigner = ZomeCallSigner
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "hc-spin-rust-utils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"napi": {
|
|
7
|
+
"name": "hc-we-rust-utils",
|
|
8
|
+
"triples": {}
|
|
9
|
+
},
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"devDependencies": {
|
|
12
|
+
"@napi-rs/cli": "^2.16.5",
|
|
13
|
+
"rimraf": "5.0.5",
|
|
14
|
+
"ava": "^5.1.1"
|
|
15
|
+
},
|
|
16
|
+
"ava": {
|
|
17
|
+
"timeout": "3m"
|
|
18
|
+
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">= 10"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"artifacts": "napi artifacts",
|
|
24
|
+
"build": "napi build --platform --release && rimraf dist && mkdir dist && cp package.json dist/ && cp index.js dist/ && cp index.d.ts dist/ && cp hc-we-rust-utils* dist/",
|
|
25
|
+
"build:debug": "napi build --platform",
|
|
26
|
+
"prepublishOnly": "napi prepublish -t npm",
|
|
27
|
+
"test": "ava",
|
|
28
|
+
"universal": "napi universal",
|
|
29
|
+
"version": "napi version"
|
|
30
|
+
}
|
|
31
|
+
}
|