@net-protocol/storage 0.1.12 → 0.1.13

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.
Files changed (2) hide show
  1. package/README.md +19 -24
  2. package/package.json +3 -3
package/README.md CHANGED
@@ -32,8 +32,8 @@ Net Storage supports three storage patterns for different file sizes:
32
32
 
33
33
  ### XML Storage
34
34
 
35
- **Best for**: Large files (> 20KB) or files containing XML references
36
- **How it works**: Splits large files into 80KB pieces, stores each using ChunkedStorage (compressed and chunked into 20KB pieces), maintains references as XML metadata
35
+ **Best for**: Large files (> 20KB) or files containing XML references
36
+ **How it works**: Splits large files into 80KB pieces (configurable via `chunkSize`), stores each using ChunkedStorage (compressed and chunked into 20KB pieces), maintains references as XML metadata
37
37
  **Use cases**: Videos, large images, datasets, any large file
38
38
 
39
39
  ## What can you do with this package?
@@ -133,38 +133,24 @@ function XmlComponent() {
133
133
  return <div>{data}</div>;
134
134
  }
135
135
 
136
- // XML storage with format options
137
- function XmlWithFormats() {
138
- // Return as tuple format with hex output
139
- const { data: tupleData } = useXmlStorage({
136
+ // XML storage with options
137
+ function XmlWithOptions() {
138
+ // With hex output (default)
139
+ const { data: hexData, isXml } = useXmlStorage({
140
140
  chainId: 8453,
141
141
  key: "my-xml-key",
142
142
  operatorAddress: "0x...",
143
- returnFormat: "tuple", // Returns [text, data] tuple
144
143
  outputFormat: "hex", // Data is hex string (default)
145
144
  useRouter: true, // Use StorageRouter for automatic detection
146
145
  });
147
146
 
148
- // Return as tuple format with string output
149
- const { data: tupleStringData } = useXmlStorage({
147
+ // With string output
148
+ const { data: stringData } = useXmlStorage({
150
149
  chainId: 8453,
151
150
  key: "my-xml-key",
152
151
  operatorAddress: "0x...",
153
- returnFormat: "tuple",
154
152
  outputFormat: "string", // Data is plain string
155
153
  });
156
-
157
- // Return as object format (default)
158
- const {
159
- data: objectData,
160
- filename,
161
- isXml,
162
- } = useXmlStorage({
163
- chainId: 8453,
164
- key: "my-xml-key",
165
- operatorAddress: "0x...",
166
- returnFormat: "object", // Returns { data, filename, isLoading, error, isXml }
167
- });
168
154
  }
169
155
 
170
156
  // Storage from router (handles chunked storage)
@@ -228,6 +214,7 @@ import {
228
214
  fileToDataUri,
229
215
  detectFileTypeFromBase64,
230
216
  base64ToDataUri,
217
+ OPTIMAL_CHUNK_SIZE,
231
218
  } from "@net-protocol/storage";
232
219
 
233
220
  // Generate storage key bytes
@@ -242,8 +229,11 @@ const assembled = assembleChunks(chunks);
242
229
  // Parse XML references
243
230
  const references = parseNetReferences('<net k="hash" v="0.0.1" />');
244
231
 
245
- // Process data for XML storage
246
- const result = processDataForStorage(data, operatorAddress);
232
+ // Process data for XML storage (default 80KB chunk size)
233
+ const result = processDataForStorage(data, operatorAddress, storageKey);
234
+
235
+ // Process with custom chunk size (40KB)
236
+ const result2 = processDataForStorage(data, operatorAddress, storageKey, 40000);
247
237
  ```
248
238
 
249
239
  ### File Utilities
@@ -297,6 +287,11 @@ const dataUri = base64ToDataUri(base64Data);
297
287
  - `getForOperatorAndKey(params)` - Get storage by operator and key
298
288
  - `readStorageData(params)` - Read with XML resolution
299
289
  - `readChunkedStorage(params)` - Read chunked storage with decompression
290
+ - `prepareXmlStorage(params)` - Prepare XML storage transactions (supports optional `chunkSize`)
291
+
292
+ ### Constants
293
+
294
+ - `OPTIMAL_CHUNK_SIZE` - Default chunk size for XML storage (80000 bytes)
300
295
 
301
296
  ## Storage Types
302
297
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@net-protocol/storage",
3
- "version": "0.1.12",
3
+ "version": "0.1.13",
4
4
  "description": "Net Storage SDK for key-value storage on the Net protocol",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -42,10 +42,10 @@
42
42
  "test:ui": "vitest --ui"
43
43
  },
44
44
  "dependencies": {
45
- "@net-protocol/core": "^0.1.8",
45
+ "@net-protocol/core": "^0.1.9",
46
46
  "pako": "^2.1.0",
47
47
  "use-async-effect": "^2.2.7",
48
- "viem": "^2.31.4"
48
+ "viem": "^2.45.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@tanstack/react-query": "^5.0.0",