@witchcraft/expressit 0.2.1 → 0.3.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/README.md +6 -4
- package/dist/Lexer.d.ts +102 -99
- package/dist/Lexer.d.ts.map +1 -1
- package/dist/Lexer.js +211 -557
- package/dist/Parser.d.ts +27 -27
- package/dist/Parser.d.ts.map +1 -1
- package/dist/Parser.js +5 -2
- package/dist/ast/builders/condition.d.ts +1 -1
- package/dist/ast/builders/condition.d.ts.map +1 -1
- package/dist/ast/builders/condition.js +1 -0
- package/dist/ast/builders/delim.d.ts +3 -3
- package/dist/ast/builders/delim.d.ts.map +1 -1
- package/dist/ast/builders/error.d.ts +2 -2
- package/dist/ast/builders/error.d.ts.map +1 -1
- package/dist/ast/builders/expression.d.ts +2 -2
- package/dist/ast/builders/expression.d.ts.map +1 -1
- package/dist/ast/builders/expression.js +2 -6
- package/dist/ast/builders/group.d.ts +1 -1
- package/dist/ast/builders/group.d.ts.map +1 -1
- package/dist/ast/builders/group.js +1 -3
- package/dist/ast/builders/pos.d.ts +2 -2
- package/dist/ast/builders/pos.d.ts.map +1 -1
- package/dist/ast/builders/token.d.ts +2 -2
- package/dist/ast/builders/token.d.ts.map +1 -1
- package/dist/ast/builders/type.d.ts +2 -2
- package/dist/ast/builders/type.d.ts.map +1 -1
- package/dist/ast/builders/variable.d.ts +3 -3
- package/dist/ast/builders/variable.d.ts.map +1 -1
- package/dist/ast/createConditionNode.d.ts +1 -1
- package/dist/ast/createConditionNode.d.ts.map +1 -1
- package/dist/ast/createGroupNode.d.ts +1 -1
- package/dist/ast/createGroupNode.d.ts.map +1 -1
- package/dist/ast/createToken.d.ts +2 -2
- package/dist/ast/createToken.d.ts.map +1 -1
- package/dist/ast/createToken.js +2 -2
- package/dist/ast/error.d.ts +2 -2
- package/dist/ast/error.d.ts.map +1 -1
- package/dist/ast/error.js +1 -0
- package/dist/ast/handlers.d.ts +23 -23
- package/dist/ast/handlers.d.ts.map +1 -1
- package/dist/ast/handlers.js +4 -4
- package/dist/examples/ParserWithSqlSupport.d.ts +62 -0
- package/dist/examples/ParserWithSqlSupport.d.ts.map +1 -0
- package/dist/examples/ParserWithSqlSupport.js +271 -0
- package/dist/examples/{shortcutContextParser.d.ts → ShortcutContextParser.d.ts} +5 -5
- package/dist/examples/ShortcutContextParser.d.ts.map +1 -0
- package/dist/examples/{shortcutContextParser.js → ShortcutContextParser.js} +2 -2
- package/dist/examples/index.d.ts +2 -1
- package/dist/examples/index.d.ts.map +1 -1
- package/dist/examples/index.js +3 -1
- package/dist/index.js +2 -2
- package/dist/internal/ExpressitError.d.ts +2 -2
- package/dist/internal/ExpressitError.d.ts.map +1 -1
- package/dist/internal/ExpressitError.js +2 -1
- package/dist/internal/checkParserOpts.d.ts +1 -1
- package/dist/internal/checkParserOpts.d.ts.map +1 -1
- package/dist/internal/checkParserOpts.js +11 -11
- package/dist/internal/parseParserOptions.d.ts +1 -1
- package/dist/internal/parseParserOptions.d.ts.map +1 -1
- package/dist/package.json.js +4 -195
- package/dist/types/ast.d.ts +60 -58
- package/dist/types/ast.d.ts.map +1 -1
- package/dist/types/ast.js +26 -27
- package/dist/types/autocomplete.d.ts +23 -21
- package/dist/types/autocomplete.d.ts.map +1 -1
- package/dist/types/autocomplete.js +24 -21
- package/dist/types/errors.d.ts +12 -10
- package/dist/types/errors.d.ts.map +1 -1
- package/dist/types/errors.js +8 -7
- package/dist/types/index.js +2 -2
- package/dist/types/parser.d.ts +9 -9
- package/dist/types/parser.d.ts.map +1 -1
- package/dist/utils/getCursorInfo.js +3 -1
- package/dist/utils/getOppositeDelimiter.d.ts +2 -2
- package/dist/utils/getOppositeDelimiter.d.ts.map +1 -1
- package/dist/utils/isDelimiter.d.ts +2 -2
- package/dist/utils/isDelimiter.d.ts.map +1 -1
- package/dist/utils/isParen.d.ts +2 -2
- package/dist/utils/isParen.d.ts.map +1 -1
- package/dist/utils/isQuote.d.ts +2 -2
- package/dist/utils/isQuote.d.ts.map +1 -1
- package/package.json +29 -27
- package/src/Lexer.ts +103 -92
- package/src/Parser.ts +70 -64
- package/src/ast/builders/condition.ts +3 -3
- package/src/ast/builders/delim.ts +5 -5
- package/src/ast/builders/error.ts +3 -3
- package/src/ast/builders/expression.ts +4 -8
- package/src/ast/builders/group.ts +2 -4
- package/src/ast/builders/pos.ts +3 -3
- package/src/ast/builders/token.ts +2 -2
- package/src/ast/builders/type.ts +2 -2
- package/src/ast/builders/variable.ts +5 -5
- package/src/ast/createConditionNode.ts +2 -2
- package/src/ast/createGroupNode.ts +4 -4
- package/src/ast/createToken.ts +6 -6
- package/src/ast/error.ts +2 -2
- package/src/ast/handlers.ts +23 -23
- package/src/examples/ParserWithSqlSupport.ts +371 -0
- package/src/examples/{shortcutContextParser.ts → ShortcutContextParser.ts} +14 -14
- package/src/examples/index.ts +2 -1
- package/src/internal/ExpressitError.ts +4 -4
- package/src/internal/checkParserOpts.ts +14 -14
- package/src/internal/parseParserOptions.ts +2 -2
- package/src/types/ast.ts +101 -96
- package/src/types/autocomplete.ts +26 -22
- package/src/types/errors.ts +18 -13
- package/src/types/parser.ts +9 -9
- package/src/utils/getCursorInfo.ts +1 -1
- package/src/utils/getOppositeDelimiter.ts +2 -2
- package/src/utils/getSurroundingErrors.ts +4 -4
- package/src/utils/isDelimiter.ts +3 -3
- package/src/utils/isParen.ts +2 -2
- package/src/utils/isQuote.ts +2 -2
- package/dist/examples/shortcutContextParser.d.ts.map +0 -1
- package/dist/global.d.js +0 -1
- package/dist/package.js +0 -7
- package/src/global.d.ts +0 -4
- package/src/package.js +0 -11
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import "@alanscodelog/utils";
|
|
2
|
+
import { enumFromArray } from "@alanscodelog/utils/enumFromArray.js";
|
|
3
|
+
const SUGGESTION_TYPE = enumFromArray([
|
|
4
|
+
"VARIABLE",
|
|
5
|
+
"ARRAY_VALUE",
|
|
6
|
+
"VALUE",
|
|
7
|
+
"PREFIX",
|
|
8
|
+
"BOOLEAN_WORD_OP",
|
|
9
|
+
"BOOLEAN_SYMBOL_OP",
|
|
10
|
+
"BACKTICK",
|
|
11
|
+
"DOUBLEQUOTE",
|
|
12
|
+
"SINGLEQUOTE",
|
|
13
|
+
"PARENL",
|
|
14
|
+
"PARENR",
|
|
15
|
+
"PROPERTY",
|
|
16
|
+
"EXPANDED_PROPERTY_OPERATOR",
|
|
17
|
+
"CUSTOM_PROPERTY_OPERATOR",
|
|
18
|
+
"PROPERTY_SEP",
|
|
19
|
+
"BRAKCETR",
|
|
20
|
+
"REGEX",
|
|
21
|
+
"REGEX_FLAGS"
|
|
22
|
+
/** This is not an oversight, I haven't figured out a fast way to detect left bracket errors. */
|
|
23
|
+
// BRAKCETL = "BRAKCETL",
|
|
24
|
+
]);
|
|
22
25
|
export {
|
|
23
26
|
SUGGESTION_TYPE
|
|
24
27
|
};
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
+
import { type EnumLike } from "@alanscodelog/utils";
|
|
1
2
|
import type { ParserOptions } from "./parser.js";
|
|
2
|
-
export declare
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
export type
|
|
8
|
-
export type
|
|
9
|
-
|
|
3
|
+
export declare const PARSER_ERROR: {
|
|
4
|
+
POSITION_ERROR: "PARSER.POSITION_ERROR";
|
|
5
|
+
CONFLICTING_OPTIONS_ERROR: "PARSER.CONFLICTING_OPTIONS_ERROR";
|
|
6
|
+
OPTION_REQUIRED_ERROR: "PARSER.OPTION_REQUIRED_ERROR";
|
|
7
|
+
};
|
|
8
|
+
export type ParserError = EnumLike<typeof PARSER_ERROR>;
|
|
9
|
+
export type ErrorInfo<T extends ParserError> = T extends ParserError ? ErrorCodesInfo[T] : never;
|
|
10
|
+
export type ErrorCodesInfo = {
|
|
11
|
+
[PARSER_ERROR.POSITION_ERROR]: {
|
|
10
12
|
start?: number;
|
|
11
13
|
end?: number;
|
|
12
14
|
};
|
|
13
|
-
[
|
|
15
|
+
[PARSER_ERROR.CONFLICTING_OPTIONS_ERROR]: {
|
|
14
16
|
prohibited: string[];
|
|
15
17
|
invalid: string;
|
|
16
18
|
};
|
|
17
|
-
[
|
|
19
|
+
[PARSER_ERROR.OPTION_REQUIRED_ERROR]: {
|
|
18
20
|
options?: (keyof ParserOptions)[];
|
|
19
21
|
requires: keyof ParserOptions;
|
|
20
22
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAGnD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAGhD,eAAO,MAAM,YAAY;;;;CAIZ,CAAA;AAEb,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,YAAY,CAAC,CAAA;AAGvD,MAAM,MAAM,SAAS,CAAC,CAAC,SAAS,WAAW,IAC1C,CAAC,SAAS,WAAW,GACnB,cAAc,CAAC,CAAC,CAAC,GACjB,KAAK,CAAA;AAGR,MAAM,MAAM,cAAc,GAAG;IAC5B,CAAC,YAAY,CAAC,cAAc,CAAC,EAAE;QAC9B,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,GAAG,CAAC,EAAE,MAAM,CAAA;KACZ,CAAA;IACD,CAAC,YAAY,CAAC,yBAAyB,CAAC,EAAE;QACzC,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,OAAO,EAAE,MAAM,CAAA;KACf,CAAA;IACD,CAAC,YAAY,CAAC,qBAAqB,CAAC,EAAE;QACrC,OAAO,CAAC,EAAE,CAAC,MAAM,aAAa,CAAC,EAAE,CAAA;QACjC,QAAQ,EAAE,MAAM,aAAa,CAAA;KAC7B,CAAA;CACD,CAAA"}
|
package/dist/types/errors.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import "@alanscodelog/utils";
|
|
2
|
+
import { enumFromArray } from "@alanscodelog/utils/enumFromArray.js";
|
|
3
|
+
const PARSER_ERROR = enumFromArray([
|
|
4
|
+
"POSITION_ERROR",
|
|
5
|
+
"CONFLICTING_OPTIONS_ERROR",
|
|
6
|
+
"OPTION_REQUIRED_ERROR"
|
|
7
|
+
], "PARSER.");
|
|
7
8
|
export {
|
|
8
|
-
|
|
9
|
+
PARSER_ERROR
|
|
9
10
|
};
|
package/dist/types/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AST_TYPE, TOKEN_TYPE } from "./ast.js";
|
|
2
2
|
import { SUGGESTION_TYPE } from "./autocomplete.js";
|
|
3
|
-
import {
|
|
3
|
+
import { PARSER_ERROR } from "./errors.js";
|
|
4
4
|
export {
|
|
5
5
|
AST_TYPE,
|
|
6
|
-
|
|
6
|
+
PARSER_ERROR,
|
|
7
7
|
SUGGESTION_TYPE,
|
|
8
8
|
TOKEN_TYPE
|
|
9
9
|
};
|
package/dist/types/parser.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { DeepRequired, MakeRequired } from "@alanscodelog/utils/types";
|
|
2
2
|
import type { ArrayNode, ConditionNode, NormalizedCondition, Position, TOKEN_TYPE, ValidToken, VariableNode } from "./ast.js";
|
|
3
|
-
export type FullParserOptions<T
|
|
3
|
+
export type FullParserOptions<T = any> = MakeRequired<ParserOptions<T>, Exclude<keyof ParserOptions<T>, "prefixableStrings" | "expandedPropertySeparator" | "customPropertyOperators" | "keywords">> & {
|
|
4
4
|
keywords: DeepRequired<KeywordOptions>;
|
|
5
5
|
};
|
|
6
|
-
export type ParserOptions<T
|
|
6
|
+
export type ParserOptions<T = any> = {
|
|
7
7
|
/**
|
|
8
8
|
* Allows any conditions (i.e. a variable or negated variable) to precede groups and append themselves to all variables inside them. Regular use of groups for changing precedence (e.g. `(a || b) && c` ) or negating expressions `!(a || b)` is still supported even if `prefixableGroups` is false.
|
|
9
9
|
*
|
|
@@ -101,7 +101,7 @@ export type ParserOptions<T extends {} = {}> = {
|
|
|
101
101
|
/**
|
|
102
102
|
* Enables regex strings as values. The value is treated as if it was quoted by forward slashes. Any repetition of lowercase characters (even if there are multiple) attached to the end are assumed to be flags and added as a single token to the value's `quotes.mode` property.
|
|
103
103
|
*
|
|
104
|
-
* Can be passed a custom function to determine when to use the regex value or not (it is converted to a regular value). The function is passed the property, the operator, and whether it's an expanded operator. If
|
|
104
|
+
* Can be passed a custom function to determine when to use the regex value or not (it is converted to a regular value). The function is passed the property, the operator, and whether it's an expanded operator. If there is an error token for the property or operator, an empty string is passed.
|
|
105
105
|
*
|
|
106
106
|
* ```ts
|
|
107
107
|
* // allow anything (`prop=/val/`, `prop:op:/val`, `prop=(/val/)`, `prop:op(/val/)`) but the value alone (`/regex/`)
|
|
@@ -257,7 +257,7 @@ export type ParserOptions<T extends {} = {}> = {
|
|
|
257
257
|
* ```ts
|
|
258
258
|
* type Operators = "contains"
|
|
259
259
|
* function valueComparer(condition: Omit<Condition, "negate">, contextValue: any, context: any): boolean {
|
|
260
|
-
* switch (operator as Operators) {
|
|
260
|
+
* switch (condition.operator as Operators) {
|
|
261
261
|
* case "contains": return (contextValue as string[]).includes(condition.value as string)
|
|
262
262
|
* // ...
|
|
263
263
|
* }
|
|
@@ -292,13 +292,13 @@ export type ParserOptions<T extends {} = {}> = {
|
|
|
292
292
|
* if (prefix) {
|
|
293
293
|
* const val = value as string // it's always a string if prefixed
|
|
294
294
|
* switch (prefix as RawPrefixes) {
|
|
295
|
-
* case "num": finalValue = parseInt(val,
|
|
295
|
+
* case "num": finalValue = parseInt(val, 10); break
|
|
296
296
|
* // ...
|
|
297
297
|
* }
|
|
298
298
|
* }
|
|
299
299
|
* // another way to allow special unquoted value types is something like this:
|
|
300
300
|
* if (typeof value === "string" && !isQuoted) {
|
|
301
|
-
* const asNum = parseInt(value,
|
|
301
|
+
* const asNum = parseInt(value, 10)
|
|
302
302
|
* if (!isNaN(asNum)) finalValue = asNum
|
|
303
303
|
* if (["true","false"].includes(value)) {
|
|
304
304
|
* finalValue = value === "true" ? true : false
|
|
@@ -415,9 +415,9 @@ export type ValueQuery = {
|
|
|
415
415
|
/** {@link ParserOptions}["valueValidator"] */
|
|
416
416
|
export type ValidationQuery = Omit<ValueQuery, "value" | "operator" | "prefix" | "regexFlags" | "property"> & {
|
|
417
417
|
value?: VariableNode | ArrayNode;
|
|
418
|
-
operator?: ValidToken<TOKEN_TYPE.VALUE | TOKEN_TYPE.OP_CUSTOM>;
|
|
419
|
-
prefix?: ValidToken<TOKEN_TYPE.VALUE>;
|
|
420
|
-
regexFlags?: ValidToken<TOKEN_TYPE.VALUE>;
|
|
418
|
+
operator?: ValidToken<typeof TOKEN_TYPE.VALUE | typeof TOKEN_TYPE.OP_CUSTOM>;
|
|
419
|
+
prefix?: ValidToken<typeof TOKEN_TYPE.VALUE>;
|
|
420
|
+
regexFlags?: ValidToken<typeof TOKEN_TYPE.VALUE>;
|
|
421
421
|
property: VariableNode[];
|
|
422
422
|
/** The property as would be passed to the {@link ParserOptions}["valueComparer"] function (i.e. joined as a string using the {@link ParseOptions}["prefixApplier"] ) */
|
|
423
423
|
propertyName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/types/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAI7H,MAAM,MAAM,iBAAiB,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/types/parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE3E,OAAO,KAAK,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAI7H,MAAM,MAAM,iBAAiB,CAAC,CAAC,GAAG,GAAG,IAAI,YAAY,CACpD,aAAa,CAAC,CAAC,CAAC,EAEhB,OAAO,CAAC,MAAM,aAAa,CAAC,CAAC,CAAC,EAC3B,mBAAmB,GACnB,2BAA2B,GAC3B,yBAAyB,GACzB,UAAU,CACZ,CACD,GACC;IAED,QAAQ,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;CACtC,CAAA;AACD,MAAM,MAAM,aAAa,CAAC,CAAC,GAAG,GAAG,IAAI;IACpC;;;;;;;;;;;;;;;OAeG;IACH,gBAAgB,CAAC,EAAE,OAAO,CAAA;IAC1B;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;IAC5B;;;;;;;;;;;;;;;;;;OAkBG;IACH,yBAAyB,CAAC,EAAE,MAAM,CAAA;IAClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,uBAAuB,CAAC,EAAE,MAAM,EAAE,CAAA;IAClC;;;;;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M,mBAAmB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,QAAQ,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,OAAO,CAAA;CAAE,CAAA;AACvG,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,GAAG,SAAS,EAAE,KAAK,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,QAAQ,GAAG,CAAC,CAAC,EAAE,GAAG,SAAS,GAAG,IAAI,CAAA;AAEnL,MAAM,MAAM,SAAS,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EAAE,CAAA;AACjD,MAAM,MAAM,aAAa,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAA;AAExE,MAAM,MAAM,YAAY,GAAG;IAC1B,kDAAkD;IAClD,QAAQ,EAAE,OAAO,CAAA;IACjB,KAAK,EAAE,MAAM,CAAA;CACb,CAAA;AACD,MAAM,MAAM,cAAc,GAAG;IAC5B,EAAE,CAAC,EAAE,YAAY,EAAE,CAAA;IACnB,GAAG,CAAC,EAAE,YAAY,EAAE,CAAA;IACpB,GAAG,CAAC,EAAE,YAAY,EAAE,CAAA;CACpB,CAAA"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { isArray } from "@alanscodelog/utils/isArray.js";
|
|
2
2
|
import { unreachable } from "@alanscodelog/utils/unreachable.js";
|
|
3
3
|
import { extractTokens } from "./extractTokens.js";
|
|
4
|
+
import "../types/ast.js";
|
|
5
|
+
import "../types/autocomplete.js";
|
|
4
6
|
function getCursorInfo(input, ast, index) {
|
|
5
7
|
const tokens = isArray(ast) ? ast : extractTokens(ast);
|
|
6
8
|
if (input.length < index || index < 0) {
|
|
@@ -37,7 +39,7 @@ function getCursorInfo(input, ast, index) {
|
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
41
|
if (token.start >= index) {
|
|
40
|
-
info.next
|
|
42
|
+
info.next ?? (info.next = token);
|
|
41
43
|
if (token.valid && !info.valid.next) {
|
|
42
44
|
info.valid.next = token;
|
|
43
45
|
break;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { generateParentsMap } from "./generateParentsMap.js";
|
|
2
|
-
import { type AnyToken, type
|
|
2
|
+
import { type AnyToken, type TokenDelimiter } from "../types/ast.js";
|
|
3
3
|
/**
|
|
4
4
|
* Given a delimiter token, returns it's opposite pair, or undefined if the type passed was not a delimiter token (so you can pass any type without checking).
|
|
5
5
|
*/
|
|
6
|
-
export declare function getOppositeDelimiter(token: AnyToken, parentsMap: ReturnType<typeof generateParentsMap>): AnyToken<
|
|
6
|
+
export declare function getOppositeDelimiter(token: AnyToken, parentsMap: ReturnType<typeof generateParentsMap>): AnyToken<TokenDelimiter> | undefined;
|
|
7
7
|
//# sourceMappingURL=getOppositeDelimiter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getOppositeDelimiter.d.ts","sourceRoot":"","sources":["../../src/utils/getOppositeDelimiter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAMjE,OAAO,EAAE,KAAK,QAAQ,EAAiE,KAAK,
|
|
1
|
+
{"version":3,"file":"getOppositeDelimiter.d.ts","sourceRoot":"","sources":["../../src/utils/getOppositeDelimiter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAMjE,OAAO,EAAE,KAAK,QAAQ,EAAiE,KAAK,cAAc,EAAqB,MAAM,iBAAiB,CAAA;AAEtJ;;GAEG;AACH,wBAAgB,oBAAoB,CACnC,KAAK,EAAE,QAAQ,EACf,UAAU,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,GAC/C,QAAQ,CAAC,cAAc,CAAC,GAAG,SAAS,CAuBtC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { type AnyToken, type
|
|
1
|
+
import { type AnyToken, type TokenDelimiter } from "../types/ast.js";
|
|
2
2
|
/**
|
|
3
3
|
* Returns whether token is a delimiter type (including if it's an expanded operator separator).
|
|
4
4
|
*/
|
|
5
|
-
export declare function isDelimiter(token?: AnyToken): token is AnyToken<
|
|
5
|
+
export declare function isDelimiter(token?: AnyToken): token is AnyToken<TokenDelimiter>;
|
|
6
6
|
//# sourceMappingURL=isDelimiter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isDelimiter.d.ts","sourceRoot":"","sources":["../../src/utils/isDelimiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,
|
|
1
|
+
{"version":3,"file":"isDelimiter.d.ts","sourceRoot":"","sources":["../../src/utils/isDelimiter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhF;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,IAAI,QAAQ,CAAC,cAAc,CAAC,CAY/E"}
|
package/dist/utils/isParen.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { type AnyToken, type
|
|
2
|
-
export declare function isParen(token?: AnyToken): token is AnyToken<
|
|
1
|
+
import { type AnyToken, type TokenParen } from "../types/ast.js";
|
|
2
|
+
export declare function isParen(token?: AnyToken): token is AnyToken<TokenParen>;
|
|
3
3
|
//# sourceMappingURL=isParen.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isParen.d.ts","sourceRoot":"","sources":["../../src/utils/isParen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,
|
|
1
|
+
{"version":3,"file":"isParen.d.ts","sourceRoot":"","sources":["../../src/utils/isParen.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAG5E,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,IAAI,QAAQ,CAAC,UAAU,CAAC,CAEvE"}
|
package/dist/utils/isQuote.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AnyToken, type
|
|
1
|
+
import { type AnyToken, type TokenQuote } from "../types/ast.js";
|
|
2
2
|
/** Returns if the token is a quote token. This includes regex delimiters. */
|
|
3
|
-
export declare function isQuote(token?: AnyToken): token is AnyToken<
|
|
3
|
+
export declare function isQuote(token?: AnyToken): token is AnyToken<TokenQuote>;
|
|
4
4
|
//# sourceMappingURL=isQuote.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isQuote.d.ts","sourceRoot":"","sources":["../../src/utils/isQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,
|
|
1
|
+
{"version":3,"file":"isQuote.d.ts","sourceRoot":"","sources":["../../src/utils/isQuote.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAc,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAA;AAE5E,6EAA6E;AAC7E,wBAAgB,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,GAAG,KAAK,IAAI,QAAQ,CAAC,UAAU,CAAC,CAEvE"}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@witchcraft/expressit",
|
|
3
3
|
"description": "A blazing fast, customizable, error-tolerant expression parser that creates safe to eval expressions + a few other goodies like autocomplete.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"exports": {
|
|
10
10
|
".": {
|
|
@@ -61,8 +61,7 @@
|
|
|
61
61
|
"build": "vite build",
|
|
62
62
|
"build:dev": "vite build --mode development",
|
|
63
63
|
"build:watch": "vite build --watch --mode production",
|
|
64
|
-
"build:types": "tsc --emitDeclarationOnly -p tsconfig.types.json
|
|
65
|
-
"build:types:fix": "tsc-alias -p tsconfig.types.json --debug",
|
|
64
|
+
"build:types": "tsc --emitDeclarationOnly -p tsconfig.types.json",
|
|
66
65
|
"lint:eslint": "eslint \"{src,tests,bin}/**/*.{cjs,js,ts}\" \"*.{cjs,js,ts}\" --max-warnings=1 --report-unused-disable-directives",
|
|
67
66
|
"lint:types": "tsc --noEmit --pretty",
|
|
68
67
|
"lint:commits": "commitlint --from $(git rev-list --max-parents=0 HEAD) --to HEAD --verbose",
|
|
@@ -70,48 +69,51 @@
|
|
|
70
69
|
"lint": "npm run lint:types && npm run lint:eslint",
|
|
71
70
|
"coverage": "vitest --exclude '.direnv/**/*' --coverage",
|
|
72
71
|
"coverage:dev": "vitest --exclude '.direnv/**/*' --watch --coverage",
|
|
73
|
-
"test": "
|
|
74
|
-
"test:
|
|
72
|
+
"test:db": "rm -rf ./tests/db/migrations && pnpm drizzle-kit generate --config ./tests/db/drizzle.config.ts",
|
|
73
|
+
"test": "pnpm test:db && npm run lint:types && vitest run --exclude '.direnv/**/*'",
|
|
74
|
+
"test:watch": "pnpm test:db && vitest --watch --exclude '.direnv/**/*'",
|
|
75
75
|
"test:inspect-errors": "cross-env INSPECT_ERRORS=true npm run test",
|
|
76
|
-
"doc": "typedoc --options typedoc.config.
|
|
76
|
+
"doc": "typedoc --options typedoc.config.js",
|
|
77
77
|
"doc:watch": "onchange -i \"src/**/*.ts\" \"typedoc.config.cjs\" -- npm run doc",
|
|
78
78
|
"doc:serve": "http-server docs --port=5001",
|
|
79
79
|
"doc:dev": "concurrently \"npm run doc:watch\" \"npm run doc:serve\"",
|
|
80
80
|
"doc:check-invalid": "typedoc --options typedoc.config.cjs --listInvalidSymbolLinks",
|
|
81
81
|
"demo:dev": "cd demo && concurrently \"vite\" \"npm run build:watch\"",
|
|
82
82
|
"demo:build": "cd demo && npm run build",
|
|
83
|
-
"actions:debug": "act -r -v -j
|
|
83
|
+
"actions:debug": "act -r -v -j release",
|
|
84
84
|
"gen:exports": "indexit update -o '${path}.js' -i **/*.d.ts",
|
|
85
85
|
"prepare": "husky && npm run build"
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@alanscodelog/utils": "^
|
|
88
|
+
"@alanscodelog/utils": "^5.1.0"
|
|
89
89
|
},
|
|
90
90
|
"devDependencies": {
|
|
91
91
|
"@alanscodelog/commitlint-config": "^3.0.1",
|
|
92
|
-
"@alanscodelog/eslint-config": "5.0.
|
|
93
|
-
"@alanscodelog/semantic-release-config": "^
|
|
94
|
-
"@alanscodelog/tsconfigs": "^
|
|
95
|
-
"@commitlint/cli": "^19.
|
|
96
|
-
"@
|
|
97
|
-
"@
|
|
98
|
-
"
|
|
92
|
+
"@alanscodelog/eslint-config": "5.0.3",
|
|
93
|
+
"@alanscodelog/semantic-release-config": "^5.0.4",
|
|
94
|
+
"@alanscodelog/tsconfigs": "^6.0.0",
|
|
95
|
+
"@commitlint/cli": "^19.6.1",
|
|
96
|
+
"@electric-sql/pglite": "^0.2.12",
|
|
97
|
+
"@types/node": "^22.10.2",
|
|
98
|
+
"@vitest/coverage-v8": "^3.1.1",
|
|
99
|
+
"concurrently": "^9.1.0",
|
|
99
100
|
"cross-env": "^7.0.3",
|
|
101
|
+
"drizzle-kit": "^0.31.0",
|
|
102
|
+
"drizzle-orm": "^0.42.0",
|
|
100
103
|
"fast-glob": "^3.3.1",
|
|
101
104
|
"http-server": "^14.1.1",
|
|
102
|
-
"husky": "^9.
|
|
105
|
+
"husky": "^9.1.7",
|
|
103
106
|
"indexit": "2.1.0-beta.3",
|
|
104
|
-
"madge": "^
|
|
107
|
+
"madge": "^8.0.0",
|
|
105
108
|
"onchange": "^7.1.0",
|
|
106
|
-
"semantic-release": "^
|
|
109
|
+
"semantic-release": "^24.2.0",
|
|
107
110
|
"ts-node": "^10.9.1",
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"vite": "^
|
|
112
|
-
"vite-
|
|
113
|
-
"
|
|
114
|
-
"vitest": "^1.6.0"
|
|
111
|
+
"typedoc": "0.28.3",
|
|
112
|
+
"typescript": "~5.8.3",
|
|
113
|
+
"vite": "^6.0.2",
|
|
114
|
+
"vite-plugin-externalize-deps": "^0.9.0",
|
|
115
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
116
|
+
"vitest": "^3.1.1"
|
|
115
117
|
},
|
|
116
118
|
"author": "Alan <alanscodelog@gmail.com>",
|
|
117
119
|
"repository": "https://github.com/witchcraftjs/expressit",
|
|
@@ -141,7 +143,7 @@
|
|
|
141
143
|
},
|
|
142
144
|
"browserslist": "defaults and supports es6-module,maintained node versions",
|
|
143
145
|
"engines": {
|
|
144
|
-
"node": ">=
|
|
146
|
+
"node": ">=20.0.0"
|
|
145
147
|
},
|
|
146
148
|
"@comments": {
|
|
147
149
|
"scripts": {
|