@ifc-lite/geometry 1.19.0 → 2.0.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/dist/geometry-coordinate.d.ts +0 -5
- package/dist/geometry-coordinate.d.ts.map +1 -1
- package/dist/geometry-coordinate.js +0 -19
- package/dist/geometry-coordinate.js.map +1 -1
- package/dist/geometry-parallel.d.ts +4 -26
- package/dist/geometry-parallel.d.ts.map +1 -1
- package/dist/geometry-parallel.js +5 -23
- package/dist/geometry-parallel.js.map +1 -1
- package/dist/geometry.worker.d.ts +0 -1
- package/dist/geometry.worker.d.ts.map +1 -1
- package/dist/geometry.worker.js.map +1 -1
- package/dist/ifc-lite-bridge.d.ts +2 -58
- package/dist/ifc-lite-bridge.d.ts.map +1 -1
- package/dist/ifc-lite-bridge.js +5 -127
- package/dist/ifc-lite-bridge.js.map +1 -1
- package/dist/index.d.ts +17 -46
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +100 -293
- package/dist/index.js.map +1 -1
- package/dist/platform-bridge.d.ts +6 -3
- package/dist/platform-bridge.d.ts.map +1 -1
- package/dist/platform-bridge.js +7 -7
- package/dist/platform-bridge.js.map +1 -1
- package/dist/progressive-loader.d.ts +5 -56
- package/dist/progressive-loader.d.ts.map +1 -1
- package/dist/progressive-loader.js +7 -132
- package/dist/progressive-loader.js.map +1 -1
- package/dist/types.d.ts +0 -29
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -14
- package/dist/default-materials.d.ts +0 -22
- package/dist/default-materials.d.ts.map +0 -1
- package/dist/default-materials.js +0 -124
- package/dist/default-materials.js.map +0 -1
- package/dist/geometry-controller.worker.d.ts +0 -4
- package/dist/geometry-controller.worker.d.ts.map +0 -1
- package/dist/geometry-controller.worker.js +0 -402
- package/dist/geometry-controller.worker.js.map +0 -1
- package/dist/geometry-deduplicator.d.ts +0 -42
- package/dist/geometry-deduplicator.d.ts.map +0 -1
- package/dist/geometry-deduplicator.js +0 -80
- package/dist/geometry-deduplicator.js.map +0 -1
- package/dist/ifc-lite-mesh-collector.d.ts +0 -111
- package/dist/ifc-lite-mesh-collector.d.ts.map +0 -1
- package/dist/ifc-lite-mesh-collector.js +0 -455
- package/dist/ifc-lite-mesh-collector.js.map +0 -1
- package/dist/lod.d.ts +0 -60
- package/dist/lod.d.ts.map +0 -1
- package/dist/lod.js +0 -113
- package/dist/lod.js.map +0 -1
- package/dist/style-cache.d.ts +0 -36
- package/dist/style-cache.d.ts.map +0 -1
- package/dist/style-cache.js +0 -127
- package/dist/style-cache.js.map +0 -1
- package/dist/wasm-bridge.d.ts +0 -22
- package/dist/wasm-bridge.d.ts.map +0 -1
- package/dist/wasm-bridge.js +0 -120
- package/dist/wasm-bridge.js.map +0 -1
- package/dist/wasm-memory-manager.d.ts +0 -178
- package/dist/wasm-memory-manager.d.ts.map +0 -1
- package/dist/wasm-memory-manager.js +0 -86
- package/dist/wasm-memory-manager.js.map +0 -1
- package/dist/zero-copy-collector.d.ts +0 -158
- package/dist/zero-copy-collector.d.ts.map +0 -1
- package/dist/zero-copy-collector.js +0 -224
- package/dist/zero-copy-collector.js.map +0 -1
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-Copy Mesh Collector - streams GPU-ready geometry with zero-copy access
|
|
3
|
-
*
|
|
4
|
-
* This collector uses the new GPU geometry API that:
|
|
5
|
-
* - Pre-interleaves vertex data (position + normal)
|
|
6
|
-
* - Pre-converts coordinates (Z-up to Y-up)
|
|
7
|
-
* - Exposes pointers for direct WASM memory access
|
|
8
|
-
*
|
|
9
|
-
* The collector provides TypedArray views into WASM memory. The caller
|
|
10
|
-
* is responsible for uploading to GPU (use @ifc-lite/renderer's ZeroCopyGpuUploader).
|
|
11
|
-
*
|
|
12
|
-
* IMPORTANT: Views become INVALID when WASM memory grows!
|
|
13
|
-
* Use the "immediate upload" pattern - create view, upload, discard.
|
|
14
|
-
*/
|
|
15
|
-
import type { IfcAPI } from '@ifc-lite/wasm';
|
|
16
|
-
import { WasmMemoryManager } from './wasm-memory-manager.js';
|
|
17
|
-
export interface ZeroCopyStreamingProgress {
|
|
18
|
-
percent: number;
|
|
19
|
-
processed: number;
|
|
20
|
-
total?: number;
|
|
21
|
-
phase: 'simple' | 'simple_complete' | 'complex' | 'complete';
|
|
22
|
-
}
|
|
23
|
-
export interface ZeroCopyBatchResult {
|
|
24
|
-
/** Number of meshes in this batch */
|
|
25
|
-
meshCount: number;
|
|
26
|
-
/** Total vertices in this batch */
|
|
27
|
-
vertexCount: number;
|
|
28
|
-
/** Total triangles in this batch */
|
|
29
|
-
triangleCount: number;
|
|
30
|
-
}
|
|
31
|
-
export interface ZeroCopyCompleteStats {
|
|
32
|
-
totalMeshes: number;
|
|
33
|
-
totalVertices: number;
|
|
34
|
-
totalTriangles: number;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Mesh metadata for draw calls and selection
|
|
38
|
-
*/
|
|
39
|
-
export interface ZeroCopyMeshMetadata {
|
|
40
|
-
expressId: number;
|
|
41
|
-
vertexOffset: number;
|
|
42
|
-
vertexCount: number;
|
|
43
|
-
indexOffset: number;
|
|
44
|
-
indexCount: number;
|
|
45
|
-
color: [number, number, number, number];
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* Batch of geometry data with zero-copy views
|
|
49
|
-
*/
|
|
50
|
-
export interface ZeroCopyBatch {
|
|
51
|
-
/** View into WASM memory for vertex data (interleaved pos+normal) */
|
|
52
|
-
vertexView: Float32Array;
|
|
53
|
-
/** View into WASM memory for index data */
|
|
54
|
-
indexView: Uint32Array;
|
|
55
|
-
/** Byte length of vertex data (for GPU buffer creation) */
|
|
56
|
-
vertexByteLength: number;
|
|
57
|
-
/** Byte length of index data */
|
|
58
|
-
indexByteLength: number;
|
|
59
|
-
/** Mesh metadata for draw calls */
|
|
60
|
-
meshMetadata: ZeroCopyMeshMetadata[];
|
|
61
|
-
/** Batch statistics */
|
|
62
|
-
stats: ZeroCopyBatchResult;
|
|
63
|
-
/** Free WASM memory (call after uploading to GPU!) */
|
|
64
|
-
free: () => void;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Zero-copy mesh collector that streams GPU-ready geometry batches
|
|
68
|
-
*
|
|
69
|
-
* Usage:
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const collector = new ZeroCopyMeshCollector(ifcApi, content);
|
|
72
|
-
*
|
|
73
|
-
* for await (const batch of collector.streamBatches()) {
|
|
74
|
-
* // Create GPU buffers
|
|
75
|
-
* const vertexBuffer = device.createBuffer({
|
|
76
|
-
* size: batch.vertexByteLength,
|
|
77
|
-
* usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
78
|
-
* });
|
|
79
|
-
*
|
|
80
|
-
* // Upload directly from WASM memory (single copy!)
|
|
81
|
-
* device.queue.writeBuffer(vertexBuffer, 0, batch.vertexView);
|
|
82
|
-
*
|
|
83
|
-
* // IMPORTANT: Free after upload!
|
|
84
|
-
* batch.free();
|
|
85
|
-
* }
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
export declare class ZeroCopyMeshCollector {
|
|
89
|
-
private ifcApi;
|
|
90
|
-
private content;
|
|
91
|
-
private memoryManager;
|
|
92
|
-
constructor(ifcApi: IfcAPI, content: string);
|
|
93
|
-
/**
|
|
94
|
-
* Stream geometry batches with zero-copy views into WASM memory
|
|
95
|
-
*
|
|
96
|
-
* @param batchSize Number of meshes per batch (default: 25)
|
|
97
|
-
* @yields Batches with views into WASM memory
|
|
98
|
-
*/
|
|
99
|
-
streamBatches(batchSize?: number): AsyncGenerator<ZeroCopyBatch>;
|
|
100
|
-
/**
|
|
101
|
-
* Parse all geometry at once (for smaller files)
|
|
102
|
-
*
|
|
103
|
-
* @returns Batch with views into WASM memory
|
|
104
|
-
*/
|
|
105
|
-
parseAll(): ZeroCopyBatch;
|
|
106
|
-
/**
|
|
107
|
-
* Get WASM memory manager for advanced use cases
|
|
108
|
-
*/
|
|
109
|
-
getMemoryManager(): WasmMemoryManager;
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Instanced geometry batch with zero-copy views
|
|
113
|
-
*/
|
|
114
|
-
export interface ZeroCopyInstancedBatch {
|
|
115
|
-
geometryId: bigint;
|
|
116
|
-
/** View into WASM memory for vertex data */
|
|
117
|
-
vertexView: Float32Array;
|
|
118
|
-
/** View into WASM memory for index data */
|
|
119
|
-
indexView: Uint32Array;
|
|
120
|
-
/** View into WASM memory for instance data [transform(16) + color(4)] */
|
|
121
|
-
instanceView: Float32Array;
|
|
122
|
-
/** Express IDs for each instance */
|
|
123
|
-
expressIds: number[];
|
|
124
|
-
/** Byte lengths for GPU buffer creation */
|
|
125
|
-
vertexByteLength: number;
|
|
126
|
-
indexByteLength: number;
|
|
127
|
-
instanceByteLength: number;
|
|
128
|
-
/** Statistics */
|
|
129
|
-
indexCount: number;
|
|
130
|
-
instanceCount: number;
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Zero-copy instanced geometry collector
|
|
134
|
-
*/
|
|
135
|
-
export declare class ZeroCopyInstancedCollector {
|
|
136
|
-
private ifcApi;
|
|
137
|
-
private content;
|
|
138
|
-
private memoryManager;
|
|
139
|
-
constructor(ifcApi: IfcAPI, content: string);
|
|
140
|
-
/**
|
|
141
|
-
* Parse instanced geometry with zero-copy views
|
|
142
|
-
*
|
|
143
|
-
* @returns Array of instanced geometry batches
|
|
144
|
-
*/
|
|
145
|
-
parseAll(): {
|
|
146
|
-
batches: ZeroCopyInstancedBatch[];
|
|
147
|
-
stats: {
|
|
148
|
-
geometryCount: number;
|
|
149
|
-
totalInstances: number;
|
|
150
|
-
};
|
|
151
|
-
free: () => void;
|
|
152
|
-
};
|
|
153
|
-
/**
|
|
154
|
-
* Get WASM memory manager for advanced use cases
|
|
155
|
-
*/
|
|
156
|
-
getMemoryManager(): WasmMemoryManager;
|
|
157
|
-
}
|
|
158
|
-
//# sourceMappingURL=zero-copy-collector.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AClC,KAAK,EAAE;YAAE,aAAa,EAAE,MAAM,CAAC;YAAC,cAAc,EAAE,MAAM,CAAA;SAAE,CAAC;QACzD,IAAI,EAAE,MAAM,IAAI,CAAC;KAClB;IAgFD;;OAEG;IACH,gBAAgB,IAAI,iBAAiB;CAGtC"}
|
|
@@ -1,224 +0,0 @@
|
|
|
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
|
-
import { WasmMemoryManager } from './wasm-memory-manager.js';
|
|
5
|
-
/**
|
|
6
|
-
* Zero-copy mesh collector that streams GPU-ready geometry batches
|
|
7
|
-
*
|
|
8
|
-
* Usage:
|
|
9
|
-
* ```typescript
|
|
10
|
-
* const collector = new ZeroCopyMeshCollector(ifcApi, content);
|
|
11
|
-
*
|
|
12
|
-
* for await (const batch of collector.streamBatches()) {
|
|
13
|
-
* // Create GPU buffers
|
|
14
|
-
* const vertexBuffer = device.createBuffer({
|
|
15
|
-
* size: batch.vertexByteLength,
|
|
16
|
-
* usage: GPUBufferUsage.VERTEX | GPUBufferUsage.COPY_DST,
|
|
17
|
-
* });
|
|
18
|
-
*
|
|
19
|
-
* // Upload directly from WASM memory (single copy!)
|
|
20
|
-
* device.queue.writeBuffer(vertexBuffer, 0, batch.vertexView);
|
|
21
|
-
*
|
|
22
|
-
* // IMPORTANT: Free after upload!
|
|
23
|
-
* batch.free();
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*/
|
|
27
|
-
export class ZeroCopyMeshCollector {
|
|
28
|
-
ifcApi;
|
|
29
|
-
content;
|
|
30
|
-
memoryManager;
|
|
31
|
-
constructor(ifcApi, content) {
|
|
32
|
-
this.ifcApi = ifcApi;
|
|
33
|
-
this.content = content;
|
|
34
|
-
// Get WASM memory for zero-copy access
|
|
35
|
-
const wasmMemory = ifcApi.getMemory();
|
|
36
|
-
this.memoryManager = new WasmMemoryManager(wasmMemory);
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Stream geometry batches with zero-copy views into WASM memory
|
|
40
|
-
*
|
|
41
|
-
* @param batchSize Number of meshes per batch (default: 25)
|
|
42
|
-
* @yields Batches with views into WASM memory
|
|
43
|
-
*/
|
|
44
|
-
async *streamBatches(batchSize = 25) {
|
|
45
|
-
// Queue to hold batches from async callback
|
|
46
|
-
const batchQueue = [];
|
|
47
|
-
let resolveWaiting = null;
|
|
48
|
-
let isComplete = false;
|
|
49
|
-
// Start async processing
|
|
50
|
-
const processingPromise = this.ifcApi.parseToGpuGeometryAsync(this.content, {
|
|
51
|
-
batchSize,
|
|
52
|
-
onBatch: (gpuGeom, _progress) => {
|
|
53
|
-
batchQueue.push(gpuGeom);
|
|
54
|
-
if (resolveWaiting) {
|
|
55
|
-
resolveWaiting();
|
|
56
|
-
resolveWaiting = null;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
onComplete: (_stats) => {
|
|
60
|
-
isComplete = true;
|
|
61
|
-
if (resolveWaiting) {
|
|
62
|
-
resolveWaiting();
|
|
63
|
-
resolveWaiting = null;
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
|
-
// Process batches as they arrive
|
|
68
|
-
while (true) {
|
|
69
|
-
while (batchQueue.length > 0) {
|
|
70
|
-
const gpuGeom = batchQueue.shift();
|
|
71
|
-
// Create zero-copy views into WASM memory
|
|
72
|
-
const vertexView = this.memoryManager.createFloat32View(gpuGeom.vertexDataPtr, gpuGeom.vertexDataLen);
|
|
73
|
-
const indexView = this.memoryManager.createUint32View(gpuGeom.indicesPtr, gpuGeom.indicesLen);
|
|
74
|
-
// Extract mesh metadata
|
|
75
|
-
const meshMetadata = [];
|
|
76
|
-
for (let i = 0; i < gpuGeom.meshCount; i++) {
|
|
77
|
-
const meta = gpuGeom.getMeshMetadata(i);
|
|
78
|
-
if (meta) {
|
|
79
|
-
meshMetadata.push({
|
|
80
|
-
expressId: meta.expressId,
|
|
81
|
-
vertexOffset: meta.vertexOffset,
|
|
82
|
-
vertexCount: meta.vertexCount,
|
|
83
|
-
indexOffset: meta.indexOffset,
|
|
84
|
-
indexCount: meta.indexCount,
|
|
85
|
-
color: meta.color,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
yield {
|
|
90
|
-
vertexView,
|
|
91
|
-
indexView,
|
|
92
|
-
vertexByteLength: gpuGeom.vertexDataByteLength,
|
|
93
|
-
indexByteLength: gpuGeom.indicesByteLength,
|
|
94
|
-
meshMetadata,
|
|
95
|
-
stats: {
|
|
96
|
-
meshCount: gpuGeom.meshCount,
|
|
97
|
-
vertexCount: gpuGeom.totalVertexCount,
|
|
98
|
-
triangleCount: gpuGeom.totalTriangleCount,
|
|
99
|
-
},
|
|
100
|
-
free: () => gpuGeom.free(),
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (isComplete && batchQueue.length === 0)
|
|
104
|
-
break;
|
|
105
|
-
// Wait for more batches
|
|
106
|
-
await new Promise((resolve) => {
|
|
107
|
-
resolveWaiting = resolve;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
await processingPromise;
|
|
111
|
-
}
|
|
112
|
-
/**
|
|
113
|
-
* Parse all geometry at once (for smaller files)
|
|
114
|
-
*
|
|
115
|
-
* @returns Batch with views into WASM memory
|
|
116
|
-
*/
|
|
117
|
-
parseAll() {
|
|
118
|
-
// Get GPU-ready geometry from WASM
|
|
119
|
-
const gpuGeom = this.ifcApi.parseToGpuGeometry(this.content);
|
|
120
|
-
// Create zero-copy views
|
|
121
|
-
const vertexView = this.memoryManager.createFloat32View(gpuGeom.vertexDataPtr, gpuGeom.vertexDataLen);
|
|
122
|
-
const indexView = this.memoryManager.createUint32View(gpuGeom.indicesPtr, gpuGeom.indicesLen);
|
|
123
|
-
// Extract mesh metadata
|
|
124
|
-
const meshMetadata = [];
|
|
125
|
-
for (let i = 0; i < gpuGeom.meshCount; i++) {
|
|
126
|
-
const meta = gpuGeom.getMeshMetadata(i);
|
|
127
|
-
if (meta) {
|
|
128
|
-
meshMetadata.push({
|
|
129
|
-
expressId: meta.expressId,
|
|
130
|
-
vertexOffset: meta.vertexOffset,
|
|
131
|
-
vertexCount: meta.vertexCount,
|
|
132
|
-
indexOffset: meta.indexOffset,
|
|
133
|
-
indexCount: meta.indexCount,
|
|
134
|
-
color: meta.color,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
return {
|
|
139
|
-
vertexView,
|
|
140
|
-
indexView,
|
|
141
|
-
vertexByteLength: gpuGeom.vertexDataByteLength,
|
|
142
|
-
indexByteLength: gpuGeom.indicesByteLength,
|
|
143
|
-
meshMetadata,
|
|
144
|
-
stats: {
|
|
145
|
-
meshCount: gpuGeom.meshCount,
|
|
146
|
-
vertexCount: gpuGeom.totalVertexCount,
|
|
147
|
-
triangleCount: gpuGeom.totalTriangleCount,
|
|
148
|
-
},
|
|
149
|
-
free: () => gpuGeom.free(),
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Get WASM memory manager for advanced use cases
|
|
154
|
-
*/
|
|
155
|
-
getMemoryManager() {
|
|
156
|
-
return this.memoryManager;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Zero-copy instanced geometry collector
|
|
161
|
-
*/
|
|
162
|
-
export class ZeroCopyInstancedCollector {
|
|
163
|
-
ifcApi;
|
|
164
|
-
content;
|
|
165
|
-
memoryManager;
|
|
166
|
-
constructor(ifcApi, content) {
|
|
167
|
-
this.ifcApi = ifcApi;
|
|
168
|
-
this.content = content;
|
|
169
|
-
const wasmMemory = ifcApi.getMemory();
|
|
170
|
-
this.memoryManager = new WasmMemoryManager(wasmMemory);
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* Parse instanced geometry with zero-copy views
|
|
174
|
-
*
|
|
175
|
-
* @returns Array of instanced geometry batches
|
|
176
|
-
*/
|
|
177
|
-
parseAll() {
|
|
178
|
-
const collection = this.ifcApi.parseToGpuInstancedGeometry(this.content);
|
|
179
|
-
const batches = [];
|
|
180
|
-
let totalInstances = 0;
|
|
181
|
-
for (let i = 0; i < collection.length; i++) {
|
|
182
|
-
const geomRef = collection.getRef(i);
|
|
183
|
-
if (!geomRef)
|
|
184
|
-
continue;
|
|
185
|
-
// Create zero-copy views
|
|
186
|
-
const vertexView = this.memoryManager.createFloat32View(geomRef.vertexDataPtr, geomRef.vertexDataLen);
|
|
187
|
-
const indexView = this.memoryManager.createUint32View(geomRef.indicesPtr, geomRef.indicesLen);
|
|
188
|
-
const instanceView = this.memoryManager.createFloat32View(geomRef.instanceDataPtr, geomRef.instanceDataLen);
|
|
189
|
-
const expressIdsView = this.memoryManager.createUint32View(geomRef.instanceExpressIdsPtr, geomRef.instanceCount);
|
|
190
|
-
batches.push({
|
|
191
|
-
geometryId: geomRef.geometryId,
|
|
192
|
-
vertexView,
|
|
193
|
-
indexView,
|
|
194
|
-
instanceView,
|
|
195
|
-
expressIds: Array.from(expressIdsView),
|
|
196
|
-
vertexByteLength: geomRef.vertexDataByteLength,
|
|
197
|
-
indexByteLength: geomRef.indicesByteLength,
|
|
198
|
-
instanceByteLength: geomRef.instanceDataByteLength,
|
|
199
|
-
indexCount: geomRef.indicesLen,
|
|
200
|
-
instanceCount: geomRef.instanceCount,
|
|
201
|
-
});
|
|
202
|
-
totalInstances += geomRef.instanceCount;
|
|
203
|
-
}
|
|
204
|
-
return {
|
|
205
|
-
batches,
|
|
206
|
-
stats: {
|
|
207
|
-
geometryCount: collection.length,
|
|
208
|
-
totalInstances,
|
|
209
|
-
},
|
|
210
|
-
free: () => {
|
|
211
|
-
if (typeof collection.free === 'function') {
|
|
212
|
-
collection.free();
|
|
213
|
-
}
|
|
214
|
-
},
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
/**
|
|
218
|
-
* Get WASM memory manager for advanced use cases
|
|
219
|
-
*/
|
|
220
|
-
getMemoryManager() {
|
|
221
|
-
return this.memoryManager;
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
//# sourceMappingURL=zero-copy-collector.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"zero-copy-collector.js","sourceRoot":"","sources":["../src/zero-copy-collector.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAkB/D,OAAO,EAAE,iBAAiB,EAA0B,MAAM,0BAA0B,CAAC;AAwDrF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,qBAAqB;IACxB,MAAM,CAAS;IACf,OAAO,CAAS;IAChB,aAAa,CAAoB;IAEzC,YAAY,MAAc,EAAE,OAAe;QACzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,uCAAuC;QACvC,MAAM,UAAU,GAAG,MAAM,CAAC,SAAS,EAA6B,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,IAAI,iBAAiB,CAAC,UAAU,CAAC,CAAC;IACzD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,CAAC,aAAa,CAAC,YAAoB,EAAE;QACzC,4CAA4C;QAC5C,MAAM,UAAU,GAAwB,EAAE,CAAC;QAC3C,IAAI,cAAc,GAAwB,IAAI,CAAC;QAC/C,IAAI,UAAU,GAAG,KAAK,CAAC;QASvB,yBAAyB;QACzB,MAAM,iBAAiB,GAAI,IAAI,CAAC,MAE9B,CAAC,uBAAuB,CAAC,IAAI,CAAC,OAAO,EAAE;YACvC,SAAS;YACT,OAAO,EAAE,CAAC,OAA0B,EAAE,SAAoC,EAAE,EAAE;gBAC5E,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEzB,IAAI,cAAc,EAAE,CAAC;oBACnB,cAAc,EAAE,CAAC;oBACjB,cAAc,GAAG,IAAI,CAAC;gBACxB,CAAC;YACH,CAAC;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