@lat-murmeldjur/weeb_3 0.0.337001 → 0.0.338001

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/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.337001",
5
+ "version": "0.0.338001",
6
6
  "license": "MIT",
7
7
  "repository": {
8
8
  "type": "git",
package/service.js CHANGED
@@ -9,15 +9,17 @@ const RAW_ROUTE_KINDS = [
9
9
  ["chunks", "chunk"]
10
10
  ];
11
11
  const FETCH_TIMEOUT_MS = 240000;
12
- const SERVICE_WORKER_MARKER = "forwarder-default24";
12
+ const SERVICE_WORKER_MARKER = "forwarder-default28";
13
13
  const SERVICE_WORKER_PROTOCOL = 10;
14
14
  const MIB_BYTES = 1024 * 1024;
15
15
  const STREAM_STORAGE_WINDOW_BYTES = MIB_BYTES / 2;
16
16
  const STREAM_LOOKAHEAD_CHUNKS = 8;
17
- const HLS_STREAM_WINDOW_BYTES = MIB_BYTES / 2;
18
- const HLS_STREAM_LOOKAHEAD_CHUNKS = 8;
19
- const HLS_LIVE_STREAM_WINDOW_BYTES = 64 * 1024;
20
- const HLS_LIVE_STREAM_LOOKAHEAD_CHUNKS = 32;
17
+ const HLS_STREAM_WINDOW_BYTES = MIB_BYTES;
18
+ const HLS_STREAM_INITIAL_LOOKAHEAD_CHUNKS = 2;
19
+ const HLS_STREAM_LOOKAHEAD_CHUNKS = 5;
20
+ const HLS_LIVE_STREAM_WINDOW_BYTES = MIB_BYTES;
21
+ const HLS_LIVE_STREAM_LOOKAHEAD_CHUNKS = 5;
22
+ const RANGE_REQUEST_FLIGHTS = new Map();
21
23
  const CLIENT_RUNTIME_PROBES = new Map();
22
24
  const CLIENT_RUNTIME_PROBE_TIMEOUT_MS = 1_500;
23
25
 
@@ -556,7 +558,12 @@ function responseHeaders(headerRows) {
556
558
  }
557
559
 
558
560
  function requestRustRange(clients, url, start, end, networkId) {
559
- return messageFirstClient(clients, {
561
+ const key = `${clients[0]?.id || ""}|${networkId}|${url}|${start}|${end}`;
562
+ const existing = RANGE_REQUEST_FLIGHTS.get(key);
563
+ if (existing) {
564
+ return existing;
565
+ }
566
+ const request = messageFirstClient(clients, {
560
567
  type: "WEEB3_FETCH_REQUEST",
561
568
  url,
562
569
  method: "GET",
@@ -579,9 +586,24 @@ function requestRustRange(clients, url, start, end, networkId) {
579
586
 
580
587
  return { ok: true, body };
581
588
  });
589
+ RANGE_REQUEST_FLIGHTS.set(key, request);
590
+ request.finally(() => {
591
+ if (RANGE_REQUEST_FLIGHTS.get(key) === request) {
592
+ RANGE_REQUEST_FLIGHTS.delete(key);
593
+ }
594
+ }).catch(() => {});
595
+ return request;
582
596
  }
583
597
 
584
- function createRustRangeStream(clients, url, size, networkId, windowBytes, lookahead) {
598
+ function createRustRangeStream(
599
+ clients,
600
+ url,
601
+ size,
602
+ networkId,
603
+ windowBytes,
604
+ initialLookahead,
605
+ lookahead
606
+ ) {
585
607
  let position = 0;
586
608
  let schedulePosition = 0;
587
609
  let admissionOpen = true;
@@ -610,7 +632,8 @@ function createRustRangeStream(clients, url, size, networkId, windowBytes, looka
610
632
  };
611
633
 
612
634
  const scheduleMore = () => {
613
- while (admissionOpen && schedulePosition < size && scheduled.size < lookahead) {
635
+ const limit = position < initialLookahead * windowBytes ? initialLookahead : lookahead;
636
+ while (admissionOpen && schedulePosition < size && scheduled.size < limit) {
614
637
  if (!admitRange()) {
615
638
  break;
616
639
  }
@@ -726,18 +749,23 @@ async function forwardRequestToRust(request, event) {
726
749
  return new Response("weeb-3 stream response has an invalid length", { status: 502 });
727
750
  }
728
751
  const liveHlsResource = hlsResource && url.searchParams.get("start") === "live";
752
+ const startupHlsResource = hlsResource && url.searchParams.get("startup") === "1";
729
753
  const windowBytes = liveHlsResource
730
754
  ? HLS_LIVE_STREAM_WINDOW_BYTES
731
755
  : hlsResource ? HLS_STREAM_WINDOW_BYTES : STREAM_STORAGE_WINDOW_BYTES;
732
756
  const lookahead = liveHlsResource
733
757
  ? HLS_LIVE_STREAM_LOOKAHEAD_CHUNKS
734
758
  : hlsResource ? HLS_STREAM_LOOKAHEAD_CHUNKS : STREAM_LOOKAHEAD_CHUNKS;
759
+ const initialLookahead = startupHlsResource
760
+ ? HLS_STREAM_INITIAL_LOOKAHEAD_CHUNKS
761
+ : lookahead;
735
762
  return new Response(createRustRangeStream(
736
763
  clients,
737
764
  request.url,
738
765
  size,
739
766
  networkId,
740
767
  windowBytes,
768
+ initialLookahead,
741
769
  lookahead
742
770
  ), {
743
771
  status,
package/weeb_3.d.ts CHANGED
@@ -84,11 +84,11 @@ export interface InitOutput {
84
84
  readonly __wbg_requestarguments_free: (a: number, b: number) => void;
85
85
  readonly requestarguments_method: (a: number, b: number) => void;
86
86
  readonly requestarguments_params: (a: number) => number;
87
- readonly __wasm_bindgen_func_elem_531: (a: number, b: number) => void;
87
+ readonly __wasm_bindgen_func_elem_526: (a: number, b: number) => void;
88
88
  readonly __wasm_bindgen_func_elem_1388: (a: number, b: number, c: number, d: number) => void;
89
89
  readonly __wasm_bindgen_func_elem_1390: (a: number, b: number, c: number, d: number) => void;
90
- readonly __wasm_bindgen_func_elem_3371: (a: number, b: number, c: number) => void;
91
- readonly __wasm_bindgen_func_elem_3297: (a: number, b: number) => void;
90
+ readonly __wasm_bindgen_func_elem_3379: (a: number, b: number, c: number) => void;
91
+ readonly __wasm_bindgen_func_elem_3305: (a: number, b: number) => void;
92
92
  readonly __wbindgen_export: (a: number, b: number) => number;
93
93
  readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
94
94
  readonly __wbindgen_export3: (a: number) => void;
package/weeb_3.js CHANGED
@@ -572,10 +572,6 @@ function __wbg_get_imports() {
572
572
  __wbg_commit_a54edce65f3858f2: function() { return handleError(function (arg0) {
573
573
  getObject(arg0).commit();
574
574
  }, arguments); },
575
- __wbg_config_deb21a1570effbf6: function(arg0) {
576
- const ret = getObject(arg0).config;
577
- return addHeapObject(ret);
578
- },
579
575
  __wbg_confirm_0951f3942a645061: function() { return handleError(function (arg0, arg1, arg2) {
580
576
  const ret = getObject(arg0).confirm(getStringFromWasm0(arg1, arg2));
581
577
  return ret;
@@ -1729,37 +1725,37 @@ function __wbg_get_imports() {
1729
1725
  },
1730
1726
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
1731
1727
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [Externref, Externref], shim_idx: 21, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1732
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_1388);
1728
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_1388);
1733
1729
  return addHeapObject(ret);
1734
1730
  },
1735
1731
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
1736
1732
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [Externref], shim_idx: 4, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1737
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_3371);
1733
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_3379);
1738
1734
  return addHeapObject(ret);
1739
1735
  },
1740
1736
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
1741
1737
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [NamedExternref("CloseEvent")], shim_idx: 4, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1742
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_3371);
1738
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_3379);
1743
1739
  return addHeapObject(ret);
1744
1740
  },
1745
1741
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
1746
1742
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [NamedExternref("Event")], shim_idx: 4, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1747
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_3371);
1743
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_3379);
1748
1744
  return addHeapObject(ret);
1749
1745
  },
1750
1746
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
1751
1747
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [NamedExternref("IDBVersionChangeEvent")], shim_idx: 23, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
1752
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_1390);
1748
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_1390);
1753
1749
  return addHeapObject(ret);
1754
1750
  },
1755
1751
  __wbindgen_cast_0000000000000006: function(arg0, arg1) {
1756
1752
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [NamedExternref("MessageEvent")], shim_idx: 4, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1757
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_3371);
1753
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_3379);
1758
1754
  return addHeapObject(ret);
1759
1755
  },
1760
1756
  __wbindgen_cast_0000000000000007: function(arg0, arg1) {
1761
1757
  // Cast intrinsic for `Closure(Closure { dtor_idx: 3, function: Function { arguments: [], shim_idx: 95, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
1762
- const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_531, __wasm_bindgen_func_elem_3297);
1758
+ const ret = makeMutClosure(arg0, arg1, wasm.__wasm_bindgen_func_elem_526, __wasm_bindgen_func_elem_3305);
1763
1759
  return addHeapObject(ret);
1764
1760
  },
1765
1761
  __wbindgen_cast_0000000000000008: function(arg0) {
@@ -1812,12 +1808,12 @@ function __wbg_get_imports() {
1812
1808
  };
1813
1809
  }
1814
1810
 
1815
- function __wasm_bindgen_func_elem_3297(arg0, arg1) {
1816
- wasm.__wasm_bindgen_func_elem_3297(arg0, arg1);
1811
+ function __wasm_bindgen_func_elem_3305(arg0, arg1) {
1812
+ wasm.__wasm_bindgen_func_elem_3305(arg0, arg1);
1817
1813
  }
1818
1814
 
1819
- function __wasm_bindgen_func_elem_3371(arg0, arg1, arg2) {
1820
- wasm.__wasm_bindgen_func_elem_3371(arg0, arg1, addHeapObject(arg2));
1815
+ function __wasm_bindgen_func_elem_3379(arg0, arg1, arg2) {
1816
+ wasm.__wasm_bindgen_func_elem_3379(arg0, arg1, addHeapObject(arg2));
1821
1817
  }
1822
1818
 
1823
1819
  function __wasm_bindgen_func_elem_1388(arg0, arg1, arg2, arg3) {
package/weeb_3_bg.wasm CHANGED
Binary file
@@ -32,11 +32,11 @@ export const weeb3no103_uploadWithRedundancy: (a: number, b: number, c: number,
32
32
  export const __wbg_requestarguments_free: (a: number, b: number) => void;
33
33
  export const requestarguments_method: (a: number, b: number) => void;
34
34
  export const requestarguments_params: (a: number) => number;
35
- export const __wasm_bindgen_func_elem_531: (a: number, b: number) => void;
35
+ export const __wasm_bindgen_func_elem_526: (a: number, b: number) => void;
36
36
  export const __wasm_bindgen_func_elem_1388: (a: number, b: number, c: number, d: number) => void;
37
37
  export const __wasm_bindgen_func_elem_1390: (a: number, b: number, c: number, d: number) => void;
38
- export const __wasm_bindgen_func_elem_3371: (a: number, b: number, c: number) => void;
39
- export const __wasm_bindgen_func_elem_3297: (a: number, b: number) => void;
38
+ export const __wasm_bindgen_func_elem_3379: (a: number, b: number, c: number) => void;
39
+ export const __wasm_bindgen_func_elem_3305: (a: number, b: number) => void;
40
40
  export const __wbindgen_export: (a: number, b: number) => number;
41
41
  export const __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
42
42
  export const __wbindgen_export3: (a: number) => void;