@stll/regex-set-wasm 1.0.9 → 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.
@@ -0,0 +1,5 @@
1
+ {
2
+ "wasm": 1747503,
3
+ "base64": 2330004,
4
+ "gzip": 600848
5
+ }
@@ -0,0 +1,125 @@
1
+ //#region src/core.d.ts
2
+ /** Options for constructing a RegexSet. */
3
+ type Options = {
4
+ /**
5
+ * Only match whole words. Wraps each pattern
6
+ * with `\b...\b`.
7
+ * @default false
8
+ */
9
+ wholeWords?: boolean;
10
+ /**
11
+ * Use Unicode word boundaries. When `true`,
12
+ * `\b` treats accented letters, CJK, etc. as
13
+ * word characters (correct for non-English text).
14
+ * When `false` (default), `\b` uses ASCII
15
+ * semantics matching JS `RegExp` behavior.
16
+ *
17
+ * Zero performance overhead in either mode;
18
+ * boundaries are verified inline per match.
19
+ * Automatically uses UAX#29 segmentation for
20
+ * Thai/CJK/Lao/Khmer/Myanmar text.
21
+ * @default true
22
+ */
23
+ unicodeBoundaries?: boolean;
24
+ /**
25
+ * Case-insensitive matching. Wraps each pattern
26
+ * with `(?i-u:...)` for ASCII case folding.
27
+ * Uses `-u` to prevent DFA state explosion from
28
+ * Unicode case tables.
29
+ *
30
+ * Edge `\b`/`\B` boundaries and leading bare-flag
31
+ * prefixes (e.g. `(?m)`, `(?m-s)`) are extracted
32
+ * before wrapping so they remain outside the `-u`
33
+ * scope, preserving `unicodeBoundaries` semantics.
34
+ * Patterns already containing any `(?{flags}-u`
35
+ * group (from RegExp `/i`, inline `(?i)`, or
36
+ * `scopeInlineFlags`) are not double-wrapped.
37
+ * @default false
38
+ */
39
+ caseInsensitive?: boolean;
40
+ };
41
+ /** A named pattern entry. */
42
+ type NamedPattern = {
43
+ /** The regex pattern (string or RegExp). */
44
+ pattern: string | RegExp;
45
+ /** Optional name for this pattern. */
46
+ name?: string;
47
+ };
48
+ /** A pattern entry: string, RegExp, or named. */
49
+ type PatternEntry = string | RegExp | NamedPattern;
50
+ /** A single match result. */
51
+ type Match = {
52
+ /** Index of the pattern that matched. */
53
+ pattern: number;
54
+ /** Start UTF-16 code unit offset. */
55
+ start: number;
56
+ /** End offset (exclusive). */
57
+ end: number;
58
+ /** The matched text. */
59
+ text: string;
60
+ /** Pattern name (if provided at construction). */
61
+ name?: string;
62
+ };
63
+ /**
64
+ * Multi-pattern regex matcher.
65
+ *
66
+ * Compiles multiple regex patterns into a single
67
+ * automaton for the main matching path. Standard
68
+ * scans use Rust's DFA engine without catastrophic
69
+ * backtracking. Some lookaround cases may use a
70
+ * targeted fallback verifier to preserve
71
+ * correctness. Uses Rust regex syntax for string
72
+ * patterns (no lookaheads/backreferences).
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * // Simple
77
+ * new RegexSet([/\d{8}/, "\\+?\\d{9,12}"]);
78
+ *
79
+ * // Named
80
+ * new RegexSet([
81
+ * { pattern: /\d{8}/, name: "ico" },
82
+ * { pattern: /\d{2}\.\d{2}\.\d{4}/, name: "date" },
83
+ * ]);
84
+ * // match.name === "date"
85
+ * ```
86
+ */
87
+ export declare class RegexSet {
88
+ private _inner;
89
+ private _names;
90
+ private _hasNames;
91
+ private _patternCount;
92
+ private _nativeIndexMap;
93
+ private _jsFallbacks;
94
+ private _nativeSingles;
95
+ private _boundaryOptions;
96
+ constructor(patterns: PatternEntry[], options?: Options, prepared?: Uint8Array);
97
+ static prepare(patterns: PatternEntry[], options?: Options): Uint8Array;
98
+ /** Number of patterns. */
99
+ get patternCount(): number;
100
+ /** Internal diagnostics: fast DFA, verified DFA, and fallback pattern counts. */
101
+ _enginePathCounts(): number[];
102
+ /** Returns `true` if any pattern matches. */
103
+ isMatch(haystack: string): boolean;
104
+ /** Find all non-overlapping matches. */
105
+ findIter(haystack: string): Match[];
106
+ /** Which pattern indices matched (not where). */
107
+ whichMatch(haystack: string): number[];
108
+ /**
109
+ * Replace all non-overlapping matches.
110
+ * `replacements[i]` replaces pattern `i`.
111
+ */
112
+ replaceAll(haystack: string, replacements: string[]): string;
113
+ private findJsFallbacks;
114
+ private findNativeSingles;
115
+ private findFirstJsFallback;
116
+ private acceptJsFallbackMatch;
117
+ }
118
+ //#endregion
119
+ //#region src/single-thread.d.ts
120
+ export type InitSource = ArrayBuffer | ArrayBufferView | URL | string | Request | Response;
121
+ export declare const initSync: (source: ArrayBuffer | ArrayBufferView) => void;
122
+ export declare const init: (source: InitSource) => Promise<void>;
123
+ //#endregion
124
+ export type { Match, NamedPattern, Options, PatternEntry };
125
+ //# sourceMappingURL=single-thread.d.mts.map