@blockcast/fec-worker 0.1.0-main.6a2e0a347fdb → 0.1.0-main.755429ea80b7
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 +1 -1
- package/dist/fec-worker-client.d.ts +4 -3
- package/dist/fec-worker-client.d.ts.map +1 -1
- package/dist/fec-worker-client.js +66 -17
- package/dist/fec-worker-client.js.map +1 -1
- package/dist/fec-worker-types.d.ts +43 -7
- package/dist/fec-worker-types.d.ts.map +1 -1
- package/dist/fec-worker.js +53 -11
- package/dist/fec-worker.js.map +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/fec-worker-client.ts +70 -18
- package/src/fec-worker-types.ts +43 -6
- package/src/fec-worker.ts +78 -16
- package/src/index.ts +2 -0
package/README.md
CHANGED
|
@@ -118,7 +118,7 @@ All messages are typed as discriminated unions in `fec-worker-types.ts`. Both th
|
|
|
118
118
|
|
|
119
119
|
`feedSource` carries the **flat 32-bit Source Symbol ID** from the MMTP Source FEC Payload ID (ISO 23008-1 §C.5.2). The WASM decoder derives `SBN = floor(ssId / K)` and `ESI = ssId % K` internally — do not pre-compute these.
|
|
120
120
|
|
|
121
|
-
`feedRepair` carries the wire-level Repair FEC Payload ID fields directly (ISO 23008-1 §C.5.3): `ssStart` is the SS_ID of the first source symbol in the block, `ssbLength`
|
|
121
|
+
`feedRepair` carries the wire-level Repair FEC Payload ID fields directly (ISO 23008-1 §C.5.3): `ssStart` is the SS_ID of the first source symbol in the block (`SBN * configured K`), `ssbLength` is the authored source-symbol count in `1..configured K`, and `rsId` is the repair index within the block. The decoder's block geometry and repair ESI use the configured K; K is never inferred from repair traffic.
|
|
122
122
|
|
|
123
123
|
### Outbound — `FecWorkerEvent` (worker → main)
|
|
124
124
|
|
|
@@ -25,7 +25,8 @@ export declare class FecWorkerClient {
|
|
|
25
25
|
configure(config: FecTrackConfig, wasmModule: WebAssembly.Module, altaPublicKey?: ArrayBuffer, altaWasmModule?: WebAssembly.Module): void;
|
|
26
26
|
/**
|
|
27
27
|
* Feed a source symbol to the Worker. data ArrayBuffer is transferred (zero-copy).
|
|
28
|
-
* Caller must not access data after this call — it is
|
|
28
|
+
* Caller must not access data after this call — it is transferred with the
|
|
29
|
+
* task's symbol batch, before any later command of this client.
|
|
29
30
|
*
|
|
30
31
|
* Optional `alta` carries the detached ALTA authenticator bytes and the
|
|
31
32
|
* byte offset in `data` where the signed payload ends. The auth buffer is
|
|
@@ -41,8 +42,8 @@ export declare class FecWorkerClient {
|
|
|
41
42
|
* Caller must not access data after this call — it is detached.
|
|
42
43
|
*
|
|
43
44
|
* Carries the wire-level Repair FEC Payload ID fields (ISO 23008-1 §C.5.3):
|
|
44
|
-
* - ssStart: SS_ID of first source symbol in the block (= SBN *
|
|
45
|
-
* - ssbLength:
|
|
45
|
+
* - ssStart: SS_ID of first source symbol in the block (= SBN * configured K)
|
|
46
|
+
* - ssbLength: authored source-symbol count (1..configured K)
|
|
46
47
|
* - rsId: repair symbol index within the block
|
|
47
48
|
*/
|
|
48
49
|
feedRepair(ssStart: number, ssbLength: number, rsId: number, data: ArrayBuffer, ts: number): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fec-worker-client.d.ts","sourceRoot":"","sources":["../src/fec-worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"fec-worker-client.d.ts","sourceRoot":"","sources":["../src/fec-worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAIX,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,kBAAkB,EAClB,MAAM,uBAAuB,CAAC;AAE/B,qBAAa,eAAe;;IAuB3B;;;OAGG;gBACS,WAAW,EAAE,MAAM,GAAG,GAAG;IAgBrC;;;;;;OAMG;IACH,SAA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M,KAAK,IAAI,GAAG,IAAI;IAIlD,2CAA2C;IAC3C,OAAO,CAAC,EAAE,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,kBAAkB,KAAK,IAAI,GAAG,IAAI;IAIvE;;;;;OAKG;IACH,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;OAGG;IACH,OAAO,IAAI,IAAI;CA4Df"}
|
|
@@ -20,6 +20,15 @@ export class FecWorkerClient {
|
|
|
20
20
|
#pendingResets = 0;
|
|
21
21
|
#resetFailed = false;
|
|
22
22
|
#disposed = false;
|
|
23
|
+
// Symbols fed during the current task, sent as one feedSymbols message
|
|
24
|
+
// when the task's microtasks run (BLO-36599). A packet stream delivers many
|
|
25
|
+
// symbols per task, and each postMessage is a structured-clone round trip
|
|
26
|
+
// on the page thread; the batch boundary is the task, not a size or timer.
|
|
27
|
+
#pendingSymbols = [];
|
|
28
|
+
#pendingTransfer = [];
|
|
29
|
+
#flushQueued = false;
|
|
30
|
+
// Batching starts only once the Worker announced it accepts feedSymbols.
|
|
31
|
+
#batchSymbols = false;
|
|
23
32
|
/**
|
|
24
33
|
* Create a FecWorkerClient.
|
|
25
34
|
* @param workerOrUrl - Either a Worker instance (for testing) or a URL to create one
|
|
@@ -49,6 +58,7 @@ export class FecWorkerClient {
|
|
|
49
58
|
configure(config, wasmModule, altaPublicKey, altaWasmModule) {
|
|
50
59
|
if (this.#disposed)
|
|
51
60
|
throw new Error("[FecWorkerClient] disposed");
|
|
61
|
+
this.#flushSymbols();
|
|
52
62
|
const cmd = {
|
|
53
63
|
type: "configure",
|
|
54
64
|
config,
|
|
@@ -67,7 +77,8 @@ export class FecWorkerClient {
|
|
|
67
77
|
}
|
|
68
78
|
/**
|
|
69
79
|
* Feed a source symbol to the Worker. data ArrayBuffer is transferred (zero-copy).
|
|
70
|
-
* Caller must not access data after this call — it is
|
|
80
|
+
* Caller must not access data after this call — it is transferred with the
|
|
81
|
+
* task's symbol batch, before any later command of this client.
|
|
71
82
|
*
|
|
72
83
|
* Optional `alta` carries the detached ALTA authenticator bytes and the
|
|
73
84
|
* byte offset in `data` where the signed payload ends. The auth buffer is
|
|
@@ -77,39 +88,63 @@ export class FecWorkerClient {
|
|
|
77
88
|
feedSource(ssId, data, ts, alta) {
|
|
78
89
|
if (this.#disposed)
|
|
79
90
|
throw new Error("[FecWorkerClient] feedSource on a disposed client");
|
|
80
|
-
|
|
81
|
-
|
|
91
|
+
if (alta) {
|
|
92
|
+
this.#queueSymbol({
|
|
82
93
|
type: "feedSource",
|
|
83
94
|
ssId,
|
|
84
95
|
data,
|
|
85
96
|
ts,
|
|
86
97
|
altaAuth: alta.auth,
|
|
87
98
|
altaPayloadEnd: alta.payloadEnd,
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
99
|
+
}, data, alta.auth);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
this.#queueSymbol({ type: "feedSource", ssId, data, ts }, data);
|
|
103
|
+
}
|
|
92
104
|
}
|
|
93
105
|
/**
|
|
94
106
|
* Feed a repair symbol to the Worker. data ArrayBuffer is transferred (zero-copy).
|
|
95
107
|
* Caller must not access data after this call — it is detached.
|
|
96
108
|
*
|
|
97
109
|
* Carries the wire-level Repair FEC Payload ID fields (ISO 23008-1 §C.5.3):
|
|
98
|
-
* - ssStart: SS_ID of first source symbol in the block (= SBN *
|
|
99
|
-
* - ssbLength:
|
|
110
|
+
* - ssStart: SS_ID of first source symbol in the block (= SBN * configured K)
|
|
111
|
+
* - ssbLength: authored source-symbol count (1..configured K)
|
|
100
112
|
* - rsId: repair symbol index within the block
|
|
101
113
|
*/
|
|
102
114
|
feedRepair(ssStart, ssbLength, rsId, data, ts) {
|
|
103
115
|
if (this.#disposed)
|
|
104
116
|
throw new Error("[FecWorkerClient] feedRepair on a disposed client");
|
|
105
|
-
this.#
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
117
|
+
this.#queueSymbol({ type: "feedRepair", ssStart, ssbLength, rsId, data, ts }, data);
|
|
118
|
+
}
|
|
119
|
+
#queueSymbol(symbol, data, auth) {
|
|
120
|
+
if (!this.#batchSymbols) {
|
|
121
|
+
this.#worker.postMessage(symbol, auth ? [data, auth] : [data]);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.#pendingSymbols.push(symbol);
|
|
125
|
+
this.#pendingTransfer.push(data);
|
|
126
|
+
if (auth)
|
|
127
|
+
this.#pendingTransfer.push(auth);
|
|
128
|
+
if (this.#flushQueued)
|
|
129
|
+
return;
|
|
130
|
+
this.#flushQueued = true;
|
|
131
|
+
queueMicrotask(() => {
|
|
132
|
+
this.#flushQueued = false;
|
|
133
|
+
this.#flushSymbols();
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Send the symbols fed so far. Every other command calls this first, so a
|
|
138
|
+
* cleanup barrier, reset or signature still follows all earlier symbols.
|
|
139
|
+
*/
|
|
140
|
+
#flushSymbols() {
|
|
141
|
+
if (this.#pendingSymbols.length === 0 || this.#disposed)
|
|
142
|
+
return;
|
|
143
|
+
const symbols = this.#pendingSymbols;
|
|
144
|
+
const transfer = this.#pendingTransfer;
|
|
145
|
+
this.#pendingSymbols = [];
|
|
146
|
+
this.#pendingTransfer = [];
|
|
147
|
+
this.#worker.postMessage({ type: "feedSymbols", symbols }, transfer);
|
|
113
148
|
}
|
|
114
149
|
/**
|
|
115
150
|
* Submit relay block signature for verification. sig and hash are transferred.
|
|
@@ -117,6 +152,7 @@ export class FecWorkerClient {
|
|
|
117
152
|
relayBlockSig(sbn, sig, hash) {
|
|
118
153
|
if (this.#disposed)
|
|
119
154
|
throw new Error("[FecWorkerClient] relayBlockSig on a disposed client");
|
|
155
|
+
this.#flushSymbols();
|
|
120
156
|
this.#worker.postMessage({ type: "relayBlockSig", sbn, sig, hash }, [sig, hash]);
|
|
121
157
|
}
|
|
122
158
|
/**
|
|
@@ -143,12 +179,16 @@ export class FecWorkerClient {
|
|
|
143
179
|
reset() {
|
|
144
180
|
if (this.#disposed)
|
|
145
181
|
throw new Error("[FecWorkerClient] reset on a disposed client");
|
|
182
|
+
this.#flushSymbols();
|
|
146
183
|
this.#pendingResets++;
|
|
147
184
|
this.#cleanupInFlight = null;
|
|
148
185
|
this.#queuedCleanupSbns.clear();
|
|
149
186
|
this.#worker.postMessage({ type: "reset" });
|
|
150
187
|
}
|
|
151
188
|
#postCleanup(sbns) {
|
|
189
|
+
// The cleanup is a queue-drain barrier: every symbol fed before it is
|
|
190
|
+
// posted must reach the Worker first.
|
|
191
|
+
this.#flushSymbols();
|
|
152
192
|
this.#cleanupInFlight = sbns;
|
|
153
193
|
const orderedSbns = [...sbns].sort((a, b) => a - b);
|
|
154
194
|
this.#worker.postMessage({ type: "cleanup", sbns: orderedSbns });
|
|
@@ -194,12 +234,21 @@ export class FecWorkerClient {
|
|
|
194
234
|
if (this.#disposed)
|
|
195
235
|
return;
|
|
196
236
|
this.#disposed = true;
|
|
237
|
+
// A terminated Worker decodes nothing; symbols still batched are dropped.
|
|
238
|
+
this.#pendingSymbols = [];
|
|
239
|
+
this.#pendingTransfer = [];
|
|
197
240
|
this.#cleanupInFlight = null;
|
|
198
241
|
this.#queuedCleanupSbns.clear();
|
|
199
242
|
this.#worker.postMessage({ type: "dispose" });
|
|
200
243
|
this.#worker.terminate();
|
|
201
244
|
}
|
|
202
245
|
#handleEvent(event) {
|
|
246
|
+
if (event.type === "capabilities") {
|
|
247
|
+
if (Array.isArray(event.commands) && event.commands.includes("feedSymbols")) {
|
|
248
|
+
this.#batchSymbols = true;
|
|
249
|
+
}
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
203
252
|
if (event.type === "resetComplete") {
|
|
204
253
|
this.#pendingResets = Math.max(0, this.#pendingResets - 1);
|
|
205
254
|
this.#resetFailed = false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fec-worker-client.js","sourceRoot":"","sources":["../src/fec-worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"fec-worker-client.js","sourceRoot":"","sources":["../src/fec-worker-client.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAaH,MAAM,OAAO,eAAe;IAClB,OAAO,CAAS;IACzB,QAAQ,GAA0D,IAAI,CAAC;IACvE,WAAW,GAA4C,IAAI,CAAC;IAC5D,cAAc,GAA+C,IAAI,CAAC;IAClE,YAAY,GAAsD,IAAI,CAAC;IACvE,kBAAkB,GAAmC,IAAI,CAAC;IAC1D,QAAQ,GAAkE,IAAI,CAAC;IAC/E,gBAAgB,GAAuB,IAAI,CAAC;IAC5C,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;IACvC,cAAc,GAAG,CAAC,CAAC;IACnB,YAAY,GAAG,KAAK,CAAC;IACrB,SAAS,GAAG,KAAK,CAAC;IAClB,uEAAuE;IACvE,4EAA4E;IAC5E,0EAA0E;IAC1E,2EAA2E;IAC3E,eAAe,GAAuB,EAAE,CAAC;IACzC,gBAAgB,GAAmB,EAAE,CAAC;IACtC,YAAY,GAAG,KAAK,CAAC;IACrB,yEAAyE;IACzE,aAAa,GAAG,KAAK,CAAC;IAEtB;;;OAGG;IACH,YAAY,WAAyB;QACpC,IAAI,WAAW,YAAY,GAAG,EAAE,CAAC;YAChC,IAAI,CAAC,OAAO,GAAG,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;QAC5D,CAAC;aAAM,CAAC;YACP,IAAI,CAAC,OAAO,GAAG,WAAW,CAAC;QAC5B,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAA+B,EAAE,EAAE,CAC5D,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC3B,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,CA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,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC;SAAM,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;QAChC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC;AAED,SAAS,wBAAwB,CAAC,KAAmB;IACpD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;IACxB,MAAM,MAAM,GACX,IAAI,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClB,IAAI,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAC5C,KAAK,MAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC/C,OAAO,4DAA4D,MAAM,EAAE,CAAC;AAC7E,CAAC"}
|
|
@@ -57,8 +57,10 @@ export interface FecBlockSnapshot {
|
|
|
57
57
|
sourceReceived: number;
|
|
58
58
|
/** Number of repair symbols received */
|
|
59
59
|
repairReceived: number;
|
|
60
|
-
/**
|
|
60
|
+
/** Configured source-block geometry (K) */
|
|
61
61
|
k: number;
|
|
62
|
+
/** Authored source symbols (SSB_length) once a repair symbol declared it */
|
|
63
|
+
ssbLength?: number;
|
|
62
64
|
/** Expected repair symbols (P) */
|
|
63
65
|
repairCount: number;
|
|
64
66
|
/** Timestamp of first symbol arrival (ms) */
|
|
@@ -132,7 +134,7 @@ export interface FecTrackStats {
|
|
|
132
134
|
liveSbn: number;
|
|
133
135
|
/** Active block snapshots */
|
|
134
136
|
blocks: FecBlockSnapshot[];
|
|
135
|
-
/** Number of blocks in the
|
|
137
|
+
/** Number of blocks in the FEC block span */
|
|
136
138
|
interleaveWindowBlocks: number;
|
|
137
139
|
/** Average recovery latency (ms) */
|
|
138
140
|
avgRecoveryMs: number;
|
|
@@ -152,7 +154,7 @@ export interface FecTrackStats {
|
|
|
152
154
|
};
|
|
153
155
|
}
|
|
154
156
|
/** Stable identities for Worker failures whose message text contains live values. */
|
|
155
|
-
export type FecWorkerErrorCode = "recovered-symbol-size-unconfigured" | "recovered-block-too-short" | "repair-symbol-size-mismatch" | "reset-failed" | "unknown-command" | "command-failed" | "worker-runtime" | "worker-message";
|
|
157
|
+
export type FecWorkerErrorCode = "recovered-symbol-size-unconfigured" | "recovered-block-too-short" | "recovered-symbol-ssb-length-invalid" | "repair-symbol-size-mismatch" | "repair-ssb-length-conflict" | "reset-failed" | "unknown-command" | "command-failed" | "worker-runtime" | "worker-message";
|
|
156
158
|
/** Per-frame metadata emitted with frame events from Worker. */
|
|
157
159
|
export interface FrameMeta {
|
|
158
160
|
/** ALTA verification result: true/false after check, null when ALTA not configured (AUTH-04) */
|
|
@@ -161,8 +163,14 @@ export interface FrameMeta {
|
|
|
161
163
|
recovered: boolean;
|
|
162
164
|
/** Source block number this frame belongs to */
|
|
163
165
|
sbn: number;
|
|
164
|
-
/** Encoding Symbol ID within the recovered source block (0..
|
|
166
|
+
/** Encoding Symbol ID within the recovered source block (0..ssbLength-1). */
|
|
165
167
|
esi?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Authored source-symbol count of the recovered block (the repair
|
|
170
|
+
* symbols' SSB_length, 1..K). Recovered frames are ESI 0..ssbLength-1;
|
|
171
|
+
* ESIs ssbLength..K-1 are encoder zero padding and are never emitted.
|
|
172
|
+
*/
|
|
173
|
+
ssbLength?: number;
|
|
166
174
|
}
|
|
167
175
|
/** Discriminated union of all commands sent from main thread to Worker. */
|
|
168
176
|
export type FecWorkerCommand = {
|
|
@@ -200,16 +208,26 @@ export type FecWorkerCommand = {
|
|
|
200
208
|
} | {
|
|
201
209
|
type: "feedRepair";
|
|
202
210
|
/** SS_Start: SS_ID of the first source symbol in the block
|
|
203
|
-
* (= SBN *
|
|
211
|
+
* (= SBN * configured K), from the MMTP Repair FEC Payload ID
|
|
204
212
|
* (ISO 23008-1 §C.5.3). */
|
|
205
213
|
ssStart: number;
|
|
206
|
-
/**
|
|
214
|
+
/** Authored source-symbol count for this block; 1..configured K. */
|
|
207
215
|
ssbLength: number;
|
|
208
216
|
/** RS_ID: repair symbol index within the block; WASM maps to
|
|
209
|
-
* repair ESI =
|
|
217
|
+
* repair ESI = configured K + RS_ID. */
|
|
210
218
|
rsId: number;
|
|
211
219
|
data: ArrayBuffer;
|
|
212
220
|
ts: number;
|
|
221
|
+
} | {
|
|
222
|
+
/**
|
|
223
|
+
* Every source and repair symbol the page fed in one task, in feed
|
|
224
|
+
* order, sharing one transfer list. The client sends symbols this
|
|
225
|
+
* way instead of one message per symbol (BLO-36599); the Worker
|
|
226
|
+
* handles each record exactly like the single-symbol command of the
|
|
227
|
+
* same `type`, and a record that fails does not stop the others.
|
|
228
|
+
*/
|
|
229
|
+
type: "feedSymbols";
|
|
230
|
+
symbols: FecSymbolCommand[];
|
|
213
231
|
} | {
|
|
214
232
|
type: "relayBlockSig";
|
|
215
233
|
sbn: number;
|
|
@@ -224,6 +242,12 @@ export type FecWorkerCommand = {
|
|
|
224
242
|
} | {
|
|
225
243
|
type: "dispose";
|
|
226
244
|
};
|
|
245
|
+
/** One symbol record of a `feedSymbols` batch. */
|
|
246
|
+
export type FecSymbolCommand = Extract<FecWorkerCommand, {
|
|
247
|
+
type: "feedSource";
|
|
248
|
+
} | {
|
|
249
|
+
type: "feedRepair";
|
|
250
|
+
}>;
|
|
227
251
|
/** Discriminated union of all events emitted from Worker to main thread. */
|
|
228
252
|
export type FecWorkerEvent = {
|
|
229
253
|
type: "frame";
|
|
@@ -244,9 +268,21 @@ export type FecWorkerEvent = {
|
|
|
244
268
|
sbns: number[];
|
|
245
269
|
} | {
|
|
246
270
|
type: "resetComplete";
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Optional commands this Worker accepts, posted once it is configured.
|
|
274
|
+
* The client uses `feedSymbols` only after the Worker names it, so a page
|
|
275
|
+
* that meets an older cached Worker bundle keeps sending one command per
|
|
276
|
+
* symbol instead of a batch that Worker would reject (BLO-36599).
|
|
277
|
+
*/
|
|
278
|
+
| {
|
|
279
|
+
type: "capabilities";
|
|
280
|
+
commands: FecWorkerOptionalCommand[];
|
|
247
281
|
} | {
|
|
248
282
|
type: "error";
|
|
249
283
|
message: string;
|
|
250
284
|
code?: FecWorkerErrorCode;
|
|
251
285
|
};
|
|
286
|
+
/** Commands a client may send only after the Worker announced them. */
|
|
287
|
+
export type FecWorkerOptionalCommand = "feedSymbols";
|
|
252
288
|
//# sourceMappingURL=fec-worker-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fec-worker-types.d.ts","sourceRoot":"","sources":["../src/fec-worker-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,mFAAmF;AACnF,MAAM,WAAW,cAAc;IAC9B,oDAAoD;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,8BAA8B;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,uBAAuB;IACvB,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC;IAC7B,2CAA2C;IAC3C,UAAU,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACtC,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,iEAAiE;IACjE,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,CAAC,EAAE,MAAM,CAAC;IACV,qDAAqD;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC;IACrB,8EAA8E;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IAAI,EAAE,eAAe,CAAA;CAAE;AAC3B;;;;;GAKG;GACD;IAAE,IAAI,EAAE,cAAc,CAAC;IAAC,QAAQ,EAAE,wBAAwB,EAAE,CAAA;CAAE,GAC9D;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,kBAAkB,CAAA;CAAE,CAAC;AAEjE,uEAAuE;AACvE,MAAM,MAAM,wBAAwB,GAAG,aAAa,CAAC"}
|
package/dist/fec-worker.js
CHANGED
|
@@ -189,15 +189,16 @@ function emitRecoveredSymbols(sbn, recoveredBlock, block) {
|
|
|
189
189
|
});
|
|
190
190
|
return;
|
|
191
191
|
}
|
|
192
|
-
|
|
192
|
+
const ssbLength = block.ssbLength ?? config.k;
|
|
193
|
+
if (recoveredBlock.byteLength !== symbolSize * ssbLength) {
|
|
193
194
|
emit({
|
|
194
195
|
type: "error",
|
|
195
196
|
code: "recovered-block-too-short",
|
|
196
|
-
message: `[FecWorker] recovered block
|
|
197
|
+
message: `[FecWorker] recovered block has the wrong length: got ${recoveredBlock.byteLength}B, expected ${symbolSize * ssbLength}B (SSB_length=${ssbLength})`
|
|
197
198
|
});
|
|
198
199
|
return;
|
|
199
200
|
}
|
|
200
|
-
for (let i = 0; i <
|
|
201
|
+
for (let i = 0; i < ssbLength; i++) {
|
|
201
202
|
const symbol = recoveredBlock.subarray(i * symbolSize, (i + 1) * symbolSize);
|
|
202
203
|
const recoveredAltaVerified = null;
|
|
203
204
|
if (altaEnabled) altaPending++;
|
|
@@ -206,7 +207,8 @@ function emitRecoveredSymbols(sbn, recoveredBlock, block) {
|
|
|
206
207
|
altaVerified: recoveredAltaVerified,
|
|
207
208
|
recovered: true,
|
|
208
209
|
sbn,
|
|
209
|
-
esi: i
|
|
210
|
+
esi: i,
|
|
211
|
+
ssbLength
|
|
210
212
|
};
|
|
211
213
|
emit({ type: "frame", data: buf, meta }, [buf]);
|
|
212
214
|
}
|
|
@@ -289,6 +291,7 @@ async function handleConfigure(cmd) {
|
|
|
289
291
|
}
|
|
290
292
|
}
|
|
291
293
|
wasmDecoder.configure_params(config.k, config.symbolSize);
|
|
294
|
+
emit({ type: "capabilities", commands: ["feedSymbols"] });
|
|
292
295
|
startSnapshotTimer();
|
|
293
296
|
emitSnapshot();
|
|
294
297
|
}
|
|
@@ -322,12 +325,13 @@ function handleFeedSource(cmd) {
|
|
|
322
325
|
block.lastSymbolTs = performance.now();
|
|
323
326
|
sourceSymbols++;
|
|
324
327
|
if (altaEnabled) altaPending++;
|
|
325
|
-
|
|
328
|
+
const authoredLength = block.ssbLength ?? block.k;
|
|
329
|
+
if (block.sourceReceived >= authoredLength && block.state === "collecting") {
|
|
326
330
|
markBlockTerminal(block, "complete");
|
|
327
331
|
blocksComplete++;
|
|
328
332
|
emitBlockUpdate(block);
|
|
329
333
|
}
|
|
330
|
-
if (result && result.byteLength > 0 && block.sourceReceived <
|
|
334
|
+
if (result && result.byteLength > 0 && block.sourceReceived < authoredLength) {
|
|
331
335
|
const recovered = new Uint8Array(toOwnedArrayBuffer(result));
|
|
332
336
|
const recoveryMs = performance.now() - block.firstSymbolTs;
|
|
333
337
|
recoveryTimes.push(recoveryMs);
|
|
@@ -348,7 +352,7 @@ function handleFeedRepair(cmd) {
|
|
|
348
352
|
if (!config) {
|
|
349
353
|
throw new Error("[FecWorker] feedRepair: config missing");
|
|
350
354
|
}
|
|
351
|
-
if (!isUint32(cmd.ssStart) || !isUint32(cmd.ssbLength) || cmd.ssbLength <= 0 || cmd.ssbLength
|
|
355
|
+
if (!isUint32(cmd.ssStart) || !isUint32(cmd.ssbLength) || cmd.ssbLength <= 0 || cmd.ssbLength > config.k || cmd.ssStart % config.k !== 0 || !isUint32(cmd.rsId) || config.k + cmd.rsId > UINT24_MAX || !(cmd.data instanceof ArrayBuffer)) {
|
|
352
356
|
throw new Error("[FecWorker] feedRepair: invalid repair symbol");
|
|
353
357
|
}
|
|
354
358
|
const view = new Uint8Array(cmd.data);
|
|
@@ -363,12 +367,20 @@ function handleFeedRepair(cmd) {
|
|
|
363
367
|
}
|
|
364
368
|
return;
|
|
365
369
|
}
|
|
366
|
-
const sbn = Math.floor(cmd.ssStart /
|
|
367
|
-
const repairEsi =
|
|
370
|
+
const sbn = Math.floor(cmd.ssStart / config.k);
|
|
371
|
+
const repairEsi = config.k + cmd.rsId;
|
|
368
372
|
if (sbn <= retiredSbnFrontier) return;
|
|
369
373
|
const existingBlock = blocks.get(sbn);
|
|
370
374
|
if (existingBlock && isTerminalBlock(existingBlock)) return;
|
|
371
375
|
if (acceptedRepairEsis.get(sbn)?.has(repairEsi)) return;
|
|
376
|
+
if (existingBlock?.ssbLength !== void 0 && existingBlock.ssbLength !== cmd.ssbLength) {
|
|
377
|
+
emit({
|
|
378
|
+
type: "error",
|
|
379
|
+
code: "repair-ssb-length-conflict",
|
|
380
|
+
message: `[FecWorker] Dropping repair symbol whose SSB_length ${cmd.ssbLength} conflicts with ${existingBlock.ssbLength} (sbn=${sbn})`
|
|
381
|
+
});
|
|
382
|
+
return;
|
|
383
|
+
}
|
|
372
384
|
const result = wasmDecoder.add_repair(
|
|
373
385
|
cmd.ssStart,
|
|
374
386
|
cmd.ssbLength,
|
|
@@ -384,10 +396,15 @@ function handleFeedRepair(cmd) {
|
|
|
384
396
|
}
|
|
385
397
|
repairEsis.add(repairEsi);
|
|
386
398
|
const block = getOrCreateBlock(sbn);
|
|
399
|
+
block.ssbLength = cmd.ssbLength;
|
|
387
400
|
block.repairReceived++;
|
|
388
401
|
block.lastSymbolTs = performance.now();
|
|
389
402
|
repairSymbols++;
|
|
390
|
-
if (
|
|
403
|
+
if (block.sourceReceived >= cmd.ssbLength && block.state === "collecting") {
|
|
404
|
+
markBlockTerminal(block, "complete");
|
|
405
|
+
blocksComplete++;
|
|
406
|
+
emitBlockUpdate(block);
|
|
407
|
+
} else if (result && result.byteLength > 0) {
|
|
391
408
|
const recovered = new Uint8Array(toOwnedArrayBuffer(result));
|
|
392
409
|
const recoveryMs = performance.now() - block.firstSymbolTs;
|
|
393
410
|
recoveryTimes.push(recoveryMs);
|
|
@@ -425,7 +442,7 @@ function handleCleanup(cmd) {
|
|
|
425
442
|
retireAcceptedIds(sbn);
|
|
426
443
|
continue;
|
|
427
444
|
}
|
|
428
|
-
currentBlock
|
|
445
|
+
currentBlock ??= getOrCreateBlock(sbn);
|
|
429
446
|
if (currentBlock.sourceReceived >= currentBlock.k) {
|
|
430
447
|
markBlockTerminal(currentBlock, "complete");
|
|
431
448
|
blocksComplete++;
|
|
@@ -518,6 +535,28 @@ function handleReset() {
|
|
|
518
535
|
emit({ type: "resetComplete" });
|
|
519
536
|
if (config) emitSnapshot();
|
|
520
537
|
}
|
|
538
|
+
function handleFeedSymbols(cmd) {
|
|
539
|
+
if (!Array.isArray(cmd.symbols)) {
|
|
540
|
+
throw new Error("[FecWorker] feedSymbols: symbols must be an array");
|
|
541
|
+
}
|
|
542
|
+
for (const symbol of cmd.symbols) {
|
|
543
|
+
try {
|
|
544
|
+
if (symbol?.type === "feedSource") handleFeedSource(symbol);
|
|
545
|
+
else if (symbol?.type === "feedRepair") handleFeedRepair(symbol);
|
|
546
|
+
else {
|
|
547
|
+
throw new Error(
|
|
548
|
+
`[FecWorker] feedSymbols: unknown symbol type ${String(symbol?.type)}`
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
} catch (err) {
|
|
552
|
+
emit({
|
|
553
|
+
type: "error",
|
|
554
|
+
code: "command-failed",
|
|
555
|
+
message: err instanceof Error ? err.message : `[FecWorker] ${String(err)}`
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
521
560
|
async function dispatchCommand(cmd) {
|
|
522
561
|
try {
|
|
523
562
|
switch (cmd.type) {
|
|
@@ -530,6 +569,9 @@ async function dispatchCommand(cmd) {
|
|
|
530
569
|
case "feedRepair":
|
|
531
570
|
handleFeedRepair(cmd);
|
|
532
571
|
break;
|
|
572
|
+
case "feedSymbols":
|
|
573
|
+
handleFeedSymbols(cmd);
|
|
574
|
+
break;
|
|
533
575
|
case "relayBlockSig":
|
|
534
576
|
handleRelayBlockSig(cmd);
|
|
535
577
|
break;
|