@upcoming/bee-js 0.14.0 → 0.15.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/cjs/bee.js +1 -1
- package/dist/cjs/modules/gsoc.js +4 -0
- package/dist/cjs/modules/pss.js +4 -0
- package/dist/cjs/utils/expose.js +2 -1
- package/dist/cjs/utils/stamps.js +17 -9
- package/dist/index.browser.min.js +1 -1
- package/dist/index.browser.min.js.map +1 -1
- package/dist/mjs/bee.js +1 -1
- package/dist/mjs/modules/gsoc.js +4 -0
- package/dist/mjs/modules/pss.js +4 -0
- package/dist/mjs/utils/expose.js +1 -1
- package/dist/mjs/utils/stamps.js +8 -1
- package/dist/types/utils/expose.d.ts +1 -1
- package/dist/types/utils/stamps.d.ts +1 -0
- package/package.json +2 -2
package/dist/mjs/bee.js
CHANGED
|
@@ -686,7 +686,7 @@ export class Bee {
|
|
|
686
686
|
}
|
|
687
687
|
});
|
|
688
688
|
}
|
|
689
|
-
gsocMine(targetOverlay, identifier, proximity =
|
|
689
|
+
gsocMine(targetOverlay, identifier, proximity = 12) {
|
|
690
690
|
targetOverlay = new PeerAddress(targetOverlay);
|
|
691
691
|
identifier = new Identifier(identifier);
|
|
692
692
|
const start = 0xb33n;
|
package/dist/mjs/modules/gsoc.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { System } from 'cafe-utility';
|
|
1
2
|
import WebSocket from 'isomorphic-ws';
|
|
2
3
|
import { uploadSingleOwnerChunk } from "../chunk/soc.js";
|
|
3
4
|
const endpoint = 'gsoc';
|
|
@@ -6,6 +7,9 @@ export async function send(requestOptions, soc, stamp, options) {
|
|
|
6
7
|
}
|
|
7
8
|
export function subscribe(url, reference, headers) {
|
|
8
9
|
const wsUrl = url.replace(/^http/i, 'ws');
|
|
10
|
+
if (System.whereAmI() === 'browser') {
|
|
11
|
+
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`);
|
|
12
|
+
}
|
|
9
13
|
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`, {
|
|
10
14
|
headers
|
|
11
15
|
});
|
package/dist/mjs/modules/pss.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { System } from 'cafe-utility';
|
|
1
2
|
import WebSocket from 'isomorphic-ws';
|
|
2
3
|
import { prepareRequestHeaders } from "../utils/headers.js";
|
|
3
4
|
import { http } from "../utils/http.js";
|
|
@@ -33,6 +34,9 @@ export async function send(requestOptions, topic, target, data, postageBatchId,
|
|
|
33
34
|
*/
|
|
34
35
|
export function subscribe(url, topic, headers) {
|
|
35
36
|
const wsUrl = url.replace(/^http/i, 'ws');
|
|
37
|
+
if (System.whereAmI() === 'browser') {
|
|
38
|
+
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic.toHex()}`);
|
|
39
|
+
}
|
|
36
40
|
return new WebSocket(`${wsUrl}/${endpoint}/subscribe/${topic.toHex()}`, {
|
|
37
41
|
headers
|
|
38
42
|
});
|
package/dist/mjs/utils/expose.js
CHANGED
|
@@ -2,4 +2,4 @@ export { getCollectionSize, makeCollectionFromFileList } from "./collection.js";
|
|
|
2
2
|
export { getFolderSize } from "./collection.node.js";
|
|
3
3
|
export { makeMaxTarget } from "./pss.js";
|
|
4
4
|
export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from "./redundancy.js";
|
|
5
|
-
export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampTheoreticalBytes, getStampUsage } from "./stamps.js";
|
|
5
|
+
export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage } from "./stamps.js";
|
package/dist/mjs/utils/stamps.js
CHANGED
|
@@ -41,7 +41,7 @@ const utilisationRateMap = {
|
|
|
41
41
|
33: 0.9842,
|
|
42
42
|
34: 0.9889
|
|
43
43
|
};
|
|
44
|
-
const effectiveSizeBreakpoints = [[22, 4.93], [23, 17.03], [24, 44.21], [25, 102.78], [26, 225.
|
|
44
|
+
const effectiveSizeBreakpoints = [[22, 4.93], [23, 17.03], [24, 44.21], [25, 102.78], [26, 225.87], [27, 480.44], [28, 1001.44], [29, 2060.27], [30, 4201.9], [31, 8519.02], [32, 17199.89], [33, 34628.46]];
|
|
45
45
|
/**
|
|
46
46
|
* Utility function that calculates the effective size of a postage batch based on its depth.
|
|
47
47
|
*
|
|
@@ -57,6 +57,13 @@ export function getStampEffectiveBytes(depth) {
|
|
|
57
57
|
const utilRate = utilisationRateMap[depth] ?? 0.99;
|
|
58
58
|
return Math.ceil(getStampTheoreticalBytes(depth) * utilRate);
|
|
59
59
|
}
|
|
60
|
+
export function getStampEffectiveBytesBreakpoints() {
|
|
61
|
+
const map = new Map();
|
|
62
|
+
for (let i = 22; i < 35; i++) {
|
|
63
|
+
map.set(i, getStampEffectiveBytes(i));
|
|
64
|
+
}
|
|
65
|
+
return map;
|
|
66
|
+
}
|
|
60
67
|
/**
|
|
61
68
|
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
62
69
|
*/
|
|
@@ -2,4 +2,4 @@ export { getCollectionSize, makeCollectionFromFileList } from './collection';
|
|
|
2
2
|
export { getFolderSize } from './collection.node';
|
|
3
3
|
export { makeMaxTarget } from './pss';
|
|
4
4
|
export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy';
|
|
5
|
-
export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampTheoreticalBytes, getStampUsage, } from './stamps';
|
|
5
|
+
export { getAmountForDuration, getDepthForSize, getStampCost, getStampDuration, getStampEffectiveBytes, getStampEffectiveBytesBreakpoints, getStampTheoreticalBytes, getStampUsage, } from './stamps';
|
|
@@ -27,6 +27,7 @@ export declare function getStampTheoreticalBytes(depth: number): number;
|
|
|
27
27
|
* @returns {number} The effective size of the postage batch in bytes.
|
|
28
28
|
*/
|
|
29
29
|
export declare function getStampEffectiveBytes(depth: number): number;
|
|
30
|
+
export declare function getStampEffectiveBytesBreakpoints(): Map<number, number>;
|
|
30
31
|
/**
|
|
31
32
|
* Utility function that calculates the cost of a postage batch based on its depth and amount.
|
|
32
33
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@upcoming/bee-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.15.1",
|
|
4
4
|
"description": "Javascript client for Bee",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bee",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"axios": "^0.28.1",
|
|
66
|
-
"cafe-utility": "^27.
|
|
66
|
+
"cafe-utility": "^27.13.0",
|
|
67
67
|
"isomorphic-ws": "^4.0.1",
|
|
68
68
|
"semver": "^7.3.5",
|
|
69
69
|
"ws": "^8.7.0"
|