@vinary-tree/liblevenshtein 0.0.0 → 4.0.0-rc.4
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.
Potentially problematic release.
This version of @vinary-tree/liblevenshtein might be problematic. Click here for more details.
- package/README.md +157 -4
- package/abi.d.ts +33 -0
- package/cljs/vinary_tree/liblevenshtein.cljs +38 -0
- package/deps.cljs +1 -0
- package/facades/clojurescript.cjs +2 -0
- package/facades/clojurescript.d.ts +2 -0
- package/facades/clojurescript.mjs +2 -0
- package/facades/native.cjs +13 -0
- package/facades/native.mjs +24 -0
- package/facades/typescript.cjs +2 -0
- package/facades/typescript.d.ts +2 -0
- package/facades/typescript.mjs +2 -0
- package/facades/wasi.cjs +10 -0
- package/facades/wasi.mjs +17 -0
- package/facades/wasm.mjs +12 -0
- package/index.d.ts +82 -0
- package/package.json +65 -6
- package/index.js +0 -2
package/README.md
CHANGED
|
@@ -1,5 +1,158 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@vinary-tree/liblevenshtein`
|
|
2
2
|
|
|
3
|
-
This
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
This package is the project-local JavaScript, TypeScript, and ClojureScript
|
|
4
|
+
facade for liblevenshtein. It does not contain a second copy of the runtime.
|
|
5
|
+
Every entry point re-exports the liblevenshtein namespace from the exact same
|
|
6
|
+
version of `@vinary-tree/vinary-tree`, so objects created by
|
|
7
|
+
`@vinary-tree/libdictenstein` can be passed directly to `transducer()`.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { dynamicDawg } from "@vinary-tree/libdictenstein";
|
|
11
|
+
import { transducer } from "@vinary-tree/liblevenshtein";
|
|
12
|
+
|
|
13
|
+
using dictionary = dynamicDawg(["cat", "cot", "cut"]);
|
|
14
|
+
using automaton = transducer(dictionary, "standard");
|
|
15
|
+
using cursor = automaton.query("cat", 1);
|
|
16
|
+
for (const match of cursor) console.log(match);
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Node selects the native N-API runtime by default. Use
|
|
20
|
+
`@vinary-tree/liblevenshtein/wasm` for the browser/static WebAssembly runtime or
|
|
21
|
+
`@vinary-tree/liblevenshtein/wasi` for the Node/WASI runtime. The WASI facade is
|
|
22
|
+
where preopened-directory persistent dictionaries are exposed as portable
|
|
23
|
+
support lands; browser persistence remains unsupported.
|
|
24
|
+
|
|
25
|
+
The ClojureScript facade mirrors the Clojure names: `transducer`, `query`,
|
|
26
|
+
`reduce-batches`, `phonetic-pattern`, `phonetic-rules`, `rewrite`, and `close!`.
|
|
27
|
+
|
|
28
|
+
<!-- BEGIN GENERATED BINDING OPERATIONS; DO NOT EDIT -->
|
|
29
|
+
|
|
30
|
+
## Support and package contract
|
|
31
|
+
|
|
32
|
+
| Property | Contract |
|
|
33
|
+
|---|---|
|
|
34
|
+
| Binding | JavaScript family |
|
|
35
|
+
| Languages/runtime | JavaScript, TypeScript, and ClojureScript on Node.js, browsers, or WASI |
|
|
36
|
+
| Support tier | Tier 1 |
|
|
37
|
+
| Distribution | npm package `@vinary-tree/liblevenshtein` |
|
|
38
|
+
| Native boundary | The facade delegates to the singleton `@vinary-tree/vinary-tree` runtime: native N-API by default, WebAssembly or WASI through explicit exports. |
|
|
39
|
+
| Canonical facade source | [`bindings/javascript`](../../bindings/javascript) |
|
|
40
|
+
|
|
41
|
+
The support tier controls release gating, not semantic quality: every tier has
|
|
42
|
+
the same snapshot, ownership, status, and ABI compatibility laws. Consult the
|
|
43
|
+
[binding architecture](../../docs/language-bindings.md) before implementing a custom provider
|
|
44
|
+
and the [family hub](../../docs/bindings/README.md) when combining independently packaged projects.
|
|
45
|
+
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
## Executable example and verification
|
|
49
|
+
|
|
50
|
+
The repository's canonical executable example is
|
|
51
|
+
[`bindings/javascript/test/facades.test.mjs`](../../bindings/javascript/test/facades.test.mjs). It exercises the same public package a user
|
|
52
|
+
installs and is run by the binding CI with:
|
|
53
|
+
|
|
54
|
+
```sh
|
|
55
|
+
npm test --prefix bindings/javascript
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Examples deliberately construct or receive resources through public project
|
|
59
|
+
packages. They never import private Rust modules, depend on object layout, or
|
|
60
|
+
reach behind the stable C/resource ABIs.
|
|
61
|
+
|
|
62
|
+
## Public API and data model
|
|
63
|
+
|
|
64
|
+
The idiomatic facade groups the stable surface into these concepts:
|
|
65
|
+
|
|
66
|
+
| Concept | Semantics |
|
|
67
|
+
|---|---|
|
|
68
|
+
| Dictionary resource | A retained `vt.dictionary.v1` capability. Construction and mutation belong to a producer such as libdictenstein. |
|
|
69
|
+
| Transducer | Immutable query configuration plus a retained dictionary provider; construction is constant-time with respect to dictionary size. |
|
|
70
|
+
| Query cursor | A one-shot traversal over the immutable dictionary revision captured at query start. |
|
|
71
|
+
| Match/batch | Owned matches are stable host values; a borrowed batch is valid only inside its documented callback or lease interval. |
|
|
72
|
+
|
|
73
|
+
Strings are Unicode; `Uint8Array` and `BigUint64Array` select byte and packed-token queries. IDs are `bigint`, never lossy JavaScript numbers. Empty terms, embedded zero bytes, non-ASCII text, and the full
|
|
74
|
+
unsigned 64-bit identifier range are represented explicitly; no facade may use
|
|
75
|
+
a sentinel value that removes a valid input from the domain.
|
|
76
|
+
|
|
77
|
+
For the exhaustive native function contract—including exact preconditions,
|
|
78
|
+
returnable statuses, complexity, and thread-safety—use the
|
|
79
|
+
[`llev_*` C ABI reference](../../docs/bindings/c-abi-reference.md). The facade
|
|
80
|
+
source linked above is the authoritative idiomatic symbol inventory; its
|
|
81
|
+
exhaustive coverage is governed by [`bindings/api-surface-map.json`](../../bindings/api-surface-map.json) and the [generated completeness matrix](../../bindings/conformance/completeness-matrix.tsv).
|
|
82
|
+
|
|
83
|
+
## Ownership, snapshots, and resource handoff
|
|
84
|
+
|
|
85
|
+
Use explicit resource management (`using`) where available or call `close()`/`close!` in `finally`. GC finalizers are fallback containment.
|
|
86
|
+
|
|
87
|
+
A transducer retains the provider resource, and a query retains the revision
|
|
88
|
+
visible at query start. Closing the original dictionary or publishing later
|
|
89
|
+
mutations cannot invalidate that query. Acquisition either completes with one
|
|
90
|
+
owned retain or fails with no ownership transfer. Teardown order is therefore
|
|
91
|
+
free across dictionary, transducer, and completed query handles.
|
|
92
|
+
|
|
93
|
+
Borrowed results are intentionally lexical. Copy data that must outlive the
|
|
94
|
+
callback; retaining a raw address, slice, memory segment, or foreign pointer is
|
|
95
|
+
an API violation even when the next operation happens to reuse the same arena.
|
|
96
|
+
|
|
97
|
+
## Errors and failure containment
|
|
98
|
+
|
|
99
|
+
Status codes become `VinaryTreeError` values carrying project, operation, status, and native diagnostic fields.
|
|
100
|
+
|
|
101
|
+
Malformed utf-8, unsupported unit domains, incompatible resource versions, closed handles, invalid bounds, allocation failures, provider faults, and contained rust panics are distinct failures. Never parse diagnostic prose to
|
|
102
|
+
branch on an error: inspect the typed status/exception first and treat the
|
|
103
|
+
message as human context. Diagnostics must be copied before another native
|
|
104
|
+
call on the same thread.
|
|
105
|
+
|
|
106
|
+
## Concurrency and reentrancy
|
|
107
|
+
|
|
108
|
+
Independent handles may be used concurrently. A cursor is single-consumer, callbacks are synchronous, and borrowed batches expire on callback return.
|
|
109
|
+
|
|
110
|
+
Snapshot capture is a linearization point, not a dictionary-wide query lock.
|
|
111
|
+
First-party immutable snapshots can be walked concurrently. A foreign provider
|
|
112
|
+
that does not advertise parallel callbacks is serialized at its callback gate;
|
|
113
|
+
the host language must not add a weaker promise.
|
|
114
|
+
|
|
115
|
+
## Performance and marshalling
|
|
116
|
+
|
|
117
|
+
- Reuse transducers for repeated queries against the same resource.
|
|
118
|
+
- Prefer streaming cursors to whole-result materialization.
|
|
119
|
+
- Prefer batch/reducer APIs when per-match boundary crossings dominate.
|
|
120
|
+
- Keep Unicode, byte, and token domains explicit to avoid transcoding.
|
|
121
|
+
- Measure native, WASM, and WASI paths independently; they have different
|
|
122
|
+
startup and marshalling costs but identical query semantics.
|
|
123
|
+
|
|
124
|
+
No host wrapper should cache unbounded query results. Applications that add a
|
|
125
|
+
memo use a revision key and a hard entry/weight bound; eviction may be
|
|
126
|
+
approximate because all values remain derivable from the retained snapshot.
|
|
127
|
+
|
|
128
|
+
## Security model
|
|
129
|
+
|
|
130
|
+
Treat a foreign resource provider and all user-controlled queries as untrusted
|
|
131
|
+
inputs. Validate lengths before allocation, preserve paging bounds, reject
|
|
132
|
+
unknown enum values, contain callbacks/panics at the boundary, and never trust
|
|
133
|
+
capability flags until interface negotiation succeeds. The normative duties
|
|
134
|
+
are in the [binding trust model](../../docs/security/binding-trust-model.md).
|
|
135
|
+
|
|
136
|
+
## Compatibility and troubleshooting
|
|
137
|
+
|
|
138
|
+
The project ABI revision, family ABI version, interface identity/version,
|
|
139
|
+
package version, and umbrella-runtime version are independent counters. Follow
|
|
140
|
+
the [ABI evolution policy](https://github.com/vinary-tree/vinary-tree-interop/blob/master/docs/abi-evolution.md); never infer compatibility from a
|
|
141
|
+
package version alone.
|
|
142
|
+
|
|
143
|
+
When loading fails, check—in order—the documented runtime/toolchain version,
|
|
144
|
+
CPU/OS artifact, native-access permission, loader search path, dependent
|
|
145
|
+
interop package pin, and process-wide JavaScript runtime identity. When a query
|
|
146
|
+
fails after construction, report the typed status and copied diagnostic before
|
|
147
|
+
reducing the case to the smallest dictionary/query pair.
|
|
148
|
+
|
|
149
|
+
## Maintainer checklist
|
|
150
|
+
|
|
151
|
+
1. Update the machine-readable binding model before changing a public symbol.
|
|
152
|
+
2. Regenerate headers/constants and the API coverage matrix.
|
|
153
|
+
3. Extend the canonical executable example and negative-path tests.
|
|
154
|
+
4. Run the language package, snapshot, leak, property, and cross-project suites.
|
|
155
|
+
5. Verify package staging contains this guide and uses coherent sibling pins.
|
|
156
|
+
6. Render diagrams headlessly and run the documentation/link/math gates.
|
|
157
|
+
|
|
158
|
+
<!-- END GENERATED BINDING OPERATIONS -->
|
package/abi.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Generated from bindings/api.json; do not edit numeric values manually. */
|
|
2
|
+
export const ABI_VERSION: 1;
|
|
3
|
+
export const API_REVISION: 2;
|
|
4
|
+
export const DEFAULT_MATCH_BATCH: 256;
|
|
5
|
+
export enum Status {
|
|
6
|
+
Ok = 0,
|
|
7
|
+
End = 1,
|
|
8
|
+
InvalidArgument = 2,
|
|
9
|
+
InvalidUtf8 = 3,
|
|
10
|
+
NullPointer = 4,
|
|
11
|
+
Panic = 5,
|
|
12
|
+
Unsupported = 6,
|
|
13
|
+
IoError = 7,
|
|
14
|
+
Closed = 8,
|
|
15
|
+
LimitExceeded = 9,
|
|
16
|
+
ProviderError = 10,
|
|
17
|
+
BatchInUse = 11,
|
|
18
|
+
DomainMismatch = 12,
|
|
19
|
+
}
|
|
20
|
+
export enum Algorithm {
|
|
21
|
+
Standard = 0,
|
|
22
|
+
Transposition = 1,
|
|
23
|
+
MergeAndSplit = 2,
|
|
24
|
+
DamerauLevenshtein = 3,
|
|
25
|
+
}
|
|
26
|
+
export enum Queryorder {
|
|
27
|
+
Traversal = 0,
|
|
28
|
+
DistanceThenTerm = 1,
|
|
29
|
+
}
|
|
30
|
+
export enum Phoneticrulesetkind {
|
|
31
|
+
EnglishOrthography = 0,
|
|
32
|
+
EnglishPhonetic = 1,
|
|
33
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
(ns vinary-tree.liblevenshtein
|
|
2
|
+
"ClojureScript facade mirroring the Clojure resource/transducer API."
|
|
3
|
+
(:require ["@vinary-tree/liblevenshtein" :as native]))
|
|
4
|
+
|
|
5
|
+
(defn transducer
|
|
6
|
+
([dictionary] (native/transducer dictionary "standard"))
|
|
7
|
+
([dictionary {:keys [algorithm] :or {algorithm :standard}}]
|
|
8
|
+
(native/transducer dictionary (name algorithm))))
|
|
9
|
+
|
|
10
|
+
(defn close! [resource] (.close resource))
|
|
11
|
+
|
|
12
|
+
(defn query
|
|
13
|
+
([automaton term max-distance]
|
|
14
|
+
(.query automaton term max-distance "traversal"))
|
|
15
|
+
([automaton term max-distance {:keys [order] :or {order :traversal}}]
|
|
16
|
+
(.query automaton term max-distance (name order))))
|
|
17
|
+
|
|
18
|
+
(defn reduce-batches
|
|
19
|
+
"Allocation-minimizing batch reduction; borrowed views must not escape f."
|
|
20
|
+
[f initial cursor]
|
|
21
|
+
(try
|
|
22
|
+
(.reduceBatches cursor f initial)
|
|
23
|
+
(finally (close! cursor))))
|
|
24
|
+
|
|
25
|
+
(defn cursor-seq [cursor]
|
|
26
|
+
(let [iterator (.call (aget cursor (.-iterator js/Symbol)) cursor)]
|
|
27
|
+
(letfn [(step []
|
|
28
|
+
(lazy-seq
|
|
29
|
+
(let [result (.next iterator)]
|
|
30
|
+
(if (.-done result)
|
|
31
|
+
(do (close! cursor) nil)
|
|
32
|
+
(cons (.-value result) (step))))))]
|
|
33
|
+
(step))))
|
|
34
|
+
|
|
35
|
+
(defn phonetic-pattern [source] (native/phoneticPattern source))
|
|
36
|
+
(defn llre-pattern [source] (native/llrePattern source))
|
|
37
|
+
(defn phonetic-rules [source] (native/phoneticRules (if (keyword? source) (name source) source)))
|
|
38
|
+
(defn rewrite [rules input] (.apply rules input))
|
package/deps.cljs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{:npm-deps {"@vinary-tree/liblevenshtein" "4.0.0-rc.4"}}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const namespace = require("@vinary-tree/vinary-tree").liblevenshtein;
|
|
3
|
+
const { assertDictionaryResource, assertSameRuntime } = require("@vinary-tree/interop");
|
|
4
|
+
if (!namespace || !namespace.runtimeIdentity) {
|
|
5
|
+
throw new Error("@vinary-tree/vinary-tree does not expose a runtime identity");
|
|
6
|
+
}
|
|
7
|
+
function transducer(dictionary, algorithm) {
|
|
8
|
+
assertDictionaryResource(dictionary);
|
|
9
|
+
assertSameRuntime(dictionary, namespace.runtimeIdentity);
|
|
10
|
+
return namespace.transducer(dictionary, algorithm);
|
|
11
|
+
}
|
|
12
|
+
const facade = Object.assign({}, namespace, { transducer });
|
|
13
|
+
module.exports = Object.assign(facade, { default: facade });
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { liblevenshtein } from "@vinary-tree/vinary-tree";
|
|
2
|
+
import { assertDictionaryResource, assertSameRuntime } from "@vinary-tree/interop";
|
|
3
|
+
|
|
4
|
+
if (!liblevenshtein?.runtimeIdentity) {
|
|
5
|
+
throw new Error("@vinary-tree/vinary-tree does not expose a runtime identity");
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const runtimeIdentity = liblevenshtein.runtimeIdentity;
|
|
9
|
+
export function transducer(dictionary, algorithm) {
|
|
10
|
+
assertDictionaryResource(dictionary);
|
|
11
|
+
assertSameRuntime(dictionary, runtimeIdentity);
|
|
12
|
+
return liblevenshtein.transducer(dictionary, algorithm);
|
|
13
|
+
}
|
|
14
|
+
export const phoneticPattern = liblevenshtein.phoneticPattern.bind(liblevenshtein);
|
|
15
|
+
export const llrePattern = liblevenshtein.llrePattern.bind(liblevenshtein);
|
|
16
|
+
export const phoneticRules = liblevenshtein.phoneticRules.bind(liblevenshtein);
|
|
17
|
+
export default {
|
|
18
|
+
...liblevenshtein,
|
|
19
|
+
runtimeIdentity,
|
|
20
|
+
transducer,
|
|
21
|
+
phoneticPattern,
|
|
22
|
+
llrePattern,
|
|
23
|
+
phoneticRules,
|
|
24
|
+
};
|
package/facades/wasi.cjs
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const namespace = require("@vinary-tree/vinary-tree/wasi").liblevenshtein;
|
|
3
|
+
const { assertDictionaryResource, assertSameRuntime } = require("@vinary-tree/interop");
|
|
4
|
+
function transducer(dictionary, algorithm) {
|
|
5
|
+
assertDictionaryResource(dictionary);
|
|
6
|
+
assertSameRuntime(dictionary, namespace.runtimeIdentity);
|
|
7
|
+
return namespace.transducer(dictionary, algorithm);
|
|
8
|
+
}
|
|
9
|
+
const facade = Object.assign({}, namespace, { transducer });
|
|
10
|
+
module.exports = Object.assign(facade, { default: facade });
|
package/facades/wasi.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { liblevenshtein } from "@vinary-tree/vinary-tree/wasi";
|
|
2
|
+
import { assertDictionaryResource, assertSameRuntime } from "@vinary-tree/interop";
|
|
3
|
+
export const runtimeIdentity = liblevenshtein.runtimeIdentity;
|
|
4
|
+
export function transducer(dictionary, algorithm) {
|
|
5
|
+
assertDictionaryResource(dictionary);
|
|
6
|
+
assertSameRuntime(dictionary, runtimeIdentity);
|
|
7
|
+
return liblevenshtein.transducer(dictionary, algorithm);
|
|
8
|
+
}
|
|
9
|
+
// The wasi build profile (--no-default-features --features wasi) has no
|
|
10
|
+
// phonetic capability, so these namespace members may be absent; binding
|
|
11
|
+
// them unconditionally crashed this module at import time (defect found by
|
|
12
|
+
// the cross-language benchmark harness, 2026-08-13). Capability-gated
|
|
13
|
+
// members stay undefined when the runtime does not provide them.
|
|
14
|
+
export const phoneticPattern = liblevenshtein.phoneticPattern?.bind(liblevenshtein);
|
|
15
|
+
export const llrePattern = liblevenshtein.llrePattern?.bind(liblevenshtein);
|
|
16
|
+
export const phoneticRules = liblevenshtein.phoneticRules?.bind(liblevenshtein);
|
|
17
|
+
export default { ...liblevenshtein, runtimeIdentity, transducer, phoneticPattern, llrePattern, phoneticRules };
|
package/facades/wasm.mjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { liblevenshtein } from "@vinary-tree/vinary-tree/wasm";
|
|
2
|
+
import { assertDictionaryResource, assertSameRuntime } from "@vinary-tree/interop";
|
|
3
|
+
export const runtimeIdentity = liblevenshtein.runtimeIdentity;
|
|
4
|
+
export function transducer(dictionary, algorithm) {
|
|
5
|
+
assertDictionaryResource(dictionary);
|
|
6
|
+
assertSameRuntime(dictionary, runtimeIdentity);
|
|
7
|
+
return liblevenshtein.transducer(dictionary, algorithm);
|
|
8
|
+
}
|
|
9
|
+
export const phoneticPattern = liblevenshtein.phoneticPattern.bind(liblevenshtein);
|
|
10
|
+
export const llrePattern = liblevenshtein.llrePattern.bind(liblevenshtein);
|
|
11
|
+
export const phoneticRules = liblevenshtein.phoneticRules.bind(liblevenshtein);
|
|
12
|
+
export default { ...liblevenshtein, runtimeIdentity, transducer, phoneticPattern, llrePattern, phoneticRules };
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import type { DictionaryResource } from "@vinary-tree/interop";
|
|
2
|
+
|
|
3
|
+
export type Algorithm =
|
|
4
|
+
| "standard"
|
|
5
|
+
| "transposition"
|
|
6
|
+
| "merge-and-split"
|
|
7
|
+
| "damerau-levenshtein";
|
|
8
|
+
export type QueryOrder = "traversal" | "distance-then-term";
|
|
9
|
+
|
|
10
|
+
export type Term =
|
|
11
|
+
| { readonly domain: "unicode"; readonly value: string }
|
|
12
|
+
| { readonly domain: "byte"; readonly value: Uint8Array }
|
|
13
|
+
| { readonly domain: "u64"; readonly value: BigUint64Array };
|
|
14
|
+
|
|
15
|
+
export interface Match {
|
|
16
|
+
readonly term: Term;
|
|
17
|
+
readonly distance: number;
|
|
18
|
+
readonly id: bigint | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface BorrowedMatch {
|
|
22
|
+
readonly distance: number;
|
|
23
|
+
readonly id: bigint | null;
|
|
24
|
+
readonly unitDomain: "byte" | "unicode" | "u64";
|
|
25
|
+
bytes(): Uint8Array;
|
|
26
|
+
utf8(): string;
|
|
27
|
+
u64(): BigUint64Array;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface BorrowedBatch extends Iterable<BorrowedMatch> {
|
|
31
|
+
readonly length: number;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface QueryCursor extends IterableIterator<Match> {
|
|
35
|
+
nextBatch(maximum: number): Match[];
|
|
36
|
+
reduceBatches<Accumulator>(
|
|
37
|
+
reducer: (accumulator: Accumulator, batch: readonly Match[]) => Accumulator,
|
|
38
|
+
initial: Accumulator,
|
|
39
|
+
): Accumulator;
|
|
40
|
+
close(): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface AutomatonSize {
|
|
44
|
+
readonly states: number;
|
|
45
|
+
readonly transitions: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface PhoneticPattern {
|
|
49
|
+
readonly size: AutomatonSize;
|
|
50
|
+
matches(input: string): boolean;
|
|
51
|
+
close(): void;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface PhoneticRuleSet {
|
|
55
|
+
readonly size: number;
|
|
56
|
+
apply(input: string): string;
|
|
57
|
+
close(): void;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface Transducer {
|
|
61
|
+
query(query: string, maximumDistance: number, order?: QueryOrder): QueryCursor;
|
|
62
|
+
query(query: Uint8Array, maximumDistance: number): QueryCursor;
|
|
63
|
+
query(query: BigUint64Array, maximumDistance: number): QueryCursor;
|
|
64
|
+
query(pattern: PhoneticPattern, maximumDistance: number): QueryCursor;
|
|
65
|
+
close(): void;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface LiblevenshteinNamespace {
|
|
69
|
+
readonly runtimeIdentity: symbol | object;
|
|
70
|
+
transducer(dictionary: DictionaryResource, algorithm?: Algorithm): Transducer;
|
|
71
|
+
phoneticPattern(source: string): PhoneticPattern;
|
|
72
|
+
llrePattern(source: string): PhoneticPattern;
|
|
73
|
+
phoneticRules(source: string | "english-orthography" | "english-phonetic"): PhoneticRuleSet;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export const runtimeIdentity: symbol | object;
|
|
77
|
+
export function transducer(dictionary: DictionaryResource, algorithm?: Algorithm): Transducer;
|
|
78
|
+
export function phoneticPattern(source: string): PhoneticPattern;
|
|
79
|
+
export function llrePattern(source: string): PhoneticPattern;
|
|
80
|
+
export function phoneticRules(source: string | "english-orthography" | "english-phonetic"): PhoneticRuleSet;
|
|
81
|
+
declare const liblevenshtein: LiblevenshteinNamespace;
|
|
82
|
+
export default liblevenshtein;
|
package/package.json
CHANGED
|
@@ -1,20 +1,79 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vinary-tree/liblevenshtein",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "4.0.0-rc.4",
|
|
4
|
+
"description": "Modular liblevenshtein facade over the shared vinary-tree runtime",
|
|
5
|
+
"author": {
|
|
6
|
+
"name": "Dylon Edwards",
|
|
7
|
+
"email": "dylon.devo@gmail.com"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
10
|
+
"sideEffects": false,
|
|
6
11
|
"license": "Apache-2.0",
|
|
7
12
|
"repository": {
|
|
8
13
|
"type": "git",
|
|
9
|
-
"url": "git+https://github.com/vinary-tree/liblevenshtein-rust.git"
|
|
14
|
+
"url": "git+https://github.com/vinary-tree/liblevenshtein-rust.git",
|
|
15
|
+
"directory": "bindings/javascript"
|
|
16
|
+
},
|
|
17
|
+
"engines": {
|
|
18
|
+
"node": ">=22.14"
|
|
19
|
+
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"@vinary-tree/interop": "4.0.0-rc.4",
|
|
22
|
+
"@vinary-tree/vinary-tree": "4.0.0-rc.4"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@vinary-tree/libdictenstein": "file:../../../libdictenstein/bindings/javascript"
|
|
26
|
+
},
|
|
27
|
+
"types": "./index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./index.d.ts",
|
|
31
|
+
"import": "./facades/native.mjs",
|
|
32
|
+
"require": "./facades/native.cjs"
|
|
33
|
+
},
|
|
34
|
+
"./typescript": {
|
|
35
|
+
"types": "./facades/typescript.d.ts",
|
|
36
|
+
"import": "./facades/typescript.mjs",
|
|
37
|
+
"require": "./facades/typescript.cjs"
|
|
38
|
+
},
|
|
39
|
+
"./clojurescript": {
|
|
40
|
+
"types": "./facades/clojurescript.d.ts",
|
|
41
|
+
"import": "./facades/clojurescript.mjs",
|
|
42
|
+
"require": "./facades/clojurescript.cjs"
|
|
43
|
+
},
|
|
44
|
+
"./wasm": {
|
|
45
|
+
"types": "./index.d.ts",
|
|
46
|
+
"default": "./facades/wasm.mjs"
|
|
47
|
+
},
|
|
48
|
+
"./wasi": {
|
|
49
|
+
"types": "./index.d.ts",
|
|
50
|
+
"import": "./facades/wasi.mjs"
|
|
51
|
+
},
|
|
52
|
+
"./cljs/vinary_tree/liblevenshtein.cljs": "./cljs/vinary_tree/liblevenshtein.cljs"
|
|
53
|
+
},
|
|
54
|
+
"cljs": {
|
|
55
|
+
"namespaces": {
|
|
56
|
+
"vinary-tree.liblevenshtein": "./cljs/vinary_tree/liblevenshtein.cljs"
|
|
57
|
+
}
|
|
10
58
|
},
|
|
11
|
-
"exports": "./index.js",
|
|
12
59
|
"files": [
|
|
13
|
-
"
|
|
60
|
+
"abi.d.ts",
|
|
61
|
+
"index.d.ts",
|
|
62
|
+
"facades/",
|
|
63
|
+
"cljs/",
|
|
64
|
+
"deps.cljs",
|
|
14
65
|
"README.md"
|
|
15
66
|
],
|
|
16
67
|
"publishConfig": {
|
|
17
68
|
"access": "public",
|
|
18
|
-
"
|
|
69
|
+
"provenance": true,
|
|
70
|
+
"tag": "next"
|
|
71
|
+
},
|
|
72
|
+
"scripts": {
|
|
73
|
+
"build": "node build.mjs",
|
|
74
|
+
"test:contract": "node --test test/facades.test.mjs && tsc -p tsconfig.test.json",
|
|
75
|
+
"test:clojurescript": "node test/clojurescript-test.mjs",
|
|
76
|
+
"test": "npm run test:contract && npm run test:clojurescript",
|
|
77
|
+
"prepack": "npm run build && npm test"
|
|
19
78
|
}
|
|
20
79
|
}
|
package/index.js
DELETED