@delali/narsil 0.4.2-next.271 → 0.4.2

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.
Files changed (103) hide show
  1. package/dist/browser/{chunk-XBWABEL3.mjs → chunk-56UNHLAF.mjs} +1 -1
  2. package/dist/browser/{chunk-DPRCAVC2.mjs → chunk-EKISQBV2.mjs} +272 -239
  3. package/dist/browser/{chunk-WRRXR57N.mjs → chunk-VAPCFSMX.mjs} +1 -1
  4. package/dist/browser/{chunk-Y5CSZDOH.mjs → chunk-VIVG3OXM.mjs} +1 -1
  5. package/dist/browser/{msgpack-leaf-FEPCLXXY.mjs → msgpack-leaf-76Q5SZ5S.mjs} +16 -9
  6. package/dist/browser/{optional-writes-HVPPDHSY.mjs → optional-writes-3HKIVZFU.mjs} +36 -2
  7. package/dist/browser/{segment-codec-leaf-A427QJUX.mjs → segment-codec-leaf-GXSRX5VT.mjs} +47 -30
  8. package/dist/{chunk-TI4G3SIG.mjs → chunk-35RWLUVY.mjs} +3 -3
  9. package/dist/{chunk-GTBJSNN2.mjs → chunk-43T3P3BE.mjs} +1 -1
  10. package/dist/{chunk-KQWTS7AM.mjs → chunk-4JLHHEBN.mjs} +1 -1
  11. package/dist/{chunk-KX3OP6VP.mjs → chunk-4YIVY3PB.mjs} +2 -2
  12. package/dist/{react-native/chunks/chunk-XGS2UYVI.mjs → chunk-5SHWA6PE.mjs} +1 -1
  13. package/dist/{chunk-BBIAUHAB.mjs → chunk-6LVQ3GLT.mjs} +3 -3
  14. package/dist/{chunk-H6LWGMPQ.mjs → chunk-6SIEVWMG.mjs} +7 -7
  15. package/dist/{chunk-NFA3WHJU.mjs → chunk-ACNHJOGC.mjs} +1 -1
  16. package/dist/{chunk-FOGTBAYN.mjs → chunk-BWPVDIRN.mjs} +12 -12
  17. package/dist/{chunk-ATQ6JR3I.mjs → chunk-C57GWAXN.mjs} +1 -1
  18. package/dist/{chunk-5E3TJ4P3.mjs → chunk-DRZP5MSG.mjs} +5 -5
  19. package/dist/{chunk-OLXFIUIZ.mjs → chunk-DZMD4OMD.mjs} +1 -1
  20. package/dist/{chunk-4WQNWAQE.mjs → chunk-EY5U4P5V.mjs} +1 -1
  21. package/dist/{chunk-Q4NLL66U.mjs → chunk-EZJ6HBG7.mjs} +2 -2
  22. package/dist/{chunk-QJFKL4NK.mjs → chunk-FE2XILWN.mjs} +4 -4
  23. package/dist/{chunk-WIT6B5OB.mjs → chunk-G3KVEHIW.mjs} +2 -2
  24. package/dist/{chunk-TANKI7TG.mjs → chunk-GTGQLCEI.mjs} +1 -1
  25. package/dist/{chunk-EALKCTWH.mjs → chunk-H23FB267.mjs} +3 -3
  26. package/dist/{chunk-YHZSSPG3.mjs → chunk-KXA77DPZ.mjs} +2 -2
  27. package/dist/{chunk-XWPNRHTG.mjs → chunk-LRIJ7U3T.mjs} +4 -4
  28. package/dist/{chunk-SSITKQU6.mjs → chunk-PNFP5THV.mjs} +3 -3
  29. package/dist/{chunk-VHIOGDVD.mjs → chunk-PQWK7KXS.mjs} +1 -1
  30. package/dist/{chunk-TT3UDDL3.mjs → chunk-QNZJYMCF.mjs} +6 -6
  31. package/dist/{chunk-33ZMFOAR.mjs → chunk-R3PFPFME.mjs} +1 -1
  32. package/dist/{chunk-XGVSG6ZU.mjs → chunk-SPA7GXST.mjs} +3 -3
  33. package/dist/{chunk-MS746XNY.mjs → chunk-WYH3QHBK.mjs} +384 -304
  34. package/dist/{chunk-MIIJ5O3O.mjs → chunk-X5V25BPN.mjs} +1 -1
  35. package/dist/{chunk-5GYGHPCH.mjs → chunk-Y7GXGJFZ.mjs} +16 -9
  36. package/dist/{chunk-4GCHJ3XD.mjs → chunk-YGRJLI2Z.mjs} +4 -4
  37. package/dist/{react-native/chunks/chunk-LE4DTMDL.mjs → chunk-ZO7VLAIT.mjs} +2 -2
  38. package/dist/{chunk-W3JH2IK6.mjs → chunk-ZTB7AWTW.mjs} +1 -1
  39. package/dist/client.mjs +2 -2
  40. package/dist/{direct-executor-PCBB6FCO.mjs → direct-executor-7G57AYXH.mjs} +4 -4
  41. package/dist/distribution/coordinator/etcd.mjs +2 -2
  42. package/dist/distribution/transport/grpc.mjs +3 -3
  43. package/dist/distribution/transport/tcp.mjs +3 -3
  44. package/dist/distribution.mjs +29 -29
  45. package/dist/index.browser.mjs +3 -3
  46. package/dist/index.mjs +4 -4
  47. package/dist/index.react-native.mjs +4 -4
  48. package/dist/{long-query-thread-4ALYIIC4.mjs → long-query-thread-KPN7NSOC.mjs} +14 -14
  49. package/dist/{msgpack-leaf-6ZBZWFRD.mjs → msgpack-leaf-LIT7TKZW.mjs} +3 -3
  50. package/dist/{optional-writes-2OK4TOLY.mjs → optional-writes-CSULLISE.mjs} +6 -6
  51. package/dist/{paged-partition-archive-Y5OAKNRB.mjs → paged-partition-archive-BKQADXOT.mjs} +13 -13
  52. package/dist/partial-words.browser.mjs +3 -3
  53. package/dist/partial-words.mjs +4 -4
  54. package/dist/pattern.browser.mjs +2 -2
  55. package/dist/pattern.mjs +2 -2
  56. package/dist/persistence/durability/checkpoint-worker.mjs +11 -11
  57. package/dist/{query-actions-UQVQZFIJ.mjs → query-actions-HTSJKZRU.mjs} +4 -4
  58. package/dist/query-suggestions/merge-worker.mjs +7 -7
  59. package/dist/query-suggestions.browser.mjs +3 -3
  60. package/dist/query-suggestions.mjs +5 -5
  61. package/dist/react-native/chunks/{chunk-AVCMTWET.mjs → chunk-AOLLV37A.mjs} +1 -1
  62. package/dist/react-native/chunks/{chunk-VRI5XH2M.mjs → chunk-DN4FT62B.mjs} +16 -9
  63. package/dist/react-native/chunks/{chunk-VIO5IPF7.mjs → chunk-EF4Y5C3Y.mjs} +2 -2
  64. package/dist/react-native/chunks/{chunk-GS6LGXY3.mjs → chunk-ESVBC3AT.mjs} +1 -1
  65. package/dist/react-native/chunks/{chunk-4OOUY2K7.mjs → chunk-H6LK5WCF.mjs} +1 -1
  66. package/dist/react-native/chunks/{chunk-5MYHYBET.mjs → chunk-JEYZQA4Z.mjs} +384 -304
  67. package/dist/react-native/chunks/{chunk-XW6GZQWP.mjs → chunk-KJQ3BUVM.mjs} +4 -4
  68. package/dist/{chunk-DA32WXBT.mjs → react-native/chunks/chunk-QYVRD6C5.mjs} +2 -2
  69. package/dist/react-native/chunks/{chunk-Z44S6WW5.mjs → chunk-X3VY2YT4.mjs} +2 -2
  70. package/dist/{chunk-OETLM4EH.mjs → react-native/chunks/chunk-ZF3VSGEI.mjs} +1 -1
  71. package/dist/react-native/chunks/{msgpack-leaf-4MIGXWZT.mjs → msgpack-leaf-FOUPTT7J.mjs} +3 -3
  72. package/dist/react-native/chunks/{optional-writes-LZDHB7FX.mjs → optional-writes-MGFFGKYQ.mjs} +5 -5
  73. package/dist/react-native/chunks/{restore-queue-J7SB263E.mjs → restore-queue-MVJTP3E4.mjs} +7 -7
  74. package/dist/react-native/chunks/{segment-codec-leaf-PEKX7TBL.mjs → segment-codec-leaf-PSWHL55A.mjs} +5 -5
  75. package/dist/react-native/chunks/{segment-merge-leaf-I2EC7H6R.mjs → segment-merge-leaf-WOJWSDLW.mjs} +6 -6
  76. package/dist/react-native/chunks/{storage-leaf-RQXM7HBO.mjs → storage-leaf-ZUN6Y44X.mjs} +9 -9
  77. package/dist/react-native/chunks/{store-leaf-EZGCLSLM.mjs → store-leaf-K5XG46FV.mjs} +6 -6
  78. package/dist/react-native/chunks/{suggestions-leaf-JNGH2JYC.mjs → suggestions-leaf-KDPM3P27.mjs} +6 -6
  79. package/dist/react-native/chunks/{worker-copies-2OWLLBCV.mjs → worker-copies-FVFMBBH6.mjs} +5 -5
  80. package/dist/react-native/partial-words.mjs +4 -4
  81. package/dist/react-native/pattern.mjs +2 -2
  82. package/dist/react-native/query-suggestions.mjs +4 -4
  83. package/dist/react-native/sync.mjs +4 -4
  84. package/dist/react-native/synonyms.mjs +4 -4
  85. package/dist/{rerank-TQ4SU76L.mjs → rerank-3QEJNMFH.mjs} +4 -4
  86. package/dist/{restore-queue-W7U2X6V3.mjs → restore-queue-Q76Q4S35.mjs} +7 -7
  87. package/dist/{segment-codec-leaf-WGP4FBXF.mjs → segment-codec-leaf-BSDDR7DQ.mjs} +5 -5
  88. package/dist/{segment-merge-leaf-FYWJQSPL.mjs → segment-merge-leaf-6TT66HC5.mjs} +5 -5
  89. package/dist/server.mjs +20 -20
  90. package/dist/{storage-leaf-GRG44RQA.mjs → storage-leaf-R5JQ2X2M.mjs} +22 -22
  91. package/dist/{store-leaf-YDJVH73G.mjs → store-leaf-NCGETZYY.mjs} +6 -6
  92. package/dist/{suggestions-leaf-5UFJV7SC.mjs → suggestions-leaf-TX3GTD6S.mjs} +8 -8
  93. package/dist/sync/filesystem.mjs +9 -9
  94. package/dist/sync/indexeddb.browser.mjs +1 -1
  95. package/dist/sync/indexeddb.mjs +2 -2
  96. package/dist/sync.browser.mjs +4 -4
  97. package/dist/sync.mjs +4 -4
  98. package/dist/synonyms.browser.mjs +3 -3
  99. package/dist/synonyms.mjs +4 -4
  100. package/dist/{thread-6YLVL2NC.mjs → thread-VLVPAUWC.mjs} +13 -13
  101. package/dist/{worker-copies-IP4L7KEW.mjs → worker-copies-NZSBQZKG.mjs} +7 -7
  102. package/dist/workers/entry.mjs +10 -10
  103. package/package.json +7 -5
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes, requireLoadedMessagePack, getNestedValue, parsedTypeOf } from './chunk-WRRXR57N.mjs';
1
+ import { NarsilError, ErrorCodes, requireLoadedMessagePack, getNestedValue, parsedTypeOf } from './chunk-VAPCFSMX.mjs';
2
2
 
3
3
  // src/core/stored-values/build.ts
4
4
  var ORDINAL_LIMIT = 4294967295;
@@ -1,6 +1,6 @@
1
- import { PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, GEO_UNIT_METRES, storedText, DEFAULT_PATTERN_WORK_CAP, MAX_FILTER_DEPTH, discardStoredValues, bitsetIsEmpty, storedValuesOf, bitsetHas, createBitSet, bitsetSet, storedValueBytes, prepareStoredValues, cachedStoredFields, bitsetClear, MAX_FILTER_TESTS, TYPO_CLAIM_SLOTS_PER_WORD, buildStoredValues, bitsetAndNotInto, bitsetAndInto, bitsetOrInto, checkedSize, fuzzyPrefixOf, boundedLevenshtein, installStoredFields, FILTER_OPERAND_COPY_DEPTH, fuzzyTermMatches, PATTERN_WORK_FLUSH_UNITS, MATCHER_STATE_BUDGET_BYTES, bitsetIterator, GrowableUint32, bitsetFromSet } from './chunk-XBWABEL3.mjs';
1
+ import { PATTERN_EXPRESSION_OPERATORS, PATTERN_TEST_OPERATORS, PATTERN_ELEMENT_OPERATORS, requireTextRangeField, isFiniteNumber, invalid, requireFieldKind, kindOfValue, requireListLength, isObjectRecord, GEO_UNIT_METRES, storedText, DEFAULT_PATTERN_WORK_CAP, MAX_FILTER_DEPTH, discardStoredValues, bitsetIsEmpty, storedValuesOf, bitsetHas, createBitSet, bitsetSet, storedValueBytes, prepareStoredValues, cachedStoredFields, bitsetClear, MAX_FILTER_TESTS, TYPO_CLAIM_SLOTS_PER_WORD, buildStoredValues, bitsetAndNotInto, bitsetAndInto, bitsetOrInto, checkedSize, fuzzyPrefixOf, boundedLevenshtein, installStoredFields, FILTER_OPERAND_COPY_DEPTH, fuzzyTermMatches, PATTERN_WORK_FLUSH_UNITS, MATCHER_STATE_BUDGET_BYTES, bitsetIterator, GrowableUint32, bitsetFromSet } from './chunk-56UNHLAF.mjs';
2
2
  import { newSyncEpoch, isSyncEpoch } from './chunk-YJHGOJAC.mjs';
3
- import { parsedTypeOf, NarsilError, ErrorCodes, isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, createNarsilError, withUnpairedSurrogatesReplaced, tokenizeOptions, getNestedValue, isPlainObject, MAX_NESTING_DEPTH, loadMessagePack, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, validateTextStorage, extractVectorFieldsFromSchema, loadedMessagePack, flattenSchema, vectorDimensionOf, isSingleStringFieldType, schemaFieldsOf, partialFieldsOf, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isStringValuedBase, compareCodePoints, isWordIndexedFieldType, messagePackUpperBoundBytes, toComparableSortValue, exceedsCodePoints, SORT_VALUE_MAX_CODE_POINTS, PROTOTYPE_POLLUTION_KEYS, sortModeOf, defaultSortMode, validateDocument, validateDocumentStrict, textFieldsChanged, getFlatSchema, getOrCreateFieldNameIndex, isWordIndexedBase, holdsUnpairedSurrogate, validateRequiredFields, requireDocumentWithinSizeLimit, isNarsilError, PLACEMENT_ROOM_REQUESTS, NEAREST_LINK_FALLBACK_HOSTS, MIN_M, MAX_M, MAX_LAYER_CAP, MAX_FILE_BYTES, INITIAL_UPPER_SLOTS, INITIAL_LIST_CAPACITY, FARTHEST_REJECTED_LINKS_KEPT, EARLIER_RELEASE_MIN_M, DEFAULT_EF_SEARCH, CONNECT_STEPS_BETWEEN_CLOCK_CHECKS, CONNECT_RESTARTS_BEFORE_ONE_PASS, COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, requireValidFieldTypes, parseVectorDimension, isStorageMode, isQuantizationMode, VALID_HNSW_METRICS, MAX_DOCUMENT_NESTING_DEPTH, NATIVE_CRC32_MIN_BYTES, CHECKSUM_YIELD_CHUNK_BYTES, raiseEarlierReleaseGraphSetting, MAX_DOCUMENT_ENCODING_DEPTH, DOCUMENT_REPLY_ENVELOPE_DEPTH, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, BYTE_ORDER_MARK_WALK_BYTES_PER_HEADER, withSortableOption, VECTOR_PATTERN, isListBase, isGeopointOrVectorType, MAX_COVERING_CELLS, LOCATION_CODE_BITS_PER_AXIS, LOCATION_CELLS_PER_AXIS, FULL_TURN_DEGREES, EARTH_RADIUS_METERS, DEG_TO_RAD, ANTIMERIDIAN_SPAN_DEGREES, truncateSortString, SORT_MODES, isSortMode, codePointCount } from './chunk-WRRXR57N.mjs';
3
+ import { parsedTypeOf, NarsilError, ErrorCodes, isLatitude, MAX_LATITUDE_DEGREES, isLongitude, MAX_LONGITUDE_DEGREES, MIN_POLYGON_POINTS, createNarsilError, withUnpairedSurrogatesReplaced, tokenizeOptions, getNestedValue, isPlainObject, MAX_NESTING_DEPTH, loadMessagePack, validateSchema, requireCreatableSchema, validateVectorPromotion, validateVectorStorage, validateTextStorage, extractVectorFieldsFromSchema, loadedMessagePack, flattenSchema, vectorDimensionOf, isSingleStringFieldType, schemaFieldsOf, partialFieldsOf, MIN_PATTERN_VALUE_LIMIT, MAX_PATTERN_VALUE_LIMIT, isStringValuedBase, compareCodePoints, isWordIndexedFieldType, messagePackUpperBoundBytes, toComparableSortValue, exceedsCodePoints, SORT_VALUE_MAX_CODE_POINTS, PROTOTYPE_POLLUTION_KEYS, sortModeOf, defaultSortMode, validateDocument, validateDocumentStrict, textFieldsChanged, getFlatSchema, getOrCreateFieldNameIndex, isWordIndexedBase, holdsUnpairedSurrogate, validateRequiredFields, requireDocumentWithinSizeLimit, isNarsilError, PLACEMENT_ROOM_REQUESTS, NEAREST_LINK_FALLBACK_HOSTS, MIN_M, MAX_M, MAX_LAYER_CAP, MAX_FILE_BYTES, INITIAL_UPPER_SLOTS, INITIAL_LIST_CAPACITY, FARTHEST_REJECTED_LINKS_KEPT, EARLIER_RELEASE_MIN_M, DEFAULT_EF_SEARCH, CONNECT_STEPS_BETWEEN_CLOCK_CHECKS, CONNECT_RESTARTS_BEFORE_ONE_PASS, COMPACTION_TOMBSTONE_RATIO, COMPACTION_ABSOLUTE_THRESHOLD, requireValidFieldTypes, parseVectorDimension, isStorageMode, isQuantizationMode, VALID_HNSW_METRICS, MAX_DOCUMENT_NESTING_DEPTH, NATIVE_CRC32_MIN_BYTES, CHECKSUM_YIELD_CHUNK_BYTES, raiseEarlierReleaseGraphSetting, MAX_DOCUMENT_ENCODING_DEPTH, DOCUMENT_REPLY_ENVELOPE_DEPTH, DOCUMENT_ENCODER_RETAINED_BUFFER_BYTES, BYTE_ORDER_MARK_WALK_BYTES_PER_HEADER, withSortableOption, VECTOR_PATTERN, isListBase, isGeopointOrVectorType, MAX_COVERING_CELLS, LOCATION_CODE_BITS_PER_AXIS, LOCATION_CELLS_PER_AXIS, FULL_TURN_DEGREES, EARTH_RADIUS_METERS, DEG_TO_RAD, ANTIMERIDIAN_SPAN_DEGREES, truncateSortString, SORT_MODES, isSortMode, codePointCount } from './chunk-VAPCFSMX.mjs';
4
4
 
5
5
  // src/analysis/registry.ts
6
6
  var tokenizers = /* @__PURE__ */ new Map();
@@ -11511,11 +11511,13 @@ function assembleFrozenSegment(segmentId, source, documentSource, sharedSnapshot
11511
11511
  isTombstoned: (ordinal) => tombstones.has(ordinal),
11512
11512
  settleRemovals: counts.settleRemovals
11513
11513
  });
11514
- const textDocuments = {
11515
- count: documentSource.count,
11516
- textFields: source.fieldLengthNames,
11517
- documentAt: (ordinal) => documentSource.readAt(ordinal)
11514
+ const textFieldsOnly = {
11515
+ kind: "fields",
11516
+ include: source.fieldLengthNames.map((fieldPath) => fieldPath.split(".")),
11517
+ exclude: []
11518
11518
  };
11519
+ const textAt2 = (ordinal) => documentSource.readAt(ordinal, textFieldsOnly);
11520
+ const textDocuments = { count: documentSource.count, textFields: source.fieldLengthNames, documentAt: textAt2 };
11519
11521
  const loadSurfaceForms = survivingSurfaceForms === void 0 ? source.readSurfaceForms : () => survivingSurfaceForms;
11520
11522
  const surfaces = createFrozenSurfaceSlot(
11521
11523
  loadSurfaceForms,
@@ -11587,7 +11589,7 @@ function assembleFrozenSegment(segmentId, source, documentSource, sharedSnapshot
11587
11589
  source.fieldNames,
11588
11590
  source.fieldLengthNames,
11589
11591
  ordinal,
11590
- documentSource.readAt(ordinal),
11592
+ textAt2(ordinal),
11591
11593
  analysis,
11592
11594
  surfaces,
11593
11595
  partialWords
@@ -12379,7 +12381,7 @@ function segmentsHostPart() {
12379
12381
 
12380
12382
  // src/core/segment-codec-code.ts
12381
12383
  var segmentCodec = codeLoader(async () => {
12382
- const [msgpack, code7] = await Promise.all([loadMessagePack(), import('./segment-codec-leaf-A427QJUX.mjs')]);
12384
+ const [msgpack, code7] = await Promise.all([loadMessagePack(), import('./segment-codec-leaf-GXSRX5VT.mjs')]);
12383
12385
  code7.bindSegmentCodecHost(optionalCodeHost(), msgpack);
12384
12386
  return code7;
12385
12387
  }, "segment codec");
@@ -12387,7 +12389,7 @@ var loadSegmentCodec = segmentCodec.load;
12387
12389
 
12388
12390
  // src/engine/optional-writes-code.ts
12389
12391
  var optionalWrites = codeLoader(async () => {
12390
- const [segmentCodec2, code7] = await Promise.all([loadSegmentCodec(), import('./optional-writes-HVPPDHSY.mjs')]);
12392
+ const [segmentCodec2, code7] = await Promise.all([loadSegmentCodec(), import('./optional-writes-3HKIVZFU.mjs')]);
12391
12393
  code7.bindOptionalWritesHost(optionalCodeHost(), segmentCodec2);
12392
12394
  return code7;
12393
12395
  }, "write");
@@ -15023,6 +15025,177 @@ function mergeGroupComponents(components, internalId, contribution) {
15023
15025
  });
15024
15026
  }
15025
15027
 
15028
+ // src/core/partition/top-k-heap.ts
15029
+ function candidateWorse(a, b) {
15030
+ if (a.score < b.score) return true;
15031
+ if (a.score > b.score) return false;
15032
+ return unorderedCandidateWorse(a, b);
15033
+ }
15034
+ function unorderedCandidateWorse(a, b) {
15035
+ return (compareScores(a.score, b.score) || compareCodePoints(a.externalId, b.externalId)) > 0;
15036
+ }
15037
+ function buildMinHeap(heap) {
15038
+ for (let index = (heap.length >> 1) - 1; index >= 0; index--) {
15039
+ siftDown(heap, index);
15040
+ }
15041
+ }
15042
+ function siftDown(heap, start) {
15043
+ const len = heap.length;
15044
+ let current = start;
15045
+ for (; ; ) {
15046
+ let worst = current;
15047
+ const left = 2 * current + 1;
15048
+ const right = 2 * current + 2;
15049
+ if (left < len && candidateWorse(heap[left], heap[worst])) worst = left;
15050
+ if (right < len && candidateWorse(heap[right], heap[worst])) worst = right;
15051
+ if (worst === current) break;
15052
+ const held = heap[current];
15053
+ heap[current] = heap[worst];
15054
+ heap[worst] = held;
15055
+ current = worst;
15056
+ }
15057
+ }
15058
+ function sortSelection(heap) {
15059
+ heap.sort((a, b) => compareScores(a.score, b.score) || compareCodePoints(a.externalId, b.externalId));
15060
+ }
15061
+
15062
+ // src/core/partition/score-buffer.ts
15063
+ var MAX_GENERATION = 2147483647;
15064
+ function createScoreBuffer(capacity) {
15065
+ return {
15066
+ scores: new Float64Array(capacity),
15067
+ stamps: new Int32Array(capacity),
15068
+ touched: new Int32Array(Math.max(1, Math.min(capacity, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY))),
15069
+ touchedCount: 0,
15070
+ generation: 0
15071
+ };
15072
+ }
15073
+ function beginScoring(buffer, capacity) {
15074
+ if (buffer.scores.length < capacity) {
15075
+ buffer.scores = new Float64Array(capacity);
15076
+ buffer.stamps = new Int32Array(capacity);
15077
+ buffer.generation = 0;
15078
+ }
15079
+ if (buffer.generation >= MAX_GENERATION) {
15080
+ buffer.stamps.fill(0);
15081
+ buffer.generation = 0;
15082
+ }
15083
+ buffer.generation++;
15084
+ buffer.touchedCount = 0;
15085
+ }
15086
+ function appendTouched(buffer, internalId) {
15087
+ if (buffer.touchedCount === buffer.touched.length) {
15088
+ const grown2 = new Int32Array(buffer.touched.length * 2);
15089
+ grown2.set(buffer.touched);
15090
+ buffer.touched = grown2;
15091
+ }
15092
+ buffer.touched[buffer.touchedCount] = internalId;
15093
+ buffer.touchedCount++;
15094
+ }
15095
+ function addScore(buffer, internalId, termScore) {
15096
+ if (buffer.stamps[internalId] === buffer.generation) {
15097
+ buffer.scores[internalId] += termScore;
15098
+ return;
15099
+ }
15100
+ buffer.stamps[internalId] = buffer.generation;
15101
+ buffer.scores[internalId] = termScore;
15102
+ appendTouched(buffer, internalId);
15103
+ }
15104
+ function markCounted(buffer, internalId) {
15105
+ const countedStamp = -buffer.generation;
15106
+ const stamp = buffer.stamps[internalId];
15107
+ if (stamp === buffer.generation || stamp === countedStamp) return false;
15108
+ buffer.stamps[internalId] = countedStamp;
15109
+ return true;
15110
+ }
15111
+ function kthBestScore(buffer, selection, resolver) {
15112
+ const wanted = selection.length;
15113
+ const { touched, touchedCount, scores } = buffer;
15114
+ let size = 0;
15115
+ let unordered = 0;
15116
+ for (let index = 0; index < touchedCount; index++) {
15117
+ const internalId = touched[index];
15118
+ const score = scores[internalId];
15119
+ if (size === wanted && !(score > selection[0])) continue;
15120
+ if (!resolver.isLive(internalId)) continue;
15121
+ let at = 0;
15122
+ if (size < wanted) {
15123
+ if (Number.isNaN(score)) {
15124
+ unordered++;
15125
+ continue;
15126
+ }
15127
+ at = size++;
15128
+ while (at > 0) {
15129
+ const parent = at - 1 >> 1;
15130
+ if (selection[parent] <= score) break;
15131
+ selection[at] = selection[parent];
15132
+ at = parent;
15133
+ }
15134
+ } else {
15135
+ for (; ; ) {
15136
+ const left = 2 * at + 1;
15137
+ if (left >= size) break;
15138
+ const right = left + 1;
15139
+ const child = right < size && selection[right] < selection[left] ? right : left;
15140
+ if (selection[child] >= score) break;
15141
+ selection[at] = selection[child];
15142
+ at = child;
15143
+ }
15144
+ }
15145
+ selection[at] = score;
15146
+ }
15147
+ if (wanted === 0) return Number.NEGATIVE_INFINITY;
15148
+ if (size === wanted) return selection[0];
15149
+ return size + unordered >= wanted ? Number.NaN : Number.NEGATIVE_INFINITY;
15150
+ }
15151
+ function hasScore(buffer, internalId) {
15152
+ return buffer.stamps[internalId] === buffer.generation;
15153
+ }
15154
+ function topKFromBuffer(buffer, k, resolver, components) {
15155
+ const wanted = Number.isFinite(k) ? Math.max(0, Math.floor(k)) : 0;
15156
+ if (wanted <= 0) return [];
15157
+ const heap = [];
15158
+ const { touched, touchedCount, scores } = buffer;
15159
+ let full = false;
15160
+ let threshold = 0;
15161
+ for (let index = 0; index < touchedCount; index++) {
15162
+ const internalId = touched[index];
15163
+ const score = scores[internalId];
15164
+ if (full && (score < threshold || Number.isNaN(score) && !Number.isNaN(threshold))) continue;
15165
+ const externalId = resolver.toExternal(internalId);
15166
+ if (externalId === void 0) continue;
15167
+ const candidate = { internalId, externalId, score };
15168
+ if (!full) {
15169
+ heap.push(candidate);
15170
+ if (heap.length === wanted) {
15171
+ buildMinHeap(heap);
15172
+ full = true;
15173
+ threshold = heap[0].score;
15174
+ }
15175
+ continue;
15176
+ }
15177
+ if (candidateWorse(heap[0], candidate)) {
15178
+ heap[0] = candidate;
15179
+ siftDown(heap, 0);
15180
+ threshold = heap[0].score;
15181
+ }
15182
+ }
15183
+ sortSelection(heap);
15184
+ const result = new Array(heap.length);
15185
+ for (let index = 0; index < heap.length; index++) {
15186
+ const entry = heap[index];
15187
+ const record = components?.get(entry.internalId);
15188
+ result[index] = {
15189
+ docId: entry.externalId,
15190
+ score: entry.score,
15191
+ termFrequencies: record?.termFrequencies ?? EMPTY_COMPONENTS,
15192
+ fieldLengths: record?.fieldLengths ?? EMPTY_COMPONENTS,
15193
+ idf: record?.idf ?? EMPTY_COMPONENTS
15194
+ };
15195
+ }
15196
+ return result;
15197
+ }
15198
+
15026
15199
  // src/core/partition/group-scoring.ts
15027
15200
  function partialFieldMarks(fieldNames, partialFields) {
15028
15201
  const marks = new Uint8Array(fieldNames.length);
@@ -15076,72 +15249,98 @@ function groupPostingCount(matches) {
15076
15249
  for (const match of matches) total += match.postingList.length;
15077
15250
  return total;
15078
15251
  }
15079
- function computeGroupContributions(context, matches, collect) {
15080
- const { fields, fieldNames, filterBitset, partialMarks } = context;
15252
+ function scoreMatchPostings(context, match, visit) {
15253
+ const { fields, filterBitset, partialMarks } = context;
15081
15254
  const scoresAreZero = context.totalDocs === 0;
15082
15255
  const onePair = fields.boundPairs.length === 2;
15256
+ const { docIds, termFrequencies, fieldNameIndices, deletedDocs, hasDeleted, count } = postingColumns(
15257
+ match.postingList
15258
+ );
15259
+ let runStart = 0;
15260
+ let runEnd = 0;
15261
+ for (let at = 0; at < count; at++) {
15262
+ const internalId = docIds[at];
15263
+ if (hasDeleted && deletedDocs.has(internalId)) continue;
15264
+ if (filterBitset && !bitsetHas(filterBitset, internalId)) continue;
15265
+ let pi = at;
15266
+ if (at < runEnd) {
15267
+ pi = fieldRun.entries[at - runStart];
15268
+ } else if (at + 2 < count && docIds[at + 2] === internalId) {
15269
+ pi = orderRunByFieldName(docIds, fieldNameIndices, fields.nameRanks, at, count)[0];
15270
+ runStart = at;
15271
+ runEnd = at + fieldRun.length;
15272
+ }
15273
+ const fieldIndex = fieldNameIndices[pi];
15274
+ if (fields.searchable[fieldIndex] === 0) continue;
15275
+ const factor = partialMarks[fieldIndex] === 1 ? match.partialFactor : match.factor;
15276
+ if (factor === 0) continue;
15277
+ const termFrequency = termFrequencies[pi];
15278
+ const fieldBoost = fields.boosts[fieldIndex];
15279
+ const avgLen = fields.averageLengths[fieldIndex];
15280
+ const actualFieldLength = fieldLengthOf(fields.lengthColumns, fieldIndex, internalId, avgLen);
15281
+ const termScore = (scoresAreZero ? 0 : computeBM25WithIDF(
15282
+ termFrequency,
15283
+ match.idf,
15284
+ actualFieldLength,
15285
+ avgLen,
15286
+ onePair ? fields.boundPairs[0] : fields.k1s[fieldIndex],
15287
+ onePair ? fields.boundPairs[1] : fields.bs[fieldIndex]
15288
+ )) * fieldBoost * factor;
15289
+ visit(internalId, fieldIndex, termFrequency, actualFieldLength, termScore);
15290
+ }
15291
+ }
15292
+ var termScores = null;
15293
+ var bestScores = null;
15294
+ function addGroupScores(context, matches, target, only, coverage) {
15295
+ const best = bestGroupScores(context, matches, target.scores.length);
15296
+ for (let index = 0; index < best.touchedCount; index++) {
15297
+ const internalId = best.touched[index];
15298
+ if (only !== null && !bitsetHas(only, internalId)) continue;
15299
+ coverage?.mark(internalId);
15300
+ addScore(target, internalId, best.scores[internalId]);
15301
+ }
15302
+ }
15303
+ function bestGroupScores(context, matches, capacity) {
15304
+ termScores ??= createScoreBuffer(capacity);
15305
+ bestScores ??= createScoreBuffer(capacity);
15306
+ const perTerm = termScores;
15307
+ const best = bestScores;
15308
+ const addTermScore = (internalId, _fieldIndex, _termFrequency, _fieldLength, termScore) => addScore(perTerm, internalId, termScore);
15309
+ beginScoring(best, capacity);
15310
+ for (const match of matches) {
15311
+ beginScoring(perTerm, capacity);
15312
+ scoreMatchPostings(context, match, addTermScore);
15313
+ for (let index = 0; index < perTerm.touchedCount; index++) {
15314
+ const internalId = perTerm.touched[index];
15315
+ const score = perTerm.scores[internalId];
15316
+ if (!hasScore(best, internalId)) addScore(best, internalId, score);
15317
+ else if (compareScores(score, best.scores[internalId]) < 0) best.scores[internalId] = score;
15318
+ }
15319
+ }
15320
+ return best;
15321
+ }
15322
+ function computeGroupContributions(context, matches) {
15323
+ const { fieldNames } = context;
15083
15324
  const best = /* @__PURE__ */ new Map();
15084
15325
  for (const match of matches) {
15085
15326
  const perTerm = /* @__PURE__ */ new Map();
15086
- const { docIds, termFrequencies, fieldNameIndices, deletedDocs, hasDeleted, count } = postingColumns(
15087
- match.postingList
15088
- );
15089
- let runStart = 0;
15090
- let runEnd = 0;
15091
- for (let at = 0; at < count; at++) {
15092
- const internalId = docIds[at];
15093
- if (hasDeleted && deletedDocs.has(internalId)) continue;
15094
- if (filterBitset && !bitsetHas(filterBitset, internalId)) continue;
15095
- let pi = at;
15096
- if (at < runEnd) {
15097
- pi = fieldRun.entries[at - runStart];
15098
- } else if (at + 2 < count && docIds[at + 2] === internalId) {
15099
- pi = orderRunByFieldName(docIds, fieldNameIndices, fields.nameRanks, at, count)[0];
15100
- runStart = at;
15101
- runEnd = at + fieldRun.length;
15102
- }
15103
- const fieldIndex = fieldNameIndices[pi];
15104
- if (fields.searchable[fieldIndex] === 0) continue;
15105
- const factor = partialMarks[fieldIndex] === 1 ? match.partialFactor : match.factor;
15106
- if (factor === 0) continue;
15327
+ scoreMatchPostings(context, match, (internalId, fieldIndex, termFrequency, actualFieldLength, termScore) => {
15107
15328
  const fieldName = fieldNames[fieldIndex];
15108
- const termFrequency = termFrequencies[pi];
15109
- const fieldBoost = fields.boosts[fieldIndex];
15110
- const avgLen = fields.averageLengths[fieldIndex];
15111
- const actualFieldLength = fieldLengthOf(fields.lengthColumns, fieldIndex, internalId, avgLen);
15112
- const termScore = (scoresAreZero ? 0 : computeBM25WithIDF(
15113
- termFrequency,
15114
- match.idf,
15115
- actualFieldLength,
15116
- avgLen,
15117
- onePair ? fields.boundPairs[0] : fields.k1s[fieldIndex],
15118
- onePair ? fields.boundPairs[1] : fields.bs[fieldIndex]
15119
- )) * fieldBoost * factor;
15120
15329
  const existing = perTerm.get(internalId);
15121
15330
  if (existing) {
15122
15331
  existing.score += termScore;
15123
- if (collect) {
15124
- existing.termFrequencies[`${fieldName}:${match.token}`] = termFrequency;
15125
- existing.fieldLengths[fieldName] = actualFieldLength;
15126
- }
15127
- } else if (collect) {
15128
- perTerm.set(internalId, {
15129
- score: termScore,
15130
- token: match.token,
15131
- idf: match.idf,
15132
- termFrequencies: { [`${fieldName}:${match.token}`]: termFrequency },
15133
- fieldLengths: { [fieldName]: actualFieldLength }
15134
- });
15135
- } else {
15136
- perTerm.set(internalId, {
15137
- score: termScore,
15138
- token: match.token,
15139
- idf: match.idf,
15140
- termFrequencies: EMPTY_COMPONENTS,
15141
- fieldLengths: EMPTY_COMPONENTS
15142
- });
15332
+ existing.termFrequencies[`${fieldName}:${match.token}`] = termFrequency;
15333
+ existing.fieldLengths[fieldName] = actualFieldLength;
15334
+ return;
15143
15335
  }
15144
- }
15336
+ perTerm.set(internalId, {
15337
+ score: termScore,
15338
+ token: match.token,
15339
+ idf: match.idf,
15340
+ termFrequencies: { [`${fieldName}:${match.token}`]: termFrequency },
15341
+ fieldLengths: { [fieldName]: actualFieldLength }
15342
+ });
15343
+ });
15145
15344
  for (const [internalId, contribution] of perTerm) {
15146
15345
  const current = best.get(internalId);
15147
15346
  if (!current || compareScores(contribution.score, current.score) < 0) {
@@ -15668,177 +15867,6 @@ function blockBoundsFor(list, columns) {
15668
15867
  return built2;
15669
15868
  }
15670
15869
 
15671
- // src/core/partition/top-k-heap.ts
15672
- function candidateWorse(a, b) {
15673
- if (a.score < b.score) return true;
15674
- if (a.score > b.score) return false;
15675
- return unorderedCandidateWorse(a, b);
15676
- }
15677
- function unorderedCandidateWorse(a, b) {
15678
- return (compareScores(a.score, b.score) || compareCodePoints(a.externalId, b.externalId)) > 0;
15679
- }
15680
- function buildMinHeap(heap) {
15681
- for (let index = (heap.length >> 1) - 1; index >= 0; index--) {
15682
- siftDown(heap, index);
15683
- }
15684
- }
15685
- function siftDown(heap, start) {
15686
- const len = heap.length;
15687
- let current = start;
15688
- for (; ; ) {
15689
- let worst = current;
15690
- const left = 2 * current + 1;
15691
- const right = 2 * current + 2;
15692
- if (left < len && candidateWorse(heap[left], heap[worst])) worst = left;
15693
- if (right < len && candidateWorse(heap[right], heap[worst])) worst = right;
15694
- if (worst === current) break;
15695
- const held = heap[current];
15696
- heap[current] = heap[worst];
15697
- heap[worst] = held;
15698
- current = worst;
15699
- }
15700
- }
15701
- function sortSelection(heap) {
15702
- heap.sort((a, b) => compareScores(a.score, b.score) || compareCodePoints(a.externalId, b.externalId));
15703
- }
15704
-
15705
- // src/core/partition/score-buffer.ts
15706
- var MAX_GENERATION = 2147483647;
15707
- function createScoreBuffer(capacity) {
15708
- return {
15709
- scores: new Float64Array(capacity),
15710
- stamps: new Int32Array(capacity),
15711
- touched: new Int32Array(Math.max(1, Math.min(capacity, SCORE_BUFFER_INITIAL_TOUCHED_CAPACITY))),
15712
- touchedCount: 0,
15713
- generation: 0
15714
- };
15715
- }
15716
- function beginScoring(buffer, capacity) {
15717
- if (buffer.scores.length < capacity) {
15718
- buffer.scores = new Float64Array(capacity);
15719
- buffer.stamps = new Int32Array(capacity);
15720
- buffer.generation = 0;
15721
- }
15722
- if (buffer.generation >= MAX_GENERATION) {
15723
- buffer.stamps.fill(0);
15724
- buffer.generation = 0;
15725
- }
15726
- buffer.generation++;
15727
- buffer.touchedCount = 0;
15728
- }
15729
- function appendTouched(buffer, internalId) {
15730
- if (buffer.touchedCount === buffer.touched.length) {
15731
- const grown2 = new Int32Array(buffer.touched.length * 2);
15732
- grown2.set(buffer.touched);
15733
- buffer.touched = grown2;
15734
- }
15735
- buffer.touched[buffer.touchedCount] = internalId;
15736
- buffer.touchedCount++;
15737
- }
15738
- function addScore(buffer, internalId, termScore) {
15739
- if (buffer.stamps[internalId] === buffer.generation) {
15740
- buffer.scores[internalId] += termScore;
15741
- return;
15742
- }
15743
- buffer.stamps[internalId] = buffer.generation;
15744
- buffer.scores[internalId] = termScore;
15745
- appendTouched(buffer, internalId);
15746
- }
15747
- function markCounted(buffer, internalId) {
15748
- const countedStamp = -buffer.generation;
15749
- const stamp = buffer.stamps[internalId];
15750
- if (stamp === buffer.generation || stamp === countedStamp) return false;
15751
- buffer.stamps[internalId] = countedStamp;
15752
- return true;
15753
- }
15754
- function kthBestScore(buffer, selection, resolver) {
15755
- const wanted = selection.length;
15756
- const { touched, touchedCount, scores } = buffer;
15757
- let size = 0;
15758
- let unordered = 0;
15759
- for (let index = 0; index < touchedCount; index++) {
15760
- const internalId = touched[index];
15761
- const score = scores[internalId];
15762
- if (size === wanted && !(score > selection[0])) continue;
15763
- if (!resolver.isLive(internalId)) continue;
15764
- let at = 0;
15765
- if (size < wanted) {
15766
- if (Number.isNaN(score)) {
15767
- unordered++;
15768
- continue;
15769
- }
15770
- at = size++;
15771
- while (at > 0) {
15772
- const parent = at - 1 >> 1;
15773
- if (selection[parent] <= score) break;
15774
- selection[at] = selection[parent];
15775
- at = parent;
15776
- }
15777
- } else {
15778
- for (; ; ) {
15779
- const left = 2 * at + 1;
15780
- if (left >= size) break;
15781
- const right = left + 1;
15782
- const child = right < size && selection[right] < selection[left] ? right : left;
15783
- if (selection[child] >= score) break;
15784
- selection[at] = selection[child];
15785
- at = child;
15786
- }
15787
- }
15788
- selection[at] = score;
15789
- }
15790
- if (wanted === 0) return Number.NEGATIVE_INFINITY;
15791
- if (size === wanted) return selection[0];
15792
- return size + unordered >= wanted ? Number.NaN : Number.NEGATIVE_INFINITY;
15793
- }
15794
- function hasScore(buffer, internalId) {
15795
- return buffer.stamps[internalId] === buffer.generation;
15796
- }
15797
- function topKFromBuffer(buffer, k, resolver, components) {
15798
- const wanted = Number.isFinite(k) ? Math.max(0, Math.floor(k)) : 0;
15799
- if (wanted <= 0) return [];
15800
- const heap = [];
15801
- const { touched, touchedCount, scores } = buffer;
15802
- let full = false;
15803
- let threshold = 0;
15804
- for (let index = 0; index < touchedCount; index++) {
15805
- const internalId = touched[index];
15806
- const score = scores[internalId];
15807
- if (full && (score < threshold || Number.isNaN(score) && !Number.isNaN(threshold))) continue;
15808
- const externalId = resolver.toExternal(internalId);
15809
- if (externalId === void 0) continue;
15810
- const candidate = { internalId, externalId, score };
15811
- if (!full) {
15812
- heap.push(candidate);
15813
- if (heap.length === wanted) {
15814
- buildMinHeap(heap);
15815
- full = true;
15816
- threshold = heap[0].score;
15817
- }
15818
- continue;
15819
- }
15820
- if (candidateWorse(heap[0], candidate)) {
15821
- heap[0] = candidate;
15822
- siftDown(heap, 0);
15823
- threshold = heap[0].score;
15824
- }
15825
- }
15826
- sortSelection(heap);
15827
- const result = new Array(heap.length);
15828
- for (let index = 0; index < heap.length; index++) {
15829
- const entry = heap[index];
15830
- const record = components?.get(entry.internalId);
15831
- result[index] = {
15832
- docId: entry.externalId,
15833
- score: entry.score,
15834
- termFrequencies: record?.termFrequencies ?? EMPTY_COMPONENTS,
15835
- fieldLengths: record?.fieldLengths ?? EMPTY_COMPONENTS,
15836
- idf: record?.idf ?? EMPTY_COMPONENTS
15837
- };
15838
- }
15839
- return result;
15840
- }
15841
-
15842
15870
  // src/core/partition/multi-term-topk.ts
15843
15871
  function prunableMultiTermLists(params, index) {
15844
15872
  if (params.queryTokens.length < 2) return null;
@@ -16473,10 +16501,14 @@ function searchFulltext(state, params) {
16473
16501
  }
16474
16502
  function scoreGroup(group, only) {
16475
16503
  if (group === null) return;
16476
- for (const [internalId, contribution] of computeGroupContributions(groupContext, group, collectComponents)) {
16477
- if (only !== null && !bitsetHas(only, internalId)) continue;
16478
- mergeGroupContribution(internalId, contribution);
16504
+ if (components !== null) {
16505
+ for (const [internalId, contribution] of computeGroupContributions(groupContext, group)) {
16506
+ if (only !== null && !bitsetHas(only, internalId)) continue;
16507
+ mergeGroupContribution(internalId, contribution);
16508
+ }
16509
+ return;
16479
16510
  }
16511
+ addGroupScores(groupContext, group, scoreBuffer, only, coverage);
16480
16512
  }
16481
16513
  const prunableList = phrases === void 0 ? prunableSingleTermList(params, state.invertedIdx, fieldNames) : null;
16482
16514
  if (prunableList !== null && maxResults !== void 0) {
@@ -19905,6 +19937,7 @@ function writesHostPart() {
19905
19937
  requireDocumentWithinSizeLimit,
19906
19938
  requireMatchingDocId,
19907
19939
  requireSurfaceFormsForPartialFields,
19940
+ setNestedValue,
19908
19941
  storedBM25Params,
19909
19942
  turnsAreBudgeted,
19910
19943
  updateDocumentVectors,
@@ -1203,7 +1203,7 @@ var loaded = null;
1203
1203
  var loading = null;
1204
1204
  function loadMessagePack() {
1205
1205
  if (loaded !== null) return Promise.resolve(loaded);
1206
- loading ??= import('./msgpack-leaf-FEPCLXXY.mjs').then(
1206
+ loading ??= import('./msgpack-leaf-76Q5SZ5S.mjs').then(
1207
1207
  (code) => {
1208
1208
  code.bindMsgpackHost({
1209
1209
  BYTE_ORDER_MARK_WALK_BYTES_PER_HEADER,
@@ -1,4 +1,4 @@
1
- import { NarsilError, ErrorCodes, loadMessagePack, ClientErrorCodes, ServerErrorCodes, describeError } from './chunk-WRRXR57N.mjs';
1
+ import { NarsilError, ErrorCodes, loadMessagePack, ClientErrorCodes, ServerErrorCodes, describeError } from './chunk-VAPCFSMX.mjs';
2
2
 
3
3
  // src/json-encoding.ts
4
4
  function toPlainNumbers(key, value) {
@@ -62,24 +62,31 @@ function encodeDocument(document) {
62
62
  }
63
63
 
64
64
  // src/serialization/msgpack-header.ts
65
- function headerAt(view, offset) {
65
+ function headerOf(headerBytes, bodyBytes, children, into) {
66
+ if (into === void 0) return { headerBytes, bodyBytes, children };
67
+ into.headerBytes = headerBytes;
68
+ into.bodyBytes = bodyBytes;
69
+ into.children = children;
70
+ return into;
71
+ }
72
+ function headerAt(view, offset, into) {
66
73
  if (offset >= view.byteLength) return null;
67
74
  const tag = view.getUint8(offset);
68
- if (tag <= 127 || tag >= 224) return { headerBytes: 1, bodyBytes: 0, children: 0 };
69
- if (tag <= 143) return { headerBytes: 1, bodyBytes: 0, children: (tag & 15) * 2 };
70
- if (tag <= 159) return { headerBytes: 1, bodyBytes: 0, children: tag & 15 };
71
- if (tag <= 191) return { headerBytes: 1, bodyBytes: tag & 31, children: 0 };
75
+ if (tag <= 127 || tag >= 224) return headerOf(1, 0, 0, into);
76
+ if (tag <= 143) return headerOf(1, 0, (tag & 15) * 2, into);
77
+ if (tag <= 159) return headerOf(1, 0, tag & 15, into);
78
+ if (tag <= 191) return headerOf(1, tag & 31, 0, into);
72
79
  const lengthBytes = LENGTH_BYTES_BY_TAG.get(tag);
73
80
  if (lengthBytes !== void 0) {
74
81
  if (offset + 1 + lengthBytes > view.byteLength) return null;
75
82
  const length = lengthBytes === 1 ? view.getUint8(offset + 1) : lengthBytes === 2 ? view.getUint16(offset + 1, false) : view.getUint32(offset + 1, false);
76
83
  const headerBytes = 1 + lengthBytes;
77
- if (ARRAY_TAGS.has(tag)) return { headerBytes, bodyBytes: 0, children: length };
78
- if (MAP_TAGS.has(tag)) return { headerBytes, bodyBytes: 0, children: length * 2 };
79
- return { headerBytes, bodyBytes: length + (EXT_TAGS.has(tag) ? 1 : 0), children: 0 };
84
+ if (ARRAY_TAGS.has(tag)) return headerOf(headerBytes, 0, length, into);
85
+ if (MAP_TAGS.has(tag)) return headerOf(headerBytes, 0, length * 2, into);
86
+ return headerOf(headerBytes, length + (EXT_TAGS.has(tag) ? 1 : 0), 0, into);
80
87
  }
81
88
  const fixedBytes = FIXED_BODY_BYTES_BY_TAG.get(tag);
82
- return fixedBytes === void 0 ? null : { headerBytes: 1, bodyBytes: fixedBytes, children: 0 };
89
+ return fixedBytes === void 0 ? null : headerOf(1, fixedBytes, 0, into);
83
90
  }
84
91
  var LENGTH_BYTES_BY_TAG = /* @__PURE__ */ new Map([
85
92
  [196, 1],