@vibecook/truffle 0.1.1 → 0.3.17
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/bin/sidecar-slim +0 -0
- package/dist/create-mesh-node.d.ts +49 -0
- package/dist/create-mesh-node.d.ts.map +1 -0
- package/dist/create-mesh-node.js +67 -0
- package/dist/create-mesh-node.js.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/sidecar.js.map +1 -1
- package/package.json +8 -8
- /package/scripts/{postinstall.js → postinstall.cjs} +0 -0
package/bin/sidecar-slim
ADDED
|
Binary file
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { NapiNode, type NapiPeerEvent } from '@vibecook/truffle-native';
|
|
2
|
+
export interface CreateMeshNodeOptions {
|
|
3
|
+
/** Node name (becomes the Tailscale hostname prefix). */
|
|
4
|
+
name: string;
|
|
5
|
+
/** Override sidecar path. If omitted, auto-resolved. */
|
|
6
|
+
sidecarPath?: string;
|
|
7
|
+
/** State directory for Tailscale. */
|
|
8
|
+
stateDir?: string;
|
|
9
|
+
/** Tailscale auth key (for headless/CI setups). */
|
|
10
|
+
authKey?: string;
|
|
11
|
+
/** Whether this node is ephemeral (removed from tailnet on stop). */
|
|
12
|
+
ephemeral?: boolean;
|
|
13
|
+
/** WebSocket listener port (0 = auto). */
|
|
14
|
+
wsPort?: number;
|
|
15
|
+
/**
|
|
16
|
+
* Auto-open the Tailscale auth URL in the default browser.
|
|
17
|
+
* Defaults to true. Set to false to handle auth manually.
|
|
18
|
+
*/
|
|
19
|
+
autoAuth?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Custom URL opener. Overrides the default browser opener.
|
|
22
|
+
* Useful in Electron where you'd use `shell.openExternal()`.
|
|
23
|
+
*/
|
|
24
|
+
openUrl?: (url: string) => void;
|
|
25
|
+
/** Called when Tailscale auth is required. Receives the auth URL. */
|
|
26
|
+
onAuthRequired?: (url: string) => void;
|
|
27
|
+
/** Called for peer change events (join, leave, update, ws_connected, etc.). */
|
|
28
|
+
onPeerChange?: (event: NapiPeerEvent) => void;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Create and start a Truffle node with sensible defaults.
|
|
32
|
+
*
|
|
33
|
+
* - Auto-resolves the sidecar binary path
|
|
34
|
+
* - Auto-opens the Tailscale auth URL in the browser (configurable)
|
|
35
|
+
* - Provides auth and peer lifecycle callbacks
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* const node = await createMeshNode({
|
|
40
|
+
* name: 'my-app',
|
|
41
|
+
* onPeerChange: (event) => console.log('Peer event:', event),
|
|
42
|
+
* });
|
|
43
|
+
*
|
|
44
|
+
* const peers = await node.getPeers();
|
|
45
|
+
* await node.send('peer-id', 'chat', Buffer.from(JSON.stringify({ text: 'hello' })));
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function createMeshNode(options: CreateMeshNodeOptions): Promise<NapiNode>;
|
|
49
|
+
//# sourceMappingURL=create-mesh-node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-mesh-node.d.ts","sourceRoot":"","sources":["../src/create-mesh-node.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAuB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAG7F,MAAM,WAAW,qBAAqB;IACpC,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mDAAmD;IACnD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,0CAA0C;IAC1C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IAChC,qEAAqE;IACrE,cAAc,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,+EAA+E;IAC/E,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC/C;AAmBD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,QAAQ,CAAC,CA2CtF"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { execSync } from 'node:child_process';
|
|
2
|
+
import { NapiNode } from '@vibecook/truffle-native';
|
|
3
|
+
import { resolveSidecarPath } from './sidecar.js';
|
|
4
|
+
/**
|
|
5
|
+
* Open a URL in the system's default browser.
|
|
6
|
+
*/
|
|
7
|
+
function defaultOpenUrl(url) {
|
|
8
|
+
try {
|
|
9
|
+
if (process.platform === 'darwin') {
|
|
10
|
+
execSync(`open "${url}"`);
|
|
11
|
+
}
|
|
12
|
+
else if (process.platform === 'win32') {
|
|
13
|
+
execSync(`start "" "${url}"`);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
execSync(`xdg-open "${url}"`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// Silently fail
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Create and start a Truffle node with sensible defaults.
|
|
25
|
+
*
|
|
26
|
+
* - Auto-resolves the sidecar binary path
|
|
27
|
+
* - Auto-opens the Tailscale auth URL in the browser (configurable)
|
|
28
|
+
* - Provides auth and peer lifecycle callbacks
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const node = await createMeshNode({
|
|
33
|
+
* name: 'my-app',
|
|
34
|
+
* onPeerChange: (event) => console.log('Peer event:', event),
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* const peers = await node.getPeers();
|
|
38
|
+
* await node.send('peer-id', 'chat', Buffer.from(JSON.stringify({ text: 'hello' })));
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export async function createMeshNode(options) {
|
|
42
|
+
const { name, autoAuth = true, openUrl: customOpenUrl, onAuthRequired, onPeerChange, sidecarPath, stateDir, authKey, ephemeral, wsPort, } = options;
|
|
43
|
+
const resolvedSidecarPath = sidecarPath ?? resolveSidecarPath();
|
|
44
|
+
const node = new NapiNode();
|
|
45
|
+
const config = {
|
|
46
|
+
name,
|
|
47
|
+
sidecarPath: resolvedSidecarPath,
|
|
48
|
+
stateDir,
|
|
49
|
+
authKey,
|
|
50
|
+
ephemeral,
|
|
51
|
+
wsPort,
|
|
52
|
+
};
|
|
53
|
+
await node.start(config);
|
|
54
|
+
// Subscribe to peer events for auth handling and user callback
|
|
55
|
+
node.onPeerChange((event) => {
|
|
56
|
+
if (event.eventType === 'auth_required' && event.authUrl) {
|
|
57
|
+
if (autoAuth) {
|
|
58
|
+
const opener = customOpenUrl ?? defaultOpenUrl;
|
|
59
|
+
opener(event.authUrl);
|
|
60
|
+
}
|
|
61
|
+
onAuthRequired?.(event.authUrl);
|
|
62
|
+
}
|
|
63
|
+
onPeerChange?.(event);
|
|
64
|
+
});
|
|
65
|
+
return node;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=create-mesh-node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-mesh-node.js","sourceRoot":"","sources":["../src/create-mesh-node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAA2C,MAAM,0BAA0B,CAAC;AAC7F,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AA+BlD;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AO,CAAC,CAAC;YACxB,CAAC;YACD,cAAc,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;QAED,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export type {
|
|
1
|
+
export { NapiNode, NapiFileTransfer } from '@vibecook/truffle-native';
|
|
2
|
+
export type { NapiNodeConfig, NapiNodeIdentity, NapiPeer, NapiPingResult, NapiHealthInfo, NapiPeerEvent, NapiNamespacedMessage, NapiFileOffer, NapiTransferResult, NapiTransferProgress, NapiFileTransferEvent, } from '@vibecook/truffle-native';
|
|
3
3
|
export { resolveSidecarPath } from './sidecar.js';
|
|
4
|
+
export { createMeshNode, type CreateMeshNodeOptions } from './create-mesh-node.js';
|
|
4
5
|
//# 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":"AACA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAGtE,YAAY,EACV,cAAc,EACd,gBAAgB,EAChB,QAAQ,EACR,cAAc,EACd,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAGlD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Re-export classes (values) from the native Rust addon
|
|
2
|
-
export {
|
|
2
|
+
export { NapiNode, NapiFileTransfer } from '@vibecook/truffle-native';
|
|
3
3
|
// Sidecar binary resolution
|
|
4
4
|
export { resolveSidecarPath } from './sidecar.js';
|
|
5
|
+
// High-level API
|
|
6
|
+
export { createMeshNode } from './create-mesh-node.js';
|
|
5
7
|
//# 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,wDAAwD;AACxD,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,wDAAwD;AACxD,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAiBtE,4BAA4B;AAC5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,iBAAiB;AACjB,OAAO,EAAE,cAAc,EAA8B,MAAM,uBAAuB,CAAC"}
|
package/dist/sidecar.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sidecar.js","sourceRoot":"","sources":["../src/sidecar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"sidecar.js","sourceRoot":"","sources":["../src/sidecar.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,C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AAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5D,MAAM,IAAI,KAAK,CACb,oDAAoD,GAAG,MAAM;QAC3D,wBAAwB,SAAS,IAAI;QACrC,mDAAmD;QACnD,gFAAgF,CACnF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibecook/truffle",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.17",
|
|
4
4
|
"description": "Mesh networking for local-first apps, built on Tailscale",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "James Yong",
|
|
@@ -47,17 +47,17 @@
|
|
|
47
47
|
"build": "tsc",
|
|
48
48
|
"clean": "rm -rf dist",
|
|
49
49
|
"typecheck": "tsc --noEmit",
|
|
50
|
-
"postinstall": "node scripts/postinstall.
|
|
50
|
+
"postinstall": "node scripts/postinstall.cjs"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@vibecook/truffle-native": "
|
|
53
|
+
"@vibecook/truffle-native": "workspace:*"
|
|
54
54
|
},
|
|
55
55
|
"optionalDependencies": {
|
|
56
|
-
"@vibecook/truffle-sidecar-darwin-arm64": "0.
|
|
57
|
-
"@vibecook/truffle-sidecar-darwin-x64": "0.
|
|
58
|
-
"@vibecook/truffle-sidecar-linux-x64": "0.
|
|
59
|
-
"@vibecook/truffle-sidecar-linux-arm64": "0.
|
|
60
|
-
"@vibecook/truffle-sidecar-win32-x64": "0.
|
|
56
|
+
"@vibecook/truffle-sidecar-darwin-arm64": "^0.3.0",
|
|
57
|
+
"@vibecook/truffle-sidecar-darwin-x64": "^0.3.0",
|
|
58
|
+
"@vibecook/truffle-sidecar-linux-x64": "^0.3.0",
|
|
59
|
+
"@vibecook/truffle-sidecar-linux-arm64": "^0.3.0",
|
|
60
|
+
"@vibecook/truffle-sidecar-win32-x64": "^0.3.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"typescript": "^5.7.0"
|
|
File without changes
|