@hashiverse/hashiverse-client-wasm 0.0.0 → 1.0.5-rc4
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/README.md +32 -0
- package/hashiverse_client_wasm.d.ts +137 -0
- package/hashiverse_client_wasm.js +9 -0
- package/hashiverse_client_wasm_bg.js +1630 -0
- package/hashiverse_client_wasm_bg.wasm +0 -0
- package/package.json +26 -9
- package/index.js +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @hashiverse/hashiverse-client-wasm
|
|
2
|
+
|
|
3
|
+
Browser/WASM client for Hashiverse — your open-source decentralized X/Twitter replacement. This package provides the Rust/WASM backend for the associated `hashiverse-client-web` repo.
|
|
4
|
+
|
|
5
|
+
[](https://github.com/hashiverse/hashiverse/actions/workflows/test-hashiverse-client-wasm.yml)
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install @hashiverse/hashiverse-client-wasm
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage (bundler — Vite, rsbuild, webpack)
|
|
14
|
+
|
|
15
|
+
```js
|
|
16
|
+
import { wasm_init, HashiverseClientWasm } from "@hashiverse/hashiverse-client-wasm";
|
|
17
|
+
|
|
18
|
+
wasm_init(true);
|
|
19
|
+
// see hashiverse-client-web for a full integration example
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
A future `@hashiverse/hashiverse-client-nodejs` package will provide a native-Node binding via NAPI-RS (parallel to the PyPI wheel). Use this WASM build only in browser/bundler contexts.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Developing this package
|
|
27
|
+
|
|
28
|
+
The rest of this document describes how to build and test `hashiverse-client-wasm` itself. End-user usage is covered above.
|
|
29
|
+
|
|
30
|
+
- Build for development with `wasm-pack build --dev`
|
|
31
|
+
- Build for release with `wasm-pack build --release`
|
|
32
|
+
- Run tests with `wasm-pack test --chrome --headless --lib`
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export interface Bio {
|
|
4
|
+
client_id: string;
|
|
5
|
+
nickname: string;
|
|
6
|
+
status: string;
|
|
7
|
+
selfie: string;
|
|
8
|
+
avatar: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface PeerInfoV1 {
|
|
12
|
+
peer_id_hex: string;
|
|
13
|
+
address: string;
|
|
14
|
+
version: string;
|
|
15
|
+
timestamp_millis: number;
|
|
16
|
+
pow_initial: number;
|
|
17
|
+
pow_current_day: number;
|
|
18
|
+
pow_current_month: number;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface Post {
|
|
22
|
+
post_id: string;
|
|
23
|
+
time_millis: number;
|
|
24
|
+
client_id: string;
|
|
25
|
+
bucket_location: string;
|
|
26
|
+
post: string;
|
|
27
|
+
encoded_post_header_hex: string;
|
|
28
|
+
healed: boolean;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface PowJobStatusV1 {
|
|
32
|
+
label: string;
|
|
33
|
+
pow_min: number;
|
|
34
|
+
best_pow_so_far: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface SingleTimelineGetMoreV1Response {
|
|
38
|
+
posts: Post[];
|
|
39
|
+
oldest_processed_time_millis: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface TrendingHashtag {
|
|
43
|
+
hashtag: string;
|
|
44
|
+
count: number;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface TrendingHashtagsFetchResponse {
|
|
48
|
+
trending_hashtags: TrendingHashtag[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface UrlPreview {
|
|
52
|
+
url: string;
|
|
53
|
+
title: string;
|
|
54
|
+
description: string;
|
|
55
|
+
image_url: string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Provides a simplified dispatch interface for [HashiverseClient] to the browser.
|
|
61
|
+
*/
|
|
62
|
+
export class HashiverseClientWasm {
|
|
63
|
+
private constructor();
|
|
64
|
+
free(): void;
|
|
65
|
+
[Symbol.dispose](): void;
|
|
66
|
+
client_storage_reset(): Promise<void>;
|
|
67
|
+
static create_from_keyphrase(key_phrase: string): Promise<HashiverseClientWasm>;
|
|
68
|
+
static create_from_stored_key(client_id_hex: string): Promise<HashiverseClientWasm>;
|
|
69
|
+
delete_all_stored_keys_v1(): Promise<void>;
|
|
70
|
+
delete_stored_key_v1(key_public: string): Promise<void>;
|
|
71
|
+
ensure_meta_post_in_current_bucket_v1(): Promise<void>;
|
|
72
|
+
fetch_trending_hashtags_v1(limit: number): Promise<TrendingHashtagsFetchResponse>;
|
|
73
|
+
fetch_url_preview_v1(url: string): Promise<UrlPreview>;
|
|
74
|
+
get_active_pow_jobs_v1(): Promise<PowJobStatusV1[]>;
|
|
75
|
+
get_all_bios(): Promise<Bio[]>;
|
|
76
|
+
get_all_known_peers_v1(): Promise<PeerInfoV1[]>;
|
|
77
|
+
get_bio(id: string): Promise<Bio>;
|
|
78
|
+
get_client_id(): string;
|
|
79
|
+
get_content_thresholds_v1(): Promise<any>;
|
|
80
|
+
get_followed_client_ids_v1(): Promise<string[]>;
|
|
81
|
+
get_followed_hashtags_v1(): Promise<string[]>;
|
|
82
|
+
get_peer_stats_v1(peer_id_hex: string): Promise<any>;
|
|
83
|
+
/**
|
|
84
|
+
* Gets all the feedbacks for a specific post
|
|
85
|
+
*
|
|
86
|
+
* The resulting vector has 256 entries - one per feedback_type that have been mapped to the statistical number of clicks a feedback button has received.
|
|
87
|
+
*/
|
|
88
|
+
get_post_feedbacks_v1(bucket_location: string, post_id: string): Promise<Uint32Array>;
|
|
89
|
+
/**
|
|
90
|
+
* Gets a specific post
|
|
91
|
+
*/
|
|
92
|
+
get_post_v1(bucket_location: string, post_id: string): Promise<Post>;
|
|
93
|
+
get_skip_warnings_for_followed_v1(): Promise<boolean>;
|
|
94
|
+
list_stored_key_ids_v1(): Promise<string[]>;
|
|
95
|
+
logged_in(): boolean;
|
|
96
|
+
multiple_timeline_get_more_followed_hashtags(): Promise<SingleTimelineGetMoreV1Response>;
|
|
97
|
+
multiple_timeline_get_more_followed_users(): Promise<SingleTimelineGetMoreV1Response>;
|
|
98
|
+
multiple_timeline_reset(): Promise<void>;
|
|
99
|
+
post_v1(post: string): Promise<Post>;
|
|
100
|
+
set_bio(nickname: string, status: string, selfie: string, avatar: string): Promise<void>;
|
|
101
|
+
set_content_thresholds_v1(thresholds: any): Promise<void>;
|
|
102
|
+
set_followed_client_id_v1(client_id: string, is_followed: boolean): Promise<void>;
|
|
103
|
+
set_followed_client_ids_v1(client_ids: any): Promise<void>;
|
|
104
|
+
set_followed_hashtag_v1(hashtag: string, is_followed: boolean): Promise<void>;
|
|
105
|
+
set_followed_hashtags_v1(hashtags: any): Promise<void>;
|
|
106
|
+
set_skip_warnings_for_followed_v1(value: boolean): Promise<void>;
|
|
107
|
+
single_timeline_get_more_hashtag_v1(hashtag: string): Promise<SingleTimelineGetMoreV1Response>;
|
|
108
|
+
single_timeline_get_more_me_mentioned_v1(): Promise<SingleTimelineGetMoreV1Response>;
|
|
109
|
+
single_timeline_get_more_me_v1(): Promise<SingleTimelineGetMoreV1Response>;
|
|
110
|
+
single_timeline_get_more_reply_to_post_v1(post_id: string): Promise<SingleTimelineGetMoreV1Response>;
|
|
111
|
+
single_timeline_get_more_sequel_v1(post_id: string): Promise<SingleTimelineGetMoreV1Response>;
|
|
112
|
+
single_timeline_get_more_user_mentioned_v1(client_id_hex: string): Promise<SingleTimelineGetMoreV1Response>;
|
|
113
|
+
single_timeline_get_more_user_v1(client_id_hex: string): Promise<SingleTimelineGetMoreV1Response>;
|
|
114
|
+
single_timeline_reset(): Promise<void>;
|
|
115
|
+
submit_feedback_v1(bucket_location: string, post_id: string, feedback_type: number): Promise<void>;
|
|
116
|
+
submit_meta_post_v1(): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Initialize the parallel PoW worker pool. Call from TypeScript, passing an
|
|
121
|
+
* array of ready `Worker` handles that each run `HashiversePowWorker.ts`.
|
|
122
|
+
*/
|
|
123
|
+
export function init_pow_workers(workers_js: any): void;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Sync PoW batch computation for sub-workers. Each sub-worker calls this function
|
|
127
|
+
* with a portion of the total iteration budget.
|
|
128
|
+
*
|
|
129
|
+
* Returns a colon-separated string: `salt_hex:pow_u8:hash_hex`
|
|
130
|
+
*/
|
|
131
|
+
export function pow_compute_batch(iteration_limit: number, pow_min: number, data_hash_hex: string): string;
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Initialise logging and panic hook. Must be called manually before using the WASM module.
|
|
135
|
+
* Pass `verbose = true` for the main worker (logs confirmation), `false` for PoW sub-workers (silent).
|
|
136
|
+
*/
|
|
137
|
+
export function wasm_init(verbose: boolean): void;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/* @ts-self-types="./hashiverse_client_wasm.d.ts" */
|
|
2
|
+
import * as wasm from "./hashiverse_client_wasm_bg.wasm";
|
|
3
|
+
import { __wbg_set_wasm } from "./hashiverse_client_wasm_bg.js";
|
|
4
|
+
|
|
5
|
+
__wbg_set_wasm(wasm);
|
|
6
|
+
wasm.__wbindgen_start();
|
|
7
|
+
export {
|
|
8
|
+
HashiverseClientWasm, init_pow_workers, pow_compute_batch, wasm_init
|
|
9
|
+
} from "./hashiverse_client_wasm_bg.js";
|