@ifc-lite/parser 3.15.0 → 4.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/block-store.d.ts +95 -0
- package/dist/block-store.d.ts.map +1 -0
- package/dist/block-store.js +285 -0
- package/dist/block-store.js.map +1 -0
- package/dist/classification-resolver.d.ts +16 -0
- package/dist/classification-resolver.d.ts.map +1 -1
- package/dist/classification-resolver.js +35 -0
- package/dist/classification-resolver.js.map +1 -1
- package/dist/columnar-parser.d.ts +13 -2
- package/dist/columnar-parser.d.ts.map +1 -1
- package/dist/columnar-parser.js +16 -3
- package/dist/columnar-parser.js.map +1 -1
- package/dist/data-store-transport.d.ts +2 -1
- package/dist/data-store-transport.d.ts.map +1 -1
- package/dist/data-store-transport.js +2 -1
- package/dist/data-store-transport.js.map +1 -1
- package/dist/entity-extractor.d.ts +9 -2
- package/dist/entity-extractor.d.ts.map +1 -1
- package/dist/entity-extractor.js +10 -4
- package/dist/entity-extractor.js.map +1 -1
- package/dist/entity-refs-from-index.d.ts +2 -1
- package/dist/entity-refs-from-index.d.ts.map +1 -1
- package/dist/entity-refs-from-index.js +17 -11
- package/dist/entity-refs-from-index.js.map +1 -1
- package/dist/entity-source.d.ts +2 -1
- package/dist/entity-source.d.ts.map +1 -1
- package/dist/entity-source.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/index.js.map +1 -1
- package/dist/on-demand-extractors.d.ts +1 -1
- package/dist/on-demand-extractors.d.ts.map +1 -1
- package/dist/on-demand-extractors.js +1 -1
- package/dist/on-demand-extractors.js.map +1 -1
- package/dist/project-units.d.ts +2 -1
- package/dist/project-units.d.ts.map +1 -1
- package/dist/project-units.js.map +1 -1
- package/dist/source-bytes.d.ts +130 -0
- package/dist/source-bytes.d.ts.map +1 -0
- package/dist/source-bytes.js +390 -0
- package/dist/source-bytes.js.map +1 -0
- package/dist/source-compress.d.ts +37 -0
- package/dist/source-compress.d.ts.map +1 -0
- package/dist/source-compress.js +104 -0
- package/dist/source-compress.js.map +1 -0
- package/dist/source-header.d.ts +12 -1
- package/dist/source-header.d.ts.map +1 -1
- package/dist/source-header.js +4 -13
- package/dist/source-header.js.map +1 -1
- package/dist/spatial-hierarchy-builder.d.ts +2 -1
- package/dist/spatial-hierarchy-builder.d.ts.map +1 -1
- package/dist/spatial-hierarchy-builder.js.map +1 -1
- package/dist/synthetic-data-store.d.ts +2 -1
- package/dist/synthetic-data-store.d.ts.map +1 -1
- package/dist/synthetic-data-store.js +2 -1
- package/dist/synthetic-data-store.js.map +1 -1
- package/dist/unit-extractor.d.ts +10 -2
- package/dist/unit-extractor.d.ts.map +1 -1
- package/dist/unit-extractor.js +40 -3
- package/dist/unit-extractor.js.map +1 -1
- package/dist/worker-parser.d.ts.map +1 -1
- package/dist/worker-parser.js +13 -5
- package/dist/worker-parser.js.map +1 -1
- package/package.json +6 -5
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/** Fixed-size blocks. See the header for why 64 KiB and not 256 KiB. */
|
|
2
|
+
export declare const DEFAULT_BLOCK_SIZE: number;
|
|
3
|
+
/**
|
|
4
|
+
* Inflated-block cache capacity, in bytes.
|
|
5
|
+
*
|
|
6
|
+
* 32 MB = 512 blocks. Sized from the measured interactive working set: the
|
|
7
|
+
* worst interactive case observed (a 1000-product selection) touches 500
|
|
8
|
+
* blocks. Sweeps are unaffected by capacity, so there is nothing to buy by
|
|
9
|
+
* going larger, and every byte here comes straight off the win.
|
|
10
|
+
*/
|
|
11
|
+
export declare const DEFAULT_CACHE_BYTES: number;
|
|
12
|
+
export interface BlockStoreCounters {
|
|
13
|
+
/** Block inflations performed. The number a regression pins. */
|
|
14
|
+
inflates: number;
|
|
15
|
+
/** Reads served entirely from cached blocks. */
|
|
16
|
+
hits: number;
|
|
17
|
+
/** Reads that had to inflate at least one block. */
|
|
18
|
+
misses: number;
|
|
19
|
+
/** Reads spanning a block boundary, which must stitch. */
|
|
20
|
+
boundaryStitches: number;
|
|
21
|
+
/** Inflated bytes produced, cumulative. */
|
|
22
|
+
bytesInflated: number;
|
|
23
|
+
/** Inflations that reused a pooled buffer. */
|
|
24
|
+
poolReuses: number;
|
|
25
|
+
/** Blocks dropped from the cache. */
|
|
26
|
+
evictions: number;
|
|
27
|
+
}
|
|
28
|
+
/** The wire/consructor shape: compressed blocks plus their offset index. */
|
|
29
|
+
export interface BlockedPayload {
|
|
30
|
+
/** All compressed blocks, concatenated. */
|
|
31
|
+
blocks: Uint8Array;
|
|
32
|
+
/**
|
|
33
|
+
* `blocks` offsets, length `blockCount + 1`. Block `i` occupies
|
|
34
|
+
* `[index[i], index[i + 1])`, so the last entry is `blocks.byteLength`.
|
|
35
|
+
*/
|
|
36
|
+
index: Uint32Array;
|
|
37
|
+
/**
|
|
38
|
+
* One byte per block: 1 = stored verbatim, 0 = deflated. Incompressible
|
|
39
|
+
* blocks (already-compressed payloads embedded in a STEP file) would
|
|
40
|
+
* otherwise grow, and a store that can grow is not one you can gate on size.
|
|
41
|
+
*/
|
|
42
|
+
storedMask: Uint8Array;
|
|
43
|
+
blockSize: number;
|
|
44
|
+
/** Logical length of the original source. */
|
|
45
|
+
totalLength: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Random-access reader over compressed blocks.
|
|
49
|
+
*
|
|
50
|
+
* Deliberately NOT an `IfcSourceBytes`: that interface is the store's public
|
|
51
|
+
* contract and must keep exactly one implementation from the outside. This is
|
|
52
|
+
* the machinery the accessor switches onto in place.
|
|
53
|
+
*/
|
|
54
|
+
export declare class BlockStore {
|
|
55
|
+
#private;
|
|
56
|
+
readonly blockSize: number;
|
|
57
|
+
readonly totalLength: number;
|
|
58
|
+
readonly blockCount: number;
|
|
59
|
+
readonly counters: BlockStoreCounters;
|
|
60
|
+
constructor(payload: BlockedPayload, cacheBytes?: number);
|
|
61
|
+
/**
|
|
62
|
+
* Bytes in `[start, end)`, as a fresh array.
|
|
63
|
+
*
|
|
64
|
+
* Always a copy, never a view: the bytes live in cache blocks that later
|
|
65
|
+
* reads may evict and hand to the pool for overwriting. A view would go
|
|
66
|
+
* stale silently, which is the worst possible failure for a byte range.
|
|
67
|
+
* Callers were already told `slice` only returns a view when `isResident`.
|
|
68
|
+
*/
|
|
69
|
+
read(start: number, end: number): Uint8Array;
|
|
70
|
+
/**
|
|
71
|
+
* UTF-8 decode of `[start, end)`.
|
|
72
|
+
*
|
|
73
|
+
* Goes through the same {@link read}, so a multi-byte sequence straddling a
|
|
74
|
+
* block boundary is decoded from stitched bytes and cannot be split.
|
|
75
|
+
*/
|
|
76
|
+
decodeUtf8(start: number, end: number): string;
|
|
77
|
+
/**
|
|
78
|
+
* The whole source, contiguous.
|
|
79
|
+
*
|
|
80
|
+
* Allocates `totalLength` and inflates every block, so it costs roughly a
|
|
81
|
+
* full sweep (~1.8 s and 343 MB on the reference model). It exists because
|
|
82
|
+
* some consumers genuinely need all the bytes; it is not a fallback to reach
|
|
83
|
+
* for casually, and `withMaterialized` on the accessor is the scoped form.
|
|
84
|
+
*/
|
|
85
|
+
materialize(): Uint8Array;
|
|
86
|
+
/** Compressed size, for accounting and the dev counter. */
|
|
87
|
+
get storedBytes(): number;
|
|
88
|
+
/** Inflated bytes currently held by the cache and the pool. */
|
|
89
|
+
get residentBytes(): number;
|
|
90
|
+
/** Drop cached blocks and pooled buffers. */
|
|
91
|
+
clearCache(): void;
|
|
92
|
+
/** The payload, for handing this store to a worker without inflating. */
|
|
93
|
+
toPayload(): BlockedPayload;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=block-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-store.d.ts","sourceRoot":"","sources":["../src/block-store.ts"],"names":[],"mappings":"AAsEA,wEAAwE;AACxE,eAAO,MAAM,kBAAkB,QAAY,CAAC;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB,QAAmB,CAAC;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AAI,IAAI;IAKlB,yEAAyE;IACzE,SAAS,IAAI,cAAc;CAS5B"}
|
|
@@ -0,0 +1,285 @@
|
|
|
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
|
+
* Block-compressed backing store for {@link IfcSourceBytes} (#2183).
|
|
6
|
+
*
|
|
7
|
+
* The source is the whole IFC file, resident for the model's lifetime because
|
|
8
|
+
* property and attribute reads slice it synchronously during React render. On
|
|
9
|
+
* a 342 MB model that is 327 MB of the viewer's main-thread heap. Deflating it
|
|
10
|
+
* into fixed-size blocks and inflating on demand trades that for ~67 MB plus a
|
|
11
|
+
* small cache.
|
|
12
|
+
*
|
|
13
|
+
* The numbers this design is built on, measured with fflate 0.8.3 on the real
|
|
14
|
+
* 342.7 MB model rather than assumed:
|
|
15
|
+
*
|
|
16
|
+
* - 64 KiB blocks at level 6: 342.7 MB -> 67 MB (19.7%), and an inflate costs
|
|
17
|
+
* 0.18 ms p50 / 0.40 ms max. 256 KiB stores 3 MB less but triples the p50
|
|
18
|
+
* to 0.69 ms, which is the wrong trade for a synchronous read on the render
|
|
19
|
+
* path. 16 KiB gives back 10 MB for latency nothing needs.
|
|
20
|
+
* - A full per-entity sweep touches 5161 of 5229 blocks -- essentially each
|
|
21
|
+
* block exactly once -- because expressId order tracks byte offset in STEP.
|
|
22
|
+
* It is a sequential scan, not a thrash, so cache CAPACITY barely matters:
|
|
23
|
+
* 32 MB and 256 MB are within 7% of each other. The cache is sized for the
|
|
24
|
+
* interactive working set, not to chase a hit rate.
|
|
25
|
+
* - Reusing evicted buffers is worth ~13% on a sweep (1.73 -> 1.53 s). Real
|
|
26
|
+
* but not load-bearing: inflate itself dominates, so the pool stays small
|
|
27
|
+
* and simple and is never allowed to justify complexity.
|
|
28
|
+
*/
|
|
29
|
+
import { safeUtf8Decode } from '@ifc-lite/data';
|
|
30
|
+
import { inflateSync } from 'fflate';
|
|
31
|
+
/**
|
|
32
|
+
* Reject a payload that cannot describe a real source.
|
|
33
|
+
*
|
|
34
|
+
* Not defensive noise: `adoptBlocks` builds a store straight from a
|
|
35
|
+
* `postMessage` payload, and the read path's contract is that it never throws.
|
|
36
|
+
*/
|
|
37
|
+
function assertValidPayload(p) {
|
|
38
|
+
if (!Number.isInteger(p.blockSize) || p.blockSize <= 0) {
|
|
39
|
+
throw new Error(`BlockStore: blockSize must be a positive integer, got ${p.blockSize}`);
|
|
40
|
+
}
|
|
41
|
+
if (!Number.isInteger(p.totalLength) || p.totalLength < 0) {
|
|
42
|
+
throw new Error(`BlockStore: totalLength must be a non-negative integer, got ${p.totalLength}`);
|
|
43
|
+
}
|
|
44
|
+
const blockCount = Math.ceil(p.totalLength / p.blockSize);
|
|
45
|
+
if (p.index.length !== blockCount + 1) {
|
|
46
|
+
throw new Error(`BlockStore: index has ${p.index.length} entries, expected ${blockCount + 1} `
|
|
47
|
+
+ `for ${p.totalLength} bytes in ${p.blockSize}-byte blocks`);
|
|
48
|
+
}
|
|
49
|
+
if (p.storedMask.length !== blockCount) {
|
|
50
|
+
throw new Error(`BlockStore: storedMask has ${p.storedMask.length} entries, expected ${blockCount}`);
|
|
51
|
+
}
|
|
52
|
+
for (let i = 1; i < p.index.length; i++) {
|
|
53
|
+
if (p.index[i] < p.index[i - 1]) {
|
|
54
|
+
throw new Error(`BlockStore: index is not monotonic at ${i}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (blockCount > 0 && p.index[blockCount] > p.blocks.byteLength) {
|
|
58
|
+
throw new Error(`BlockStore: index ends at ${p.index[blockCount]} but blocks hold ${p.blocks.byteLength} bytes`);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** Fixed-size blocks. See the header for why 64 KiB and not 256 KiB. */
|
|
62
|
+
export const DEFAULT_BLOCK_SIZE = 64 * 1024;
|
|
63
|
+
/**
|
|
64
|
+
* Inflated-block cache capacity, in bytes.
|
|
65
|
+
*
|
|
66
|
+
* 32 MB = 512 blocks. Sized from the measured interactive working set: the
|
|
67
|
+
* worst interactive case observed (a 1000-product selection) touches 500
|
|
68
|
+
* blocks. Sweeps are unaffected by capacity, so there is nothing to buy by
|
|
69
|
+
* going larger, and every byte here comes straight off the win.
|
|
70
|
+
*/
|
|
71
|
+
export const DEFAULT_CACHE_BYTES = 32 * 1024 * 1024;
|
|
72
|
+
/** Evicted buffers kept for reuse. Small on purpose: worth ~13%, not more. */
|
|
73
|
+
const MAX_POOLED_BUFFERS = 64;
|
|
74
|
+
/**
|
|
75
|
+
* Random-access reader over compressed blocks.
|
|
76
|
+
*
|
|
77
|
+
* Deliberately NOT an `IfcSourceBytes`: that interface is the store's public
|
|
78
|
+
* contract and must keep exactly one implementation from the outside. This is
|
|
79
|
+
* the machinery the accessor switches onto in place.
|
|
80
|
+
*/
|
|
81
|
+
export class BlockStore {
|
|
82
|
+
blockSize;
|
|
83
|
+
totalLength;
|
|
84
|
+
blockCount;
|
|
85
|
+
#blocks;
|
|
86
|
+
#index;
|
|
87
|
+
#storedMask;
|
|
88
|
+
/** Inflated blocks. A `Map` is insertion-ordered, which is the LRU order. */
|
|
89
|
+
#cache = new Map();
|
|
90
|
+
#pool = [];
|
|
91
|
+
#maxCachedBlocks;
|
|
92
|
+
counters = {
|
|
93
|
+
inflates: 0, hits: 0, misses: 0, boundaryStitches: 0,
|
|
94
|
+
bytesInflated: 0, poolReuses: 0, evictions: 0,
|
|
95
|
+
};
|
|
96
|
+
constructor(payload, cacheBytes = DEFAULT_CACHE_BYTES) {
|
|
97
|
+
// Validated because this is reached from `sourceBytesFromTransferable`,
|
|
98
|
+
// i.e. across a worker boundary, where the payload is whatever the other
|
|
99
|
+
// side sent. `IfcSourceBytes.slice` promises never to throw; a malformed
|
|
100
|
+
// payload would break that promise deep inside a read, far from the cause.
|
|
101
|
+
// Failing loudly at construction keeps the blast radius at the boundary.
|
|
102
|
+
assertValidPayload(payload);
|
|
103
|
+
this.blockSize = payload.blockSize;
|
|
104
|
+
this.totalLength = payload.totalLength;
|
|
105
|
+
this.#blocks = payload.blocks;
|
|
106
|
+
this.#index = payload.index;
|
|
107
|
+
this.#storedMask = payload.storedMask;
|
|
108
|
+
this.blockCount = Math.max(0, payload.index.length - 1);
|
|
109
|
+
// At least one block, or a read on a tiny source could never be served.
|
|
110
|
+
this.#maxCachedBlocks = Math.max(1, Math.floor(cacheBytes / payload.blockSize));
|
|
111
|
+
}
|
|
112
|
+
/** Uncompressed length of block `i`; the last block is short. */
|
|
113
|
+
#blockLength(i) {
|
|
114
|
+
const start = i * this.blockSize;
|
|
115
|
+
return Math.min(this.blockSize, this.totalLength - start);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The inflated block `i`, from cache or by inflating it.
|
|
119
|
+
*
|
|
120
|
+
* The returned view is owned by the cache and is only valid until the block
|
|
121
|
+
* is evicted, which is why every public read copies out of it rather than
|
|
122
|
+
* handing it to a caller.
|
|
123
|
+
*/
|
|
124
|
+
#block(i) {
|
|
125
|
+
const cached = this.#cache.get(i);
|
|
126
|
+
if (cached !== undefined) {
|
|
127
|
+
// Refresh recency: delete + re-set moves it to the end of the Map order.
|
|
128
|
+
this.#cache.delete(i);
|
|
129
|
+
this.#cache.set(i, cached);
|
|
130
|
+
return cached;
|
|
131
|
+
}
|
|
132
|
+
const from = this.#index[i];
|
|
133
|
+
const to = this.#index[i + 1];
|
|
134
|
+
const compressed = this.#blocks.subarray(from, to);
|
|
135
|
+
const length = this.#blockLength(i);
|
|
136
|
+
let out;
|
|
137
|
+
if (this.#storedMask[i] === 1) {
|
|
138
|
+
// Stored verbatim: still copied, because the caller-visible bytes must
|
|
139
|
+
// not alias the compressed backing store. NOT counted as an inflate --
|
|
140
|
+
// conflating the two would make the dev counter overstate decompression
|
|
141
|
+
// work on exactly the models with incompressible content.
|
|
142
|
+
out = this.#take(length);
|
|
143
|
+
out.set(compressed.subarray(0, length));
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
const reused = this.#takeExact(length);
|
|
147
|
+
out = reused !== null
|
|
148
|
+
? inflateSync(compressed, { out: reused })
|
|
149
|
+
: inflateSync(compressed);
|
|
150
|
+
this.counters.inflates++;
|
|
151
|
+
this.counters.bytesInflated += out.byteLength;
|
|
152
|
+
}
|
|
153
|
+
this.#cache.set(i, out);
|
|
154
|
+
this.#evictIfNeeded();
|
|
155
|
+
return out;
|
|
156
|
+
}
|
|
157
|
+
/** A pooled buffer of exactly `length`, or null when none fits. */
|
|
158
|
+
#takeExact(length) {
|
|
159
|
+
for (let i = this.#pool.length - 1; i >= 0; i--) {
|
|
160
|
+
if (this.#pool[i].byteLength === length) {
|
|
161
|
+
const buf = this.#pool[i];
|
|
162
|
+
this.#pool.splice(i, 1);
|
|
163
|
+
this.counters.poolReuses++;
|
|
164
|
+
return buf;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return null;
|
|
168
|
+
}
|
|
169
|
+
#take(length) {
|
|
170
|
+
return this.#takeExact(length) ?? new Uint8Array(length);
|
|
171
|
+
}
|
|
172
|
+
#evictIfNeeded() {
|
|
173
|
+
while (this.#cache.size > this.#maxCachedBlocks) {
|
|
174
|
+
const oldest = this.#cache.keys().next().value;
|
|
175
|
+
const buf = this.#cache.get(oldest);
|
|
176
|
+
this.#cache.delete(oldest);
|
|
177
|
+
this.counters.evictions++;
|
|
178
|
+
if (buf !== undefined && this.#pool.length < MAX_POOLED_BUFFERS)
|
|
179
|
+
this.#pool.push(buf);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Bytes in `[start, end)`, as a fresh array.
|
|
184
|
+
*
|
|
185
|
+
* Always a copy, never a view: the bytes live in cache blocks that later
|
|
186
|
+
* reads may evict and hand to the pool for overwriting. A view would go
|
|
187
|
+
* stale silently, which is the worst possible failure for a byte range.
|
|
188
|
+
* Callers were already told `slice` only returns a view when `isResident`.
|
|
189
|
+
*/
|
|
190
|
+
read(start, end) {
|
|
191
|
+
if (end <= start)
|
|
192
|
+
return new Uint8Array(0);
|
|
193
|
+
const first = Math.floor(start / this.blockSize);
|
|
194
|
+
const last = Math.floor((end - 1) / this.blockSize);
|
|
195
|
+
// Counted BEFORE reading, while it is still knowable: once #block() has
|
|
196
|
+
// run, every block it touched is cached and the distinction is gone.
|
|
197
|
+
let served = true;
|
|
198
|
+
for (let i = first; i <= last; i++) {
|
|
199
|
+
if (!this.#cache.has(i)) {
|
|
200
|
+
served = false;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
if (served)
|
|
205
|
+
this.counters.hits++;
|
|
206
|
+
else
|
|
207
|
+
this.counters.misses++;
|
|
208
|
+
if (first === last) {
|
|
209
|
+
const block = this.#block(first);
|
|
210
|
+
const offset = start - first * this.blockSize;
|
|
211
|
+
// slice() on the cached block copies, which is what we want here.
|
|
212
|
+
return block.slice(offset, offset + (end - start));
|
|
213
|
+
}
|
|
214
|
+
this.counters.boundaryStitches++;
|
|
215
|
+
const out = new Uint8Array(end - start);
|
|
216
|
+
let written = 0;
|
|
217
|
+
for (let i = first; i <= last; i++) {
|
|
218
|
+
const block = this.#block(i);
|
|
219
|
+
const blockStart = i * this.blockSize;
|
|
220
|
+
const from = Math.max(start, blockStart) - blockStart;
|
|
221
|
+
// #blockLength, not block.byteLength: for a well-formed store they are
|
|
222
|
+
// equal, and for a malformed one trusting the payload would overflow
|
|
223
|
+
// the output with a RangeError instead of reading short.
|
|
224
|
+
const to = Math.min(end, blockStart + this.#blockLength(i)) - blockStart;
|
|
225
|
+
out.set(block.subarray(from, to), written);
|
|
226
|
+
written += to - from;
|
|
227
|
+
}
|
|
228
|
+
return out;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* UTF-8 decode of `[start, end)`.
|
|
232
|
+
*
|
|
233
|
+
* Goes through the same {@link read}, so a multi-byte sequence straddling a
|
|
234
|
+
* block boundary is decoded from stitched bytes and cannot be split.
|
|
235
|
+
*/
|
|
236
|
+
decodeUtf8(start, end) {
|
|
237
|
+
if (end <= start)
|
|
238
|
+
return '';
|
|
239
|
+
return safeUtf8Decode(this.read(start, end), 0, end - start);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The whole source, contiguous.
|
|
243
|
+
*
|
|
244
|
+
* Allocates `totalLength` and inflates every block, so it costs roughly a
|
|
245
|
+
* full sweep (~1.8 s and 343 MB on the reference model). It exists because
|
|
246
|
+
* some consumers genuinely need all the bytes; it is not a fallback to reach
|
|
247
|
+
* for casually, and `withMaterialized` on the accessor is the scoped form.
|
|
248
|
+
*/
|
|
249
|
+
materialize() {
|
|
250
|
+
const out = new Uint8Array(this.totalLength);
|
|
251
|
+
for (let i = 0; i < this.blockCount; i++) {
|
|
252
|
+
out.set(this.#block(i), i * this.blockSize);
|
|
253
|
+
}
|
|
254
|
+
return out;
|
|
255
|
+
}
|
|
256
|
+
/** Compressed size, for accounting and the dev counter. */
|
|
257
|
+
get storedBytes() {
|
|
258
|
+
return this.#blocks.byteLength;
|
|
259
|
+
}
|
|
260
|
+
/** Inflated bytes currently held by the cache and the pool. */
|
|
261
|
+
get residentBytes() {
|
|
262
|
+
let n = 0;
|
|
263
|
+
for (const b of this.#cache.values())
|
|
264
|
+
n += b.byteLength;
|
|
265
|
+
for (const b of this.#pool)
|
|
266
|
+
n += b.byteLength;
|
|
267
|
+
return n;
|
|
268
|
+
}
|
|
269
|
+
/** Drop cached blocks and pooled buffers. */
|
|
270
|
+
clearCache() {
|
|
271
|
+
this.#cache.clear();
|
|
272
|
+
this.#pool.length = 0;
|
|
273
|
+
}
|
|
274
|
+
/** The payload, for handing this store to a worker without inflating. */
|
|
275
|
+
toPayload() {
|
|
276
|
+
return {
|
|
277
|
+
blocks: this.#blocks,
|
|
278
|
+
index: this.#index,
|
|
279
|
+
storedMask: this.#storedMask,
|
|
280
|
+
blockSize: this.blockSize,
|
|
281
|
+
totalLength: this.totalLength,
|
|
282
|
+
};
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
//# sourceMappingURL=block-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-store.js","sourceRoot":"","sources":["../src/block-store.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;GAKG;AACH,SAAS,kBAAkB,CAAC,CAAiB;IAC3C,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC;IAC1F,CAAC;IACD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,WAAW,GAAG,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC;IAClG,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC;IAC1D,IAAI,CAAC,CAAC,KAAK,CAAC,MAAM,KAAK,UAAU,GAAG,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CACb,yBAAyB,CAAC,CAAC,KAAK,CAAC,MAAM,sBAAsB,UAAU,GAAG,CAAC,GAAG;cAC5E,OAAO,CAAC,CAAC,WAAW,aAAa,CAAC,CAAC,SAAS,cAAc,CAC7D,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,CAAC,UAAU,CAAC,MAAM,KAAK,UAAU,EAAE,CAA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AAM,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAED,2DAA2D;IAC3D,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;IACjC,CAAC;IAED,+DAA+D;IAC/D,IAAI,aAAa;QACf,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAAE,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;QACxD,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,KAAK;YAAE,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC;QAC9C,OAAO,CAAC,CAAC;IACX,CAAC;IAED,6CAA6C;IAC7C,UAAU;QACR,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;IACxB,CAAC;IAED,yEAAyE;IACzE,SAAS;QACP,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,OAAO;YACpB,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,UAAU,EAAE,IAAI,CAAC,WAAW;YAC5B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -15,4 +15,20 @@ export interface ClassificationInfo {
|
|
|
15
15
|
* Returns an array of classification references with system info.
|
|
16
16
|
*/
|
|
17
17
|
export declare function extractClassificationsOnDemand(store: IfcDataStore, entityId: number): ClassificationInfo[];
|
|
18
|
+
/**
|
|
19
|
+
* List the distinct classification system names present in a model —
|
|
20
|
+
* CHEAP and EXACT.
|
|
21
|
+
*
|
|
22
|
+
* Unlike extractClassificationsOnDemand (which resolves classifications for
|
|
23
|
+
* ONE entity by walking its reference chain, and is only reachable through
|
|
24
|
+
* elements that already have a classification association), this walks the
|
|
25
|
+
* IfcClassification entities directly via the byType index. A model
|
|
26
|
+
* typically has only a handful of IfcClassification entities (one per
|
|
27
|
+
* system), regardless of how many elements are classified, so this is an
|
|
28
|
+
* O(few) map lookup + loop — not a per-entity or per-element scan.
|
|
29
|
+
*
|
|
30
|
+
* A model can carry SEVERAL systems at once (e.g. Uniclass, OmniClass, and
|
|
31
|
+
* a national system) — this returns all of them, sorted alphabetically.
|
|
32
|
+
*/
|
|
33
|
+
export declare function extractClassificationSystemsOnDemand(store: IfcDataStore): string[];
|
|
18
34
|
//# sourceMappingURL=classification-resolver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classification-resolver.d.ts","sourceRoot":"","sources":["../src/classification-resolver.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC1C,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,GACjB,kBAAkB,EAAE,CA0EtB"}
|
|
1
|
+
{"version":3,"file":"classification-resolver.d.ts","sourceRoot":"","sources":["../src/classification-resolver.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,WAAW,kBAAkB;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC1C,KAAK,EAAE,YAAY,EACnB,QAAQ,EAAE,MAAM,GACjB,kBAAkB,EAAE,CA0EtB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oCAAoC,CAAC,KAAK,EAAE,YAAY,GAAG,MAAM,EAAE,CAoBlF"}
|
|
@@ -87,6 +87,41 @@ export function extractClassificationsOnDemand(store, entityId) {
|
|
|
87
87
|
}
|
|
88
88
|
return results;
|
|
89
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* List the distinct classification system names present in a model —
|
|
92
|
+
* CHEAP and EXACT.
|
|
93
|
+
*
|
|
94
|
+
* Unlike extractClassificationsOnDemand (which resolves classifications for
|
|
95
|
+
* ONE entity by walking its reference chain, and is only reachable through
|
|
96
|
+
* elements that already have a classification association), this walks the
|
|
97
|
+
* IfcClassification entities directly via the byType index. A model
|
|
98
|
+
* typically has only a handful of IfcClassification entities (one per
|
|
99
|
+
* system), regardless of how many elements are classified, so this is an
|
|
100
|
+
* O(few) map lookup + loop — not a per-entity or per-element scan.
|
|
101
|
+
*
|
|
102
|
+
* A model can carry SEVERAL systems at once (e.g. Uniclass, OmniClass, and
|
|
103
|
+
* a national system) — this returns all of them, sorted alphabetically.
|
|
104
|
+
*/
|
|
105
|
+
export function extractClassificationSystemsOnDemand(store) {
|
|
106
|
+
const ids = store.entityIndex.byType.get('IFCCLASSIFICATION');
|
|
107
|
+
if (!ids || ids.length === 0 || !store.source?.length)
|
|
108
|
+
return [];
|
|
109
|
+
const extractor = new EntityExtractor(store.source);
|
|
110
|
+
const names = new Set();
|
|
111
|
+
for (const id of ids) {
|
|
112
|
+
const ref = store.entityIndex.byId.get(id);
|
|
113
|
+
if (!ref)
|
|
114
|
+
continue;
|
|
115
|
+
const entity = extractor.extractEntity(ref);
|
|
116
|
+
if (!entity)
|
|
117
|
+
continue;
|
|
118
|
+
// IfcClassification: [Source, Edition, EditionDate, Name, ...]
|
|
119
|
+
const name = entity.attributes?.[3];
|
|
120
|
+
if (typeof name === 'string' && name.length > 0)
|
|
121
|
+
names.add(name);
|
|
122
|
+
}
|
|
123
|
+
return Array.from(names).sort();
|
|
124
|
+
}
|
|
90
125
|
/**
|
|
91
126
|
* Walk up the IfcClassificationReference chain to find the root IfcClassification system.
|
|
92
127
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classification-resolver.js","sourceRoot":"","sources":["../src/classification-resolver.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;;GAGG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAYlD;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC1C,KAAmB,EACnB,QAAgB;IAEhB,IAAI,WAAiC,CAAC;IAEtC,IAAI,KAAK,CAAC,yBAAyB,EAAE,CAAC;QAClC,WAAW,GAAG,KAAK,CAAC,yBAAyB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAChE,CAAC;SAAM,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QAC7B,0DAA0D;QAC1D,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,gBAAgB,CAAC,wBAAwB,EAAE,SAAS,CAAC,CAAC;QAC/G,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC;YAAE,WAAW,GAAG,OAAO,CAAC;IAClD,CAAC;IAED,gEAAgE;IAChE,IAAI,KAAK,CAAC,aAAa,EAAE,CAAC;QACtB,MAAM,OAAO,GAAG,KAAK,CAAC,aAAa,CAAC,UAAU,CAAC,QAAQ,EAAE,gBAAgB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAC;QACpG,KAAK,M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AAC;aAAM,CAAC;YACJ,MAAM;QACV,CAAC;IACL,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,CAAC;AACrB,CAAC"}
|
|
@@ -8,10 +8,21 @@ import type { EntityRef } from './types.js';
|
|
|
8
8
|
import { StringTable, EntityTableBuilder, PropertyTableBuilder, RelationshipGraphBuilder } from '@ifc-lite/data';
|
|
9
9
|
import type { QuantityTable, PropertyValue, IfcStoreBase, IfcEntity, IfcAttributeValue } from '@ifc-lite/data';
|
|
10
10
|
import type { EntityByIdIndex } from './columnar-parser-indexes.js';
|
|
11
|
+
import { type IfcSourceBytes } from './source-bytes.js';
|
|
11
12
|
export type { SpatialIndex, EntityByIdIndex } from './columnar-parser-indexes.js';
|
|
12
13
|
export interface IfcDataStore extends IfcStoreBase {
|
|
13
14
|
parseTime: number;
|
|
14
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The IFC source bytes, behind an accessor rather than a resident
|
|
17
|
+
* `Uint8Array` (#2183). Read ranges with `slice`/`decodeUtf8`; use
|
|
18
|
+
* `withMaterialized` for the genuine whole-file consumers, and
|
|
19
|
+
* `toTransferable()` to hand it to a worker without materialising here.
|
|
20
|
+
*
|
|
21
|
+
* `byteLength === 0` is a supported state (server-parsed, synthetic, GLB,
|
|
22
|
+
* point-cloud), and `length` is aliased so existing presence guards keep
|
|
23
|
+
* their meaning.
|
|
24
|
+
*/
|
|
25
|
+
source: IfcSourceBytes;
|
|
15
26
|
entityIndex: {
|
|
16
27
|
byId: EntityByIdIndex;
|
|
17
28
|
byType: Map<string, number[]>;
|
|
@@ -197,7 +208,7 @@ export declare function extractRootAttributesFromEntity(entity: IfcEntity): {
|
|
|
197
208
|
* (#1075)
|
|
198
209
|
*/
|
|
199
210
|
export declare function pickLongName(entity: IfcEntity): string;
|
|
200
|
-
export { extractClassificationsOnDemand, extractMaterialsOnDemand, extractAllMaterialsOnDemand, extractMaterialPropertiesOnDemand, extractMaterialPropertiesForMaterialId, resolveMaterialDefId, resolveAllMaterialDefIds, collectMaterialLeaves, buildMaterialUsageIndex, getMaterialDisplay, extractTypePropertiesOnDemand, extractTypeEntityOwnProperties, extractTypeQuantitiesOnDemand, extractDocumentsOnDemand, extractRelationshipsOnDemand, extractGroupMembersOnDemand, extractGeoreferencingOnDemand, parsePropertyValue, extractPsetsFromIds, extractQsetsFromIds, } from './on-demand-extractors.js';
|
|
211
|
+
export { extractClassificationsOnDemand, extractClassificationSystemsOnDemand, extractMaterialsOnDemand, extractAllMaterialsOnDemand, extractMaterialPropertiesOnDemand, extractMaterialPropertiesForMaterialId, resolveMaterialDefId, resolveAllMaterialDefIds, collectMaterialLeaves, buildMaterialUsageIndex, getMaterialDisplay, extractTypePropertiesOnDemand, extractTypeEntityOwnProperties, extractTypeQuantitiesOnDemand, extractDocumentsOnDemand, extractRelationshipsOnDemand, extractGroupMembersOnDemand, extractGeoreferencingOnDemand, parsePropertyValue, extractPsetsFromIds, extractQsetsFromIds, } from './on-demand-extractors.js';
|
|
201
212
|
export { mergeInheritedPropertySets } from './property-set-merge.js';
|
|
202
213
|
export type { ClassificationInfo, MaterialInfo, MaterialLayerInfo, MaterialProfileInfo, MaterialConstituentInfo, MaterialPsetGroup, MaterialLeaf, MaterialUsage, TypePropertyInfo, TypeQuantityInfo, DocumentInfo, EntityRelationships, GroupMember, GeorefInfo, } from './on-demand-extractors.js';
|
|
203
214
|
//# sourceMappingURL=columnar-parser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"columnar-parser.d.ts","sourceRoot":"","sources":["../src/columnar-parser.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAQ5C,OAAO,EACH,WAAW,EACX,kBAAkB,EAClB,oBAAoB,EAEpB,wBAAwB,EAG3B,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAoB,aAAa,EAAE,aAAa,EAA4B,YAAY,EAAE,SAAS,EAAE,iBAAiB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B,CAAC;AAErE,YAAY,EACR,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,EACjB,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,WAAW,EACX,UAAU,GACb,MAAM,2BAA2B,CAAC"}
|
package/dist/columnar-parser.js
CHANGED
|
@@ -15,6 +15,7 @@ import { GEOMETRY_TYPES, REL_TYPE_MAP, QUANTITY_TYPE_MAP, SPATIAL_TYPES, HIERARC
|
|
|
15
15
|
import { extractRelFast, extractPropertyRelFast } from './columnar-parser-relationships.js';
|
|
16
16
|
import { safeUtf8Decode } from '@ifc-lite/data';
|
|
17
17
|
import { parseSourceHeader } from './source-header.js';
|
|
18
|
+
import { contiguousSourceBytes } from './source-bytes.js';
|
|
18
19
|
function detectSchemaVersion(buffer) {
|
|
19
20
|
const headerEnd = Math.min(buffer.length, 2000);
|
|
20
21
|
const headerText = safeUtf8Decode(buffer, 0, headerEnd).toUpperCase();
|
|
@@ -414,14 +415,26 @@ export class ColumnarParser {
|
|
|
414
415
|
// The hierarchy panel can render immediately while property/association
|
|
415
416
|
// parsing continues. This lets the panel appear at the same time as
|
|
416
417
|
// geometry streaming completes.
|
|
417
|
-
|
|
418
|
+
// ONE accessor, shared by the store field and the entity source.
|
|
419
|
+
//
|
|
420
|
+
// These used to be built separately -- `BufferEntitySource` got the raw
|
|
421
|
+
// `uint8Buffer` and wrapped it in its own accessor, while `source` got
|
|
422
|
+
// another. That is invisible while both are resident views over the
|
|
423
|
+
// same bytes, and fatal once the source can switch to compressed
|
|
424
|
+
// storage in place (#2183): `getEntity` would keep reading its private
|
|
425
|
+
// resident accessor, so the original buffer would never be released and
|
|
426
|
+
// the store would serve entities from one representation and properties
|
|
427
|
+
// from the other. Measured: with two accessors the buffer survives GC
|
|
428
|
+
// after the swap; with one it is collected.
|
|
429
|
+
const source = contiguousSourceBytes(uint8Buffer);
|
|
430
|
+
const entitySource = new BufferEntitySource(source, entityIndex);
|
|
418
431
|
const earlyStore = {
|
|
419
432
|
fileSize: buffer.byteLength,
|
|
420
433
|
schemaVersion,
|
|
421
434
|
sourceHeader,
|
|
422
435
|
entityCount: totalEntities,
|
|
423
436
|
parseTime: performance.now() - startTime,
|
|
424
|
-
source
|
|
437
|
+
source,
|
|
425
438
|
entityIndex,
|
|
426
439
|
strings,
|
|
427
440
|
entities: entityTable,
|
|
@@ -932,6 +945,6 @@ export function pickLongName(entity) {
|
|
|
932
945
|
return typeof raw === 'string' ? raw : '';
|
|
933
946
|
}
|
|
934
947
|
// Re-export on-demand extraction functions from focused module
|
|
935
|
-
export { extractClassificationsOnDemand, extractMaterialsOnDemand, extractAllMaterialsOnDemand, extractMaterialPropertiesOnDemand, extractMaterialPropertiesForMaterialId, resolveMaterialDefId, resolveAllMaterialDefIds, collectMaterialLeaves, buildMaterialUsageIndex, getMaterialDisplay, extractTypePropertiesOnDemand, extractTypeEntityOwnProperties, extractTypeQuantitiesOnDemand, extractDocumentsOnDemand, extractRelationshipsOnDemand, extractGroupMembersOnDemand, extractGeoreferencingOnDemand, parsePropertyValue, extractPsetsFromIds, extractQsetsFromIds, } from './on-demand-extractors.js';
|
|
948
|
+
export { extractClassificationsOnDemand, extractClassificationSystemsOnDemand, extractMaterialsOnDemand, extractAllMaterialsOnDemand, extractMaterialPropertiesOnDemand, extractMaterialPropertiesForMaterialId, resolveMaterialDefId, resolveAllMaterialDefIds, collectMaterialLeaves, buildMaterialUsageIndex, getMaterialDisplay, extractTypePropertiesOnDemand, extractTypeEntityOwnProperties, extractTypeQuantitiesOnDemand, extractDocumentsOnDemand, extractRelationshipsOnDemand, extractGroupMembersOnDemand, extractGeoreferencingOnDemand, parsePropertyValue, extractPsetsFromIds, extractQsetsFromIds, } from './on-demand-extractors.js';
|
|
936
949
|
export { mergeInheritedPropertySets } from './property-set-merge.js';
|
|
937
950
|
//# sourceMappingURL=columnar-parser.js.map
|