@flighthq/spatial 0.3.0-next.906.07cea63 → 0.3.1-next.209.43ef1bc
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/contract.d.ts +2 -0
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +2 -0
- package/dist/contract.js.map +1 -1
- package/dist/explainSpatialIndexing.d.ts +3 -0
- package/dist/explainSpatialIndexing.d.ts.map +1 -0
- package/dist/explainSpatialIndexing.js +14 -0
- package/dist/explainSpatialIndexing.js.map +1 -0
- package/dist/formatSpatialIndexingNotice.d.ts +3 -0
- package/dist/formatSpatialIndexingNotice.d.ts.map +1 -0
- package/dist/formatSpatialIndexingNotice.js +38 -0
- package/dist/formatSpatialIndexingNotice.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/spatialIndex.d.ts +2 -2
- package/dist/spatialIndex.d.ts.map +1 -1
- package/dist/spatialIndex.js +9 -3
- package/dist/spatialIndex.js.map +1 -1
- package/dist/uniformGrid.d.ts +3 -1
- package/dist/uniformGrid.d.ts.map +1 -1
- package/dist/uniformGrid.js +254 -31
- package/dist/uniformGrid.js.map +1 -1
- package/package.json +5 -3
- package/src/explainSpatialIndexing.test.ts +76 -0
- package/src/formatSpatialIndexingNotice.test.ts +116 -0
- package/src/uniformGrid.test.ts +713 -3
package/dist/contract.d.ts
CHANGED
package/dist/contract.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
package/dist/contract.js
CHANGED
package/dist/contract.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../src/contract.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { SpatialIndex, SpatialIndexingExplanation, SpatialObjectId } from '@flighthq/types/contract';
|
|
2
|
+
export declare function explainSpatialIndexing(index: Readonly<SpatialIndex>, id: SpatialObjectId): SpatialIndexingExplanation;
|
|
3
|
+
//# sourceMappingURL=explainSpatialIndexing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explainSpatialIndexing.d.ts","sourceRoot":"","sources":["../src/explainSpatialIndexing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAY1G,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,eAAe,GAAG,0BAA0B,CAErH"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Reports how the index is currently holding `id`, as plain data. Pure: reads only, indexes nothing,
|
|
2
|
+
// never throws on an unknown id, and retains no reference to the backend. Import it to answer "why is
|
|
3
|
+
// this object not in my query results?" — `absent` means it was never inserted or was removed,
|
|
4
|
+
// `declined` means its bounds were non-finite or inverted and it is deliberately not held, `overflow`
|
|
5
|
+
// means it is held but cannot be usefully bucketed, and `cells` reports the bucket count the
|
|
6
|
+
// per-object bound caps.
|
|
7
|
+
//
|
|
8
|
+
// This is the pull half of the diagnostics convention, and the measurement seam a regression test
|
|
9
|
+
// asserts the cost bound against: `bucketCount` is the number that goes unbounded when the bound is
|
|
10
|
+
// removed, so a test can pin it without timing anything.
|
|
11
|
+
export function explainSpatialIndexing(index, id) {
|
|
12
|
+
return index.runtime.backend.explainSpatialIndexing(id);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=explainSpatialIndexing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"explainSpatialIndexing.js","sourceRoot":"","sources":["../src/explainSpatialIndexing.ts"],"names":[],"mappings":"AAEA,qGAAqG;AACrG,sGAAsG;AACtG,+FAA+F;AAC/F,sGAAsG;AACtG,6FAA6F;AAC7F,yBAAyB;AACzB,EAAE;AACF,kGAAkG;AAClG,oGAAoG;AACpG,yDAAyD;AACzD,MAAM,UAAU,sBAAsB,CAAC,KAA6B,EAAE,EAAmB;IACvF,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,EAAE,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatSpatialIndexingNotice.d.ts","sourceRoot":"","sources":["../src/formatSpatialIndexingNotice.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAiBtE,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,MAAM,CAsB3F"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { MAX_INDEXED_CELLS_PER_OBJECT } from './uniformGrid';
|
|
2
|
+
// Renders an indexing notice as a caller-facing sentence, and is the only place in this package that
|
|
3
|
+
// holds one. Import it to turn the structured record a SpatialIndexingGuard receives into something a
|
|
4
|
+
// developer reads; leave it unimported and neither the text nor its cost reaches a bundle.
|
|
5
|
+
//
|
|
6
|
+
// This package deliberately stops at the structured guard seam plus this optional formatter rather
|
|
7
|
+
// than adding an `enableSpatialGuards` that chooses reporting policy. A caller can send the record to
|
|
8
|
+
// tests, telemetry, a host sink, or `@flighthq/log`, choosing its own channel and deduplication. An
|
|
9
|
+
// application that installs no guard pays only the runtime's null checks and can leave this formatter
|
|
10
|
+
// unimported. Core guard modules may import the logger through the ratified narrow exception; spatial's
|
|
11
|
+
// caller-composed shape is a package choice, not a workaround for the layer rule. Wiring the two halves
|
|
12
|
+
// to the standard logger remains one line:
|
|
13
|
+
//
|
|
14
|
+
// setSpatialIndexingGuard((notice) => logWarn({ message: formatSpatialIndexingNotice(notice) }, 'spatial'));
|
|
15
|
+
export function formatSpatialIndexingNotice(notice) {
|
|
16
|
+
if (notice.reason === 'invalid-cell-size') {
|
|
17
|
+
return `createUniformGridSpatialBackend(${notice.cellSize}): cellSize must be a positive finite number. ${notice.operation}SpatialObject(${notice.id}) used the bounded overflow path instead, so results remain correct but queries scan this object.`;
|
|
18
|
+
}
|
|
19
|
+
if (notice.reason === 'inverted-bounds') {
|
|
20
|
+
return `${notice.operation}SpatialObject(${notice.id}): minX/minY must not exceed maxX/maxY, so the object was not indexed and no query will return it. The operation returns false for this — normalize or correct the bounds upstream.`;
|
|
21
|
+
}
|
|
22
|
+
if (notice.reason === 'missing-id') {
|
|
23
|
+
if (notice.operation === 'remove') {
|
|
24
|
+
return `removeSpatialObject(${notice.id}): the id was not indexed, so removal was a no-op. Check the object's indexing lifecycle if this was unexpected.`;
|
|
25
|
+
}
|
|
26
|
+
return `updateSpatialObject(${notice.id}): the id was not indexed, so update used its documented insert behavior and left the object in '${notice.mode}' mode. Use insertSpatialObject for a new id, or check the object's indexing lifecycle.`;
|
|
27
|
+
}
|
|
28
|
+
if (notice.mode === 'declined') {
|
|
29
|
+
return `${notice.operation}SpatialObject(${notice.id}): the bounds are not finite, so the object was not indexed and no query will return it. The operation returns false for this — check the sentinel, and check what produced NaN/Infinity bounds upstream.`;
|
|
30
|
+
}
|
|
31
|
+
if (notice.mode === 'overflow') {
|
|
32
|
+
return `${notice.operation}SpatialObject(${notice.id}): the bounds span ${notice.wouldOccupyBucketCount} cells, over the ${MAX_INDEXED_CELLS_PER_OBJECT} per-object budget, so the object is held in the flat overflow list instead of the grid. Results are unaffected. If this is not a one-off outlier, the grid's cellSize is too small for the objects being indexed — size it to a typical object.`;
|
|
33
|
+
}
|
|
34
|
+
// `cells` and `absent` are ordinary outcomes no guard reports, so reaching here means a backend
|
|
35
|
+
// notified about something this text does not cover. Say exactly that rather than inventing advice.
|
|
36
|
+
return `${notice.operation}SpatialObject(${notice.id}): indexed as '${notice.mode}', which carries no caller-facing advice.`;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=formatSpatialIndexingNotice.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"formatSpatialIndexingNotice.js","sourceRoot":"","sources":["../src/formatSpatialIndexingNotice.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,eAAe,CAAC;AAE7D,qGAAqG;AACrG,sGAAsG;AACtG,2FAA2F;AAC3F,EAAE;AACF,mGAAmG;AACnG,sGAAsG;AACtG,oGAAoG;AACpG,sGAAsG;AACtG,wGAAwG;AACxG,wGAAwG;AACxG,2CAA2C;AAC3C,EAAE;AACF,+GAA+G;AAC/G,MAAM,UAAU,2BAA2B,CAAC,MAAuC;IACjF,IAAI,MAAM,CAAC,MAAM,KAAK,mBAAmB,EAAE,CAAC;QAC1C,OAAO,mCAAmC,MAAM,CAAC,QAAQ,iDAAiD,MAAM,CAAC,SAAS,iBAAiB,MAAM,CAAC,EAAE,mGAAmG,CAAC;IAC1P,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,iBAAiB,EAAE,CAAC;QACxC,OAAO,GAAG,MAAM,CAAC,SAAS,iBAAiB,MAAM,CAAC,EAAE,qLAAqL,CAAC;IAC5O,CAAC;IACD,IAAI,MAAM,CAAC,MAAM,KAAK,YAAY,EAAE,CAAC;QACnC,IAAI,MAAM,CAAC,SAAS,KAAK,QAAQ,EAAE,CAAC;YAClC,OAAO,uBAAuB,MAAM,CAAC,EAAE,kHAAkH,CAAC;QAC5J,CAAC;QACD,OAAO,uBAAuB,MAAM,CAAC,EAAE,oGAAoG,MAAM,CAAC,IAAI,yFAAyF,CAAC;IAClP,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,GAAG,MAAM,CAAC,SAAS,iBAAiB,MAAM,CAAC,EAAE,2MAA2M,CAAC;IAClQ,CAAC;IACD,IAAI,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QAC/B,OAAO,GAAG,MAAM,CAAC,SAAS,iBAAiB,MAAM,CAAC,EAAE,sBAAsB,MAAM,CAAC,sBAAsB,oBAAoB,4BAA4B,kPAAkP,CAAC;IAC5Y,CAAC;IACD,gGAAgG;IAChG,oGAAoG;IACpG,OAAO,GAAG,MAAM,CAAC,SAAS,iBAAiB,MAAM,CAAC,EAAE,kBAAkB,MAAM,CAAC,IAAI,2CAA2C,CAAC;AAC/H,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { clearSpatialIndex, createSpatialIndex, createUniformGridSpatialBackend, insertSpatialObject, querySpatialPairs, querySpatialPoint, querySpatialRay, querySpatialRegion, removeSpatialObject, updateSpatialObject, } from './contract';
|
|
1
|
+
export { MAX_INDEXED_CELLS_PER_OBJECT, clearSpatialIndex, createSpatialIndex, createUniformGridSpatialBackend, explainSpatialIndexing, formatSpatialIndexingNotice, insertSpatialObject, querySpatialPairs, querySpatialPoint, querySpatialRay, querySpatialRegion, removeSpatialObject, setSpatialIndexingGuard, updateSpatialObject, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { clearSpatialIndex, createSpatialIndex, createUniformGridSpatialBackend, insertSpatialObject, querySpatialPairs, querySpatialPoint, querySpatialRay, querySpatialRegion, removeSpatialObject, updateSpatialObject, } from './contract';
|
|
1
|
+
export { MAX_INDEXED_CELLS_PER_OBJECT, clearSpatialIndex, createSpatialIndex, createUniformGridSpatialBackend, explainSpatialIndexing, formatSpatialIndexingNotice, insertSpatialObject, querySpatialPairs, querySpatialPoint, querySpatialRay, querySpatialRegion, removeSpatialObject, setSpatialIndexingGuard, updateSpatialObject, } from './contract';
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,4BAA4B,EAC5B,iBAAiB,EACjB,kBAAkB,EAClB,+BAA+B,EAC/B,sBAAsB,EACtB,2BAA2B,EAC3B,mBAAmB,EACnB,iBAAiB,EACjB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,YAAY,CAAC"}
|
package/dist/spatialIndex.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { SpatialAabb, SpatialIndex, SpatialIndexBackend, SpatialObjectId, SpatialPair } from '@flighthq/types/contract';
|
|
2
2
|
export declare function clearSpatialIndex(index: Readonly<SpatialIndex>): void;
|
|
3
3
|
export declare function createSpatialIndex(backend?: SpatialIndexBackend): SpatialIndex;
|
|
4
|
-
export declare function insertSpatialObject(index: Readonly<SpatialIndex>, id: SpatialObjectId, bounds: Readonly<SpatialAabb>):
|
|
4
|
+
export declare function insertSpatialObject(index: Readonly<SpatialIndex>, id: SpatialObjectId, bounds: Readonly<SpatialAabb>): boolean;
|
|
5
5
|
export declare function querySpatialPairs(index: Readonly<SpatialIndex>, out: SpatialPair[]): void;
|
|
6
6
|
export declare function querySpatialPoint(index: Readonly<SpatialIndex>, x: number, y: number, out: SpatialObjectId[]): void;
|
|
7
7
|
export declare function querySpatialRay(index: Readonly<SpatialIndex>, x: number, y: number, dx: number, dy: number, out: SpatialObjectId[]): void;
|
|
8
8
|
export declare function querySpatialRegion(index: Readonly<SpatialIndex>, region: Readonly<SpatialAabb>, out: SpatialObjectId[]): void;
|
|
9
9
|
export declare function removeSpatialObject(index: Readonly<SpatialIndex>, id: SpatialObjectId): void;
|
|
10
|
-
export declare function updateSpatialObject(index: Readonly<SpatialIndex>, id: SpatialObjectId, bounds: Readonly<SpatialAabb>):
|
|
10
|
+
export declare function updateSpatialObject(index: Readonly<SpatialIndex>, id: SpatialObjectId, bounds: Readonly<SpatialAabb>): boolean;
|
|
11
11
|
//# sourceMappingURL=spatialIndex.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialIndex.d.ts","sourceRoot":"","sources":["../src/spatialIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI,CAErE;AAMD,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAM9E;
|
|
1
|
+
{"version":3,"file":"spatialIndex.d.ts","sourceRoot":"","sources":["../src/spatialIndex.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,WAAW,EACZ,MAAM,0BAA0B,CAAC;AAKlC,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,GAAG,IAAI,CAErE;AAMD,wBAAgB,kBAAkB,CAAC,OAAO,CAAC,EAAE,mBAAmB,GAAG,YAAY,CAM9E;AAOD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC7B,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC5B,OAAO,CAET;AAKD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,IAAI,CAEzF;AAGD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,IAAI,CAEnH;AAID,wBAAgB,eAAe,CAC7B,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC7B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,EAAE,EAAE,MAAM,EACV,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,eAAe,EAAE,GACrB,IAAI,CAEN;AAGD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC7B,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,EAC7B,GAAG,EAAE,eAAe,EAAE,GACrB,IAAI,CAEN;AAGD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,eAAe,GAAG,IAAI,CAE5F;AAMD,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,QAAQ,CAAC,YAAY,CAAC,EAC7B,EAAE,EAAE,eAAe,EACnB,MAAM,EAAE,QAAQ,CAAC,WAAW,CAAC,GAC5B,OAAO,CAET"}
|
package/dist/spatialIndex.js
CHANGED
|
@@ -15,9 +15,12 @@ export function createSpatialIndex(backend) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
// Adds an object to the index under `id` with its current bounds. The bounds are copied; the caller
|
|
18
|
-
// may reuse its own value afterward.
|
|
18
|
+
// may reuse its own value afterward. Returns false when the bounds cannot be indexed at all
|
|
19
|
+
// (non-finite or inverted) — the object is then absent from every query rather than present at a
|
|
20
|
+
// nonsense position. Oversized-but-valid bounds return true and stay fully queryable; the backend
|
|
21
|
+
// decides how to hold them. explainSpatialIndexing reports which happened.
|
|
19
22
|
export function insertSpatialObject(index, id, bounds) {
|
|
20
|
-
index.runtime.backend.insertSpatialObject(id, bounds);
|
|
23
|
+
return index.runtime.backend.insertSpatialObject(id, bounds);
|
|
21
24
|
}
|
|
22
25
|
// Fills `out` (cleared first) with every deduplicated candidate pair — each unordered pair at most
|
|
23
26
|
// once, never an object with itself. A pair is a broadphase candidate: the two objects are close
|
|
@@ -43,8 +46,11 @@ export function removeSpatialObject(index, id) {
|
|
|
43
46
|
index.runtime.backend.removeSpatialObject(id);
|
|
44
47
|
}
|
|
45
48
|
// Moves an already-inserted object to new bounds. Inserting a not-yet-present id behaves as insert.
|
|
49
|
+
// Returns the same sentinel as insertSpatialObject. A declined update removes the object rather than
|
|
50
|
+
// leaving it at its old bounds, so a caller that ignores the sentinel can never read a stale position
|
|
51
|
+
// as a current one.
|
|
46
52
|
export function updateSpatialObject(index, id, bounds) {
|
|
47
|
-
index.runtime.backend.updateSpatialObject(id, bounds);
|
|
53
|
+
return index.runtime.backend.updateSpatialObject(id, bounds);
|
|
48
54
|
}
|
|
49
55
|
// The default uniform-grid cell size when createSpatialIndex is called without an explicit backend —
|
|
50
56
|
// a middle-of-the-road choice; a workload with a known typical object size should pass its own grid.
|
package/dist/spatialIndex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spatialIndex.js","sourceRoot":"","sources":["../src/spatialIndex.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAEhE,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAC5C,CAAC;AAED,yFAAyF;AACzF,kGAAkG;AAClG,mGAAmG;AACnG,4DAA4D;AAC5D,MAAM,UAAU,kBAAkB,CAAC,OAA6B;IAC9D,OAAO;QACL,OAAO,EAAE;YACP,OAAO,EAAE,OAAO,IAAI,+BAA+B,CAAC,yBAAyB,CAAC;SAC/E;KACF,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,
|
|
1
|
+
{"version":3,"file":"spatialIndex.js","sourceRoot":"","sources":["../src/spatialIndex.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AAEhE,gFAAgF;AAChF,MAAM,UAAU,iBAAiB,CAAC,KAA6B;IAC7D,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;AAC5C,CAAC;AAED,yFAAyF;AACzF,kGAAkG;AAClG,mGAAmG;AACnG,4DAA4D;AAC5D,MAAM,UAAU,kBAAkB,CAAC,OAA6B;IAC9D,OAAO;QACL,OAAO,EAAE;YACP,OAAO,EAAE,OAAO,IAAI,+BAA+B,CAAC,yBAAyB,CAAC;SAC/E;KACF,CAAC;AACJ,CAAC;AAED,oGAAoG;AACpG,4FAA4F;AAC5F,iGAAiG;AACjG,kGAAkG;AAClG,2EAA2E;AAC3E,MAAM,UAAU,mBAAmB,CACjC,KAA6B,EAC7B,EAAmB,EACnB,MAA6B;IAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED,mGAAmG;AACnG,iGAAiG;AACjG,8FAA8F;AAC9F,MAAM,UAAU,iBAAiB,CAAC,KAA6B,EAAE,GAAkB;IACjF,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC;AAC/C,CAAC;AAED,qFAAqF;AACrF,MAAM,UAAU,iBAAiB,CAAC,KAA6B,EAAE,CAAS,EAAE,CAAS,EAAE,GAAsB;IAC3G,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,EAAE,GAAG,CAAC,CAAC;AACrD,CAAC;AAED,iGAAiG;AACjG,kGAAkG;AAClG,MAAM,UAAU,eAAe,CAC7B,KAA6B,EAC7B,CAAS,EACT,CAAS,EACT,EAAU,EACV,EAAU,EACV,GAAsB;IAEtB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;AAC3D,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,kBAAkB,CAChC,KAA6B,EAC7B,MAA6B,EAC7B,GAAsB;IAEtB,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AACxD,CAAC;AAED,sEAAsE;AACtE,MAAM,UAAU,mBAAmB,CAAC,KAA6B,EAAE,EAAmB;IACpF,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;AAChD,CAAC;AAED,oGAAoG;AACpG,qGAAqG;AACrG,sGAAsG;AACtG,oBAAoB;AACpB,MAAM,UAAU,mBAAmB,CACjC,KAA6B,EAC7B,EAAmB,EACnB,MAA6B;IAE7B,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;AAC/D,CAAC;AAED,qGAAqG;AACrG,qGAAqG;AACrG,MAAM,yBAAyB,GAAG,GAAG,CAAC"}
|
package/dist/uniformGrid.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import type { SpatialIndexBackend } from '@flighthq/types/contract';
|
|
1
|
+
import type { SpatialIndexBackend, SpatialIndexingGuard } from '@flighthq/types/contract';
|
|
2
|
+
export declare const MAX_INDEXED_CELLS_PER_OBJECT = 1024;
|
|
2
3
|
export declare function createUniformGridSpatialBackend(cellSize: number): SpatialIndexBackend;
|
|
4
|
+
export declare function setSpatialIndexingGuard(guard: SpatialIndexingGuard | null): void;
|
|
3
5
|
//# sourceMappingURL=uniformGrid.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uniformGrid.d.ts","sourceRoot":"","sources":["../src/uniformGrid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,mBAAmB,
|
|
1
|
+
{"version":3,"file":"uniformGrid.d.ts","sourceRoot":"","sources":["../src/uniformGrid.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAGV,mBAAmB,EAGnB,oBAAoB,EAMrB,MAAM,0BAA0B,CAAC;AAiBlC,eAAO,MAAM,4BAA4B,OAAO,CAAC;AAejD,wBAAgB,+BAA+B,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAkDrF;AAKD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,oBAAoB,GAAG,IAAI,GAAG,IAAI,CAEhF"}
|