@yoch/frozenminisearch 1.0.1 → 1.1.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/CHANGELOG.md +27 -5
- package/README.md +38 -20
- package/dist/cjs/index.cjs +545 -275
- package/dist/es/index.d.ts +32 -8
- package/dist/es/index.js +545 -275
- package/package.json +10 -2
package/dist/es/index.d.ts
CHANGED
|
@@ -411,6 +411,21 @@ interface FrozenPostingsLayout {
|
|
|
411
411
|
/** Adaptive-width unsigned column (1/2/4 bytes per element) for field lengths and packed radix columns. */
|
|
412
412
|
type FieldLengthArray = PackedIndexArray;
|
|
413
413
|
|
|
414
|
+
/**
|
|
415
|
+
* Runtime stored fields. Single store field → one column (no per-doc Record at rest).
|
|
416
|
+
* Wire format stays row JSON; encode/decode can skip intermediate row arrays when layout is known.
|
|
417
|
+
*/
|
|
418
|
+
type StoredFieldsLayout = {
|
|
419
|
+
kind: 'none';
|
|
420
|
+
} | {
|
|
421
|
+
kind: 'single';
|
|
422
|
+
field: string;
|
|
423
|
+
values: unknown[];
|
|
424
|
+
} | {
|
|
425
|
+
kind: 'multi';
|
|
426
|
+
rows: (Record<string, unknown> | undefined)[];
|
|
427
|
+
};
|
|
428
|
+
|
|
414
429
|
interface FrozenMemoryBreakdown {
|
|
415
430
|
termCount: number;
|
|
416
431
|
documentCount: number;
|
|
@@ -444,7 +459,7 @@ interface FrozenMemoryBreakdown {
|
|
|
444
459
|
/**
|
|
445
460
|
* Low-level parameters for {@link assembleFrozen} (custom frozen index pipelines).
|
|
446
461
|
* Field types are part of the public surface for advanced assembly; typical apps use
|
|
447
|
-
* {@link buildFrozenFromDocuments}, {@link FrozenMiniSearch.
|
|
462
|
+
* {@link buildFrozenFromDocuments}, {@link FrozenMiniSearch.fromJson}, or binary load instead.
|
|
448
463
|
*/
|
|
449
464
|
interface FrozenAssembleParams<T = any> {
|
|
450
465
|
options: OptionsWithDefaults<T>;
|
|
@@ -456,7 +471,7 @@ interface FrozenAssembleParams<T = any> {
|
|
|
456
471
|
fieldCount: number;
|
|
457
472
|
externalIds: unknown[];
|
|
458
473
|
idLookup: IdToShortIdLookup;
|
|
459
|
-
storedFields:
|
|
474
|
+
storedFields: StoredFieldsLayout;
|
|
460
475
|
fieldLengthMatrix: FieldLengthArray;
|
|
461
476
|
avgFieldLength: Float32Array;
|
|
462
477
|
index: FrozenTermIndex;
|
|
@@ -464,7 +479,7 @@ interface FrozenAssembleParams<T = any> {
|
|
|
464
479
|
postings: FrozenPostingsLayout;
|
|
465
480
|
}
|
|
466
481
|
|
|
467
|
-
/**
|
|
482
|
+
/** MiniSearch JSON snapshot (`toJSON` wire format, `serializationVersion` 1 or 2). */
|
|
468
483
|
type SerializedIndexEntry = Record<string, number>;
|
|
469
484
|
type MiniSearchSnapshot = {
|
|
470
485
|
documentCount: number;
|
|
@@ -592,17 +607,26 @@ declare class FrozenMiniSearch<T = any> {
|
|
|
592
607
|
/** Build a read-only index in one pass from documents. */
|
|
593
608
|
static fromDocuments<T>(documents: readonly T[], options: Options<T>): FrozenMiniSearch<T>;
|
|
594
609
|
/**
|
|
595
|
-
*
|
|
596
|
-
*
|
|
610
|
+
* Export this index as a MiniSearch wire snapshot (`serializationVersion: 2`).
|
|
611
|
+
* Use for migration or interchange with the `minisearch` package (`JSON.stringify` works via this method).
|
|
612
|
+
* Not the primary persistence format — prefer {@link saveBinarySync} for production (size and load time).
|
|
613
|
+
* Term order in `index` may differ from MiniSearch native `toJSON`; search scores stay equivalent.
|
|
614
|
+
*/
|
|
615
|
+
toJSON(): MiniSearchSnapshot;
|
|
616
|
+
/**
|
|
617
|
+
* Build a new frozen index **from** a MiniSearch JSON snapshot string (import / migration).
|
|
618
|
+
* Accepts the wire format produced by MiniSearch `toJSON` or by {@link toJSON} on this class.
|
|
619
|
+
* Distinct from {@link loadBinarySync}: JSON is MiniSearch interchange, not the native frozen binary.
|
|
620
|
+
* No runtime dependency on the `minisearch` package.
|
|
597
621
|
*/
|
|
598
|
-
static
|
|
622
|
+
static fromJson<T>(json: string, options?: Options<T>): FrozenMiniSearch<T>;
|
|
599
623
|
/**
|
|
600
|
-
* Same as {@link
|
|
624
|
+
* Same as {@link fromJson} with a pre-parsed snapshot object.
|
|
601
625
|
* `storedFields` are shallow-copied; callers must not mutate nested values
|
|
602
626
|
* after load if they intend to keep the index immutable.
|
|
603
627
|
*/
|
|
604
628
|
static fromMiniSearchSnapshot<T>(snapshot: MiniSearchSnapshot, options?: Options<T>): FrozenMiniSearch<T>;
|
|
605
|
-
/** Accepts any object exposing `toJSON()` in
|
|
629
|
+
/** Accepts any object exposing `toJSON()` in MiniSearch snapshot shape. */
|
|
606
630
|
static fromMiniSearch<T>(source: {
|
|
607
631
|
toJSON(): MiniSearchSnapshot;
|
|
608
632
|
}, options?: Options<T>): FrozenMiniSearch<T>;
|