@ifc-lite/cache 3.7.3 → 3.8.0
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 +2 -0
- package/SPEC.md +522 -0
- package/dist/adapt.d.ts +2 -1
- package/dist/adapt.d.ts.map +1 -1
- package/dist/adapt.js +1 -0
- package/dist/adapt.js.map +1 -1
- package/dist/chunk-inflate-pool.d.ts +3 -0
- package/dist/chunk-inflate-pool.d.ts.map +1 -0
- package/dist/chunk-inflate-pool.js +6 -0
- package/dist/chunk-inflate-pool.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/reader.d.ts +4 -1
- package/dist/reader.d.ts.map +1 -1
- package/dist/reader.js +7 -2
- package/dist/reader.js.map +1 -1
- package/dist/sections/coordinate-info.d.ts.map +1 -1
- package/dist/sections/coordinate-info.js +14 -0
- package/dist/sections/coordinate-info.js.map +1 -1
- package/dist/sections/geometry-chunks.d.ts +24 -4
- package/dist/sections/geometry-chunks.d.ts.map +1 -1
- package/dist/sections/geometry-chunks.js +20 -8
- package/dist/sections/geometry-chunks.js.map +1 -1
- package/dist/sections/mesh-metadata.d.ts +1 -1
- package/dist/sections/selection-relationships.d.ts +9 -0
- package/dist/sections/selection-relationships.d.ts.map +1 -0
- package/dist/sections/selection-relationships.js +71 -0
- package/dist/sections/selection-relationships.js.map +1 -0
- package/dist/types-entity-index.d.ts +27 -0
- package/dist/types-entity-index.d.ts.map +1 -0
- package/dist/types-entity-index.js +5 -0
- package/dist/types-entity-index.js.map +1 -0
- package/dist/types.d.ts +10 -33
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/buffer-utils.d.ts +23 -0
- package/dist/utils/buffer-utils.d.ts.map +1 -1
- package/dist/utils/buffer-utils.js +58 -0
- package/dist/utils/buffer-utils.js.map +1 -1
- package/dist/workers/chunk-inflate-pool.d.ts +30 -0
- package/dist/workers/chunk-inflate-pool.d.ts.map +1 -0
- package/dist/workers/chunk-inflate-pool.js +167 -0
- package/dist/workers/chunk-inflate-pool.js.map +1 -0
- package/dist/workers/geometry-compression-client.d.ts +19 -2
- package/dist/workers/geometry-compression-client.d.ts.map +1 -1
- package/dist/workers/geometry-compression-client.js +53 -16
- package/dist/workers/geometry-compression-client.js.map +1 -1
- package/dist/workers/geometry-compression-handler.d.ts.map +1 -1
- package/dist/workers/geometry-compression-handler.js +12 -2
- package/dist/workers/geometry-compression-handler.js.map +1 -1
- package/dist/workers/geometry-compression-protocol.d.ts +7 -0
- package/dist/workers/geometry-compression-protocol.d.ts.map +1 -1
- package/dist/workers/geometry-compression-protocol.js +7 -1
- package/dist/workers/geometry-compression-protocol.js.map +1 -1
- package/dist/writer.d.ts +2 -2
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js +21 -2
- package/dist/writer.js.map +1 -1
- package/package.json +14 -7
package/dist/types.js
CHANGED
|
@@ -150,7 +150,8 @@ export const MAGIC = 0x4C434649; // "IFCL" in little-endian
|
|
|
150
150
|
/** v21: relationship indexing covers every schema-resolvable exact IfcRel*
|
|
151
151
|
* class (#4205). The bytes are unchanged, but cache keys must miss v20 graphs
|
|
152
152
|
* that were produced before those buckets existed. */
|
|
153
|
-
export const FORMAT_VERSION =
|
|
153
|
+
export const FORMAT_VERSION = 28; // v28: parser relationship coverage in the entity-index trailer, #9947;
|
|
154
|
+
// Legacy versions: // v27: optional CoordinateInfo IfcSite world origin, #9480; v26: bytes unchanged, but keys must miss v25 graphs, which may hold a misread relationship edge (`((#10),#14),#40` as "#14 relates #10") that nothing downstream refuses any more, #9192; v25: per-mesh shadingColor/localBounds/localToWorld trailer (sections/mesh-metadata.ts), #7350; v24: optional CoordinateInfo recovery count and length-unit scale, #7239; v23: type/mapped/instanced finishes, #5984
|
|
154
155
|
/** Geometry chunking parameters (v13+). Grouping is a WRITE-side layout
|
|
155
156
|
* policy: readers only trust the directory, so these can change without a
|
|
156
157
|
* format bump. Cell size mirrors the renderer's spatial bucketing default
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;+DAE+D;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAY/D,0BAA0B;AAC1B,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAAC,CAAC,0BAA0B;AAE3D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH;;;;;;GAMG;AACH;;;;;;;;;;GAUG;AACH;;;;;;;;;;GAUG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8EG;AACH;;qFAEqF;AACrF;0DAC0D;AAC1D;;sDAEsD;AACtD,MAAM,CAAC,MAAM,cAAc,GAAG,EAAE,CAAC,CAAC,wEAAwE;AAC1G,+dAA+d;AAE/d;;;yEAGyE;AACzE,MAAM,CAAC,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAC3C,2EAA2E;AAC3E,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AACzD,4EAA4E;AAC5E,MAAM,CAAC,MAAM,iCAAiC,GAAG,EAAE,GAAG,IAAI,CAAC;AAE3D,qDAAqD;AACrD,MAAM,CAAN,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,2DAAQ,CAAA;IACR,qDAAqD;IACrD,uEAAmB,CAAA;AACrB,CAAC,EAJW,kBAAkB,KAAlB,kBAAkB,QAI7B;AAmBD,yCAAyC;AACzC,MAAM,CAAN,IAAY,WAWX;AAXD,WAAY,WAAW;IACrB,mDAAW,CAAA;IACX,qDAAY,CAAA;IACZ,yDAAc,CAAA;IACd,yDAAc,CAAA;IACd,+DAAiB,CAAA;IACjB,qDAAY,CAAA;IACZ,mDAAW,CAAA;IACX,iDAAU,CAAA;IACV,2DAAe,CAAA;IACf,oEAAoB,CAAA;AACtB,CAAC,EAXW,WAAW,KAAX,WAAW,QAWtB;AAED,yBAAyB;AACzB,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,qDAAU,CAAA;IACV,iDAAQ,CAAA;IACR,qDAAU,CAAA;AACZ,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED,mBAAmB;AACnB,MAAM,CAAN,IAAY,WAcX;AAdD,WAAY,WAAW;IACrB,6CAAQ,CAAA;IACR,yDAAmB,CAAA;IACnB,2DAAoB,CAAA;IACpB,yDAAmB,CAAA;IACnB;;;;;;;OAOG;IACH,mEAAwB,CAAA;AAC1B,CAAC,EAdW,WAAW,KAAX,WAAW,QActB;AAED,oBAAoB;AACpB,MAAM,CAAN,IAAY,YAGX;AAHD,WAAY,YAAY;IACtB,+CAAQ,CAAA;IACR,2DAAmB,CAAA;AACrB,CAAC,EAHW,YAAY,KAAZ,YAAY,QAGvB;AAgID,2BAA2B;AAC3B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC;AAE9B,kCAAkC;AAClC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC"}
|
|
@@ -29,6 +29,24 @@ export declare class BufferWriter {
|
|
|
29
29
|
/** Build final buffer */
|
|
30
30
|
build(): ArrayBuffer;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Aligned storage for the 4-byte arrays a reader copies out (mesh positions, normals, indices).
|
|
34
|
+
* Allocating one ArrayBuffer per array was most of a large cache hit's chunk decode in Chrome
|
|
35
|
+
* (~150 vs ~75 ms for Holter-shaped data). Arrays from one arena share ~1 MiB blocks, so a
|
|
36
|
+
* structured clone of one of them copies its whole block: post an owned copy instead.
|
|
37
|
+
*/
|
|
38
|
+
export declare class ArrayArena {
|
|
39
|
+
/** The buffer the last `take` returned an offset into. */
|
|
40
|
+
buffer: ArrayBuffer | null;
|
|
41
|
+
private block;
|
|
42
|
+
private used;
|
|
43
|
+
/** Bytes the caller still expects to take: a new block is no larger than that (a small chunk keeps a small block). */
|
|
44
|
+
private expected;
|
|
45
|
+
/** `capacityHint`: an upper bound of the bytes that will be taken, e.g. a chunk record's decompressed length. */
|
|
46
|
+
constructor(capacityHint?: number);
|
|
47
|
+
/** Reserve `byteLength` bytes at a 4-byte aligned offset; read the buffer from `buffer`. */
|
|
48
|
+
take(byteLength: number): number;
|
|
49
|
+
}
|
|
32
50
|
/**
|
|
33
51
|
* Reader for parsing binary buffers
|
|
34
52
|
*/
|
|
@@ -36,6 +54,8 @@ export declare class BufferReader {
|
|
|
36
54
|
private view;
|
|
37
55
|
private bytes;
|
|
38
56
|
private offset;
|
|
57
|
+
/** When set, 4-byte arrays are copied into it instead of one ArrayBuffer each. */
|
|
58
|
+
arena: ArrayArena | null;
|
|
39
59
|
constructor(buffer: ArrayBuffer);
|
|
40
60
|
get position(): number;
|
|
41
61
|
set position(pos: number);
|
|
@@ -66,6 +86,9 @@ export declare class BufferReader {
|
|
|
66
86
|
readUint8Array(length: number): Uint8Array;
|
|
67
87
|
readUint16Array(length: number): Uint16Array;
|
|
68
88
|
readUint32Array(length: number): Uint32Array;
|
|
89
|
+
private arenaBuffer;
|
|
90
|
+
/** Copy the next `byteLength` bytes into the arena; returns their offset in `arenaBuffer`. */
|
|
91
|
+
private readIntoArena;
|
|
69
92
|
readInt32Array(length: number): Int32Array;
|
|
70
93
|
readFloat32Array(length: number): Float32Array;
|
|
71
94
|
readFloat64Array(length: number): Float64Array;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-utils.d.ts","sourceRoot":"","sources":["../../src/utils/buffer-utils.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAoB;IAClC,OA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I,QAAQ,IAAI,MAAM,CAErB;IAED,IAAI,QAAQ,CAAC,GAAG,EAAE,MAAM,EAEvB;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,eAAe;IASvB,SAAS,IAAI,MAAM;IAKnB,UAAU,IAAI,MAAM;IAOpB,UAAU,IAAI,MAAM;IAOpB,SAAS,IAAI,MAAM;IAOnB,aAAa,IAAI,MAAM;IAOvB,WAAW,IAAI,MAAM;IAOrB,WAAW,IAAI,MAAM;IAOrB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAOrC,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAI1C,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW;IAK5C,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW;IAS5C,OAAO,CAAC,WAAW,CAA4B;IAE/C,8FAA8F;IAC9F,OAAO,CAAC,aAAa;IASrB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,UAAU;IAK1C,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAS9C,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY;IAK9C,UAAU,IAAI,MAAM;IAOpB,iCAAiC;IACjC,KAAK,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAK7B,iBAAiB;IACjB,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;CAG1B;AAED,KAAK,UAAU,GACX,UAAU,GACV,WAAW,GACX,WAAW,GACX,UAAU,GACV,YAAY,GACZ,YAAY,CAAC"}
|
|
@@ -104,6 +104,44 @@ export class BufferWriter {
|
|
|
104
104
|
return result.buffer;
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
|
+
/** Arena block size: one allocation serves many mesh arrays. */
|
|
108
|
+
const ARENA_BLOCK_BYTES = 1 << 20;
|
|
109
|
+
/**
|
|
110
|
+
* Aligned storage for the 4-byte arrays a reader copies out (mesh positions, normals, indices).
|
|
111
|
+
* Allocating one ArrayBuffer per array was most of a large cache hit's chunk decode in Chrome
|
|
112
|
+
* (~150 vs ~75 ms for Holter-shaped data). Arrays from one arena share ~1 MiB blocks, so a
|
|
113
|
+
* structured clone of one of them copies its whole block: post an owned copy instead.
|
|
114
|
+
*/
|
|
115
|
+
export class ArrayArena {
|
|
116
|
+
/** The buffer the last `take` returned an offset into. */
|
|
117
|
+
buffer = null;
|
|
118
|
+
block = null;
|
|
119
|
+
used = 0;
|
|
120
|
+
/** Bytes the caller still expects to take: a new block is no larger than that (a small chunk keeps a small block). */
|
|
121
|
+
expected;
|
|
122
|
+
/** `capacityHint`: an upper bound of the bytes that will be taken, e.g. a chunk record's decompressed length. */
|
|
123
|
+
constructor(capacityHint = Number.POSITIVE_INFINITY) {
|
|
124
|
+
this.expected = capacityHint;
|
|
125
|
+
}
|
|
126
|
+
/** Reserve `byteLength` bytes at a 4-byte aligned offset; read the buffer from `buffer`. */
|
|
127
|
+
take(byteLength) {
|
|
128
|
+
const size = (byteLength + 3) & ~3;
|
|
129
|
+
this.expected = Math.max(0, this.expected - size);
|
|
130
|
+
// A large array gets its own buffer: it would waste most of a block's tail.
|
|
131
|
+
if (size > ARENA_BLOCK_BYTES / 4) {
|
|
132
|
+
this.buffer = new ArrayBuffer(size);
|
|
133
|
+
return 0;
|
|
134
|
+
}
|
|
135
|
+
if (this.block === null || this.used + size > this.block.byteLength) {
|
|
136
|
+
this.block = new ArrayBuffer(Math.min(ARENA_BLOCK_BYTES, size + Math.ceil(this.expected / 4) * 4));
|
|
137
|
+
this.used = 0;
|
|
138
|
+
}
|
|
139
|
+
const byteOffset = this.used;
|
|
140
|
+
this.used += size;
|
|
141
|
+
this.buffer = this.block;
|
|
142
|
+
return byteOffset;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
107
145
|
/**
|
|
108
146
|
* Reader for parsing binary buffers
|
|
109
147
|
*/
|
|
@@ -111,6 +149,8 @@ export class BufferReader {
|
|
|
111
149
|
view;
|
|
112
150
|
bytes;
|
|
113
151
|
offset = 0;
|
|
152
|
+
/** When set, 4-byte arrays are copied into it instead of one ArrayBuffer each. */
|
|
153
|
+
arena = null;
|
|
114
154
|
constructor(buffer) {
|
|
115
155
|
this.view = new DataView(buffer);
|
|
116
156
|
this.bytes = new Uint8Array(buffer);
|
|
@@ -198,14 +238,32 @@ export class BufferReader {
|
|
|
198
238
|
return new Uint16Array(bytes.buffer, bytes.byteOffset, length);
|
|
199
239
|
}
|
|
200
240
|
readUint32Array(length) {
|
|
241
|
+
if (this.arena) {
|
|
242
|
+
const byteOffset = this.readIntoArena(length * 4);
|
|
243
|
+
return new Uint32Array(this.arenaBuffer, byteOffset, length);
|
|
244
|
+
}
|
|
201
245
|
const bytes = this.readBytes(length * 4);
|
|
202
246
|
return new Uint32Array(bytes.buffer, bytes.byteOffset, length);
|
|
203
247
|
}
|
|
248
|
+
arenaBuffer = null;
|
|
249
|
+
/** Copy the next `byteLength` bytes into the arena; returns their offset in `arenaBuffer`. */
|
|
250
|
+
readIntoArena(byteLength) {
|
|
251
|
+
this.ensureAvailable(byteLength);
|
|
252
|
+
const byteOffset = this.arena.take(byteLength);
|
|
253
|
+
const buffer = (this.arenaBuffer = this.arena.buffer);
|
|
254
|
+
new Uint8Array(buffer, byteOffset, byteLength).set(this.bytes.subarray(this.offset, this.offset + byteLength));
|
|
255
|
+
this.offset += byteLength;
|
|
256
|
+
return byteOffset;
|
|
257
|
+
}
|
|
204
258
|
readInt32Array(length) {
|
|
205
259
|
const bytes = this.readBytes(length * 4);
|
|
206
260
|
return new Int32Array(bytes.buffer, bytes.byteOffset, length);
|
|
207
261
|
}
|
|
208
262
|
readFloat32Array(length) {
|
|
263
|
+
if (this.arena) {
|
|
264
|
+
const byteOffset = this.readIntoArena(length * 4);
|
|
265
|
+
return new Float32Array(this.arenaBuffer, byteOffset, length);
|
|
266
|
+
}
|
|
209
267
|
const bytes = this.readBytes(length * 4);
|
|
210
268
|
return new Float32Array(bytes.buffer, bytes.byteOffset, length);
|
|
211
269
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buffer-utils.js","sourceRoot":"","sources":["../../src/utils/buffer-utils.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;GAEG;AAEH;;GAEG;AACH,MAAM,OAAO,YAAY;IACf,MAAM,GAAiB,EAAE,CAAC;IAC1B,YAAY,CAAa;IACzB,IAAI,CAAW;IACf,MAAM,GAAW,CAAC,CAAC;IACnB,SAAS,GAAW,CAAC,CAAC;IAE9B,YAAY,cAAsB,IAAI,GAAG,IAAI;QAC3C,IAAI,CAAC,YAAY,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACrD,CAAC;IAEO,cAAc,CAAC,KAAa;QAClC,IAAI,IAAI,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;YACnD,wCAAwC;YACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;YAC7D,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC;YAE9B,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC1D,IAAI,CAAC,YAAY,GAAG,IAAI,UAAU,CAAC,OAAO,CAAC,CAAC;YAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YACnD,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,UAAU,CAAC,KAAa;QACtB,IA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AAU,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,gBAAgB,CAAC,MAAc;QAC7B,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACzC,OAAO,IAAI,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,UAAU;QACR,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;QAClC,OAAO,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAED,iCAAiC;IACjC,KAAK,CAAC,QAAgB;QACpB,MAAM,OAAO,GAAG,CAAC,QAAQ,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,CAAC,GAAG,QAAQ,CAAC;QACjE,IAAI,CAAC,MAAM,IAAI,OAAO,CAAC;IACzB,CAAC;IAED,iBAAiB;IACjB,IAAI,CAAC,KAAa;QAChB,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ChunkInflate } from '../sections/geometry-chunks.js';
|
|
2
|
+
import { type CompressionWorkerPort } from './geometry-compression-client.js';
|
|
3
|
+
/** A stored chunk that does not inflate: the cache entry is corrupt. */
|
|
4
|
+
export declare class CorruptChunkError extends Error {
|
|
5
|
+
name: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ChunkInflatePoolOptions {
|
|
8
|
+
/** Worker factory; the module worker by default. */
|
|
9
|
+
createWorker?: () => CompressionWorkerPort;
|
|
10
|
+
/** A worker owing replies that answers nothing for this long is treated as failed. */
|
|
11
|
+
stallMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class ChunkInflatePool {
|
|
14
|
+
private readonly lanes;
|
|
15
|
+
private next;
|
|
16
|
+
private fallback;
|
|
17
|
+
private corrupt;
|
|
18
|
+
constructor(size: number, options?: ChunkInflatePoolOptions);
|
|
19
|
+
/** Start every worker now, so they boot while other work runs. */
|
|
20
|
+
start(): this;
|
|
21
|
+
readonly inflate: ChunkInflate;
|
|
22
|
+
/** A chunk the worker's codec refused: corrupt if it fails here too, else the worker cannot inflate. */
|
|
23
|
+
private confirmHere;
|
|
24
|
+
/** True once a worker failed and chunks inflate on the calling thread. */
|
|
25
|
+
get inflatingHere(): boolean;
|
|
26
|
+
close(): void;
|
|
27
|
+
private markCorrupt;
|
|
28
|
+
private useFallback;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=chunk-inflate-pool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-inflate-pool.d.ts","sourceRoot":"","sources":["../../src/workers/chunk-inflate-pool.ts"],"names":[],"mappings":"AA6BA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAgD,KAAK,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAE5H,wEAAwE;AACxE,qBAAa,iBAAkB,SAAQ,KAAK;IACjC,IAAI,SAAuB;CACrC;AAED,MAAM,WAAW,uBAAuB;IACtC,oDAAoD;IACpD,YAAY,CAAC,EAAE,MAAM,qBAAqB,CAAC;IAC3C,sFAAsF;IACtF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAoDD,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,IAAI,CAAK;IACjB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,OAAO,CAAkC;gBAErC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,uBAA4B;IAK/D,kEAAkE;IAClE,KAAK,IAAI,IAAI;IAUb,QAAQ,CAAC,OAAO,EAAE,YAAY,CAqB5B;IAEF,wGAAwG;YAC1F,WAAW;IAYzB,0EAA0E;IAC1E,IAAI,aAAa,IAAI,OAAO,CAA0B;IAEtD,KAAK,IAAI,IAAI;IAIb,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,WAAW;CAOpB"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* Inflates a cache hit's compressed geometry chunks on a few workers, so the
|
|
6
|
+
* deflate-raw decode (DecompressionStream plus its Blob/stream plumbing) does
|
|
7
|
+
* not run on the main thread. Pass `pool.inflate` to `openGeometryChunksV13`.
|
|
8
|
+
* Output is byte-identical: the workers run the same `inflateRaw`.
|
|
9
|
+
*
|
|
10
|
+
* Two kinds of failure, handled differently:
|
|
11
|
+
* - The worker fails (it cannot start, crashes, sends an unreadable or
|
|
12
|
+
* wrong-length reply, or answers nothing for `stallMs` while it owes
|
|
13
|
+
* replies): the pool inflates on the calling thread from then on, including
|
|
14
|
+
* the requests that were in flight. A worker problem costs time, never the load.
|
|
15
|
+
* - A worker's `inflateRaw` threw on a chunk: that one chunk is tried here.
|
|
16
|
+
* If it fails here too, the entry is corrupt: it and every remaining chunk
|
|
17
|
+
* reject at once with `CorruptChunkError`, nothing more is inflated, and the
|
|
18
|
+
* caller's corrupt-entry path (delete the entry, parse fresh) starts without
|
|
19
|
+
* delay. If it inflates here, the worker cannot inflate (its codec
|
|
20
|
+
* environment): the pool falls back as above, and the entry is kept.
|
|
21
|
+
* - A chunk that does not inflate on the calling thread (after a fallback, or
|
|
22
|
+
* with no worker at all) is corrupt too, with the same `CorruptChunkError`.
|
|
23
|
+
*
|
|
24
|
+
* Workers start only on `start()` or the first compressed chunk: a
|
|
25
|
+
* metadata-only entry, or one whose chunks are all stored raw, starts none.
|
|
26
|
+
*/
|
|
27
|
+
import { inflateRaw } from '../sections/geometry-codec.js';
|
|
28
|
+
import { GeometryCompressionSession, WorkerCodecError } from './geometry-compression-client.js';
|
|
29
|
+
/** A stored chunk that does not inflate: the cache entry is corrupt. */
|
|
30
|
+
export class CorruptChunkError extends Error {
|
|
31
|
+
name = 'CorruptChunkError';
|
|
32
|
+
}
|
|
33
|
+
/** No reply for this long while replies are owed: the worker is stuck (a chunk inflates in milliseconds). */
|
|
34
|
+
const STALL_MS = 5000;
|
|
35
|
+
/** A stall timer this late fired after a long main-thread task, which may have queued replies behind it. */
|
|
36
|
+
const LATE_TIMER_MS = 1000;
|
|
37
|
+
class Lane {
|
|
38
|
+
stallMs;
|
|
39
|
+
session;
|
|
40
|
+
owed = 0;
|
|
41
|
+
timer = null;
|
|
42
|
+
constructor(createWorker, stallMs) {
|
|
43
|
+
this.stallMs = stallMs;
|
|
44
|
+
this.session = new GeometryCompressionSession(createWorker);
|
|
45
|
+
}
|
|
46
|
+
async inflate(stored, rawLength) {
|
|
47
|
+
this.owed++;
|
|
48
|
+
this.arm();
|
|
49
|
+
try {
|
|
50
|
+
return await this.session.inflate(stored, rawLength);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
this.owed--;
|
|
54
|
+
this.arm(true);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
close() {
|
|
58
|
+
this.disarm();
|
|
59
|
+
this.session.close();
|
|
60
|
+
}
|
|
61
|
+
/** (Re)start the stall timer while replies are owed; a reply counts as progress. */
|
|
62
|
+
arm(progress = false) {
|
|
63
|
+
if (this.owed === 0 || this.session.failed)
|
|
64
|
+
return this.disarm();
|
|
65
|
+
if (this.timer !== null && !progress)
|
|
66
|
+
return;
|
|
67
|
+
this.disarm();
|
|
68
|
+
const armedAt = performance.now();
|
|
69
|
+
this.timer = setTimeout(() => {
|
|
70
|
+
this.timer = null;
|
|
71
|
+
// Late: the main thread was busy, and replies may be queued behind this task. Look again.
|
|
72
|
+
if (performance.now() - armedAt > this.stallMs + LATE_TIMER_MS)
|
|
73
|
+
return this.arm(true);
|
|
74
|
+
this.session.abort(new Error(`no reply for ${this.stallMs} ms`));
|
|
75
|
+
}, this.stallMs);
|
|
76
|
+
}
|
|
77
|
+
disarm() {
|
|
78
|
+
if (this.timer !== null)
|
|
79
|
+
clearTimeout(this.timer);
|
|
80
|
+
this.timer = null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
export class ChunkInflatePool {
|
|
84
|
+
lanes;
|
|
85
|
+
next = 0;
|
|
86
|
+
fallback = false;
|
|
87
|
+
corrupt = null;
|
|
88
|
+
constructor(size, options = {}) {
|
|
89
|
+
const stallMs = options.stallMs ?? STALL_MS;
|
|
90
|
+
this.lanes = Array.from({ length: Math.max(1, Math.floor(size)) }, () => new Lane(options.createWorker, stallMs));
|
|
91
|
+
}
|
|
92
|
+
/** Start every worker now, so they boot while other work runs. */
|
|
93
|
+
start() {
|
|
94
|
+
if (this.fallback || this.corrupt)
|
|
95
|
+
return this;
|
|
96
|
+
try {
|
|
97
|
+
for (const lane of this.lanes)
|
|
98
|
+
lane.session.start();
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
this.useFallback(error);
|
|
102
|
+
}
|
|
103
|
+
return this;
|
|
104
|
+
}
|
|
105
|
+
inflate = async (stored, rawLength) => {
|
|
106
|
+
if (this.corrupt)
|
|
107
|
+
throw this.corrupt;
|
|
108
|
+
if (!this.fallback) {
|
|
109
|
+
const lane = this.lanes[this.next++ % this.lanes.length];
|
|
110
|
+
try {
|
|
111
|
+
return await lane.inflate(stored, rawLength);
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
if (this.corrupt)
|
|
115
|
+
throw this.corrupt;
|
|
116
|
+
if (error instanceof WorkerCodecError)
|
|
117
|
+
return this.confirmHere(stored, error);
|
|
118
|
+
this.useFallback(error);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
let raw;
|
|
122
|
+
try {
|
|
123
|
+
raw = await inflateRaw(stored);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
// Here, without a worker to blame: the data does not inflate, the entry is corrupt.
|
|
127
|
+
throw this.markCorrupt(error instanceof Error ? error : new Error(String(error)));
|
|
128
|
+
}
|
|
129
|
+
if (this.corrupt)
|
|
130
|
+
throw this.corrupt; // another chunk found the entry corrupt meanwhile
|
|
131
|
+
return raw;
|
|
132
|
+
};
|
|
133
|
+
/** A chunk the worker's codec refused: corrupt if it fails here too, else the worker cannot inflate. */
|
|
134
|
+
async confirmHere(stored, workerError) {
|
|
135
|
+
let raw;
|
|
136
|
+
try {
|
|
137
|
+
raw = await inflateRaw(stored);
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
throw this.markCorrupt(workerError);
|
|
141
|
+
}
|
|
142
|
+
if (this.corrupt)
|
|
143
|
+
throw this.corrupt;
|
|
144
|
+
this.useFallback(workerError);
|
|
145
|
+
return raw;
|
|
146
|
+
}
|
|
147
|
+
/** True once a worker failed and chunks inflate on the calling thread. */
|
|
148
|
+
get inflatingHere() { return this.fallback; }
|
|
149
|
+
close() {
|
|
150
|
+
for (const lane of this.lanes)
|
|
151
|
+
lane.close();
|
|
152
|
+
}
|
|
153
|
+
markCorrupt(error) {
|
|
154
|
+
this.corrupt ??= new CorruptChunkError(`a geometry chunk did not inflate here or on a worker; the cache entry is corrupt (${error.message})`);
|
|
155
|
+
this.close(); // the other workers' requests reject now, as corrupt (checked first above)
|
|
156
|
+
return this.corrupt;
|
|
157
|
+
}
|
|
158
|
+
useFallback(error) {
|
|
159
|
+
if (this.fallback)
|
|
160
|
+
return;
|
|
161
|
+
this.fallback = true;
|
|
162
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
163
|
+
console.warn(`[cache] chunk inflate worker failed (${reason}); inflating the remaining chunks on this thread`);
|
|
164
|
+
this.close();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=chunk-inflate-pool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunk-inflate-pool.js","sourceRoot":"","sources":["../../src/workers/chunk-inflate-pool.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAE3D,OAAO,EAAE,0BAA0B,EAAE,gBAAgB,EAA8B,MAAM,kCAAkC,CAAC;AAE5H,wEAAwE;AACxE,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IACjC,IAAI,GAAG,mBAAmB,CAAC;CACrC;AASD,6GAA6G;AAC7G,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,4GAA4G;AAC5G,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAM,IAAI;IAK8E;IAJ7E,OAAO,CAA6B;IACrC,IAAI,GAAG,CAAC,CAAC;IACT,KAAK,GAAyC,IAAI,CAAC;IAE3D,YAAY,YAAuD,EAAmB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;QACnG,IAAI,CAAC,OAAO,GAAG,IAAI,0BAA0B,CAAC,YAAY,CAAC,CAAC;IAC9D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAkB,EAAE,SAAiB;QACjD,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,GAAG,EAAE,CAAC;QACX,IAAI,CAAC;YACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACvD,CAAC;gBAAS,CAAC;YACT,IAAI,CAAC,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,EAAE,CAAC;QACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAA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B,CAAC;IAEO,WAAW,CAAC,KAAc;QAChC,IAAI,IAAI,CAAC,QAAQ;YAAE,OAAO;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;QACrB,MAAM,MAAM,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACtE,OAAO,CAAC,IAAI,CAAC,wCAAwC,MAAM,kDAAkD,CAAC,CAAC;QAC/G,IAAI,CAAC,KAAK,EAAE,CAAC;IACf,CAAC;CACF"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type { CompressionRequest } from './geometry-compression-protocol.js';
|
|
1
|
+
import type { CompressionRequest, InflateRequest } from './geometry-compression-protocol.js';
|
|
2
|
+
/** The worker's codec threw on a request (the data, or the worker's codec environment), as opposed to the worker itself failing. */
|
|
3
|
+
export declare class WorkerCodecError extends Error {
|
|
4
|
+
name: string;
|
|
5
|
+
}
|
|
2
6
|
type StoredChunk = {
|
|
3
7
|
bytes: Uint8Array<ArrayBuffer>;
|
|
4
8
|
compressed: boolean;
|
|
@@ -7,7 +11,7 @@ export interface CompressionWorkerPort {
|
|
|
7
11
|
onmessage: ((event: MessageEvent<unknown>) => void) | null;
|
|
8
12
|
onerror: ((event: ErrorEvent) => void) | null;
|
|
9
13
|
onmessageerror: ((event: MessageEvent<unknown>) => void) | null;
|
|
10
|
-
postMessage(message: CompressionRequest, transfers: ArrayBuffer[]): void;
|
|
14
|
+
postMessage(message: CompressionRequest | InflateRequest, transfers: ArrayBuffer[]): void;
|
|
11
15
|
terminate(): void;
|
|
12
16
|
}
|
|
13
17
|
/** Private per-write owner. The existing builder bounds requests to four chunks. */
|
|
@@ -19,7 +23,20 @@ export declare class GeometryCompressionSession {
|
|
|
19
23
|
private readonly pending;
|
|
20
24
|
constructor(createWorker?: () => CompressionWorkerPort);
|
|
21
25
|
compress(raw: Uint8Array<ArrayBuffer>): Promise<StoredChunk>;
|
|
26
|
+
/**
|
|
27
|
+
* Inflate one stored deflate-raw chunk off the calling thread. `stored` is
|
|
28
|
+
* copied (a view into the cache entry cannot be transferred); the result must
|
|
29
|
+
* be exactly `rawLength` bytes, the chunk directory's uncompressed length.
|
|
30
|
+
*/
|
|
31
|
+
inflate(stored: Uint8Array, rawLength: number): Promise<Uint8Array<ArrayBuffer>>;
|
|
32
|
+
private request;
|
|
33
|
+
/** Start the worker now (it boots while other work runs); requests start it otherwise. */
|
|
34
|
+
start(): CompressionWorkerPort;
|
|
22
35
|
close(): void;
|
|
36
|
+
/** End the session: the worker stops and every pending request rejects with `error`. */
|
|
37
|
+
abort(error: Error): void;
|
|
38
|
+
/** True once the session ended (closed, aborted or its worker failed). */
|
|
39
|
+
get failed(): boolean;
|
|
23
40
|
private receive;
|
|
24
41
|
private fail;
|
|
25
42
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-compression-client.d.ts","sourceRoot":"","sources":["../../src/workers/geometry-compression-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAuB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"geometry-compression-client.d.ts","sourceRoot":"","sources":["../../src/workers/geometry-compression-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAuB,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAGlH,oIAAoI;AACpI,qBAAa,gBAAiB,SAAQ,KAAK;IAChC,IAAI,SAAsB;CACpC;AAED,KAAK,WAAW,GAAG;IAAE,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,CAAC;IAAC,UAAU,EAAE,OAAO,CAAA;CAAE,CAAC;AAC3E,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC3D,OAAO,EAAE,CAAC,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAC9C,cAAc,EAAE,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IAChE,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,cAAc,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,IAAI,CAAC;IAC1F,SAAS,IAAI,IAAI,CAAC;CACnB;AAED,oFAAoF;AACpF,qBAAa,0BAA0B;IASzB,OAAO,CAAC,QAAQ,CAAC,YAAY;IARzC,OAAO,CAAC,MAAM,CAAC,CAAwB;IACvC,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,OAAO,CAAC,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAGnB;gBAEwB,YAAY,GAAE,MAAM,qBAC6C;IAE9F,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;IAQ5D;;;;OAIG;IACH,OAAO,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAIhF,OAAO,CAAC,OAAO;IAaf,0FAA0F;IAC1F,KAAK,IAAI,qBAAqB;IAc9B,KAAK,IAAI,IAAI;IAIb,wFAAwF;IACxF,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAIzB,0EAA0E;IAC1E,IAAI,MAAM,IAAI,OAAO,CAAuC;IAE5D,OAAO,CAAC,OAAO;IAmCf,OAAO,CAAC,IAAI;CAYb"}
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
4
|
import { accountWorkerMessages } from '@ifc-lite/load-trace';
|
|
5
|
+
/** The worker's codec threw on a request (the data, or the worker's codec environment), as opposed to the worker itself failing. */
|
|
6
|
+
export class WorkerCodecError extends Error {
|
|
7
|
+
name = 'WorkerCodecError';
|
|
8
|
+
}
|
|
5
9
|
/** Private per-write owner. The existing builder bounds requests to four chunks. */
|
|
6
10
|
export class GeometryCompressionSession {
|
|
7
11
|
createWorker;
|
|
@@ -14,33 +18,58 @@ export class GeometryCompressionSession {
|
|
|
14
18
|
}
|
|
15
19
|
compress(raw) {
|
|
16
20
|
if (this.failure)
|
|
17
|
-
return Promise.reject(this.failure);
|
|
21
|
+
return Promise.reject(this.failure); // the session's own failure comes first, as before
|
|
18
22
|
if (raw.byteOffset !== 0 || raw.byteLength !== raw.buffer.byteLength) {
|
|
19
23
|
return Promise.reject(new Error('Geometry compression requires an owned whole buffer'));
|
|
20
24
|
}
|
|
25
|
+
return this.request(raw.buffer, false, raw.byteLength);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Inflate one stored deflate-raw chunk off the calling thread. `stored` is
|
|
29
|
+
* copied (a view into the cache entry cannot be transferred); the result must
|
|
30
|
+
* be exactly `rawLength` bytes, the chunk directory's uncompressed length.
|
|
31
|
+
*/
|
|
32
|
+
inflate(stored, rawLength) {
|
|
33
|
+
return this.request(stored.slice().buffer, true, rawLength).then((chunk) => chunk.bytes);
|
|
34
|
+
}
|
|
35
|
+
request(buffer, inflate, length) {
|
|
36
|
+
if (this.failure)
|
|
37
|
+
return Promise.reject(this.failure);
|
|
21
38
|
return new Promise((resolve, reject) => {
|
|
22
39
|
const id = ++this.nextId;
|
|
23
|
-
this.pending.set(id, { length
|
|
40
|
+
this.pending.set(id, { length, inflate, resolve, reject });
|
|
24
41
|
try {
|
|
25
|
-
|
|
26
|
-
this.worker = accountWorkerMessages(this.createWorker(), 'cacheCompression'); // #6957
|
|
27
|
-
this.worker.onmessage = event => this.receive(event.data);
|
|
28
|
-
this.worker.onerror = event => {
|
|
29
|
-
event.preventDefault();
|
|
30
|
-
this.fail(new Error(`Geometry compression worker failed: ${event.message}`));
|
|
31
|
-
};
|
|
32
|
-
this.worker.onmessageerror = () => this.fail(new Error('Geometry compression response could not be decoded'));
|
|
33
|
-
}
|
|
34
|
-
this.worker.postMessage({ id, buffer: raw.buffer }, [raw.buffer]);
|
|
42
|
+
this.start().postMessage(inflate ? { id, op: 'inflate', buffer } : { id, buffer }, [buffer]);
|
|
35
43
|
}
|
|
36
44
|
catch (error) {
|
|
37
45
|
this.fail(error instanceof Error ? error : new Error(String(error)));
|
|
38
46
|
}
|
|
39
47
|
});
|
|
40
48
|
}
|
|
49
|
+
/** Start the worker now (it boots while other work runs); requests start it otherwise. */
|
|
50
|
+
start() {
|
|
51
|
+
if (this.failure)
|
|
52
|
+
throw this.failure;
|
|
53
|
+
if (!this.worker) {
|
|
54
|
+
this.worker = accountWorkerMessages(this.createWorker(), 'cacheCompression'); // #6957
|
|
55
|
+
this.worker.onmessage = event => this.receive(event.data);
|
|
56
|
+
this.worker.onerror = event => {
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
this.fail(new Error(`Geometry compression worker failed: ${event.message}`));
|
|
59
|
+
};
|
|
60
|
+
this.worker.onmessageerror = () => this.fail(new Error('Geometry compression response could not be decoded'));
|
|
61
|
+
}
|
|
62
|
+
return this.worker;
|
|
63
|
+
}
|
|
41
64
|
close() {
|
|
42
65
|
this.fail(new Error('Geometry compression session closed'));
|
|
43
66
|
}
|
|
67
|
+
/** End the session: the worker stops and every pending request rejects with `error`. */
|
|
68
|
+
abort(error) {
|
|
69
|
+
this.fail(error);
|
|
70
|
+
}
|
|
71
|
+
/** True once the session ended (closed, aborted or its worker failed). */
|
|
72
|
+
get failed() { return this.failure !== undefined; }
|
|
44
73
|
receive(value) {
|
|
45
74
|
if (!value || typeof value !== 'object') {
|
|
46
75
|
this.fail(new Error('Invalid geometry compression response'));
|
|
@@ -53,14 +82,22 @@ export class GeometryCompressionSession {
|
|
|
53
82
|
return;
|
|
54
83
|
}
|
|
55
84
|
if ('error' in response) {
|
|
56
|
-
|
|
85
|
+
// An inflate's codec error is about that chunk's data: reject it alone and keep the worker
|
|
86
|
+
// (its handler caught the throw). A compress error still ends the session, as before.
|
|
87
|
+
if (pending.inflate) {
|
|
88
|
+
this.pending.delete(response.id);
|
|
89
|
+
pending.reject(new WorkerCodecError(`Chunk inflate failed in the worker: ${String(response.error)}`));
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
this.fail(new WorkerCodecError(`Geometry compression failed: ${String(response.error)}`));
|
|
57
93
|
return;
|
|
58
94
|
}
|
|
59
95
|
if (!('buffer' in response) || !(response.buffer instanceof ArrayBuffer)
|
|
60
96
|
|| typeof response.compressed !== 'boolean'
|
|
61
|
-
|| (response.compressed
|
|
62
|
-
|| (response.compressed
|
|
63
|
-
|
|
97
|
+
|| (pending.inflate && (response.compressed || response.buffer.byteLength !== pending.length))
|
|
98
|
+
|| (!pending.inflate && response.compressed && response.buffer.byteLength === 0)
|
|
99
|
+
|| (!pending.inflate && (response.compressed ? response.buffer.byteLength >= pending.length
|
|
100
|
+
: response.buffer.byteLength !== pending.length))) {
|
|
64
101
|
this.fail(new Error('Invalid geometry compression result length or flags'));
|
|
65
102
|
return;
|
|
66
103
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-compression-client.js","sourceRoot":"","sources":["../../src/workers/geometry-compression-client.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"geometry-compression-client.js","sourceRoot":"","sources":["../../src/workers/geometry-compression-client.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAG/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,oIAAoI;AACpI,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IAChC,IAAI,GAAG,kBAAkB,CAAC;CACpC;AAWD,oFAAoF;AACpF,MAAM,OAAO,0BAA0B;IASR;IARrB,MAAM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IAAI,CAAC,KAAY;QACvB,IAAI,IAAI,CAAC,OAAO;YAAE,OAAO;QACzB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC;QACxB,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,SAAS,GAAG,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,cAAc,GAAG,IAAI,CAAC;YACjE,MAAM,CAAC,SAAS,EAAE,CAAC;QACrB,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE;YAAE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnE,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geometry-compression-handler.d.ts","sourceRoot":"","sources":["../../src/workers/geometry-compression-handler.ts"],"names":[],"mappings":"AAKA,OAAO,
|
|
1
|
+
{"version":3,"file":"geometry-compression-handler.d.ts","sourceRoot":"","sources":["../../src/workers/geometry-compression-handler.ts"],"names":[],"mappings":"AAKA,OAAO,EAA0C,KAAK,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAEtH,sFAAsF;AACtF,wBAAsB,wBAAwB,CAC5C,KAAK,EAAE,OAAO,EACd,IAAI,EAAE,CAAC,QAAQ,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,EAAE,KAAK,IAAI,GACtE,OAAO,CAAC,IAAI,CAAC,CAiBf"}
|
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
2
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
3
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
-
import { chooseStoredGeometryChunk } from '../sections/geometry-codec.js';
|
|
5
|
-
import { isCompressionRequest } from './geometry-compression-protocol.js';
|
|
4
|
+
import { chooseStoredGeometryChunk, inflateRaw } from '../sections/geometry-codec.js';
|
|
5
|
+
import { isCompressionRequest, isInflateRequest } from './geometry-compression-protocol.js';
|
|
6
6
|
/** Canonical codec handler shared by the real worker and transport contract tests. */
|
|
7
7
|
export async function handleCompressionRequest(value, send) {
|
|
8
|
+
if (isInflateRequest(value)) {
|
|
9
|
+
try {
|
|
10
|
+
const raw = await inflateRaw(new Uint8Array(value.buffer));
|
|
11
|
+
send({ id: value.id, buffer: raw.buffer, compressed: false }, [raw.buffer]);
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
send({ id: value.id, error: error instanceof Error ? error.message : String(error) }, []);
|
|
15
|
+
}
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
8
18
|
if (!isCompressionRequest(value))
|
|
9
19
|
throw new Error('Invalid geometry compression request');
|
|
10
20
|
try {
|