@lat-murmeldjur/weeb_3 0.0.324001 → 0.0.326001
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 +1 -1
- package/service.js +7 -3
- package/weeb_3.d.ts +5 -11
- package/weeb_3.js +422 -469
- package/weeb_3_bg.wasm +0 -0
- package/weeb_3_bg.wasm.d.ts +5 -11
package/package.json
CHANGED
package/service.js
CHANGED
|
@@ -630,13 +630,15 @@ function requestRustRange(clients, url, start, end, networkId) {
|
|
|
630
630
|
});
|
|
631
631
|
}
|
|
632
632
|
|
|
633
|
-
function createRustRangeStream(clients, url, size, networkId) {
|
|
633
|
+
function createRustRangeStream(clients, url, size, networkId, stagedStart) {
|
|
634
634
|
let position = 0;
|
|
635
635
|
let schedulePosition = 0;
|
|
636
|
+
let stagedWindows = stagedStart ? 4 : 0;
|
|
636
637
|
const scheduled = new Map();
|
|
637
638
|
|
|
638
639
|
const scheduleMore = () => {
|
|
639
|
-
|
|
640
|
+
const lookahead = stagedWindows > 0 ? 4 : STREAM_LOOKAHEAD_CHUNKS;
|
|
641
|
+
while (schedulePosition < size && scheduled.size < lookahead) {
|
|
640
642
|
const start = schedulePosition;
|
|
641
643
|
const end = Math.min(start + STREAM_STORAGE_WINDOW_BYTES - 1, size - 1);
|
|
642
644
|
scheduled.set(start, requestRustRange(clients, url, start, end, networkId));
|
|
@@ -670,6 +672,7 @@ function createRustRangeStream(clients, url, size, networkId) {
|
|
|
670
672
|
const body = toUint8Array(response.body);
|
|
671
673
|
position = start + body.byteLength;
|
|
672
674
|
controller.enqueue(body);
|
|
675
|
+
stagedWindows = Math.max(0, stagedWindows - 1);
|
|
673
676
|
scheduleMore();
|
|
674
677
|
} catch (error) {
|
|
675
678
|
controller.error(error);
|
|
@@ -711,7 +714,8 @@ async function forwardRequestToRust(request, event) {
|
|
|
711
714
|
|
|
712
715
|
if (response.stream && request.method !== "HEAD") {
|
|
713
716
|
const size = Number(headers.get("Content-Length") || "0");
|
|
714
|
-
|
|
717
|
+
const stagedStart = headers.get("X-Weeb3-Stream-Start") === "1";
|
|
718
|
+
return new Response(createRustRangeStream(clients, request.url, size, networkId, stagedStart), {
|
|
715
719
|
status,
|
|
716
720
|
headers
|
|
717
721
|
});
|
package/weeb_3.d.ts
CHANGED
|
@@ -84,21 +84,15 @@ 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
|
|
88
|
-
readonly
|
|
89
|
-
readonly
|
|
90
|
-
readonly
|
|
91
|
-
readonly
|
|
92
|
-
readonly __wasm_bindgen_func_elem_3634: (a: number, b: number, c: number) => void;
|
|
93
|
-
readonly __wasm_bindgen_func_elem_3634_3: (a: number, b: number, c: number) => void;
|
|
94
|
-
readonly __wasm_bindgen_func_elem_3634_4: (a: number, b: number, c: number) => void;
|
|
95
|
-
readonly __wasm_bindgen_func_elem_3634_6: (a: number, b: number, c: number) => void;
|
|
96
|
-
readonly __wasm_bindgen_func_elem_3560: (a: number, b: number) => void;
|
|
87
|
+
readonly __wasm_bindgen_func_elem_590: (a: number, b: number) => void;
|
|
88
|
+
readonly __wasm_bindgen_func_elem_1559: (a: number, b: number, c: number, d: number) => void;
|
|
89
|
+
readonly __wasm_bindgen_func_elem_1561: (a: number, b: number, c: number, d: number) => void;
|
|
90
|
+
readonly __wasm_bindgen_func_elem_3692: (a: number, b: number, c: number) => void;
|
|
91
|
+
readonly __wasm_bindgen_func_elem_3617: (a: number, b: number) => void;
|
|
97
92
|
readonly __wbindgen_export: (a: number, b: number) => number;
|
|
98
93
|
readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
|
|
99
94
|
readonly __wbindgen_export3: (a: number) => void;
|
|
100
95
|
readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
|
|
101
|
-
readonly __wbindgen_export5: (a: number, b: number) => void;
|
|
102
96
|
readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
|
|
103
97
|
readonly __wbindgen_start: () => void;
|
|
104
98
|
}
|