@lat-murmeldjur/weeb_3 0.0.320001 → 0.0.321001
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 +93 -213
- package/package.json +11 -4
- package/service.js +851 -0
- package/snippets/weeb_3-03f860286800ffdb/static/hls_loader.js +6 -0
- package/weeb_3.d.ts +108 -11
- package/weeb_3.js +863 -319
- package/weeb_3_bg.wasm +0 -0
- package/weeb_3_bg.wasm.d.ts +30 -11
package/README.md
CHANGED
|
@@ -1,41 +1,61 @@
|
|
|
1
|
-
# Weeb-3 -
|
|
1
|
+
# Weeb-3 - Browser-side Swarm client library
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`weeb-3` is a browser-side Swarm client built in Rust and compiled to WebAssembly.
|
|
4
|
+
The main `weeb-3` project is the full released browser client, published at [lat-murmeldjur.github.io/weeb-3](https://lat-murmeldjur.github.io/weeb-3), where the client is used together with its own interface.
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
This npm package is the library edition of that same client. Projects can use the API directly or mount the bundled browser interface with `renderInterface(container)`.
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Project repository: [github.com/lat-murmeldjur/weeb-3](https://github.com/lat-murmeldjur/weeb-3)
|
|
8
9
|
|
|
9
|
-
|
|
10
|
+
Project site: [lat-murmeldjur.github.io/weeb-3](https://lat-murmeldjur.github.io/weeb-3)
|
|
10
11
|
|
|
11
|
-
|
|
12
|
+
## Installation
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
```shell
|
|
15
|
+
npm install @lat-murmeldjur/weeb_3
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## What this package contains
|
|
16
19
|
|
|
17
|
-
|
|
20
|
+
This package contains the browser-targeted WebAssembly build of the `weeb-3` client together with the JavaScript wrapper needed to initialize and use it from an application.
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
cargo run
|
|
21
|
-
```
|
|
22
|
+
The main exports are:
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
- `Weeb3No103` as the higher-level client interface
|
|
25
|
+
- `BootstrapNode` for defining bootstrap peers
|
|
26
|
+
- `Weeb3` for lower-level direct access to the underlying client
|
|
24
27
|
|
|
25
|
-
|
|
28
|
+
The higher-level `Weeb3No103` interface provides the main methods used by the embedding example:
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
- `start(options?)`
|
|
31
|
+
- `connect()`
|
|
32
|
+
- `networkState()`
|
|
33
|
+
- `switchMainnet()` / `switch_mainnet()`
|
|
34
|
+
- `switchTestnet()` / `switch_testnet()`
|
|
35
|
+
- `switchNetwork(mode)` / `switch_network(mode)`
|
|
36
|
+
- `connectProfile(mode)` / `connect_profile(mode)`
|
|
37
|
+
- `retrieve(address)`
|
|
38
|
+
- `upload(file, encryption, index_string, add_to_feed, feed_topic)`
|
|
39
|
+
- `uploadWithRedundancy(file, encryption, redundancy_level, index_string, add_to_feed, feed_topic)`
|
|
40
|
+
- `postUploadBytesWithRedundancy(bytes, mime, filename, encryption, redundancy_level, add_to_feed, feed_topic)`
|
|
41
|
+
- `openStreamFeed(owner, topic)`
|
|
42
|
+
- `playHlsStream(owner, topic, media_type, index?)`
|
|
43
|
+
- `attachHlsStream(media, owner, topic, options)`
|
|
44
|
+
- `detachHlsStream()`
|
|
45
|
+
- `configureStreamingRoutes(service_worker_url, route_base)`
|
|
46
|
+
- `renderInterface(container)`
|
|
47
|
+
- `resetStamp()`
|
|
48
|
+
- `postPushChunk(data, soc, chunk_address, stamp)`
|
|
28
49
|
|
|
29
|
-
|
|
50
|
+
Sequence-feed indexes use Bee's fixed-width eight-byte big-endian encoding.
|
|
30
51
|
|
|
31
|
-
|
|
52
|
+
## HLS streaming
|
|
32
53
|
|
|
33
|
-
- `
|
|
34
|
-
- `static/weeb_3.js`
|
|
35
|
-
- `static/weeb_3_bg.wasm`
|
|
36
|
-
- `static/weeb_3.d.ts`
|
|
54
|
+
HLS playback is an optional dapp integration, not a Bee/Swarm standard. `playHlsStream(...)` displays a stream in the bundled interface after `renderInterface(container)`. For an application-owned `<video>` or `<audio>` element, call `attachHlsStream(media, owner, topic, { start: "beginning" })`; use `"current-window"` for a rolling/live presentation. Call `detachHlsStream()` before removing or replacing that element. The Service Worker must be copied from the package to a same-origin URL whose scope contains the page, then configured with `configureStreamingRoutes(...)`. Canonical mainnet links use `/stream/{owner}/{topic}[/{index}]`; testnet inserts `/testnet` before `/stream`.
|
|
37
55
|
|
|
38
|
-
|
|
56
|
+
## Basic usage
|
|
57
|
+
|
|
58
|
+
Call `init()` once before creating a client instance so the WebAssembly module is loaded.
|
|
39
59
|
|
|
40
60
|
```js
|
|
41
61
|
import init, { Weeb3No103, BootstrapNode } from "@lat-murmeldjur/weeb_3";
|
|
@@ -44,224 +64,84 @@ await init();
|
|
|
44
64
|
|
|
45
65
|
const weeb3node = new Weeb3No103();
|
|
46
66
|
|
|
47
|
-
//
|
|
67
|
+
// Start with the built-in mainnet profile and browser-dialable bootnodes.
|
|
48
68
|
weeb3node.start();
|
|
49
69
|
console.log(await weeb3node.networkState());
|
|
50
70
|
|
|
51
|
-
// Switch explicitly between
|
|
71
|
+
// Switch explicitly between built-in profiles.
|
|
52
72
|
await weeb3node.switchTestnet();
|
|
53
73
|
await weeb3node.switchMainnet();
|
|
54
74
|
|
|
55
|
-
//
|
|
56
|
-
// "testnet", "sepolia",
|
|
75
|
+
// Or use the generic form. Accepted values include:
|
|
76
|
+
// "mainnet", "gnosis", "1", "testnet", "sepolia", and "10".
|
|
57
77
|
await weeb3node.switchNetwork("testnet");
|
|
58
78
|
await weeb3node.switchNetwork("mainnet");
|
|
59
79
|
|
|
60
|
-
//
|
|
80
|
+
// You can still start with explicit browser-dialable bootnodes and network id.
|
|
81
|
+
const BOOTSTRAP_NODES = [
|
|
82
|
+
new BootstrapNode("/ip4/example/tcp/443/wss/p2p/examplePeerId", true),
|
|
83
|
+
];
|
|
84
|
+
|
|
61
85
|
weeb3node.start({
|
|
62
86
|
networkId: "1",
|
|
63
|
-
bootstrapNodes:
|
|
64
|
-
new BootstrapNode("/ip4/example/tcp/443/wss/p2p/examplePeerId", true),
|
|
65
|
-
],
|
|
87
|
+
bootstrapNodes: BOOTSTRAP_NODES,
|
|
66
88
|
});
|
|
67
89
|
|
|
68
90
|
// Or start with the built-in testnet profile.
|
|
69
91
|
weeb3node.start({ testnet: true });
|
|
70
|
-
|
|
71
|
-
const ready = await weeb3node.ready(1, 20_000);
|
|
72
92
|
```
|
|
73
93
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
The publishing workflow defaults to the GitHub repository owner scope. If a different npm scope is needed, set the `NPM_SCOPE` repository variable in GitHub Actions before pushing to `main`.
|
|
77
|
-
|
|
78
|
-
## [Notes]
|
|
79
|
-
|
|
80
|
-
### Compatibility - Supported Browsers
|
|
81
|
-
|
|
82
|
-
- Chrome (on Windows 11)
|
|
83
|
-
- Chrome (Android)
|
|
84
|
-
- Brave (on Windows 11)
|
|
85
|
-
- Edge
|
|
86
|
-
- Firefox (on Windows 11)
|
|
87
|
-
- Firefox (on Android)
|
|
88
|
-
|
|
89
|
-
Testing and improving support for other browsers is planned.
|
|
90
|
-
|
|
91
|
-
### How it works (architectural overview)
|
|
92
|
-
|
|
93
|
-
The weeb-3 client consists of several logical components:
|
|
94
|
-
|
|
95
|
-
- The browser interface, implemented primarily by `static/index.html`, `src/interface.rs`, `src/interface_conventions.rs`, and `src/interface_runtime_conventions.rs`.
|
|
96
|
-
- The libp2p / Swarm node, whose main entry point is `src/lib.rs`.
|
|
97
|
-
- The Swarm protocol handlers and data pipelines for handshake, peer discovery, pricing, accounting, retrieval, pushsync, pseudosettle, swap, manifests, feeds, streaming, and uploads.
|
|
98
|
-
- The Service Worker in `static/service.js`, which provides deterministic browser routes for Swarm content and forwards canonical requests into the Rust runtime.
|
|
99
|
-
- The npm / library facade in `src/library.rs`, which wraps the same runtime for embedding in other browser applications.
|
|
100
|
-
- Browser persistence, secure local state, network profiles, and on-chain integration implemented by `src/persistence.rs`, `src/secure_vault.rs`, `src/network_profile.rs`, and `src/on_chain.rs`.
|
|
101
|
-
|
|
102
|
-
Below is a piece-by-piece overview of the current component logic.
|
|
103
|
-
|
|
104
|
-
#### The interface
|
|
105
|
-
|
|
106
|
-
The default browser application is instantiated by `static/index.html`, which loads the generated Wasm module and calls `interweeb` from `src/interface.rs`.
|
|
107
|
-
|
|
108
|
-
`interweeb` creates a `Weeb3` node, clears legacy hash-based paths through `src/nav.rs`, and delegates the rest of the UI setup to `mount_interface`. `mount_interface` can either start the runtime itself or attach the interface to a runtime that has already been started by the package wrapper.
|
|
109
|
-
|
|
110
|
-
The interface layer currently has the following roles:
|
|
111
|
-
|
|
112
|
-
- Starting the libp2p / Swarm runtime in an async browser task when requested.
|
|
113
|
-
- Installing UI conventions and rendering the interface shell.
|
|
114
|
-
- Preloading the secure vault module before sensitive upload, feed, stamp, or cheque operations are requested.
|
|
115
|
-
- Registering the Service Worker and routing Service Worker messages back to the Rust runtime.
|
|
116
|
-
- Reading the configured network profile, network id, and browser-dialable bootnodes, then passing bootnode connection requests to the `Weeb3` node.
|
|
117
|
-
- Wiring the navigation input so BZZ references, raw byte routes, and chunk routes can be opened from the UI.
|
|
118
|
-
- Wiring upload controls for single files, tar-based collections, optional encryption, index document selection, optional feed publishing, and postage-stamp reuse or reset.
|
|
119
|
-
- Wiring on-chain controls for upload prerequisites, postage batch acquisition, chequebook deployment, cheque signer persistence, and chequebook deposits through the browser wallet.
|
|
120
|
-
- Providing runtime controls such as pausing and resuming transfers.
|
|
121
|
-
- Rendering retrieved resources, website iframes, streaming media, raw downloads, logs, connection status, network state, and progress rows.
|
|
122
|
-
|
|
123
|
-
The current interface no longer assumes that requests are handled by a shared worker. The tab owns the `Weeb3` runtime, while the Service Worker acts as a request forwarder between browser fetch events and the active controlled client.
|
|
124
|
-
|
|
125
|
-
#### The weeb process
|
|
126
|
-
|
|
127
|
-
The main Swarm client is implemented in `src/lib.rs`. It is compiled only for the `wasm32` target and is designed to run in the browser event loop.
|
|
128
|
-
|
|
129
|
-
At a high level, `src/lib.rs` does the following:
|
|
130
|
-
|
|
131
|
-
- Imports the generated protobuf protocol modules from `etiquette_0` through `etiquette_8`.
|
|
132
|
-
- Defines the Swarm protocol names used by the client, including handshake, pricing, hive peer discovery, pseudosettle, retrieval, pushsync, and swap.
|
|
133
|
-
- Defines network mode helpers for testnet and mainnet. The built-in profiles currently map Swarm network id `10` to the Sepolia-based testnet profile and Swarm network id `1` to the Gnosis / xDAI mainnet profile.
|
|
134
|
-
- Defines the `Weeb3` client, which owns the libp2p `Swarm`, runtime channels, connection state, network id, progress store, transfer pause flag, and peer registry.
|
|
135
|
-
- Defines `Wings`, the in-memory peer and accounting registry used to track connected peers, overlay addresses, bootnodes, accounting peers, settlement state, known underlays, and self-observed ephemeral addresses.
|
|
136
|
-
- Exposes the runtime functions used by the interface and library wrapper.
|
|
137
|
-
|
|
138
|
-
The most important public `Weeb3` operations are:
|
|
139
|
-
|
|
140
|
-
1. Changing the network id and bootnode address.
|
|
141
|
-
2. Disconnecting and clearing peer state when the active network profile changes.
|
|
142
|
-
3. Uploading a `File` or tar collection, optionally encrypted, optionally with an index document, and optionally as a feed update.
|
|
143
|
-
4. Pushing a raw chunk through pushsync.
|
|
144
|
-
5. Resolving and acquiring BZZ resources.
|
|
145
|
-
6. Retrieving raw bytes or individual chunks.
|
|
146
|
-
7. Reading feed envelopes and feed content.
|
|
147
|
-
8. Resetting the active postage stamp state.
|
|
148
|
-
9. Reporting logs, connection counts, active network id, and progress snapshots.
|
|
149
|
-
10. Pausing or resuming transfers.
|
|
150
|
-
11. Running the asynchronous protocol loop.
|
|
94
|
+
## Example corresponding to `example.html`
|
|
151
95
|
|
|
152
|
-
|
|
96
|
+
This is a compact npm-import form of the same usage pattern shown in the project's `example.html`:
|
|
153
97
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
- Uses authenticated Noise and Yamux multiplexing for libp2p connections.
|
|
157
|
-
- Enables the stream behavior used by the Swarm protocol handlers.
|
|
158
|
-
- Creates the peer registry, connection registry, progress store, transfer control flag, and runtime channels.
|
|
159
|
-
- Initializes the default Swarm network id to `10`.
|
|
160
|
-
|
|
161
|
-
The `run` function is the long-running runtime loop. It builds a channel-based asynchronous task graph for the browser runtime and coordinates the major subsystems:
|
|
162
|
-
|
|
163
|
-
- Peer discovery, bootnode dialing, connection retry, and connection cleanup.
|
|
164
|
-
- Incoming and outgoing libp2p stream handling.
|
|
165
|
-
- Handshake, identify, pricing, and peer promotion.
|
|
166
|
-
- Accounting, pseudosettle refreshes, cheque sending, and swap-related settlement messages.
|
|
167
|
-
- High-level BZZ resolution, range preparation, and BZZ range retrieval.
|
|
168
|
-
- Data-level retrieval and upload requests.
|
|
169
|
-
- Chunk-level retrieval and pushsync with bounded concurrency.
|
|
170
|
-
- Upload progress reporting.
|
|
171
|
-
- Transfer pause and cancellation checks.
|
|
172
|
-
- Log forwarding to the interface.
|
|
173
|
-
|
|
174
|
-
The runtime is heavily asynchronous, but it is still running inside the browser's Wasm execution environment. It uses `spawn_local`, async channels, short queue polling, and protocol-specific retry delays rather than OS threads.
|
|
175
|
-
|
|
176
|
-
#### The Swarm Client Subcomponents
|
|
177
|
-
|
|
178
|
-
The main runtime depends on several focused modules:
|
|
179
|
-
|
|
180
|
-
- `src/handlers.rs` implements the libp2p stream handlers for Swarm protocol traffic such as handshake, hive, pricing, pseudosettle, retrieval, pushsync, and swap.
|
|
181
|
-
- `src/accounting.rs` implements local accounting, price calculations, reservations, peer credit / debit tracking, refresh triggers, and settlement coordination.
|
|
182
|
-
- `src/addresses.rs` normalizes and validates browser-dialable underlays, including WebSocket and secure WebSocket multiaddresses.
|
|
183
|
-
- `src/retrieval.rs` implements chunk retrieval, peer selection, validation, decryption, data joining, and request coordination.
|
|
184
|
-
- `src/upload.rs` implements file splitting, optional encryption, chunk creation, postage stamp use, pushsync, manifest creation, SOC creation, and feed upload support.
|
|
185
|
-
- `src/manifest.rs` interprets Swarm manifests.
|
|
186
|
-
- `src/manifest_upload.rs` creates manifests for uploads and collections.
|
|
187
|
-
- `src/bzz_stream.rs` parses canonical BZZ resources, resolves manifests and paths, prepares range trees, and retrieves byte ranges for BZZ resources.
|
|
188
|
-
- `src/streaming_player.rs` integrates range retrieval with browser fetch requests and streaming media playback.
|
|
189
|
-
- `src/nav.rs` normalizes browser paths and extracts BZZ route references from the location bar.
|
|
190
|
-
- `src/ens.rs` resolves ENS content hashes to Swarm references.
|
|
191
|
-
- `src/events.rs` stores progress rows and progress revisions for the UI and package wrapper.
|
|
192
|
-
- `src/persistence.rs` stores browser-side data in IndexedDB.
|
|
193
|
-
- `src/secure_vault.rs` manages sensitive local state such as upload identities, postage-stamp state, feed ownership, and cheque signer material.
|
|
194
|
-
- `src/network_profile.rs` defines the built-in testnet and mainnet profiles, wallet chain ids, token symbols, and bootnodes.
|
|
195
|
-
- `src/on_chain.rs` implements browser wallet and contract interactions for postage batches, price oracle access, chequebook operations, swap token operations, and related state.
|
|
196
|
-
- Batch state held by `weeb-3-secure` is requested with the active Swarm network id, so testnet and mainnet use separate batch owners, batch ids, bucket counters, and temp-auth authorization.
|
|
197
|
-
- `src/interface_conventions.rs` and `src/interface_runtime_conventions.rs` contain DOM helpers, UI rendering, route parsing, network controls, and Service Worker runtime integration.
|
|
198
|
-
- `src/library.rs` exposes the Wasm runtime to JavaScript as `Weeb3No103` and `BootstrapNode`.
|
|
199
|
-
- `src/conventions.rs` and `src/interface_conventions.rs` collect common encoding, decoding, hashing, resource, UI, and protocol helper logic.
|
|
200
|
-
|
|
201
|
-
The ABI files in `src/*.json` are consumed by the on-chain module and cover contracts such as the postage stamp contract, price oracle, factory, sBZZ token, and simple swap contract.
|
|
202
|
-
|
|
203
|
-
#### Persistence and identity
|
|
204
|
-
|
|
205
|
-
The browser runtime maintains a mix of ephemeral and persistent state.
|
|
206
|
-
|
|
207
|
-
The libp2p identity used by a `Weeb3` runtime is generated when the node is created. That makes the live peer identity tab-local and runtime-local. Peer maps, connection attempts, active streams, and accounting state are kept in memory by the `Weeb3` and `Wings` structures.
|
|
208
|
-
|
|
209
|
-
Browser persistence is used for state that should survive page reloads or browser sessions, such as retrieved chunks, chequebook data, signer material, postage-stamp state, and other runtime settings. Sensitive state is routed through the secure vault module instead of being handled directly by ordinary UI code.
|
|
210
|
-
|
|
211
|
-
Wallet access is requested only for on-chain operations. The browser wallet is used for chain switching, account access, postage purchase flows, chequebook deployment, and deposits. Upload/feed identities and cheque signer keys are managed separately from the wallet account so that Swarm protocol operations do not require signing every action with the injected wallet.
|
|
212
|
-
|
|
213
|
-
When the network profile changes, the runtime clears the current peer state and increments its connection generation so stale dialing, handshake, and connection events do not leak into the new network session.
|
|
214
|
-
|
|
215
|
-
### The Service Worker
|
|
216
|
-
|
|
217
|
-
The Service Worker in `static/service.js` sits between the browser fetch layer and the active weeb-3 page. Its role has expanded beyond the original static cache approach.
|
|
218
|
-
|
|
219
|
-
Single files can still be displayed without a Service Worker by creating `Blob` object URLs with the correct MIME type. This is enough for images, documents, and other standalone files. It is not enough for full websites, because browser-generated object URLs contain random identifiers and therefore cannot reliably satisfy relative paths for scripts, stylesheets, images, and other website assets.
|
|
98
|
+
```js
|
|
99
|
+
import init, { Weeb3No103, BootstrapNode } from "@lat-murmeldjur/weeb_3";
|
|
220
100
|
|
|
221
|
-
|
|
101
|
+
await init();
|
|
222
102
|
|
|
223
|
-
|
|
224
|
-
- Testnet can be selected from routes with `/testnet`, for example `/weeb-3/testnet` to boot the interface in testnet mode or `/weeb-3/testnet/bzz/<reference>/<path>` for a testnet BZZ link.
|
|
225
|
-
- Raw byte and chunk routes below `/bytes/`, `/chunks/`, and `/chunk/` are forwarded to the Rust runtime.
|
|
226
|
-
- `POST` requests to the scoped `/bzz` endpoint are forwarded as upload requests, including upload headers such as encryption, collection, and index-document hints.
|
|
227
|
-
- Fetch requests are forwarded to the active controlled client through `postMessage` and `MessageChannel`.
|
|
228
|
-
- BZZ resources can be answered as full responses, byte-range responses, or streaming responses depending on MIME type, request headers, and resource size.
|
|
229
|
-
- The app shell is cached with a network-first strategy so that the interface can continue to load when a cached shell is available.
|
|
103
|
+
const weeb3node = new Weeb3No103();
|
|
230
104
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
The Service Worker is security-sensitive. Browsers only enable it for secure origins, and a trusted certificate is required for normal deployment. Because a Service Worker can intercept requests for its scope, production deployments should treat Service Worker replacement, injected pages, and malicious Swarm-hosted websites as important security boundaries. The current architecture reduces some risk by rendering Swarm websites in iframes and by keeping sensitive state behind the secure vault layer, but security hardening remains an active development area.
|
|
105
|
+
await weeb3node.switchMainnet();
|
|
234
106
|
|
|
235
|
-
|
|
107
|
+
const entries = await weeb3node.retrieve(
|
|
108
|
+
"695fceb3a8c212cd123e2e40d86ec08b52fe4fe6ca46687ce9ea69b8f05471f6aa25b5d4d41bf78b1db3479c048fd5fd8137ba844604821b71786196306b68e7"
|
|
109
|
+
);
|
|
110
|
+
```
|
|
236
111
|
|
|
237
|
-
|
|
112
|
+
## Erasure-coding selector
|
|
238
113
|
|
|
239
|
-
|
|
240
|
-
- `async-std` and `async-lock` for async runtime primitives that work in the browser Wasm target.
|
|
241
|
-
- `wasm-bindgen`, `wasm-bindgen-futures`, `js-sys`, and `web-sys` for JavaScript, DOM, Service Worker, browser API, and Promise integration.
|
|
242
|
-
- `web3`, `alloy`, `alloy-signer-local`, and `ethers` for wallet, signing, ABI, and on-chain contract interaction.
|
|
243
|
-
- `indexed_db_futures` for browser IndexedDB persistence.
|
|
244
|
-
- `tar` and `mime_guess` for collection upload handling and MIME inference.
|
|
245
|
-
- `getrandom` with the `wasm_js` backend for browser-compatible randomness.
|
|
246
|
-
- `base64`, `hex`, `byteorder`, and numeric / cryptographic helper crates for protocol encoding and Swarm data structures.
|
|
247
|
-
- `tokio` and `tower-http` for the local development server used outside the Wasm target.
|
|
114
|
+
Legacy upload methods use Bee's Medium level. Explicit upload levels are `0` None, `1` Medium, `2` Strong, `3` Insane, and `4` Paranoid. The generated TypeScript declaration exposes this as `UploadRedundancyLevel = 0 | 1 | 2 | 3 | 4`.
|
|
248
115
|
|
|
249
|
-
|
|
116
|
+
`renderInterface(container)` includes a Medium-default erasure-coding dropdown. A custom interface can populate its own dropdown from the same canonical metadata:
|
|
250
117
|
|
|
251
|
-
|
|
118
|
+
```js
|
|
119
|
+
import init, {
|
|
120
|
+
Weeb3No103,
|
|
121
|
+
defaultUploadRedundancyLevel,
|
|
122
|
+
uploadRedundancyOptions,
|
|
123
|
+
} from "@lat-murmeldjur/weeb_3";
|
|
252
124
|
|
|
253
|
-
|
|
125
|
+
await init();
|
|
126
|
+
const node = new Weeb3No103();
|
|
127
|
+
const choices = uploadRedundancyOptions();
|
|
128
|
+
const level = defaultUploadRedundancyLevel();
|
|
129
|
+
|
|
130
|
+
const result = await node.uploadWithRedundancy(
|
|
131
|
+
file,
|
|
132
|
+
true,
|
|
133
|
+
level,
|
|
134
|
+
"",
|
|
135
|
+
false,
|
|
136
|
+
"",
|
|
137
|
+
);
|
|
138
|
+
```
|
|
254
139
|
|
|
255
|
-
|
|
140
|
+
Retrieval reads the level encoded in the Swarm tree and uses parity when data shards are unavailable.
|
|
256
141
|
|
|
257
|
-
##
|
|
142
|
+
## Notes
|
|
258
143
|
|
|
259
|
-
-
|
|
260
|
-
-
|
|
261
|
-
-
|
|
262
|
-
-
|
|
263
|
-
- More complete and stable JavaScript package documentation and examples for the `Weeb3No103` wrapper.
|
|
264
|
-
- Continued improvements to BZZ path handling, streaming media retrieval, byte-range serving, and manifest fork lookup performance.
|
|
265
|
-
- Worker-based partitioning or multithreading where browser support and the project architecture make it practical.
|
|
266
|
-
- Additional Swarm feature coverage, including ACT and other protocol features not yet fully implemented.
|
|
267
|
-
- Continued wallet, postage, chequebook, and swap UX refinements.
|
|
144
|
+
- This package is meant for browser applications, not a plain Node.js runtime.
|
|
145
|
+
- Use one active `Weeb3No103` node and HLS session per loaded Wasm module.
|
|
146
|
+
- The package does not publish the standalone site HTML, but `renderInterface(container)` embeds the same interface shell—including its erasure-coding selector—from the Wasm bundle.
|
|
147
|
+
- The full released browser client remains available in the main project repository and on the project site.
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@lat-murmeldjur/weeb_3",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "A Swarm client for browsers",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.321001",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"repository": {
|
|
8
8
|
"type": "git",
|
|
@@ -20,14 +20,15 @@
|
|
|
20
20
|
"registry": "https://registry.npmjs.org/"
|
|
21
21
|
},
|
|
22
22
|
"files": [
|
|
23
|
-
"snippets
|
|
23
|
+
"snippets",
|
|
24
24
|
"weeb_3.d.ts",
|
|
25
25
|
"weeb_3.js",
|
|
26
26
|
"weeb_3_bg.wasm",
|
|
27
|
-
"weeb_3_bg.wasm.d.ts"
|
|
27
|
+
"weeb_3_bg.wasm.d.ts",
|
|
28
|
+
"service.js"
|
|
28
29
|
],
|
|
29
30
|
"sideEffects": [
|
|
30
|
-
"./snippets
|
|
31
|
+
"./snippets/**/*"
|
|
31
32
|
],
|
|
32
33
|
"keywords": [
|
|
33
34
|
"bee",
|
|
@@ -41,6 +42,12 @@
|
|
|
41
42
|
"types": "./weeb_3.d.ts",
|
|
42
43
|
"import": "./weeb_3.js",
|
|
43
44
|
"default": "./weeb_3.js"
|
|
45
|
+
},
|
|
46
|
+
"./service.js": {
|
|
47
|
+
"default": "./service.js"
|
|
44
48
|
}
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"hls.js": "^1.6.2"
|
|
45
52
|
}
|
|
46
53
|
}
|