@vibecook/truffle 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/dist/index.d.ts +3 -12
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -12
- package/dist/index.js.map +1 -1
- package/dist/sidecar.d.ts +21 -0
- package/dist/sidecar.d.ts.map +1 -0
- package/dist/sidecar.js +61 -0
- package/dist/sidecar.js.map +1 -0
- package/package.json +39 -16
- package/scripts/postinstall.js +87 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
3
|
-
export {
|
|
4
|
-
export type { DeviceManagerEvents, DeviceIdentity } from '@vibecook/truffle-mesh';
|
|
5
|
-
export { PrimaryElection } from '@vibecook/truffle-mesh';
|
|
6
|
-
export type { ElectionConfig, ElectionState, PrimaryElectionEvents } from '@vibecook/truffle-mesh';
|
|
7
|
-
export { MeshMessageBus } from '@vibecook/truffle-mesh';
|
|
8
|
-
export { StoreSyncAdapter } from '@vibecook/truffle-store-sync';
|
|
9
|
-
export type { ISyncableStore, StoreSyncAdapterConfig } from '@vibecook/truffle-store-sync';
|
|
10
|
-
export { createLogger, TypedEventEmitter } from '@vibecook/truffle-types';
|
|
11
|
-
export type { BaseDevice, DeviceRole, DeviceStatus, MeshMessage, MeshMessageType, MeshEnvelope, Logger, DeviceSlice, SidecarConfig, SidecarStatus, TailnetPeer, } from '@vibecook/truffle-types';
|
|
12
|
-
export type { IMessageBus, BusMessage, BusMessageHandler } from '@vibecook/truffle-protocol';
|
|
1
|
+
export { NapiMeshNode, NapiFileTransferAdapter, NapiMessageBus, NapiStoreSyncAdapter, } from '@vibecook/truffle-native';
|
|
2
|
+
export type { NapiMeshNodeConfig, NapiMeshTimingConfig, NapiBaseDevice, NapiIncomingMessage, NapiTailnetPeer, NapiMeshEvent, NapiFileTransferAdapterConfig, NapiFileTransferOffer, NapiAdapterTransferInfo, NapiBusMessage, NapiFileTransferEvent, NapiStoreSyncConfig, NapiOutgoingSyncMessage, NapiDeviceSlice, } from '@vibecook/truffle-native';
|
|
3
|
+
export { resolveSidecarPath } from './sidecar.js';
|
|
13
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AAGjC,YAAY,EACV,kBAAkB,EAClB,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,6BAA6B,EAC7B,qBAAqB,EACrB,uBAAuB,EACvB,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,eAAe,GAChB,MAAM,0BAA0B,CAAA;AAGjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
export { MeshNode, createMeshNode } from '@vibecook/truffle-mesh';
|
|
6
|
-
export { DeviceManager } from '@vibecook/truffle-mesh';
|
|
7
|
-
export { PrimaryElection } from '@vibecook/truffle-mesh';
|
|
8
|
-
export { MeshMessageBus } from '@vibecook/truffle-mesh';
|
|
9
|
-
// Store sync
|
|
10
|
-
export { StoreSyncAdapter } from '@vibecook/truffle-store-sync';
|
|
11
|
-
// Types & utilities
|
|
12
|
-
export { createLogger, TypedEventEmitter } from '@vibecook/truffle-types';
|
|
1
|
+
// Re-export classes (values) from the native Rust addon
|
|
2
|
+
export { NapiMeshNode, NapiFileTransferAdapter, NapiMessageBus, NapiStoreSyncAdapter, } from '@vibecook/truffle-native';
|
|
3
|
+
// Sidecar binary resolution
|
|
4
|
+
export { resolveSidecarPath } from './sidecar.js';
|
|
13
5
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,cAAc,EACd,oBAAoB,GACrB,MAAM,0BAA0B,CAAA;AAoBjC,4BAA4B;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidecar binary resolution for @vibecook/truffle.
|
|
3
|
+
*
|
|
4
|
+
* Resolves the Go sidecar binary path using a 3-level fallback:
|
|
5
|
+
* 1. Platform-specific npm package (installed via optionalDependencies)
|
|
6
|
+
* 2. Postinstall-downloaded binary (fallback for --no-optional)
|
|
7
|
+
* 3. Error with clear instructions
|
|
8
|
+
*
|
|
9
|
+
* Follows the esbuild pattern for distributing platform-specific binaries.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Resolve the path to the Go sidecar binary for the current platform.
|
|
13
|
+
*
|
|
14
|
+
* Resolution order:
|
|
15
|
+
* 1. Platform-specific `@vibecook/truffle-sidecar-{os}-{arch}` npm package
|
|
16
|
+
* 2. Binary downloaded by postinstall into `packages/core/bin/`
|
|
17
|
+
*
|
|
18
|
+
* @throws {Error} if no binary is found for the current platform
|
|
19
|
+
*/
|
|
20
|
+
export declare function resolveSidecarPath(): string;
|
|
21
|
+
//# sourceMappingURL=sidecar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidecar.d.ts","sourceRoot":"","sources":["../src/sidecar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAiBH;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CA8B3C"}
|
package/dist/sidecar.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sidecar binary resolution for @vibecook/truffle.
|
|
3
|
+
*
|
|
4
|
+
* Resolves the Go sidecar binary path using a 3-level fallback:
|
|
5
|
+
* 1. Platform-specific npm package (installed via optionalDependencies)
|
|
6
|
+
* 2. Postinstall-downloaded binary (fallback for --no-optional)
|
|
7
|
+
* 3. Error with clear instructions
|
|
8
|
+
*
|
|
9
|
+
* Follows the esbuild pattern for distributing platform-specific binaries.
|
|
10
|
+
*/
|
|
11
|
+
import { existsSync } from 'node:fs';
|
|
12
|
+
import { createRequire } from 'node:module';
|
|
13
|
+
import { dirname, join } from 'node:path';
|
|
14
|
+
import { fileURLToPath } from 'node:url';
|
|
15
|
+
const require = createRequire(import.meta.url);
|
|
16
|
+
const PLATFORM_PACKAGES = {
|
|
17
|
+
'darwin-arm64': '@vibecook/truffle-sidecar-darwin-arm64',
|
|
18
|
+
'darwin-x64': '@vibecook/truffle-sidecar-darwin-x64',
|
|
19
|
+
'linux-x64': '@vibecook/truffle-sidecar-linux-x64',
|
|
20
|
+
'linux-arm64': '@vibecook/truffle-sidecar-linux-arm64',
|
|
21
|
+
'win32-x64': '@vibecook/truffle-sidecar-win32-x64',
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Resolve the path to the Go sidecar binary for the current platform.
|
|
25
|
+
*
|
|
26
|
+
* Resolution order:
|
|
27
|
+
* 1. Platform-specific `@vibecook/truffle-sidecar-{os}-{arch}` npm package
|
|
28
|
+
* 2. Binary downloaded by postinstall into `packages/core/bin/`
|
|
29
|
+
*
|
|
30
|
+
* @throws {Error} if no binary is found for the current platform
|
|
31
|
+
*/
|
|
32
|
+
export function resolveSidecarPath() {
|
|
33
|
+
const key = `${process.platform}-${process.arch}`;
|
|
34
|
+
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
35
|
+
const binName = `sidecar-slim${ext}`;
|
|
36
|
+
// 1. Try platform-specific npm package (optionalDependency)
|
|
37
|
+
const pkg = PLATFORM_PACKAGES[key];
|
|
38
|
+
if (pkg) {
|
|
39
|
+
try {
|
|
40
|
+
const pkgJsonPath = require.resolve(`${pkg}/package.json`);
|
|
41
|
+
const binPath = join(dirname(pkgJsonPath), 'bin', binName);
|
|
42
|
+
if (existsSync(binPath))
|
|
43
|
+
return binPath;
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Package not installed — fall through
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// 2. Try postinstall-downloaded binary (fallback)
|
|
50
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
51
|
+
const localBin = join(__dirname, '..', 'bin', binName);
|
|
52
|
+
if (existsSync(localBin))
|
|
53
|
+
return localBin;
|
|
54
|
+
// 3. Nothing found
|
|
55
|
+
const supported = Object.keys(PLATFORM_PACKAGES).join(', ');
|
|
56
|
+
throw new Error(`[truffle] Sidecar binary not found for platform "${key}".\n` +
|
|
57
|
+
`Supported platforms: ${supported}\n` +
|
|
58
|
+
`Try reinstalling: npm install @vibecook/truffle\n` +
|
|
59
|
+
`Or build from source: cd packages/sidecar-slim && go build -o bin/sidecar-slim`);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=sidecar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidecar.js","sourceRoot":"","sources":["../src/sidecar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AACzC,OAAO,EAAE,aAAa,EAAE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QAAQ,CAAA;IAEzC,mBAAmB;IACnB,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAC3D,MAAM,IAAI,KAAK,CACb,oDAAoD,GAAG,MAAM;QAC3D,wBAAwB,SAAS,IAAI;QACrC,mDAAmD;QACnD,gFAAgF,CACnF,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibecook/truffle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Mesh networking for local-first apps, built on Tailscale",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
|
-
"import": "./dist/index.js"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
5
|
"license": "MIT",
|
|
6
|
+
"author": "James Yong",
|
|
15
7
|
"repository": {
|
|
16
8
|
"type": "git",
|
|
17
9
|
"url": "https://github.com/jamesyong-42/truffle.git",
|
|
@@ -21,20 +13,51 @@
|
|
|
21
13
|
"bugs": {
|
|
22
14
|
"url": "https://github.com/jamesyong-42/truffle/issues"
|
|
23
15
|
},
|
|
24
|
-
"
|
|
16
|
+
"keywords": [
|
|
17
|
+
"mesh",
|
|
18
|
+
"networking",
|
|
19
|
+
"tailscale",
|
|
20
|
+
"local-first",
|
|
21
|
+
"p2p",
|
|
22
|
+
"napi",
|
|
23
|
+
"rust"
|
|
24
|
+
],
|
|
25
25
|
"engines": {
|
|
26
26
|
"node": ">=18"
|
|
27
27
|
},
|
|
28
|
+
"publishConfig": {
|
|
29
|
+
"access": "public"
|
|
30
|
+
},
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"type": "module",
|
|
33
|
+
"main": "dist/index.js",
|
|
34
|
+
"types": "dist/index.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist",
|
|
43
|
+
"bin",
|
|
44
|
+
"scripts"
|
|
45
|
+
],
|
|
28
46
|
"scripts": {
|
|
29
47
|
"build": "tsc",
|
|
30
48
|
"clean": "rm -rf dist",
|
|
31
|
-
"typecheck": "tsc --noEmit"
|
|
49
|
+
"typecheck": "tsc --noEmit",
|
|
50
|
+
"postinstall": "node scripts/postinstall.js"
|
|
32
51
|
},
|
|
33
52
|
"dependencies": {
|
|
34
|
-
"@vibecook/truffle-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"@vibecook/truffle-
|
|
53
|
+
"@vibecook/truffle-native": "0.1.1"
|
|
54
|
+
},
|
|
55
|
+
"optionalDependencies": {
|
|
56
|
+
"@vibecook/truffle-sidecar-darwin-arm64": "0.1.0",
|
|
57
|
+
"@vibecook/truffle-sidecar-darwin-x64": "0.1.0",
|
|
58
|
+
"@vibecook/truffle-sidecar-linux-x64": "0.1.0",
|
|
59
|
+
"@vibecook/truffle-sidecar-linux-arm64": "0.1.0",
|
|
60
|
+
"@vibecook/truffle-sidecar-win32-x64": "0.1.0"
|
|
38
61
|
},
|
|
39
62
|
"devDependencies": {
|
|
40
63
|
"typescript": "^5.7.0"
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Postinstall script for @vibecook/truffle.
|
|
5
|
+
*
|
|
6
|
+
* Verifies the sidecar binary is available via optionalDependencies.
|
|
7
|
+
* If missing (e.g., --no-optional), falls back to downloading from GitHub Releases.
|
|
8
|
+
*
|
|
9
|
+
* This follows the esbuild pattern: optionalDependencies as primary, HTTP download as fallback.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-require-imports */
|
|
13
|
+
|
|
14
|
+
const { existsSync, mkdirSync, chmodSync } = require('fs');
|
|
15
|
+
const { join, dirname } = require('path');
|
|
16
|
+
const { execSync } = require('child_process');
|
|
17
|
+
|
|
18
|
+
const GITHUB_REPO = 'jamesyong-42/truffle';
|
|
19
|
+
|
|
20
|
+
const PLATFORM_PACKAGES = {
|
|
21
|
+
'darwin-arm64': '@vibecook/truffle-sidecar-darwin-arm64',
|
|
22
|
+
'darwin-x64': '@vibecook/truffle-sidecar-darwin-x64',
|
|
23
|
+
'linux-x64': '@vibecook/truffle-sidecar-linux-x64',
|
|
24
|
+
'linux-arm64': '@vibecook/truffle-sidecar-linux-arm64',
|
|
25
|
+
'win32-x64': '@vibecook/truffle-sidecar-win32-x64',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Go asset names use GOOS/GOARCH conventions (amd64 instead of x64)
|
|
29
|
+
const GITHUB_ASSETS = {
|
|
30
|
+
'darwin-arm64': 'tsnet-sidecar-darwin-arm64',
|
|
31
|
+
'darwin-x64': 'tsnet-sidecar-darwin-amd64',
|
|
32
|
+
'linux-x64': 'tsnet-sidecar-linux-amd64',
|
|
33
|
+
'linux-arm64': 'tsnet-sidecar-linux-arm64',
|
|
34
|
+
'win32-x64': 'tsnet-sidecar-windows-amd64.exe',
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
function main() {
|
|
38
|
+
const key = `${process.platform}-${process.arch}`;
|
|
39
|
+
const pkg = PLATFORM_PACKAGES[key];
|
|
40
|
+
const ext = process.platform === 'win32' ? '.exe' : '';
|
|
41
|
+
const binName = `sidecar-slim${ext}`;
|
|
42
|
+
|
|
43
|
+
if (!pkg) {
|
|
44
|
+
console.warn(`[truffle] No prebuilt sidecar for ${key}. Build from source: cd packages/sidecar-slim && go build`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// Check if the optionalDependency was installed
|
|
49
|
+
try {
|
|
50
|
+
const pkgJson = require.resolve(`${pkg}/package.json`);
|
|
51
|
+
const binPath = join(dirname(pkgJson), 'bin', binName);
|
|
52
|
+
if (existsSync(binPath)) {
|
|
53
|
+
return; // All good
|
|
54
|
+
}
|
|
55
|
+
} catch {
|
|
56
|
+
// Not installed — fall through to download
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Fallback: download from GitHub Releases
|
|
60
|
+
const asset = GITHUB_ASSETS[key];
|
|
61
|
+
if (!asset) return;
|
|
62
|
+
|
|
63
|
+
const version = require('../package.json').version;
|
|
64
|
+
const url = `https://github.com/${GITHUB_REPO}/releases/download/v${version}/${asset}`;
|
|
65
|
+
|
|
66
|
+
console.log(`[truffle] Sidecar not found via npm. Downloading from GitHub Releases...`);
|
|
67
|
+
|
|
68
|
+
try {
|
|
69
|
+
const binDir = join(__dirname, '..', 'bin');
|
|
70
|
+
mkdirSync(binDir, { recursive: true });
|
|
71
|
+
const dest = join(binDir, binName);
|
|
72
|
+
|
|
73
|
+
execSync(`curl -fsSL "${url}" -o "${dest}"`, { stdio: 'pipe' });
|
|
74
|
+
|
|
75
|
+
if (process.platform !== 'win32') {
|
|
76
|
+
chmodSync(dest, 0o755);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
console.log(`[truffle] Sidecar downloaded successfully.`);
|
|
80
|
+
} catch {
|
|
81
|
+
console.warn(`[truffle] Could not download sidecar binary.`);
|
|
82
|
+
console.warn(`[truffle] Download manually: ${url}`);
|
|
83
|
+
console.warn(`[truffle] Or build from source: cd packages/sidecar-slim && go build -o bin/sidecar-slim`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
main();
|