trilean-regex 1.0.2 → 1.0.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.
package/dist/errors.d.cts CHANGED
@@ -4,10 +4,9 @@
4
4
  *
5
5
  * This is the only error this package's parser ever throws. There is no partial-AST return, no best-effort fallback -- a pattern either parses completely into a `RegexNode` or this is thrown, matching the "clear parse error, not a fuzzy runtime failure" goal a portable grammar exists for in the first place.
6
6
  */
7
- declare class RegexParseError extends Error {
7
+ export declare class RegexParseError extends Error {
8
8
  readonly pattern: string;
9
9
  readonly index: number;
10
10
  constructor(pattern: string, index: number, reason: string);
11
11
  }
12
- //#endregion
13
- export { RegexParseError };
12
+ //#endregion
package/dist/errors.d.ts CHANGED
@@ -4,10 +4,9 @@
4
4
  *
5
5
  * This is the only error this package's parser ever throws. There is no partial-AST return, no best-effort fallback -- a pattern either parses completely into a `RegexNode` or this is thrown, matching the "clear parse error, not a fuzzy runtime failure" goal a portable grammar exists for in the first place.
6
6
  */
7
- declare class RegexParseError extends Error {
7
+ export declare class RegexParseError extends Error {
8
8
  readonly pattern: string;
9
9
  readonly index: number;
10
10
  constructor(pattern: string, index: number, reason: string);
11
11
  }
12
- //#endregion
13
- export { RegexParseError };
12
+ //#endregion
@@ -7,9 +7,9 @@ import { CompiledNfa } from "./nfa.cjs";
7
7
  *
8
8
  * Runs in O(length x states) time and allocates no more than two small state sets at a time, regardless of the pattern's shape -- there is no exponential blow-up for any input this compiles, which is the whole reason this package builds an automaton instead of calling a backtracking engine.
9
9
  */
10
- declare function matchesNfa(nfa: CompiledNfa, input: string): boolean;
10
+ export declare function matchesNfa(nfa: CompiledNfa, input: string): boolean;
11
11
  /** A parsed and compiled pattern, ready to test any number of inputs without re-parsing or re-compiling. */
12
- interface CompiledPattern {
12
+ export interface CompiledPattern {
13
13
  /** Whether any substring of `input` matches this pattern -- see `matchesNfa`. */
14
14
  test: (input: string) => boolean;
15
15
  }
@@ -19,11 +19,10 @@ interface CompiledPattern {
19
19
  * Prefer this over `testPattern` when the same pattern will be tested against more than one input: it parses and compiles exactly once, and the returned `CompiledPattern.test` is then only the O(length x states) simulation.
20
20
  * @throws `RegexParseError` if `pattern` is not a valid pattern in this grammar.
21
21
  */
22
- declare function compilePattern(pattern: string): CompiledPattern;
22
+ export declare function compilePattern(pattern: string): CompiledPattern;
23
23
  /**
24
24
  * Parses `pattern` and tests it against `input` in one call. Equivalent to `compilePattern(pattern).test(input)`, and exactly as cheap for a single test -- prefer `compilePattern` instead when the same pattern will be reused, so the parse and compile steps happen once rather than once per input.
25
25
  * @throws `RegexParseError` if `pattern` is not a valid pattern in this grammar.
26
26
  */
27
- declare function testPattern(pattern: string, input: string): boolean;
28
- //#endregion
29
- export { CompiledPattern, compilePattern, matchesNfa, testPattern };
27
+ export declare function testPattern(pattern: string, input: string): boolean;
28
+ //#endregion
package/dist/matcher.d.ts CHANGED
@@ -7,9 +7,9 @@ import { CompiledNfa } from "./nfa.js";
7
7
  *
8
8
  * Runs in O(length x states) time and allocates no more than two small state sets at a time, regardless of the pattern's shape -- there is no exponential blow-up for any input this compiles, which is the whole reason this package builds an automaton instead of calling a backtracking engine.
9
9
  */
10
- declare function matchesNfa(nfa: CompiledNfa, input: string): boolean;
10
+ export declare function matchesNfa(nfa: CompiledNfa, input: string): boolean;
11
11
  /** A parsed and compiled pattern, ready to test any number of inputs without re-parsing or re-compiling. */
12
- interface CompiledPattern {
12
+ export interface CompiledPattern {
13
13
  /** Whether any substring of `input` matches this pattern -- see `matchesNfa`. */
14
14
  test: (input: string) => boolean;
15
15
  }
@@ -19,11 +19,10 @@ interface CompiledPattern {
19
19
  * Prefer this over `testPattern` when the same pattern will be tested against more than one input: it parses and compiles exactly once, and the returned `CompiledPattern.test` is then only the O(length x states) simulation.
20
20
  * @throws `RegexParseError` if `pattern` is not a valid pattern in this grammar.
21
21
  */
22
- declare function compilePattern(pattern: string): CompiledPattern;
22
+ export declare function compilePattern(pattern: string): CompiledPattern;
23
23
  /**
24
24
  * Parses `pattern` and tests it against `input` in one call. Equivalent to `compilePattern(pattern).test(input)`, and exactly as cheap for a single test -- prefer `compilePattern` instead when the same pattern will be reused, so the parse and compile steps happen once rather than once per input.
25
25
  * @throws `RegexParseError` if `pattern` is not a valid pattern in this grammar.
26
26
  */
27
- declare function testPattern(pattern: string, input: string): boolean;
28
- //#endregion
29
- export { CompiledPattern, compilePattern, matchesNfa, testPattern };
27
+ export declare function testPattern(pattern: string, input: string): boolean;
28
+ //#endregion
package/dist/nfa.d.cts CHANGED
@@ -6,7 +6,7 @@ type CharTest = (codeUnit: number) => boolean;
6
6
  *
7
7
  * `anchorStart`/`anchorEnd` are what let `^`/`$` live anywhere in the pattern -- inside a group, inside an alternation branch -- rather than only at the very start or end of the whole pattern text: they are ordinary epsilon transitions that the closure walk additionally gates on the absolute string position, so `^`'s condition ("this position is index 0 of the whole input") is checked at the moment the automaton would step through it, not baked into where `^` was allowed to appear syntactically.
8
8
  */
9
- type NfaState = {
9
+ export type NfaState = {
10
10
  kind: "char";
11
11
  test: CharTest;
12
12
  to: number;
@@ -23,12 +23,11 @@ type NfaState = {
23
23
  } | {
24
24
  kind: "match";
25
25
  };
26
- interface CompiledNfa {
26
+ export interface CompiledNfa {
27
27
  readonly states: readonly NfaState[];
28
28
  readonly start: number;
29
29
  readonly matchState: number;
30
30
  }
31
31
  /** Compiles a `RegexNode` AST into a Thompson-construction NFA, ready for `matchesNfa` (see `matcher.ts`) to simulate. Construction is linear in the size of the AST -- bounded repetition is the only node kind that can multiply state count beyond that, by exactly the multiple its own bound names, which is a property of what `{n,m}` means rather than of this algorithm. */
32
- declare function compileToNfa(node: RegexNode): CompiledNfa;
33
- //#endregion
34
- export { CompiledNfa, NfaState, compileToNfa };
32
+ export declare function compileToNfa(node: RegexNode): CompiledNfa;
33
+ //#endregion
package/dist/nfa.d.ts CHANGED
@@ -6,7 +6,7 @@ type CharTest = (codeUnit: number) => boolean;
6
6
  *
7
7
  * `anchorStart`/`anchorEnd` are what let `^`/`$` live anywhere in the pattern -- inside a group, inside an alternation branch -- rather than only at the very start or end of the whole pattern text: they are ordinary epsilon transitions that the closure walk additionally gates on the absolute string position, so `^`'s condition ("this position is index 0 of the whole input") is checked at the moment the automaton would step through it, not baked into where `^` was allowed to appear syntactically.
8
8
  */
9
- type NfaState = {
9
+ export type NfaState = {
10
10
  kind: "char";
11
11
  test: CharTest;
12
12
  to: number;
@@ -23,12 +23,11 @@ type NfaState = {
23
23
  } | {
24
24
  kind: "match";
25
25
  };
26
- interface CompiledNfa {
26
+ export interface CompiledNfa {
27
27
  readonly states: readonly NfaState[];
28
28
  readonly start: number;
29
29
  readonly matchState: number;
30
30
  }
31
31
  /** Compiles a `RegexNode` AST into a Thompson-construction NFA, ready for `matchesNfa` (see `matcher.ts`) to simulate. Construction is linear in the size of the AST -- bounded repetition is the only node kind that can multiply state count beyond that, by exactly the multiple its own bound names, which is a property of what `{n,m}` means rather than of this algorithm. */
32
- declare function compileToNfa(node: RegexNode): CompiledNfa;
33
- //#endregion
34
- export { CompiledNfa, NfaState, compileToNfa };
32
+ export declare function compileToNfa(node: RegexNode): CompiledNfa;
33
+ //#endregion
package/dist/parser.d.cts CHANGED
@@ -6,6 +6,5 @@ import { d as RegexNode } from "./ast-D8HLFxxv.cjs";
6
6
  * Never returns a partial result: a pattern either parses completely, with nothing left over, or this throws `RegexParseError` naming exactly where parsing could not proceed.
7
7
  * @throws `RegexParseError` if `pattern` is not a complete, valid pattern in this grammar.
8
8
  */
9
- declare function parseRegex(pattern: string): RegexNode;
10
- //#endregion
11
- export { parseRegex };
9
+ export declare function parseRegex(pattern: string): RegexNode;
10
+ //#endregion
package/dist/parser.d.ts CHANGED
@@ -6,6 +6,5 @@ import { d as RegexNode } from "./ast-D8HLFxxv.js";
6
6
  * Never returns a partial result: a pattern either parses completely, with nothing left over, or this throws `RegexParseError` naming exactly where parsing could not proceed.
7
7
  * @throws `RegexParseError` if `pattern` is not a complete, valid pattern in this grammar.
8
8
  */
9
- declare function parseRegex(pattern: string): RegexNode;
10
- //#endregion
11
- export { parseRegex };
9
+ export declare function parseRegex(pattern: string): RegexNode;
10
+ //#endregion
@@ -1,8 +1,7 @@
1
1
  import { a as CharClassNode } from "./ast-D8HLFxxv.cjs";
2
2
  //#region src/shorthand-classes.d.ts
3
3
  /** The letter each shorthand class is written with, case distinguishing the positive form (`d`, `w`, `s`) from its negation (`D`, `W`, `S`). */
4
- type ShorthandClassLetter = "d" | "D" | "w" | "W" | "s" | "S";
4
+ export type ShorthandClassLetter = "d" | "D" | "w" | "W" | "s" | "S";
5
5
  /** Expands a shorthand class letter (`d`/`D`/`w`/`W`/`s`/`S`) to the `CharClassNode` it stands for. Uppercase negates the corresponding lowercase letter's ranges rather than owning a separate range table, since a shorthand class and its negation are the same set by definition. */
6
- declare function expandShorthandClass(letter: ShorthandClassLetter): CharClassNode;
7
- //#endregion
8
- export { ShorthandClassLetter, expandShorthandClass };
6
+ export declare function expandShorthandClass(letter: ShorthandClassLetter): CharClassNode;
7
+ //#endregion
@@ -1,8 +1,7 @@
1
1
  import { a as CharClassNode } from "./ast-D8HLFxxv.js";
2
2
  //#region src/shorthand-classes.d.ts
3
3
  /** The letter each shorthand class is written with, case distinguishing the positive form (`d`, `w`, `s`) from its negation (`D`, `W`, `S`). */
4
- type ShorthandClassLetter = "d" | "D" | "w" | "W" | "s" | "S";
4
+ export type ShorthandClassLetter = "d" | "D" | "w" | "W" | "s" | "S";
5
5
  /** Expands a shorthand class letter (`d`/`D`/`w`/`W`/`s`/`S`) to the `CharClassNode` it stands for. Uppercase negates the corresponding lowercase letter's ranges rather than owning a separate range table, since a shorthand class and its negation are the same set by definition. */
6
- declare function expandShorthandClass(letter: ShorthandClassLetter): CharClassNode;
7
- //#endregion
8
- export { ShorthandClassLetter, expandShorthandClass };
6
+ export declare function expandShorthandClass(letter: ShorthandClassLetter): CharClassNode;
7
+ //#endregion
package/package.json CHANGED
@@ -1,17 +1,30 @@
1
1
  {
2
2
  "name": "trilean-regex",
3
- "version": "1.0.2",
4
3
  "description": "A portable regular-expression grammar -- a true regular language, with a Thompson-construction reference matcher -- so a pattern means the same thing in process and wherever trilean-sql can push it down to a database's own engine.",
5
- "type": "module",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/ExaDev/trilean.git",
9
- "directory": "packages/trilean-regex"
10
- },
11
- "homepage": "https://github.com/ExaDev/trilean/tree/main/packages/trilean-regex",
4
+ "version": "1.0.4",
12
5
  "bugs": {
13
6
  "url": "https://github.com/ExaDev/trilean/issues"
14
7
  },
8
+ "devDependencies": {
9
+ "@arethetypeswrong/cli": "^0.18.5",
10
+ "@exadev/eslint-config": "3.0.0",
11
+ "@types/node": "^26.4.0",
12
+ "@vitest/coverage-v8": "^5.0.0",
13
+ "eslint": "^10.9.1",
14
+ "eslint-config-prettier": "^10.1.8",
15
+ "eslint-plugin-prettier": "^5.5.6",
16
+ "globals": "^17.11.0",
17
+ "prettier": "^3.9.6",
18
+ "publint": "^0.3.24",
19
+ "tsdown": "^0.23.0",
20
+ "turbo": "^2.10.12",
21
+ "typescript": "^6.0.3",
22
+ "typescript-eslint": "^8.68.0",
23
+ "vitest": "^5.0.0"
24
+ },
25
+ "engines": {
26
+ "node": ">=20"
27
+ },
15
28
  "exports": {
16
29
  ".": {
17
30
  "types": {
@@ -30,63 +43,50 @@
30
43
  "require": "./dist/*.cjs"
31
44
  }
32
45
  },
33
- "main": "./dist/index.cjs",
34
- "module": "./dist/index.js",
35
- "types": "./dist/index.d.ts",
36
46
  "files": [
37
47
  "dist"
38
48
  ],
49
+ "homepage": "https://github.com/ExaDev/trilean/tree/main/packages/trilean-regex",
50
+ "keywords": [
51
+ "finite-automaton",
52
+ "isomorphic",
53
+ "nfa",
54
+ "parser",
55
+ "regex",
56
+ "regular-expression",
57
+ "regular-language",
58
+ "trilean"
59
+ ],
60
+ "license": "MIT",
61
+ "main": "./dist/index.cjs",
62
+ "module": "./dist/index.js",
39
63
  "publishConfig": {
40
64
  "access": "public",
41
65
  "provenance": true,
42
66
  "registry": "https://registry.npmjs.org/"
43
67
  },
44
- "sideEffects": false,
45
- "engines": {
46
- "node": ">=20"
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "git+https://github.com/ExaDev/trilean.git",
71
+ "directory": "packages/trilean-regex"
47
72
  },
48
- "license": "MIT",
49
73
  "scripts": {
50
- "build": "turbo run _build",
51
74
  "_build": "tsdown",
52
- "lint": "turbo run _lint",
53
75
  "_lint": "eslint . --fix --cache --max-warnings 0",
54
- "typecheck": "turbo run _typecheck _typecheck:attw",
76
+ "_prepush": "true",
77
+ "_test": "vitest run --project unit",
78
+ "_test:coverage": "vitest run --project unit --coverage",
55
79
  "_typecheck": "tsc -p tsconfig.json && tsc -p tsconfig.node.json",
56
80
  "_typecheck:attw": "attw --pack",
81
+ "build": "turbo run _build",
82
+ "lint": "turbo run _lint",
83
+ "prepublishOnly": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && publint && attw --pack",
84
+ "prepush": "turbo run _prepush",
57
85
  "test": "turbo run _test",
58
- "_test": "vitest run --project unit",
59
86
  "test:coverage": "turbo run _test:coverage",
60
- "_test:coverage": "vitest run --project unit --coverage",
61
- "prepush": "turbo run _prepush",
62
- "_prepush": "true",
63
- "prepublishOnly": "pnpm run lint && pnpm run typecheck && pnpm run test && pnpm run build && publint && attw --pack"
87
+ "typecheck": "turbo run _typecheck _typecheck:attw"
64
88
  },
65
- "keywords": [
66
- "regex",
67
- "regular-expression",
68
- "regular-language",
69
- "finite-automaton",
70
- "nfa",
71
- "parser",
72
- "trilean",
73
- "isomorphic"
74
- ],
75
- "devDependencies": {
76
- "@arethetypeswrong/cli": "^0.18.5",
77
- "@exadev/eslint-config": "2.12.1",
78
- "@types/node": "^26.4.0",
79
- "@vitest/coverage-v8": "^4.1.11",
80
- "eslint": "^10.9.1",
81
- "eslint-config-prettier": "^10.1.8",
82
- "eslint-plugin-prettier": "^5.5.6",
83
- "globals": "^17.11.0",
84
- "prettier": "^3.9.6",
85
- "publint": "^0.3.24",
86
- "tsdown": "^0.22.14",
87
- "turbo": "^2.10.12",
88
- "typescript": "^6.0.3",
89
- "typescript-eslint": "^8.68.0",
90
- "vitest": "^4.1.11"
91
- }
89
+ "sideEffects": false,
90
+ "type": "module",
91
+ "types": "./dist/index.d.ts"
92
92
  }