@ja-platform/parser-expressions 0.0.0-dev-20261021200117 → 0.0.0-dev-20261021213526

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.
Files changed (45) hide show
  1. package/dist/@types/CombinedParser.d.ts +1 -1
  2. package/dist/@types/ExpressionParser.d.ts +1 -1
  3. package/dist/@types/definitions/ValidationContext.d.ts +1 -1
  4. package/dist/@types/expressions/AbstractExpression.d.ts +1 -1
  5. package/dist/@types/expressions/EvaluatedExpression.d.ts +2 -1
  6. package/dist/@types/expressions/ListExpression.d.ts +2 -1
  7. package/dist/@types/expressions/constant/ConstantExpression.d.ts +1 -1
  8. package/dist/@types/expressions/function/FunctionExpression.d.ts +2 -1
  9. package/dist/@types/expressions/shorthand/FormatShorthandExpression.d.ts +1 -1
  10. package/dist/@types/expressions/shorthand/ShorthandExpression.d.ts +2 -1
  11. package/dist/@types/expressions/text/AbstractFormatExpression.d.ts +3 -1
  12. package/dist/@types/expressions/text/FormatStringExpression.d.ts +1 -1
  13. package/dist/@types/index.d.ts +19 -2
  14. package/dist/@types/utils/parserUtils.d.ts +2 -2
  15. package/dist/CombinedParser.js.map +1 -1
  16. package/dist/ExpressionParser.js.map +1 -1
  17. package/dist/definitions/ValidationContext.js.map +1 -1
  18. package/dist/expressions/AbstractExpression.js.map +1 -1
  19. package/dist/expressions/EvaluatedExpression.js +16 -12
  20. package/dist/expressions/EvaluatedExpression.js.map +1 -1
  21. package/dist/expressions/ListExpression.js +3 -3
  22. package/dist/expressions/ListExpression.js.map +1 -1
  23. package/dist/expressions/constant/ConstantExpression.js +4 -3
  24. package/dist/expressions/constant/ConstantExpression.js.map +1 -1
  25. package/dist/expressions/function/FunctionExpression.js +2 -2
  26. package/dist/expressions/function/FunctionExpression.js.map +1 -1
  27. package/dist/expressions/shorthand/FormatShorthandExpression.js +4 -3
  28. package/dist/expressions/shorthand/FormatShorthandExpression.js.map +1 -1
  29. package/dist/expressions/shorthand/ShorthandExpression.js +6 -4
  30. package/dist/expressions/shorthand/ShorthandExpression.js.map +1 -1
  31. package/dist/expressions/text/AbstractFormatExpression.js +13 -12
  32. package/dist/expressions/text/AbstractFormatExpression.js.map +1 -1
  33. package/dist/expressions/text/FormatStringExpression.js.map +1 -1
  34. package/dist/index.js +25 -3
  35. package/dist/index.js.map +1 -1
  36. package/dist/tsconfig.tsbuildinfo +1 -1
  37. package/dist/utils/parserUtils.js +10 -6
  38. package/dist/utils/parserUtils.js.map +1 -1
  39. package/package.json +2 -2
  40. package/dist/@types/expressions/index.d.ts +0 -9
  41. package/dist/@types/tokens/index.d.ts +0 -10
  42. package/dist/expressions/index.js +0 -26
  43. package/dist/expressions/index.js.map +0 -1
  44. package/dist/tokens/index.js +0 -33
  45. package/dist/tokens/index.js.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { ExpressionParser } from './ExpressionParser';
2
2
  import { AbstractExpression } from './expressions/AbstractExpression';
3
- import { ExpressionSource } from './tokens';
3
+ import { ExpressionSource } from './tokens/AbstractToken';
4
4
  /**
5
5
  * Try parsers in order and stop at the first matching expression.
6
6
  */
@@ -1,4 +1,4 @@
1
- import { ExpressionSource } from './tokens';
1
+ import { ExpressionSource } from './tokens/AbstractToken';
2
2
  import { AbstractExpression } from './expressions/AbstractExpression';
3
3
  /**
4
4
  * Return null for unrecognized syntax; throw for malformed input belonging to this parser.
@@ -1,4 +1,4 @@
1
- import type { ReferencePath } from '../tokens';
1
+ import type { ReferencePath } from '../tokens/code/CodeToken';
2
2
  import type { Type } from '@ja-platform/parser-type-system';
3
3
  /**
4
4
  * Resolve declared references for expression validation without reading or evaluating values.
@@ -1,4 +1,4 @@
1
- import { AbstractToken } from '../tokens';
1
+ import { AbstractToken } from '../tokens/AbstractToken';
2
2
  import type { ValidationContext } from '../definitions/ValidationContext';
3
3
  export interface ExpressionDiagnostic {
4
4
  token: AbstractToken;
@@ -1,6 +1,7 @@
1
1
  import { ExpressionParser } from '../ExpressionParser';
2
2
  import { AbstractExpression, AbstractExpressionOptions } from './AbstractExpression';
3
- import { AbstractToken, CodeToken, ExpressionSource } from '../tokens';
3
+ import { AbstractToken, ExpressionSource } from '../tokens/AbstractToken';
4
+ import { CodeToken } from '../tokens/code/CodeToken';
4
5
  /**
5
6
  * Code explicitly marked for evaluation by the `$:` prefix.
6
7
  * Examples include `$:count + 1`, `$:true`, `$:{name: user.name}` and `$:[1, 2]`.
@@ -1,5 +1,6 @@
1
1
  import { ExpressionParser } from '../ExpressionParser';
2
- import { AbstractToken, DelimiterToken, ExpressionSource } from '../tokens';
2
+ import { AbstractToken, ExpressionSource } from '../tokens/AbstractToken';
3
+ import { DelimiterToken } from '../tokens/DelimiterToken';
3
4
  import { AbstractExpression, AbstractExpressionOptions } from './AbstractExpression';
4
5
  /**
5
6
  * A comma-separated list retaining item tokens, separators and whitespace.
@@ -1,6 +1,6 @@
1
1
  import { ExpressionParser } from '../../ExpressionParser';
2
2
  import { AbstractExpression, AbstractExpressionOptions } from '../AbstractExpression';
3
- import { ExpressionSource } from '../../tokens';
3
+ import { ExpressionSource } from '../../tokens/AbstractToken';
4
4
  import { Type } from '@ja-platform/parser-type-system';
5
5
  export interface ConstantExpressionOptions<T> extends AbstractExpressionOptions {
6
6
  value: T;
@@ -1,7 +1,8 @@
1
1
  import { ExpressionParser } from '../../ExpressionParser';
2
2
  import { AbstractExpression, AbstractExpressionOptions } from '../AbstractExpression';
3
3
  import { EvaluatedExpression } from '../EvaluatedExpression';
4
- import { CodeToken, ExpressionSource } from '../../tokens';
4
+ import { CodeToken } from '../../tokens/code/CodeToken';
5
+ import { ExpressionSource } from '../../tokens/AbstractToken';
5
6
  /**
6
7
  * An explicitly evaluated function call, such as `$:save(true)` or `$:worker.save(user.name)`.
7
8
  * The root code expression must be a call; this type exposes its target and arguments for editing.
@@ -1,6 +1,6 @@
1
1
  import { ExpressionParser } from '../../ExpressionParser';
2
2
  import { ShorthandExpression, ShorthandExpressionOptions } from './ShorthandExpression';
3
- import { ExpressionSource } from '../../tokens';
3
+ import { ExpressionSource } from '../../tokens/AbstractToken';
4
4
  export interface FormatShorthandExpressionOptions extends ShorthandExpressionOptions {
5
5
  format: string;
6
6
  }
@@ -1,6 +1,7 @@
1
1
  import { ExpressionParser } from '../../ExpressionParser';
2
2
  import { AbstractExpression, AbstractExpressionOptions, ExpressionDiagnostic } from '../AbstractExpression';
3
- import { CodeToken, ExpressionSource, ReferencePath } from '../../tokens';
3
+ import { ExpressionSource } from '../../tokens/AbstractToken';
4
+ import { CodeToken, ReferencePath } from '../../tokens/code/CodeToken';
4
5
  import type { ValidationContext } from '../../definitions/ValidationContext';
5
6
  import type { Type } from '@ja-platform/parser-type-system';
6
7
  export interface ShorthandExpressionOptions extends AbstractExpressionOptions {
@@ -1,5 +1,7 @@
1
1
  import { ExpressionParser } from '../../ExpressionParser';
2
- import { AbstractToken, ExpressionSource, TextToken, PlaceholderToken } from '../../tokens';
2
+ import { AbstractToken, ExpressionSource } from '../../tokens/AbstractToken';
3
+ import { TextToken } from '../../tokens/text/TextToken';
4
+ import { PlaceholderToken } from '../../tokens/text/PlaceholderToken';
3
5
  import type { ValidationContext } from '../../definitions/ValidationContext';
4
6
  import { AbstractExpression, AbstractExpressionOptions, ExpressionDiagnostic } from '../AbstractExpression';
5
7
  export interface AbstractFormatExpressionOptions<P extends AbstractExpression> extends AbstractExpressionOptions {
@@ -1,4 +1,4 @@
1
- import { ExpressionSource } from '../../tokens';
1
+ import { ExpressionSource } from '../../tokens/AbstractToken';
2
2
  import { EvaluatedExpression } from '../EvaluatedExpression';
3
3
  import { ShorthandExpression } from '../shorthand/ShorthandExpression';
4
4
  import { AbstractFormatExpression, AbstractFormatExpressionOptions, AbstractFormatExpressionParser } from './AbstractFormatExpression';
@@ -4,6 +4,23 @@ export * from './utils/parserUtils';
4
4
  export * from './code-parsers/CodeParser';
5
5
  export * from './code-parsers/JavaScriptParser';
6
6
  export { formatValue, formatValueAsync } from './utils/valueFormatting';
7
- export * from './expressions';
7
+ export * from './expressions/AbstractExpression';
8
+ export * from './expressions/ListExpression';
9
+ export * from './expressions/EvaluatedExpression';
10
+ export * from './expressions/shorthand/ShorthandExpression';
11
+ export * from './expressions/shorthand/FormatShorthandExpression';
12
+ export * from './expressions/constant/ConstantExpression';
13
+ export * from './expressions/function/FunctionExpression';
14
+ export * from './expressions/text/FormatStringExpression';
15
+ export * from './expressions/text/AbstractFormatExpression';
8
16
  export * from './definitions/ValidationContext';
9
- export * from './tokens';
17
+ export * from './tokens/AbstractToken';
18
+ export * from './tokens/DelimiterToken';
19
+ export * from './tokens/EnumToken';
20
+ export * from './tokens/text/TextToken';
21
+ export * from './tokens/code/JSToken';
22
+ export * from './tokens/code/PrefixToken';
23
+ export * from './tokens/code/IdentifierToken';
24
+ export * from './tokens/text/PlaceholderToken';
25
+ export * from './tokens/code/CodeToken';
26
+ export { stringify, codeToken, javascriptToken, hasFunctionPrefix, leadingTrivia } from './utils/tokenUtils';
@@ -1,5 +1,5 @@
1
- import { AbstractExpression } from '../expressions';
2
- import { ExpressionSource } from '../tokens';
1
+ import { AbstractExpression } from '../expressions/AbstractExpression';
2
+ import { ExpressionSource } from '../tokens/AbstractToken';
3
3
  /**
4
4
  * Recognize evaluated code and references before preserving remaining input as constant text.
5
5
  * Callers can compose their own parser order instead.
@@ -1 +1 @@
1
- {"version":3,"file":"CombinedParser.js","sourceRoot":"","sources":["../src/CombinedParser.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAItD;;GAEG;AACH,oBAA+E,SAAQ,mCAAmB;IAGxG,YAAY,OAAuC;QACjD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,IAAI,UAAU,GAAa,IAAI,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,UAAU,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1D,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzD,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from './ExpressionParser';\nimport { AbstractExpression } from './expressions/AbstractExpression';\nimport { ExpressionSource } from './tokens';\n\n/**\n * Try parsers in order and stop at the first matching expression.\n */\nexport class CombinedParser<T extends AbstractExpression = AbstractExpression> extends ExpressionParser<T> {\n readonly parsers: readonly ExpressionParser<T>[];\n\n constructor(parsers: readonly ExpressionParser<T>[]) {\n super();\n this.parsers = Object.freeze([...parsers]);\n }\n\n tryParse(source: ExpressionSource, start = 0): T | null {\n let expression: T | null = null;\n let index = 0;\n while (expression === null && index < this.parsers.length) {\n expression = this.parsers[index].tryParse(source, start);\n index++;\n }\n return expression;\n }\n}\n"]}
1
+ {"version":3,"file":"CombinedParser.js","sourceRoot":"","sources":["../src/CombinedParser.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAItD;;GAEG;AACH,oBAA+E,SAAQ,mCAAmB;IAGxG,YAAY,OAAuC;QACjD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAC7C,CAAC;IAED,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,IAAI,UAAU,GAAa,IAAI,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,OAAO,UAAU,KAAK,IAAI,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAC1D,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;YACzD,KAAK,EAAE,CAAC;QACV,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from './ExpressionParser';\nimport { AbstractExpression } from './expressions/AbstractExpression';\nimport { ExpressionSource } from './tokens/AbstractToken';\n\n/**\n * Try parsers in order and stop at the first matching expression.\n */\nexport class CombinedParser<T extends AbstractExpression = AbstractExpression> extends ExpressionParser<T> {\n readonly parsers: readonly ExpressionParser<T>[];\n\n constructor(parsers: readonly ExpressionParser<T>[]) {\n super();\n this.parsers = Object.freeze([...parsers]);\n }\n\n tryParse(source: ExpressionSource, start = 0): T | null {\n let expression: T | null = null;\n let index = 0;\n while (expression === null && index < this.parsers.length) {\n expression = this.parsers[index].tryParse(source, start);\n index++;\n }\n return expression;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressionParser.js","sourceRoot":"","sources":["../src/ExpressionParser.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH;IAGE;;OAEG;IACH,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;YACzC,MAAM,IAAI,WAAW,CAAC,wBAAwB,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionSource } from './tokens';\nimport { AbstractExpression } from './expressions/AbstractExpression';\n\n/**\n * Return null for unrecognized syntax; throw for malformed input belonging to this parser.\n */\nexport abstract class ExpressionParser<T extends AbstractExpression = AbstractExpression> {\n abstract tryParse(source: ExpressionSource, start?: number): T | null;\n\n /**\n * Require a valid match, preserving any syntax error from the concrete parser.\n */\n parse(source: ExpressionSource, start = 0): T {\n const expression = this.tryParse(source, start);\n if (!expression || !expression.isValid()) {\n throw new SyntaxError(`Input does not match ${this.constructor.name}.`);\n }\n return expression;\n }\n}\n"]}
1
+ {"version":3,"file":"ExpressionParser.js","sourceRoot":"","sources":["../src/ExpressionParser.ts"],"names":[],"mappings":";;;AAGA;;GAEG;AACH;IAGE;;OAEG;IACH,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAChD,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;YACzC,MAAM,IAAI,WAAW,CAAC,wBAAwB,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,CAAC,CAAC;QAC1E,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionSource } from './tokens/AbstractToken';\nimport { AbstractExpression } from './expressions/AbstractExpression';\n\n/**\n * Return null for unrecognized syntax; throw for malformed input belonging to this parser.\n */\nexport abstract class ExpressionParser<T extends AbstractExpression = AbstractExpression> {\n abstract tryParse(source: ExpressionSource, start?: number): T | null;\n\n /**\n * Require a valid match, preserving any syntax error from the concrete parser.\n */\n parse(source: ExpressionSource, start = 0): T {\n const expression = this.tryParse(source, start);\n if (!expression || !expression.isValid()) {\n throw new SyntaxError(`Input does not match ${this.constructor.name}.`);\n }\n return expression;\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ValidationContext.js","sourceRoot":"","sources":["../../src/definitions/ValidationContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReferencePath } from '../tokens';\nimport type { Type } from '@ja-platform/parser-type-system';\n\n/**\n * Resolve declared references for expression validation without reading or evaluating values.\n */\nexport interface ValidationContext {\n getReference(path: ReferencePath): Type | null;\n}\n"]}
1
+ {"version":3,"file":"ValidationContext.js","sourceRoot":"","sources":["../../src/definitions/ValidationContext.ts"],"names":[],"mappings":"","sourcesContent":["import type { ReferencePath } from '../tokens/code/CodeToken';\nimport type { Type } from '@ja-platform/parser-type-system';\n\n/**\n * Resolve declared references for expression validation without reading or evaluating values.\n */\nexport interface ValidationContext {\n getReference(path: ReferencePath): Type | null;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractExpression.js","sourceRoot":"","sources":["../../src/expressions/AbstractExpression.ts"],"names":[],"mappings":";;;AAiBA;;;;;GAKG;AACH;IAIE,YAAsB,IAAY,EAAE,OAAU;;;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,mCACP,OAAO,KACV,KAAK,cAAE,OAAO,CAAC,KAAK,mCAAI,MAAA,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,0CAAE,KAAK,mCAAI,CAAC,EACrD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAC3C,CAAC;IACJ,CAAC;IAOD;;OAEG;IACH,QAAQ,CAAC,QAA2B;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,WAAuC,CAAC;QAC1D,OAAO,IAAI,IAAI,iCAAM,IAAI,CAAC,OAAO,KAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,IAAG,CAAC;IAC1F,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,GAAG;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,OAAO,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAC3F,CAAC;CACF","sourcesContent":["import { AbstractToken } from '../tokens';\nimport type { ValidationContext } from '../definitions/ValidationContext';\n\nexport interface ExpressionDiagnostic {\n token: AbstractToken;\n message: string;\n}\n\nexport interface AbstractExpressionOptions {\n start?: number;\n /**\n * Complete source tokens prepared by a parser or value factory.\n * Constructors store these tokens without interpreting their source.\n */\n tokens: readonly AbstractToken[];\n}\n\n/**\n * Shared source tokens and positions for concrete expression types.\n * Concrete types represent constant text such as `42`, references such as `user.name`,\n * evaluated code such as `$:count + 1`, or format strings such as `Hello {user.name}`.\n * raw() reproduces source syntax.\n */\nexport abstract class AbstractExpression<O extends AbstractExpressionOptions = AbstractExpressionOptions> {\n type: string;\n options: O;\n\n protected constructor(type: string, options: O) {\n this.type = type;\n this.options = {\n ...options,\n start: options.start ?? options.tokens[0]?.start ?? 0,\n tokens: Object.freeze([...options.tokens])\n };\n }\n\n /**\n * Check whether the stored value and tokens represent this expression type.\n */\n abstract isValid(): boolean;\n\n /**\n * Validate references against declarations without evaluating values.\n */\n validate(_context: ValidationContext): ExpressionDiagnostic[] {\n return [];\n }\n\n clone(): this {\n const Type = this.constructor as new (options: O) => this;\n return new Type({ ...this.options, tokens: this.tokens.map((token) => token.clone()) });\n }\n\n get tokens(): readonly AbstractToken[] {\n return this.options.tokens;\n }\n\n /**\n * Reproduce source syntax, including whitespace, delimiters and escapes.\n */\n raw(): string {\n return this.tokens.map((token) => token.raw()).join('');\n }\n\n get start(): number | null {\n return this.options.start;\n }\n\n set start(start: number) {\n this.options.start = start;\n }\n\n toString(): string {\n return '[object ' + this.constructor.name + ' <' + this.raw() + ', ' + this.start + '>]';\n }\n}\n"]}
1
+ {"version":3,"file":"AbstractExpression.js","sourceRoot":"","sources":["../../src/expressions/AbstractExpression.ts"],"names":[],"mappings":";;;AAiBA;;;;;GAKG;AACH;IAIE,YAAsB,IAAY,EAAE,OAAU;;;QAC5C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,mCACP,OAAO,KACV,KAAK,cAAE,OAAO,CAAC,KAAK,mCAAI,MAAA,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,0CAAE,KAAK,mCAAI,CAAC,EACrD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,GAC3C,CAAC;IACJ,CAAC;IAOD;;OAEG;IACH,QAAQ,CAAC,QAA2B;QAClC,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,KAAK;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,WAAuC,CAAC;QAC1D,OAAO,IAAI,IAAI,iCAAM,IAAI,CAAC,OAAO,KAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,IAAG,CAAC;IAC1F,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED;;OAEG;IACH,GAAG;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;IAED,IAAI,KAAK,CAAC,KAAa;QACrB,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,OAAO,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IAC3F,CAAC;CACF","sourcesContent":["import { AbstractToken } from '../tokens/AbstractToken';\nimport type { ValidationContext } from '../definitions/ValidationContext';\n\nexport interface ExpressionDiagnostic {\n token: AbstractToken;\n message: string;\n}\n\nexport interface AbstractExpressionOptions {\n start?: number;\n /**\n * Complete source tokens prepared by a parser or value factory.\n * Constructors store these tokens without interpreting their source.\n */\n tokens: readonly AbstractToken[];\n}\n\n/**\n * Shared source tokens and positions for concrete expression types.\n * Concrete types represent constant text such as `42`, references such as `user.name`,\n * evaluated code such as `$:count + 1`, or format strings such as `Hello {user.name}`.\n * raw() reproduces source syntax.\n */\nexport abstract class AbstractExpression<O extends AbstractExpressionOptions = AbstractExpressionOptions> {\n type: string;\n options: O;\n\n protected constructor(type: string, options: O) {\n this.type = type;\n this.options = {\n ...options,\n start: options.start ?? options.tokens[0]?.start ?? 0,\n tokens: Object.freeze([...options.tokens])\n };\n }\n\n /**\n * Check whether the stored value and tokens represent this expression type.\n */\n abstract isValid(): boolean;\n\n /**\n * Validate references against declarations without evaluating values.\n */\n validate(_context: ValidationContext): ExpressionDiagnostic[] {\n return [];\n }\n\n clone(): this {\n const Type = this.constructor as new (options: O) => this;\n return new Type({ ...this.options, tokens: this.tokens.map((token) => token.clone()) });\n }\n\n get tokens(): readonly AbstractToken[] {\n return this.options.tokens;\n }\n\n /**\n * Reproduce source syntax, including whitespace, delimiters and escapes.\n */\n raw(): string {\n return this.tokens.map((token) => token.raw()).join('');\n }\n\n get start(): number | null {\n return this.options.start;\n }\n\n set start(start: number) {\n this.options.start = start;\n }\n\n toString(): string {\n return '[object ' + this.constructor.name + ' <' + this.raw() + ', ' + this.start + '>]';\n }\n}\n"]}
@@ -3,7 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EvaluatedExpressionParser = exports.EvaluatedExpression = void 0;
4
4
  const ExpressionParser_1 = require("../ExpressionParser");
5
5
  const AbstractExpression_1 = require("./AbstractExpression");
6
- const tokens_1 = require("../tokens");
6
+ const CodeToken_1 = require("../tokens/code/CodeToken");
7
+ const tokenUtils_1 = require("../utils/tokenUtils");
8
+ const JSToken_1 = require("../tokens/code/JSToken");
9
+ const PrefixToken_1 = require("../tokens/code/PrefixToken");
10
+ const TextToken_1 = require("../tokens/text/TextToken");
7
11
  /**
8
12
  * Code explicitly marked for evaluation by the `$:` prefix.
9
13
  * Examples include `$:count + 1`, `$:true`, `$:{name: user.name}` and `$:[1, 2]`.
@@ -24,15 +28,15 @@ class EvaluatedExpression extends AbstractExpression_1.AbstractExpression {
24
28
  super(EvaluatedExpression.TYPE, options);
25
29
  }
26
30
  isValid() {
27
- const prefixes = this.tokens.filter((token) => token instanceof tokens_1.PrefixToken);
28
- const code = this.tokens.filter((token) => token instanceof tokens_1.CodeToken);
31
+ const prefixes = this.tokens.filter((token) => token instanceof PrefixToken_1.PrefixToken);
32
+ const code = this.tokens.filter((token) => token instanceof CodeToken_1.CodeToken);
29
33
  return (prefixes.length === 1 &&
30
- prefixes[0].raw() === tokens_1.FUNCTION_PREFIX &&
34
+ prefixes[0].raw() === PrefixToken_1.FUNCTION_PREFIX &&
31
35
  code.length === 1 &&
32
36
  this.tokens.indexOf(prefixes[0]) < this.tokens.indexOf(code[0]));
33
37
  }
34
38
  get codeToken() {
35
- return (0, tokens_1.codeToken)(this.tokens);
39
+ return (0, tokenUtils_1.codeToken)(this.tokens);
36
40
  }
37
41
  withCode(token) {
38
42
  const original = this.codeToken;
@@ -61,10 +65,10 @@ class EvaluatedExpressionParser extends ExpressionParser_1.ExpressionParser {
61
65
  tryParse(source, start = 0) {
62
66
  let matches;
63
67
  if (typeof source === 'string') {
64
- matches = (0, tokens_1.hasFunctionPrefix)(source);
68
+ matches = (0, tokenUtils_1.hasFunctionPrefix)(source);
65
69
  }
66
70
  else {
67
- matches = source.some((token) => token instanceof tokens_1.PrefixToken);
71
+ matches = source.some((token) => token instanceof PrefixToken_1.PrefixToken);
68
72
  }
69
73
  let expression = null;
70
74
  if (matches) {
@@ -85,16 +89,16 @@ class EvaluatedExpressionParser extends ExpressionParser_1.ExpressionParser {
85
89
  return expression;
86
90
  }
87
91
  sourceTokens(source, start = 0) {
88
- const trivia = (0, tokens_1.leadingTrivia)(source);
89
- if (!source.slice(trivia.length).startsWith(tokens_1.FUNCTION_PREFIX)) {
92
+ const trivia = (0, tokenUtils_1.leadingTrivia)(source);
93
+ if (!source.slice(trivia.length).startsWith(PrefixToken_1.FUNCTION_PREFIX)) {
90
94
  throw new SyntaxError('Expected an evaluation prefix.');
91
95
  }
92
96
  const tokens = [];
93
97
  if (trivia) {
94
- tokens.push(new tokens_1.TextToken(trivia, start));
98
+ tokens.push(new TextToken_1.TextToken(trivia, start));
95
99
  }
96
- tokens.push(new tokens_1.PrefixToken(start + trivia.length));
97
- tokens.push(new tokens_1.JSToken(source.slice(trivia.length + tokens_1.FUNCTION_PREFIX.length), start + trivia.length + tokens_1.FUNCTION_PREFIX.length));
100
+ tokens.push(new PrefixToken_1.PrefixToken(start + trivia.length));
101
+ tokens.push(new JSToken_1.JSToken(source.slice(trivia.length + PrefixToken_1.FUNCTION_PREFIX.length), start + trivia.length + PrefixToken_1.FUNCTION_PREFIX.length));
98
102
  return tokens;
99
103
  }
100
104
  }
@@ -1 +1 @@
1
- {"version":3,"file":"EvaluatedExpression.js","sourceRoot":"","sources":["../../src/expressions/EvaluatedExpression.ts"],"names":[],"mappings":";;;AAAA,0DAAuD;AACvD,6DAAqF;AACrF,sCAWmB;AAEnB;;;;;;;;;;;GAWG;AACH,yBAAiC,SAAQ,uCAA6C;IAGpF,MAAM,CAAC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AAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,wBAAe,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,WAAW,CAAC,gCAAgC,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,MAAM,GAAoB,EAAE,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,IAAI,kBAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,IAAI,oBAAW,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,IAAI,CACT,IAAI,gBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,wBAAe,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,wBAAe,CAAC,MAAM,CAAC,CAClH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions } from './AbstractExpression';\nimport {\n AbstractToken,\n CodeToken,\n codeToken,\n ExpressionSource,\n JSToken,\n PrefixToken,\n TextToken,\n FUNCTION_PREFIX,\n hasFunctionPrefix,\n leadingTrivia\n} from '../tokens';\n\n/**\n * Code explicitly marked for evaluation by the `$:` prefix.\n * Examples include `$:count + 1`, `$:true`, `$:{name: user.name}` and `$:[1, 2]`.\n * The code token owns the language's syntax tree; the supplied scope executes its code.\n * Prefixed calls are specialized by FunctionExpression when using the combined parser.\n *\n * @example\n * ```ts\n * EvaluatedExpression.parse('$:count + 1').code(); // 'count + 1'\n * EvaluatedExpression.parse('$:{active: true}').raw(); // '$:{active: true}'\n * ```\n */\nexport class EvaluatedExpression extends AbstractExpression<AbstractExpressionOptions> {\n static TYPE = 'evaluated-expression';\n\n static parse(source: ExpressionSource, start = 0): EvaluatedExpression {\n return new EvaluatedExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractExpressionOptions) {\n super(EvaluatedExpression.TYPE, options);\n }\n\n isValid(): boolean {\n const prefixes = this.tokens.filter((token) => token instanceof PrefixToken);\n const code = this.tokens.filter((token) => token instanceof CodeToken);\n return (\n prefixes.length === 1 &&\n prefixes[0].raw() === FUNCTION_PREFIX &&\n code.length === 1 &&\n this.tokens.indexOf(prefixes[0]) < this.tokens.indexOf(code[0])\n );\n }\n\n get codeToken(): CodeToken {\n return codeToken(this.tokens);\n }\n\n withCode(token: CodeToken): this {\n const original = this.codeToken;\n const Type = this.constructor as new (options: AbstractExpressionOptions) => this;\n return new Type({\n ...this.options,\n tokens: this.tokens.map((current) => {\n let replacement = current;\n if (current === original) {\n replacement = token;\n }\n return replacement;\n })\n });\n }\n\n /**\n * Executable code without the evaluation prefix or surrounding source trivia.\n */\n code(): string {\n return this.codeToken.code;\n }\n}\n\n/**\n * Recognize the syntax owned by EvaluatedExpression.\n */\nexport class EvaluatedExpressionParser extends ExpressionParser<EvaluatedExpression> {\n tryParse(source: ExpressionSource, start = 0): EvaluatedExpression | null {\n let matches: boolean;\n if (typeof source === 'string') {\n matches = hasFunctionPrefix(source);\n } else {\n matches = source.some((token) => token instanceof PrefixToken);\n }\n let expression: EvaluatedExpression | null = null;\n if (matches) {\n let tokens: readonly AbstractToken[];\n if (typeof source === 'string') {\n tokens = this.sourceTokens(source, start);\n } else {\n tokens = source;\n }\n expression = new EvaluatedExpression({\n tokens\n });\n if (!expression.isValid()) {\n throw new SyntaxError('Expected a prefixed code expression.');\n }\n }\n return expression;\n }\n\n sourceTokens(source: string, start = 0): readonly AbstractToken[] {\n const trivia = leadingTrivia(source);\n if (!source.slice(trivia.length).startsWith(FUNCTION_PREFIX)) {\n throw new SyntaxError('Expected an evaluation prefix.');\n }\n const tokens: AbstractToken[] = [];\n if (trivia) {\n tokens.push(new TextToken(trivia, start));\n }\n tokens.push(new PrefixToken(start + trivia.length));\n tokens.push(\n new JSToken(source.slice(trivia.length + FUNCTION_PREFIX.length), start + trivia.length + FUNCTION_PREFIX.length)\n );\n return tokens;\n }\n}\n"]}
1
+ {"version":3,"file":"EvaluatedExpression.js","sourceRoot":"","sources":["../../src/expressions/EvaluatedExpression.ts"],"names":[],"mappings":";;;AAAA,0DAAuD;AACvD,6DAAqF;AAErF,wDAAqD;AACrD,oDAAkF;AAClF,oDAAiD;AACjD,4DAA0E;AAC1E,wDAAqD;AAErD;;;;;;;;;;;GAWG;AACH,yBAAiC,SAAQ,uCAA6C;IAGpF,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,yBAAyB,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAED,YAAY,OAAkC;QAC5C,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO;QACL,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,yBAAW,CAAC,CAAC;QAC7E,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,qBAAS,CAAC,CAAC;QACvE,OAAO,CACL,QAAQ,CAAC,MAAM,KAAK,CAAC;YACrB,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,6BAAe;YACrC,IAAI,CAAC,MAAM,KAAK,CAAC;YACjB,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAChE,CAAC;IACJ,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAA,sBAAS,EAAC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AG,MAAM,CAAC;YAClB,CAAC;YACD,UAAU,GAAG,IAAI,mBAAmB,CAAC;gBACnC,MAAM;aACP,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;gBAC1B,MAAM,IAAI,WAAW,CAAC,sCAAsC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,KAAK,GAAG,CAAC;QACpC,MAAM,MAAM,GAAG,IAAA,0BAAa,EAAC,MAAM,CAAC,CAAC;QACrC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,6BAAe,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,WAAW,CAAC,gCAAgC,CAAC,CAAC;QAC1D,CAAC;QACD,MAAM,MAAM,GAAoB,EAAE,CAAC;QACnC,IAAI,MAAM,EAAE,CAAC;YACX,MAAM,CAAC,IAAI,CAAC,IAAI,qBAAS,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,IAAI,yBAAW,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;QACpD,MAAM,CAAC,IAAI,CACT,IAAI,iBAAO,CAAC,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,6BAAe,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,6BAAe,CAAC,MAAM,CAAC,CAClH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions } from './AbstractExpression';\nimport { AbstractToken, ExpressionSource } from '../tokens/AbstractToken';\nimport { CodeToken } from '../tokens/code/CodeToken';\nimport { codeToken, hasFunctionPrefix, leadingTrivia } from '../utils/tokenUtils';\nimport { JSToken } from '../tokens/code/JSToken';\nimport { PrefixToken, FUNCTION_PREFIX } from '../tokens/code/PrefixToken';\nimport { TextToken } from '../tokens/text/TextToken';\n\n/**\n * Code explicitly marked for evaluation by the `$:` prefix.\n * Examples include `$:count + 1`, `$:true`, `$:{name: user.name}` and `$:[1, 2]`.\n * The code token owns the language's syntax tree; the supplied scope executes its code.\n * Prefixed calls are specialized by FunctionExpression when using the combined parser.\n *\n * @example\n * ```ts\n * EvaluatedExpression.parse('$:count + 1').code(); // 'count + 1'\n * EvaluatedExpression.parse('$:{active: true}').raw(); // '$:{active: true}'\n * ```\n */\nexport class EvaluatedExpression extends AbstractExpression<AbstractExpressionOptions> {\n static TYPE = 'evaluated-expression';\n\n static parse(source: ExpressionSource, start = 0): EvaluatedExpression {\n return new EvaluatedExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractExpressionOptions) {\n super(EvaluatedExpression.TYPE, options);\n }\n\n isValid(): boolean {\n const prefixes = this.tokens.filter((token) => token instanceof PrefixToken);\n const code = this.tokens.filter((token) => token instanceof CodeToken);\n return (\n prefixes.length === 1 &&\n prefixes[0].raw() === FUNCTION_PREFIX &&\n code.length === 1 &&\n this.tokens.indexOf(prefixes[0]) < this.tokens.indexOf(code[0])\n );\n }\n\n get codeToken(): CodeToken {\n return codeToken(this.tokens);\n }\n\n withCode(token: CodeToken): this {\n const original = this.codeToken;\n const Type = this.constructor as new (options: AbstractExpressionOptions) => this;\n return new Type({\n ...this.options,\n tokens: this.tokens.map((current) => {\n let replacement = current;\n if (current === original) {\n replacement = token;\n }\n return replacement;\n })\n });\n }\n\n /**\n * Executable code without the evaluation prefix or surrounding source trivia.\n */\n code(): string {\n return this.codeToken.code;\n }\n}\n\n/**\n * Recognize the syntax owned by EvaluatedExpression.\n */\nexport class EvaluatedExpressionParser extends ExpressionParser<EvaluatedExpression> {\n tryParse(source: ExpressionSource, start = 0): EvaluatedExpression | null {\n let matches: boolean;\n if (typeof source === 'string') {\n matches = hasFunctionPrefix(source);\n } else {\n matches = source.some((token) => token instanceof PrefixToken);\n }\n let expression: EvaluatedExpression | null = null;\n if (matches) {\n let tokens: readonly AbstractToken[];\n if (typeof source === 'string') {\n tokens = this.sourceTokens(source, start);\n } else {\n tokens = source;\n }\n expression = new EvaluatedExpression({\n tokens\n });\n if (!expression.isValid()) {\n throw new SyntaxError('Expected a prefixed code expression.');\n }\n }\n return expression;\n }\n\n sourceTokens(source: string, start = 0): readonly AbstractToken[] {\n const trivia = leadingTrivia(source);\n if (!source.slice(trivia.length).startsWith(FUNCTION_PREFIX)) {\n throw new SyntaxError('Expected an evaluation prefix.');\n }\n const tokens: AbstractToken[] = [];\n if (trivia) {\n tokens.push(new TextToken(trivia, start));\n }\n tokens.push(new PrefixToken(start + trivia.length));\n tokens.push(\n new JSToken(source.slice(trivia.length + FUNCTION_PREFIX.length), start + trivia.length + FUNCTION_PREFIX.length)\n );\n return tokens;\n }\n}\n"]}
@@ -2,14 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ListExpressionParser = exports.ListExpression = void 0;
4
4
  const ExpressionParser_1 = require("../ExpressionParser");
5
- const tokens_1 = require("../tokens");
5
+ const DelimiterToken_1 = require("../tokens/DelimiterToken");
6
6
  const AbstractExpression_1 = require("./AbstractExpression");
7
7
  /**
8
8
  * A comma-separated list retaining item tokens, separators and whitespace.
9
9
  */
10
10
  class ListExpression extends AbstractExpression_1.AbstractExpression {
11
11
  isDelimiter(token) {
12
- return token instanceof tokens_1.DelimiterToken;
12
+ return token instanceof DelimiterToken_1.DelimiterToken;
13
13
  }
14
14
  get items() {
15
15
  return this.tokens.filter((token) => !this.isDelimiter(token));
@@ -34,7 +34,7 @@ class ListExpressionParser extends ExpressionParser_1.ExpressionParser {
34
34
  ? Array.from(source.matchAll(/[,\s]+|[^,\s]+/g), (match) => {
35
35
  const position = start + match.index;
36
36
  return /^[,\s]/.test(match[0])
37
- ? new tokens_1.DelimiterToken(match[0], position)
37
+ ? new DelimiterToken_1.DelimiterToken(match[0], position)
38
38
  : this.options.parseItem({ source: match[0], start: position });
39
39
  })
40
40
  : source;
@@ -1 +1 @@
1
- {"version":3,"file":"ListExpression.js","sourceRoot":"","sources":["../../src/expressions/ListExpression.ts"],"names":[],"mappings":";;;AAAA,0DAAuD;AACvD,sCAA4E;AAC5E,6DAAqF;AAErF;;GAEG;AACH,oBAA8D,SAAQ,uCAAkB;IAC5E,WAAW,CAAC,KAAoB;QACxC,OAAO,KAAK,YAAY,uBAAc,CAAC;IACzC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAQ,CAAC;IACxE,CAAC;IAED,OAAO;QACL,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACtG,OAAO,CACL,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;YACvB,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAC5B,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CACtG,CACF,CAAC;IACJ,CAAC;CACF;;AAOD;;GAEG;AACH,0BAA2E,SAAQ,mCAAmB;IACpG,YAAqB,OAAuC;QAC1D,KAAK,EAAE,CAAC;uBADW,OAAO;IAE5B,CAAC;IAED,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,MAAM,MAAM,GACV,OAAO,MAAM,KAAK,QAAQ;YACxB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvD,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;gBACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC5B,CAAC,CAAC,IAAI,uBAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;oBACxC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YACpE,CAAC,CAAC;YACJ,CAAC,CAAC,MAAM,CAAC;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../ExpressionParser';\nimport { AbstractToken, DelimiterToken, ExpressionSource } from '../tokens';\nimport { AbstractExpression, AbstractExpressionOptions } from './AbstractExpression';\n\n/**\n * A comma-separated list retaining item tokens, separators and whitespace.\n */\nexport abstract class ListExpression<T extends AbstractToken> extends AbstractExpression {\n protected isDelimiter(token: AbstractToken): token is DelimiterToken {\n return token instanceof DelimiterToken;\n }\n\n get items(): readonly T[] {\n return this.tokens.filter((token) => !this.isDelimiter(token)) as T[];\n }\n\n isValid(): boolean {\n const tokens = this.tokens.filter((token) => !(this.isDelimiter(token) && /^\\s+$/.test(token.raw())));\n return (\n tokens.length % 2 === 1 &&\n tokens.every((token, index) =>\n index % 2 === 1 ? this.isDelimiter(token) && /^\\s*,\\s*$/.test(token.raw()) : !this.isDelimiter(token)\n )\n );\n }\n}\n\nexport interface ListExpressionParserOptions<E extends ListExpression<AbstractToken>> {\n parseItem: (input: { source: string; start: number }) => AbstractToken;\n createExpression: (options: AbstractExpressionOptions) => E;\n}\n\n/**\n * Parses list structure while delegating item syntax to the owning expression.\n */\nexport class ListExpressionParser<E extends ListExpression<AbstractToken>> extends ExpressionParser<E> {\n constructor(readonly options: ListExpressionParserOptions<E>) {\n super();\n }\n\n tryParse(source: ExpressionSource, start = 0): E {\n const tokens =\n typeof source === 'string'\n ? Array.from(source.matchAll(/[,\\s]+|[^,\\s]+/g), (match) => {\n const position = start + match.index;\n return /^[,\\s]/.test(match[0])\n ? new DelimiterToken(match[0], position)\n : this.options.parseItem({ source: match[0], start: position });\n })\n : source;\n return this.options.createExpression({ tokens });\n }\n}\n"]}
1
+ {"version":3,"file":"ListExpression.js","sourceRoot":"","sources":["../../src/expressions/ListExpression.ts"],"names":[],"mappings":";;;AAAA,0DAAuD;AAEvD,6DAA0D;AAC1D,6DAAqF;AAErF;;GAEG;AACH,oBAA8D,SAAQ,uCAAkB;IAC5E,WAAW,CAAC,KAAoB;QACxC,OAAO,KAAK,YAAY,+BAAc,CAAC;IACzC,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAQ,CAAC;IACxE,CAAC;IAED,OAAO;QACL,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;QACtG,OAAO,CACL,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC;YACvB,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAC5B,KAAK,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,IAAI,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CACtG,CACF,CAAC;IACJ,CAAC;CACF;;AAOD;;GAEG;AACH,0BAA2E,SAAQ,mCAAmB;IACpG,YAAqB,OAAuC;QAC1D,KAAK,EAAE,CAAC;uBADW,OAAO;IAE5B,CAAC;IAED,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,MAAM,MAAM,GACV,OAAO,MAAM,KAAK,QAAQ;YACxB,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;gBACvD,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;gBACrC,OAAO,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;oBAC5B,CAAC,CAAC,IAAI,+BAAc,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC;oBACxC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YACpE,CAAC,CAAC;YACJ,CAAC,CAAC,MAAM,CAAC;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;IACnD,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../ExpressionParser';\nimport { AbstractToken, ExpressionSource } from '../tokens/AbstractToken';\nimport { DelimiterToken } from '../tokens/DelimiterToken';\nimport { AbstractExpression, AbstractExpressionOptions } from './AbstractExpression';\n\n/**\n * A comma-separated list retaining item tokens, separators and whitespace.\n */\nexport abstract class ListExpression<T extends AbstractToken> extends AbstractExpression {\n protected isDelimiter(token: AbstractToken): token is DelimiterToken {\n return token instanceof DelimiterToken;\n }\n\n get items(): readonly T[] {\n return this.tokens.filter((token) => !this.isDelimiter(token)) as T[];\n }\n\n isValid(): boolean {\n const tokens = this.tokens.filter((token) => !(this.isDelimiter(token) && /^\\s+$/.test(token.raw())));\n return (\n tokens.length % 2 === 1 &&\n tokens.every((token, index) =>\n index % 2 === 1 ? this.isDelimiter(token) && /^\\s*,\\s*$/.test(token.raw()) : !this.isDelimiter(token)\n )\n );\n }\n}\n\nexport interface ListExpressionParserOptions<E extends ListExpression<AbstractToken>> {\n parseItem: (input: { source: string; start: number }) => AbstractToken;\n createExpression: (options: AbstractExpressionOptions) => E;\n}\n\n/**\n * Parses list structure while delegating item syntax to the owning expression.\n */\nexport class ListExpressionParser<E extends ListExpression<AbstractToken>> extends ExpressionParser<E> {\n constructor(readonly options: ListExpressionParserOptions<E>) {\n super();\n }\n\n tryParse(source: ExpressionSource, start = 0): E {\n const tokens =\n typeof source === 'string'\n ? Array.from(source.matchAll(/[,\\s]+|[^,\\s]+/g), (match) => {\n const position = start + match.index;\n return /^[,\\s]/.test(match[0])\n ? new DelimiterToken(match[0], position)\n : this.options.parseItem({ source: match[0], start: position });\n })\n : source;\n return this.options.createExpression({ tokens });\n }\n}\n"]}
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ConstantExpressionParser = exports.ConstantExpression = void 0;
4
4
  const ExpressionParser_1 = require("../../ExpressionParser");
5
5
  const AbstractExpression_1 = require("../AbstractExpression");
6
- const tokens_1 = require("../../tokens");
6
+ const TextToken_1 = require("../../tokens/text/TextToken");
7
+ const tokenUtils_1 = require("../../utils/tokenUtils");
7
8
  const parser_type_system_1 = require("@ja-platform/parser-type-system");
8
9
  /**
9
10
  * A constant with an explicitly selected value type and preserved source syntax.
@@ -39,8 +40,8 @@ class ConstantExpressionParser extends ExpressionParser_1.ExpressionParser {
39
40
  tryParse(source, start = 0) {
40
41
  var _a;
41
42
  var _b;
42
- const text = (0, tokens_1.stringify)(source);
43
- const tokens = typeof source === 'string' ? [new tokens_1.TextToken(text, start)] : source;
43
+ const text = (0, tokenUtils_1.stringify)(source);
44
+ const tokens = typeof source === 'string' ? [new TextToken_1.TextToken(text, start)] : source;
44
45
  return new ConstantExpression({
45
46
  value: this.valueType.parse(text),
46
47
  valueType: this.valueType,
@@ -1 +1 @@
1
- {"version":3,"file":"ConstantExpression.js","sourceRoot":"","sources":["../../../src/expressions/constant/ConstantExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,8DAAsF;AACtF,yCAAsE;AACtE,wEAAiE;AAOjE;;;GAGG;AACH,wBAA4C,SAAQ,uCAAgD;IAGlG,MAAM,CAAC,KAAK,CAAI,MAAwB,EAAE,SAAkB,EAAE,KAAK,GAAG,CAAC;QACrE,OAAO,IAAI,wBAAwB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,YAAY,OAAqC;QAC/C,KAAK,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAChC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;CACF;;AArBQ,uBAAI,GAAG,qBAAqB,CAAC;AAuBtC;;GAEG;AACH,8BAAkD,SAAQ,mCAAuC;IAG/F,YAAY,GAAG,CAAC,SAAS,CAAkE;QACzF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAK,6BAA+B,CAAC;IACjE,CAAC;IAED,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;;;QAC1C,MAAM,IAAI,GAAG,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,kBAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAClF,OAAO,IAAI,kBAAkB,CAAC;YAC5B,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM;YACN,KAAK,QAAE,MAAA,MAAM,CAAC,CAAC,CAAC,0CAAE,KAAK,mCAAI,KAAK;SACjC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions } from '../AbstractExpression';\nimport { ExpressionSource, TextToken, stringify } from '../../tokens';\nimport { Type, textType } from '@ja-platform/parser-type-system';\n\nexport interface ConstantExpressionOptions<T> extends AbstractExpressionOptions {\n value: T;\n valueType: Type<T>;\n}\n\n/**\n * A constant with an explicitly selected value type and preserved source syntax.\n * The caller selects the value type; types are never inferred from the source.\n */\nexport class ConstantExpression<T = string> extends AbstractExpression<ConstantExpressionOptions<T>> {\n static TYPE = 'constant-expression';\n\n static parse<T>(source: ExpressionSource, valueType: Type<T>, start = 0): ConstantExpression<T> {\n return new ConstantExpressionParser(valueType).parse(source, start);\n }\n\n constructor(options: ConstantExpressionOptions<T>) {\n super(ConstantExpression.TYPE, options);\n }\n\n get valueType(): Type<T> {\n return this.options.valueType;\n }\n\n isValid(): boolean {\n return this.valueType.is(this.options.value);\n }\n\n value(): T {\n return this.options.value;\n }\n}\n\n/**\n * Parse constants using the supplied type. Place last when composing other syntax.\n */\nexport class ConstantExpressionParser<T = string> extends ExpressionParser<ConstantExpression<T>> {\n readonly valueType: Type<T>;\n\n constructor(...[valueType]: string extends T ? [valueType?: Type<T>] : [valueType: Type<T>]) {\n super();\n this.valueType = valueType ?? (textType as unknown as Type<T>);\n }\n\n tryParse(source: ExpressionSource, start = 0): ConstantExpression<T> {\n const text = stringify(source);\n const tokens = typeof source === 'string' ? [new TextToken(text, start)] : source;\n return new ConstantExpression({\n value: this.valueType.parse(text),\n valueType: this.valueType,\n tokens,\n start: tokens[0]?.start ?? start\n });\n }\n}\n"]}
1
+ {"version":3,"file":"ConstantExpression.js","sourceRoot":"","sources":["../../../src/expressions/constant/ConstantExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,8DAAsF;AAEtF,2DAAwD;AACxD,uDAAmD;AACnD,wEAAiE;AAOjE;;;GAGG;AACH,wBAA4C,SAAQ,uCAAgD;IAGlG,MAAM,CAAC,KAAK,CAAI,MAAwB,EAAE,SAAkB,EAAE,KAAK,GAAG,CAAC;QACrE,OAAO,IAAI,wBAAwB,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACtE,CAAC;IAED,YAAY,OAAqC;QAC/C,KAAK,CAAC,kBAAkB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC;IAChC,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,CAAC;CACF;;AArBQ,uBAAI,GAAG,qBAAqB,CAAC;AAuBtC;;GAEG;AACH,8BAAkD,SAAQ,mCAAuC;IAG/F,YAAY,GAAG,CAAC,SAAS,CAAkE;QACzF,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,SAAS,GAAG,SAAS,aAAT,SAAS,cAAT,SAAS,GAAK,6BAA+B,CAAC;IACjE,CAAC;IAED,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;;;QAC1C,MAAM,IAAI,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,MAAM,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,qBAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAClF,OAAO,IAAI,kBAAkB,CAAC;YAC5B,KAAK,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC;YACjC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,MAAM;YACN,KAAK,QAAE,MAAA,MAAM,CAAC,CAAC,CAAC,0CAAE,KAAK,mCAAI,KAAK;SACjC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions } from '../AbstractExpression';\nimport { ExpressionSource } from '../../tokens/AbstractToken';\nimport { TextToken } from '../../tokens/text/TextToken';\nimport { stringify } from '../../utils/tokenUtils';\nimport { Type, textType } from '@ja-platform/parser-type-system';\n\nexport interface ConstantExpressionOptions<T> extends AbstractExpressionOptions {\n value: T;\n valueType: Type<T>;\n}\n\n/**\n * A constant with an explicitly selected value type and preserved source syntax.\n * The caller selects the value type; types are never inferred from the source.\n */\nexport class ConstantExpression<T = string> extends AbstractExpression<ConstantExpressionOptions<T>> {\n static TYPE = 'constant-expression';\n\n static parse<T>(source: ExpressionSource, valueType: Type<T>, start = 0): ConstantExpression<T> {\n return new ConstantExpressionParser(valueType).parse(source, start);\n }\n\n constructor(options: ConstantExpressionOptions<T>) {\n super(ConstantExpression.TYPE, options);\n }\n\n get valueType(): Type<T> {\n return this.options.valueType;\n }\n\n isValid(): boolean {\n return this.valueType.is(this.options.value);\n }\n\n value(): T {\n return this.options.value;\n }\n}\n\n/**\n * Parse constants using the supplied type. Place last when composing other syntax.\n */\nexport class ConstantExpressionParser<T = string> extends ExpressionParser<ConstantExpression<T>> {\n readonly valueType: Type<T>;\n\n constructor(...[valueType]: string extends T ? [valueType?: Type<T>] : [valueType: Type<T>]) {\n super();\n this.valueType = valueType ?? (textType as unknown as Type<T>);\n }\n\n tryParse(source: ExpressionSource, start = 0): ConstantExpression<T> {\n const text = stringify(source);\n const tokens = typeof source === 'string' ? [new TextToken(text, start)] : source;\n return new ConstantExpression({\n value: this.valueType.parse(text),\n valueType: this.valueType,\n tokens,\n start: tokens[0]?.start ?? start\n });\n }\n}\n"]}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunctionExpressionParser = exports.FunctionExpression = void 0;
4
4
  const ExpressionParser_1 = require("../../ExpressionParser");
5
5
  const EvaluatedExpression_1 = require("../EvaluatedExpression");
6
- const tokens_1 = require("../../tokens");
6
+ const CodeToken_1 = require("../../tokens/code/CodeToken");
7
7
  /**
8
8
  * An explicitly evaluated function call, such as `$:save(true)` or `$:worker.save(user.name)`.
9
9
  * The root code expression must be a call; this type exposes its target and arguments for editing.
@@ -25,7 +25,7 @@ class FunctionExpression extends EvaluatedExpression_1.EvaluatedExpression {
25
25
  this.type = FunctionExpression.TYPE;
26
26
  }
27
27
  isValid() {
28
- return super.isValid() && this.tokens.some((token) => token instanceof tokens_1.CodeToken && token.isCallExpression());
28
+ return super.isValid() && this.tokens.some((token) => token instanceof CodeToken_1.CodeToken && token.isCallExpression());
29
29
  }
30
30
  get arguments() {
31
31
  return this.codeToken.arguments;
@@ -1 +1 @@
1
- {"version":3,"file":"FunctionExpression.js","sourceRoot":"","sources":["../../../src/expressions/function/FunctionExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAE1D,gEAAwF;AACxF,yCAA2D;AAE3D;;;;;;;;;;;GAWG;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mBAAmB,CAAC,IAAuB;QACzC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;IAC3D,CAAC;CACF;;AA/CQ,uBAAI,GAAG,qBAAqB,CAAC;AAiDtC;;GAEG;AACH,8BAAsC,SAAQ,mCAAoC;IAChF,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,MAAM,SAAS,GAAG,IAAI,+CAAyB,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC1E,IAAI,UAAU,GAA8B,IAAI,CAAC;QACjD,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,SAAS,GAAG,IAAI,kBAAkB,iCAAM,SAAS,CAAC,OAAO,KAAE,MAAM,EAAE,SAAS,CAAC,MAAM,IAAG,CAAC;YAC7F,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;gBACxB,UAAU,GAAG,SAAS,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions } from '../AbstractExpression';\nimport { EvaluatedExpression, EvaluatedExpressionParser } from '../EvaluatedExpression';\nimport { CodeToken, ExpressionSource } from '../../tokens';\n\n/**\n * An explicitly evaluated function call, such as `$:save(true)` or `$:worker.save(user.name)`.\n * The root code expression must be a call; this type exposes its target and arguments for editing.\n *\n * @example\n * ```ts\n * const expression = FunctionExpression.parse('$:save(true)');\n * expression.functionName(); // 'save'\n * expression.withName('persist').raw(); // '$:persist(true)'\n * expression.withArgumentSources(['false']).raw(); // '$:save(false)'\n * ```\n */\nexport class FunctionExpression extends EvaluatedExpression {\n static TYPE = 'function-expression';\n\n static parse(source: ExpressionSource, start = 0): FunctionExpression {\n return new FunctionExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractExpressionOptions) {\n super(options);\n this.type = FunctionExpression.TYPE;\n }\n\n isValid(): boolean {\n return super.isValid() && this.tokens.some((token) => token instanceof CodeToken && token.isCallExpression());\n }\n\n get arguments(): CodeToken['arguments'] {\n return this.codeToken.arguments;\n }\n\n functionName(): string {\n return this.codeToken.functionName();\n }\n\n withName(name: string): this {\n return this.withCode(this.codeToken.withName(name));\n }\n\n /**\n * Replace arguments using expression source in the code token's language.\n * Constant text is inserted verbatim; callers supply any required quoting or escaping.\n */\n withArguments(args: readonly AbstractExpression[]): this {\n const argumentsSource = args.map((argument) => {\n let source: string;\n if (argument instanceof EvaluatedExpression) {\n source = argument.code();\n } else {\n source = argument.raw();\n }\n return source;\n });\n return this.withArgumentSources(argumentsSource);\n }\n\n withArgumentSources(args: readonly string[]): this {\n return this.withCode(this.codeToken.withArguments(args));\n }\n}\n\n/**\n * Recognize the syntax owned by FunctionExpression.\n */\nexport class FunctionExpressionParser extends ExpressionParser<FunctionExpression> {\n tryParse(source: ExpressionSource, start = 0): FunctionExpression | null {\n const evaluated = new EvaluatedExpressionParser().tryParse(source, start);\n let expression: FunctionExpression | null = null;\n if (evaluated) {\n const candidate = new FunctionExpression({ ...evaluated.options, tokens: evaluated.tokens });\n if (candidate.isValid()) {\n expression = candidate;\n }\n }\n return expression;\n }\n}\n"]}
1
+ {"version":3,"file":"FunctionExpression.js","sourceRoot":"","sources":["../../../src/expressions/function/FunctionExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAE1D,gEAAwF;AACxF,2DAAwD;AAGxD;;;;;;;;;;;GAWG;AACH,wBAAgC,SAAQ,yCAAmB;IAGzD,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,wBAAwB,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7D,CAAC;IAED,YAAY,OAAkC;QAC5C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBA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C,MAAM,SAAS,GAAG,IAAI,+CAAyB,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;QAC1E,IAAI,UAAU,GAA8B,IAAI,CAAC;QACjD,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,SAAS,GAAG,IAAI,kBAAkB,iCAAM,SAAS,CAAC,OAAO,KAAE,MAAM,EAAE,SAAS,CAAC,MAAM,IAAG,CAAC;YAC7F,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;gBACxB,UAAU,GAAG,SAAS,CAAC;YACzB,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions } from '../AbstractExpression';\nimport { EvaluatedExpression, EvaluatedExpressionParser } from '../EvaluatedExpression';\nimport { CodeToken } from '../../tokens/code/CodeToken';\nimport { ExpressionSource } from '../../tokens/AbstractToken';\n\n/**\n * An explicitly evaluated function call, such as `$:save(true)` or `$:worker.save(user.name)`.\n * The root code expression must be a call; this type exposes its target and arguments for editing.\n *\n * @example\n * ```ts\n * const expression = FunctionExpression.parse('$:save(true)');\n * expression.functionName(); // 'save'\n * expression.withName('persist').raw(); // '$:persist(true)'\n * expression.withArgumentSources(['false']).raw(); // '$:save(false)'\n * ```\n */\nexport class FunctionExpression extends EvaluatedExpression {\n static TYPE = 'function-expression';\n\n static parse(source: ExpressionSource, start = 0): FunctionExpression {\n return new FunctionExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractExpressionOptions) {\n super(options);\n this.type = FunctionExpression.TYPE;\n }\n\n isValid(): boolean {\n return super.isValid() && this.tokens.some((token) => token instanceof CodeToken && token.isCallExpression());\n }\n\n get arguments(): CodeToken['arguments'] {\n return this.codeToken.arguments;\n }\n\n functionName(): string {\n return this.codeToken.functionName();\n }\n\n withName(name: string): this {\n return this.withCode(this.codeToken.withName(name));\n }\n\n /**\n * Replace arguments using expression source in the code token's language.\n * Constant text is inserted verbatim; callers supply any required quoting or escaping.\n */\n withArguments(args: readonly AbstractExpression[]): this {\n const argumentsSource = args.map((argument) => {\n let source: string;\n if (argument instanceof EvaluatedExpression) {\n source = argument.code();\n } else {\n source = argument.raw();\n }\n return source;\n });\n return this.withArgumentSources(argumentsSource);\n }\n\n withArgumentSources(args: readonly string[]): this {\n return this.withCode(this.codeToken.withArguments(args));\n }\n}\n\n/**\n * Recognize the syntax owned by FunctionExpression.\n */\nexport class FunctionExpressionParser extends ExpressionParser<FunctionExpression> {\n tryParse(source: ExpressionSource, start = 0): FunctionExpression | null {\n const evaluated = new EvaluatedExpressionParser().tryParse(source, start);\n let expression: FunctionExpression | null = null;\n if (evaluated) {\n const candidate = new FunctionExpression({ ...evaluated.options, tokens: evaluated.tokens });\n if (candidate.isValid()) {\n expression = candidate;\n }\n }\n return expression;\n }\n}\n"]}
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FormatShorthandExpressionParser = exports.FormatShorthandExpression = void 0;
4
4
  const ExpressionParser_1 = require("../../ExpressionParser");
5
5
  const ShorthandExpression_1 = require("./ShorthandExpression");
6
- const tokens_1 = require("../../tokens");
6
+ const TextToken_1 = require("../../tokens/text/TextToken");
7
+ const tokenUtils_1 = require("../../utils/tokenUtils");
7
8
  /**
8
9
  * A shorthand reference with a format specifier, such as `price:.2f`.
9
10
  * Commonly used inside a format-string placeholder, for example `{price:.2f}`.
@@ -36,7 +37,7 @@ FormatShorthandExpression.TYPE = 'format-shorthand-expression';
36
37
  */
37
38
  class FormatShorthandExpressionParser extends ExpressionParser_1.ExpressionParser {
38
39
  tryParse(source, start = 0) {
39
- const text = (0, tokens_1.stringify)(source);
40
+ const text = (0, tokenUtils_1.stringify)(source);
40
41
  const match = text.match(/:\s*([\w.]+)\s*$/);
41
42
  let expression = null;
42
43
  if (match) {
@@ -45,7 +46,7 @@ class FormatShorthandExpressionParser extends ExpressionParser_1.ExpressionParse
45
46
  if (shorthand) {
46
47
  let tokens;
47
48
  if (typeof source === 'string') {
48
- tokens = [...shorthand.tokens, new tokens_1.TextToken(text.slice(match.index), start + match.index)];
49
+ tokens = [...shorthand.tokens, new TextToken_1.TextToken(text.slice(match.index), start + match.index)];
49
50
  }
50
51
  else {
51
52
  tokens = source;
@@ -1 +1 @@
1
- {"version":3,"file":"FormatShorthandExpression.js","sourceRoot":"","sources":["../../../src/expressions/shorthand/FormatShorthandExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,+DAAmH;AACnH,yCAAqF;AAMrF;;;;;;;;;;;;GAYG;AACH,+BAAuC,SAAQ,yCAAqD;IAGlG,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,+BAA+B,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,YAAY,OAAyC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5F,CAAC;CACF;;AAdiB,8BAAI,GAAG,6BAA6B,CAAC;AAgBvD;;GAEG;AACH,qCAA6C,SAAQ,mCAA2C;IAC9F,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAA,kBAAS,EAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC7C,IAAI,UAAU,GAAqC,IAAI,CAAC;QACxD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,SAAS,GAAG,IAAI,+CAAyB,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC7E,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,MAAgC,CAAC;gBACrC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAC/B,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,kBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC9F,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,MAAM,CAAC;gBAClB,CAAC;gBACD,UAAU,GAAG,IAAI,yBAAyB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { ShorthandExpression, ShorthandExpressionOptions, ShorthandExpressionParser } from './ShorthandExpression';\nimport { AbstractToken, ExpressionSource, TextToken, stringify } from '../../tokens';\n\nexport interface FormatShorthandExpressionOptions extends ShorthandExpressionOptions {\n format: string;\n}\n\n/**\n * A shorthand reference with a format specifier, such as `price:.2f`.\n * Commonly used inside a format-string placeholder, for example `{price:.2f}`.\n * The scope resolves the reference before the format specifier is applied to its value.\n *\n * @example\n * ```ts\n * const expression = FormatShorthandExpression.parse('price:.2f');\n * expression.path; // ['price']\n * expression.format; // '.2f'\n * expression.raw(); // 'price:.2f'\n * ```\n */\nexport class FormatShorthandExpression extends ShorthandExpression<FormatShorthandExpressionOptions> {\n static readonly TYPE = 'format-shorthand-expression';\n\n static parse(source: ExpressionSource, start = 0): FormatShorthandExpression {\n return new FormatShorthandExpressionParser().parse(source, start);\n }\n\n constructor(options: FormatShorthandExpressionOptions) {\n super(options);\n this.type = FormatShorthandExpression.TYPE;\n }\n\n isValid(): boolean {\n return super.isValid() && typeof this.format === 'string' && /^[\\w.]+$/.test(this.format);\n }\n}\n\n/**\n * Recognize the syntax owned by FormatShorthandExpression.\n */\nexport class FormatShorthandExpressionParser extends ExpressionParser<FormatShorthandExpression> {\n tryParse(source: ExpressionSource, start = 0): FormatShorthandExpression | null {\n const text = stringify(source);\n const match = text.match(/:\\s*([\\w.]+)\\s*$/);\n let expression: FormatShorthandExpression | null = null;\n if (match) {\n const reference = text.slice(0, match.index);\n const shorthand = new ShorthandExpressionParser().tryParse(reference, start);\n if (shorthand) {\n let tokens: readonly AbstractToken[];\n if (typeof source === 'string') {\n tokens = [...shorthand.tokens, new TextToken(text.slice(match.index), start + match.index)];\n } else {\n tokens = source;\n }\n expression = new FormatShorthandExpression({ format: match[1], tokens });\n }\n }\n return expression;\n }\n}\n"]}
1
+ {"version":3,"file":"FormatShorthandExpression.js","sourceRoot":"","sources":["../../../src/expressions/shorthand/FormatShorthandExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,+DAAmH;AAEnH,2DAAwD;AACxD,uDAAmD;AAMnD;;;;;;;;;;;;GAYG;AACH,+BAAuC,SAAQ,yCAAqD;IAGlG,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,+BAA+B,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACpE,CAAC;IAED,YAAY,OAAyC;QACnD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC;IAC7C,CAAC;IAED,OAAO;QACL,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5F,CAAC;CACF;;AAdiB,8BAAI,GAAG,6BAA6B,CAAC;AAgBvD;;GAEG;AACH,qCAA6C,SAAQ,mCAA2C;IAC9F,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,MAAM,IAAI,GAAG,IAAA,sBAAS,EAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAC7C,IAAI,UAAU,GAAqC,IAAI,CAAC;QACxD,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;YAC7C,MAAM,SAAS,GAAG,IAAI,+CAAyB,EAAE,CAAC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;YAC7E,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,MAAgC,CAAC;gBACrC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;oBAC/B,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,qBAAS,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC9F,CAAC;qBAAM,CAAC;oBACN,MAAM,GAAG,MAAM,CAAC;gBAClB,CAAC;gBACD,UAAU,GAAG,IAAI,yBAAyB,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { ShorthandExpression, ShorthandExpressionOptions, ShorthandExpressionParser } from './ShorthandExpression';\nimport { AbstractToken, ExpressionSource } from '../../tokens/AbstractToken';\nimport { TextToken } from '../../tokens/text/TextToken';\nimport { stringify } from '../../utils/tokenUtils';\n\nexport interface FormatShorthandExpressionOptions extends ShorthandExpressionOptions {\n format: string;\n}\n\n/**\n * A shorthand reference with a format specifier, such as `price:.2f`.\n * Commonly used inside a format-string placeholder, for example `{price:.2f}`.\n * The scope resolves the reference before the format specifier is applied to its value.\n *\n * @example\n * ```ts\n * const expression = FormatShorthandExpression.parse('price:.2f');\n * expression.path; // ['price']\n * expression.format; // '.2f'\n * expression.raw(); // 'price:.2f'\n * ```\n */\nexport class FormatShorthandExpression extends ShorthandExpression<FormatShorthandExpressionOptions> {\n static readonly TYPE = 'format-shorthand-expression';\n\n static parse(source: ExpressionSource, start = 0): FormatShorthandExpression {\n return new FormatShorthandExpressionParser().parse(source, start);\n }\n\n constructor(options: FormatShorthandExpressionOptions) {\n super(options);\n this.type = FormatShorthandExpression.TYPE;\n }\n\n isValid(): boolean {\n return super.isValid() && typeof this.format === 'string' && /^[\\w.]+$/.test(this.format);\n }\n}\n\n/**\n * Recognize the syntax owned by FormatShorthandExpression.\n */\nexport class FormatShorthandExpressionParser extends ExpressionParser<FormatShorthandExpression> {\n tryParse(source: ExpressionSource, start = 0): FormatShorthandExpression | null {\n const text = stringify(source);\n const match = text.match(/:\\s*([\\w.]+)\\s*$/);\n let expression: FormatShorthandExpression | null = null;\n if (match) {\n const reference = text.slice(0, match.index);\n const shorthand = new ShorthandExpressionParser().tryParse(reference, start);\n if (shorthand) {\n let tokens: readonly AbstractToken[];\n if (typeof source === 'string') {\n tokens = [...shorthand.tokens, new TextToken(text.slice(match.index), start + match.index)];\n } else {\n tokens = source;\n }\n expression = new FormatShorthandExpression({ format: match[1], tokens });\n }\n }\n return expression;\n }\n}\n"]}
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ShorthandExpressionParser = exports.ShorthandExpression = void 0;
4
4
  const ExpressionParser_1 = require("../../ExpressionParser");
5
5
  const AbstractExpression_1 = require("../AbstractExpression");
6
- const tokens_1 = require("../../tokens");
6
+ const CodeToken_1 = require("../../tokens/code/CodeToken");
7
+ const tokenUtils_1 = require("../../utils/tokenUtils");
8
+ const JSToken_1 = require("../../tokens/code/JSToken");
7
9
  /**
8
10
  * A reference resolved through the scope without an evaluation prefix.
9
11
  * Examples include `user.name`, `items[0].name` and `user['name']`.
@@ -27,10 +29,10 @@ class ShorthandExpression extends AbstractExpression_1.AbstractExpression {
27
29
  return (_a = this.options.format) !== null && _a !== void 0 ? _a : null;
28
30
  }
29
31
  get codeToken() {
30
- return (0, tokens_1.codeToken)(this.tokens);
32
+ return (0, tokenUtils_1.codeToken)(this.tokens);
31
33
  }
32
34
  isValid() {
33
- const code = this.tokens.filter((token) => token instanceof tokens_1.CodeToken);
35
+ const code = this.tokens.filter((token) => token instanceof CodeToken_1.CodeToken);
34
36
  return code.length === 1 && code[0].referencePath() != null;
35
37
  }
36
38
  get path() {
@@ -66,7 +68,7 @@ class ShorthandExpressionParser extends ExpressionParser_1.ExpressionParser {
66
68
  try {
67
69
  let tokens;
68
70
  if (typeof source === 'string') {
69
- tokens = [new tokens_1.JSToken(source, start)];
71
+ tokens = [new JSToken_1.JSToken(source, start)];
70
72
  }
71
73
  else {
72
74
  tokens = source;
@@ -1 +1 @@
1
- {"version":3,"file":"ShorthandExpression.js","sourceRoot":"","sources":["../../../src/expressions/shorthand/ShorthandExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,8DAA4G;AAC5G,yCAA6G;AAQ7G;;;;;;;;;;GAUG;AACH,yBAEE,SAAQ,uCAAqB;IAG7B,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,yBAAyB,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAED,YAAY,OAAU;QACpB,KAAK,CAAC,mBAAmB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3C,CAAC;IAED,IAA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I,MAAgC,CAAC;YACrC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,MAAM,GAAG,CAAC,IAAI,gBAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,MAAM,CAAC;YAClB,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,mBAAmB,CAAC;gBACxC,MAAM;aACP,CAAC,CAAC;YACH,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;gBACxB,UAAU,GAAG,SAAS,CAAC;YACzB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC,EAAE,CAAC;gBACpC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions, ExpressionDiagnostic } from '../AbstractExpression';\nimport { AbstractToken, CodeToken, codeToken, ExpressionSource, JSToken, ReferencePath } from '../../tokens';\nimport type { ValidationContext } from '../../definitions/ValidationContext';\nimport type { Type } from '@ja-platform/parser-type-system';\n\nexport interface ShorthandExpressionOptions extends AbstractExpressionOptions {\n format?: string;\n}\n\n/**\n * A reference resolved through the scope without an evaluation prefix.\n * Examples include `user.name`, `items[0].name` and `user['name']`.\n * Dynamic keys, call receivers, optional chains and arithmetic are not shorthand references.\n *\n * @example\n * ```ts\n * ShorthandExpression.parse('user.name').path; // ['user', 'name']\n * ShorthandExpression.parse('items[0].name').raw(); // 'items[0].name'\n * ```\n */\nexport class ShorthandExpression<\n O extends ShorthandExpressionOptions = ShorthandExpressionOptions\n> extends AbstractExpression<O> {\n static TYPE = 'shorthand-expression';\n\n static parse(source: ExpressionSource, start = 0): ShorthandExpression {\n return new ShorthandExpressionParser().parse(source, start);\n }\n\n constructor(options: O) {\n super(ShorthandExpression.TYPE, options);\n }\n\n get format(): string | null {\n return this.options.format ?? null;\n }\n\n get codeToken(): CodeToken {\n return codeToken(this.tokens);\n }\n\n isValid(): boolean {\n const code = this.tokens.filter((token): token is CodeToken => token instanceof CodeToken);\n return code.length === 1 && code[0].referencePath() != null;\n }\n\n get path(): ReferencePath {\n const path = this.codeToken.referencePath();\n if (path == null) throw new TypeError('Shorthand expressions require a static reference path.');\n return path;\n }\n\n /**\n * Resolve the referenced type without evaluating its value or retaining the result.\n */\n resolveType(context: ValidationContext): Type | null {\n return context.getReference(this.path);\n }\n\n /**\n * Report an unresolved reference using its original source token.\n */\n validate(context: ValidationContext): ExpressionDiagnostic[] {\n if (this.resolveType(context) != null) {\n return [];\n }\n return [{ token: this.codeToken, message: `'${this.codeToken.code}' is not defined` }];\n }\n}\n\n/**\n * Recognize the syntax owned by ShorthandExpression.\n */\nexport class ShorthandExpressionParser extends ExpressionParser<ShorthandExpression> {\n tryParse(source: ExpressionSource, start = 0): ShorthandExpression | null {\n let expression: ShorthandExpression | null = null;\n try {\n let tokens: readonly AbstractToken[];\n if (typeof source === 'string') {\n tokens = [new JSToken(source, start)];\n } else {\n tokens = source;\n }\n const candidate = new ShorthandExpression({\n tokens\n });\n if (candidate.isValid()) {\n expression = candidate;\n }\n } catch (error) {\n if (!(error instanceof SyntaxError)) {\n throw error;\n }\n }\n return expression;\n }\n}\n"]}
1
+ {"version":3,"file":"ShorthandExpression.js","sourceRoot":"","sources":["../../../src/expressions/shorthand/ShorthandExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,8DAA4G;AAE5G,2DAAuE;AACvE,uDAAmD;AACnD,uDAAoD;AAQpD;;;;;;;;;;GAUG;AACH,yBAEE,SAAQ,uCAAqB;IAG7B,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,yBAAyB,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CA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C;IAClF,QAAQ,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC1C,IAAI,UAAU,GAA+B,IAAI,CAAC;QAClD,IAAI,CAAC;YACH,IAAI,MAAgC,CAAC;YACrC,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC/B,MAAM,GAAG,CAAC,IAAI,iBAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC;YACxC,CAAC;iBAAM,CAAC;gBACN,MAAM,GAAG,MAAM,CAAC;YAClB,CAAC;YACD,MAAM,SAAS,GAAG,IAAI,mBAAmB,CAAC;gBACxC,MAAM;aACP,CAAC,CAAC;YACH,IAAI,SAAS,CAAC,OAAO,EAAE,EAAE,CAAC;gBACxB,UAAU,GAAG,SAAS,CAAC;YACzB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC,EAAE,CAAC;gBACpC,MAAM,KAAK,CAAC;YACd,CAAC;QACH,CAAC;QACD,OAAO,UAAU,CAAC;IACpB,CAAC;CACF","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractExpression, AbstractExpressionOptions, ExpressionDiagnostic } from '../AbstractExpression';\nimport { AbstractToken, ExpressionSource } from '../../tokens/AbstractToken';\nimport { CodeToken, ReferencePath } from '../../tokens/code/CodeToken';\nimport { codeToken } from '../../utils/tokenUtils';\nimport { JSToken } from '../../tokens/code/JSToken';\nimport type { ValidationContext } from '../../definitions/ValidationContext';\nimport type { Type } from '@ja-platform/parser-type-system';\n\nexport interface ShorthandExpressionOptions extends AbstractExpressionOptions {\n format?: string;\n}\n\n/**\n * A reference resolved through the scope without an evaluation prefix.\n * Examples include `user.name`, `items[0].name` and `user['name']`.\n * Dynamic keys, call receivers, optional chains and arithmetic are not shorthand references.\n *\n * @example\n * ```ts\n * ShorthandExpression.parse('user.name').path; // ['user', 'name']\n * ShorthandExpression.parse('items[0].name').raw(); // 'items[0].name'\n * ```\n */\nexport class ShorthandExpression<\n O extends ShorthandExpressionOptions = ShorthandExpressionOptions\n> extends AbstractExpression<O> {\n static TYPE = 'shorthand-expression';\n\n static parse(source: ExpressionSource, start = 0): ShorthandExpression {\n return new ShorthandExpressionParser().parse(source, start);\n }\n\n constructor(options: O) {\n super(ShorthandExpression.TYPE, options);\n }\n\n get format(): string | null {\n return this.options.format ?? null;\n }\n\n get codeToken(): CodeToken {\n return codeToken(this.tokens);\n }\n\n isValid(): boolean {\n const code = this.tokens.filter((token): token is CodeToken => token instanceof CodeToken);\n return code.length === 1 && code[0].referencePath() != null;\n }\n\n get path(): ReferencePath {\n const path = this.codeToken.referencePath();\n if (path == null) throw new TypeError('Shorthand expressions require a static reference path.');\n return path;\n }\n\n /**\n * Resolve the referenced type without evaluating its value or retaining the result.\n */\n resolveType(context: ValidationContext): Type | null {\n return context.getReference(this.path);\n }\n\n /**\n * Report an unresolved reference using its original source token.\n */\n validate(context: ValidationContext): ExpressionDiagnostic[] {\n if (this.resolveType(context) != null) {\n return [];\n }\n return [{ token: this.codeToken, message: `'${this.codeToken.code}' is not defined` }];\n }\n}\n\n/**\n * Recognize the syntax owned by ShorthandExpression.\n */\nexport class ShorthandExpressionParser extends ExpressionParser<ShorthandExpression> {\n tryParse(source: ExpressionSource, start = 0): ShorthandExpression | null {\n let expression: ShorthandExpression | null = null;\n try {\n let tokens: readonly AbstractToken[];\n if (typeof source === 'string') {\n tokens = [new JSToken(source, start)];\n } else {\n tokens = source;\n }\n const candidate = new ShorthandExpression({\n tokens\n });\n if (candidate.isValid()) {\n expression = candidate;\n }\n } catch (error) {\n if (!(error instanceof SyntaxError)) {\n throw error;\n }\n }\n return expression;\n }\n}\n"]}
@@ -2,7 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.AbstractFormatExpressionParser = exports.AbstractFormatExpression = void 0;
4
4
  const ExpressionParser_1 = require("../../ExpressionParser");
5
- const tokens_1 = require("../../tokens");
5
+ const TextToken_1 = require("../../tokens/text/TextToken");
6
+ const PlaceholderToken_1 = require("../../tokens/text/PlaceholderToken");
6
7
  const AbstractExpression_1 = require("../AbstractExpression");
7
8
  /**
8
9
  * Shared format text, placeholder tokens, source positions, and rendering.
@@ -12,11 +13,11 @@ class AbstractFormatExpression extends AbstractExpression_1.AbstractExpression {
12
13
  return this.options.tokens;
13
14
  }
14
15
  isValid() {
15
- return this.tokens.every((token) => token instanceof tokens_1.TextToken || (token instanceof tokens_1.PlaceholderToken && token.expression.isValid()));
16
+ return this.tokens.every((token) => token instanceof TextToken_1.TextToken || (token instanceof PlaceholderToken_1.PlaceholderToken && token.expression.isValid()));
16
17
  }
17
18
  get parameters() {
18
19
  return this.tokens
19
- .filter((token) => token instanceof tokens_1.PlaceholderToken)
20
+ .filter((token) => token instanceof PlaceholderToken_1.PlaceholderToken)
20
21
  .map((token) => token.expression);
21
22
  }
22
23
  withParameters(parameters) {
@@ -28,9 +29,9 @@ class AbstractFormatExpression extends AbstractExpression_1.AbstractExpression {
28
29
  let start = this.start;
29
30
  const tokens = [];
30
31
  for (const token of this.tokens) {
31
- const replacement = token instanceof tokens_1.PlaceholderToken
32
+ const replacement = token instanceof PlaceholderToken_1.PlaceholderToken
32
33
  ? parser.placeholder(parameters[index++], start)
33
- : new tokens_1.TextToken(token.raw(), start);
34
+ : new TextToken_1.TextToken(token.raw(), start);
34
35
  tokens.push(replacement);
35
36
  start = replacement.end;
36
37
  }
@@ -57,7 +58,7 @@ class AbstractFormatExpression extends AbstractExpression_1.AbstractExpression {
57
58
  .map((token) => {
58
59
  var _a;
59
60
  let text;
60
- if (token instanceof tokens_1.TextToken) {
61
+ if (token instanceof TextToken_1.TextToken) {
61
62
  text = token.decodedText;
62
63
  }
63
64
  else {
@@ -82,12 +83,12 @@ class AbstractFormatExpressionParser extends ExpressionParser_1.ExpressionParser
82
83
  throw new SyntaxError('Unsupported expression in a format placeholder.');
83
84
  }
84
85
  parsed.start = start;
85
- return new tokens_1.PlaceholderToken(parsed, start);
86
+ return new PlaceholderToken_1.PlaceholderToken(parsed, start);
86
87
  }
87
88
  validateToken(token) {
88
- if (token instanceof tokens_1.TextToken)
89
+ if (token instanceof TextToken_1.TextToken)
89
90
  return;
90
- if (token instanceof tokens_1.PlaceholderToken) {
91
+ if (token instanceof PlaceholderToken_1.PlaceholderToken) {
91
92
  this.placeholder(token.expression, token.start);
92
93
  return;
93
94
  }
@@ -134,14 +135,14 @@ class AbstractFormatExpressionParser extends ExpressionParser_1.ExpressionParser
134
135
  if (!expression)
135
136
  throw new SyntaxError('Expected an expression inside a placeholder.');
136
137
  if (i > start)
137
- tokens.push(new tokens_1.TextToken(source.slice(start, i), offset + start));
138
+ tokens.push(new TextToken_1.TextToken(source.slice(start, i), offset + start));
138
139
  expression.start = offset + i;
139
- tokens.push(new tokens_1.PlaceholderToken(expression, offset + i));
140
+ tokens.push(new PlaceholderToken_1.PlaceholderToken(expression, offset + i));
140
141
  start = end + 1;
141
142
  i = end;
142
143
  }
143
144
  if (start < source.length)
144
- tokens.push(new tokens_1.TextToken(source.slice(start), offset + start));
145
+ tokens.push(new TextToken_1.TextToken(source.slice(start), offset + start));
145
146
  return tokens;
146
147
  }
147
148
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractFormatExpression.js","sourceRoot":"","sources":["../../../src/expressions/text/AbstractFormatExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAC1D,yCAA4F;AAE5F,8DAA4G;AAM5G;;GAEG;AACH,8BAGE,SAAQ,uCAAsD;IAC9D,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,kBAAS,IAAI,CAAC,KAAK,YAAY,yBAAgB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAC3G,C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AK,IAAI,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;QACvB,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,IAAI,KAAK,IAAI;gBAAE,CAAC,EAAE,CAAC;iBAClB,IAAI,IAAI,KAAK,KAAK;gBAAE,KAAK,GAAG,EAAE,CAAC;QACtC,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxD,KAAK,GAAG,IAAI,CAAC;QACf,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACxB,KAAK,EAAE,CAAC;QACV,CAAC;aAAM,IAAI,IAAI,KAAK,GAAG,IAAI,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC;YACzC,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractToken, ExpressionSource, TextToken, PlaceholderToken } from '../../tokens';\nimport type { ValidationContext } from '../../definitions/ValidationContext';\nimport { AbstractExpression, AbstractExpressionOptions, ExpressionDiagnostic } from '../AbstractExpression';\n\nexport interface AbstractFormatExpressionOptions<P extends AbstractExpression> extends AbstractExpressionOptions {\n tokens: readonly (TextToken | PlaceholderToken<P>)[];\n}\n\n/**\n * Shared format text, placeholder tokens, source positions, and rendering.\n */\nexport abstract class AbstractFormatExpression<\n T extends AbstractFormatExpression<T, P>,\n P extends AbstractExpression = AbstractExpression\n> extends AbstractExpression<AbstractFormatExpressionOptions<P>> {\n get tokens(): readonly (TextToken | PlaceholderToken<P>)[] {\n return this.options.tokens;\n }\n\n isValid(): boolean {\n return this.tokens.every(\n (token) => token instanceof TextToken || (token instanceof PlaceholderToken && token.expression.isValid())\n );\n }\n\n get parameters(): readonly P[] {\n return this.tokens\n .filter((token): token is PlaceholderToken<P> => token instanceof PlaceholderToken)\n .map((token) => token.expression);\n }\n\n protected abstract getParser(): AbstractFormatExpressionParser<T, P>;\n\n withParameters(parameters: readonly P[]): T {\n if (parameters.length !== this.parameters.length) {\n throw new Error('Expected one expression for each format-string placeholder.');\n }\n const parser = this.getParser();\n let index = 0;\n let start = this.start;\n const tokens: (TextToken | PlaceholderToken<P>)[] = [];\n for (const token of this.tokens) {\n const replacement =\n token instanceof PlaceholderToken\n ? parser.placeholder(parameters[index++], start)\n : new TextToken(token.raw(), start);\n tokens.push(replacement);\n start = replacement.end;\n }\n return parser.parse(tokens, this.start);\n }\n\n /**\n * Validate each placeholder against the supplied declarations.\n */\n validate(context: ValidationContext): ExpressionDiagnostic[] {\n return this.parameters.flatMap((expression) => expression.validate(context));\n }\n\n /**\n * Assemble the text using resolved placeholder values in parameter order.\n * This does not parse source or evaluate parameters.\n *\n * @example\n * ```ts\n * FormatStringExpression.parse('Hello {user.name}').render(['Sam']); // 'Hello Sam'\n * ```\n */\n render(values: readonly unknown[]): string {\n let index = 0;\n return this.tokens\n .map((token) => {\n let text: string;\n if (token instanceof TextToken) {\n text = token.decodedText;\n } else {\n text = String(values[index++] ?? '');\n }\n return text;\n })\n .join('');\n }\n\n toString(): string {\n return this.raw();\n }\n}\n\nexport abstract class AbstractFormatExpressionParser<\n T extends AbstractFormatExpression<T, P>,\n P extends AbstractExpression = AbstractExpression\n> extends ExpressionParser<T> {\n protected abstract parsePlaceholder(source: ExpressionSource, start: number): P;\n protected abstract createExpression(options: AbstractFormatExpressionOptions<P>): T;\n\n /**\n * Reparse replacements through the concrete grammar, retaining their expression kind.\n */\n placeholder(expression: AbstractExpression, start: number): PlaceholderToken<P> {\n const parsed = this.parsePlaceholder(expression.raw(), start + 1);\n if (parsed.type !== expression.type) {\n throw new SyntaxError('Unsupported expression in a format placeholder.');\n }\n parsed.start = start;\n return new PlaceholderToken(parsed, start);\n }\n\n protected validateToken(token: AbstractToken): asserts token is TextToken | PlaceholderToken<P> {\n if (token instanceof TextToken) return;\n if (token instanceof PlaceholderToken) {\n this.placeholder(token.expression, token.start);\n return;\n }\n throw new SyntaxError('Expected valid format text and placeholders.');\n }\n\n tryParse(source: ExpressionSource, start = 0): T {\n source = source ?? '';\n let tokens: (TextToken | PlaceholderToken<P>)[];\n if (typeof source === 'string') {\n tokens = this.tokens(source, start);\n } else {\n tokens = [];\n for (const token of source) {\n this.validateToken(token);\n tokens.push(token);\n }\n }\n const expression = this.createExpression({ start, tokens });\n if (!expression.isValid()) {\n throw new SyntaxError('Expected valid format text and placeholders.');\n }\n return expression;\n }\n\n tokens(source: string, offset = 0): (TextToken | PlaceholderToken<P>)[] {\n const tokens: (TextToken | PlaceholderToken<P>)[] = [];\n let start = 0;\n for (let i = 0; i < source.length; i++) {\n if (source[i] !== '{') continue;\n // Doubled braces encode literal text, so they never start a placeholder.\n if (source[i + 1] === '{') {\n i++;\n continue;\n }\n const end = placeholderEnd({ source, start: i });\n // Preserve unmatched opening braces as text.\n if (end < 0) break;\n const text = source.slice(i + 1, end);\n if (text.trim() === '') throw new SyntaxError('Expected an expression inside a placeholder.');\n const expression = this.parsePlaceholder(text, offset + i + 1);\n if (!expression) throw new SyntaxError('Expected an expression inside a placeholder.');\n if (i > start) tokens.push(new TextToken(source.slice(start, i), offset + start));\n expression.start = offset + i;\n tokens.push(new PlaceholderToken(expression, offset + i));\n start = end + 1;\n i = end;\n }\n if (start < source.length) tokens.push(new TextToken(source.slice(start), offset + start));\n return tokens;\n }\n}\n\n/**\n * Balance placeholder braces independently of the embedded language. Single, double and\n * backtick quotes are opaque spans with backslash escapes; comments, regex literals and\n * nested template interpolation have no special boundary rules.\n * Return -1 for an unmatched opening brace or unfinished quoted span.\n */\nfunction placeholderEnd({ source, start }: { source: string; start: number }): number {\n let depth = 1;\n let quote = '';\n for (let i = start + 1; i < source.length; i++) {\n const char = source[i];\n if (quote) {\n if (char === '\\\\') i++;\n else if (char === quote) quote = '';\n } else if (char === \"'\" || char === '\"' || char === '`') {\n quote = char;\n } else if (char === '{') {\n depth++;\n } else if (char === '}' && --depth === 0) {\n return i;\n }\n }\n return -1;\n}\n"]}
1
+ {"version":3,"file":"AbstractFormatExpression.js","sourceRoot":"","sources":["../../../src/expressions/text/AbstractFormatExpression.ts"],"names":[],"mappings":";;;AAAA,6DAA0D;AAE1D,2DAAwD;AACxD,yEAAsE;AAEtE,8DAA4G;AAM5G;;GAEG;AACH,8BAGE,SAAQ,uCAAsD;IAC9D,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7B,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CACtB,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,YAAY,qBAAS,IAAI,CAAC,KAAK,YAAY,mCAAgB,IAAI,KAAK,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC,CAC3G,CAAC;IACJ,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,MAAM;aACf,MAAM,CAAC,CAAC,KAAK,EAAgC,EAAE,CAAC,KAAK,YAAY,mCAAgB,CAAC;aAClF,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IAID,cAAc,CAAC,UAAwB;QACrC,IAAI,UAAU,CAAC,MAAM,KAAK,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;QACjF,CAAC;QACD,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;QAChC,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,IAAI,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACvB,MAAM,MAAM,GAAwC,EAAE,CAAC;QACvD,KAAK,MAAM,KAAK,IAAI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AAC;YACzC,OAAO,CAAC,CAAC;QACX,CAAC;IACH,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC","sourcesContent":["import { ExpressionParser } from '../../ExpressionParser';\nimport { AbstractToken, ExpressionSource } from '../../tokens/AbstractToken';\nimport { TextToken } from '../../tokens/text/TextToken';\nimport { PlaceholderToken } from '../../tokens/text/PlaceholderToken';\nimport type { ValidationContext } from '../../definitions/ValidationContext';\nimport { AbstractExpression, AbstractExpressionOptions, ExpressionDiagnostic } from '../AbstractExpression';\n\nexport interface AbstractFormatExpressionOptions<P extends AbstractExpression> extends AbstractExpressionOptions {\n tokens: readonly (TextToken | PlaceholderToken<P>)[];\n}\n\n/**\n * Shared format text, placeholder tokens, source positions, and rendering.\n */\nexport abstract class AbstractFormatExpression<\n T extends AbstractFormatExpression<T, P>,\n P extends AbstractExpression = AbstractExpression\n> extends AbstractExpression<AbstractFormatExpressionOptions<P>> {\n get tokens(): readonly (TextToken | PlaceholderToken<P>)[] {\n return this.options.tokens;\n }\n\n isValid(): boolean {\n return this.tokens.every(\n (token) => token instanceof TextToken || (token instanceof PlaceholderToken && token.expression.isValid())\n );\n }\n\n get parameters(): readonly P[] {\n return this.tokens\n .filter((token): token is PlaceholderToken<P> => token instanceof PlaceholderToken)\n .map((token) => token.expression);\n }\n\n protected abstract getParser(): AbstractFormatExpressionParser<T, P>;\n\n withParameters(parameters: readonly P[]): T {\n if (parameters.length !== this.parameters.length) {\n throw new Error('Expected one expression for each format-string placeholder.');\n }\n const parser = this.getParser();\n let index = 0;\n let start = this.start;\n const tokens: (TextToken | PlaceholderToken<P>)[] = [];\n for (const token of this.tokens) {\n const replacement =\n token instanceof PlaceholderToken\n ? parser.placeholder(parameters[index++], start)\n : new TextToken(token.raw(), start);\n tokens.push(replacement);\n start = replacement.end;\n }\n return parser.parse(tokens, this.start);\n }\n\n /**\n * Validate each placeholder against the supplied declarations.\n */\n validate(context: ValidationContext): ExpressionDiagnostic[] {\n return this.parameters.flatMap((expression) => expression.validate(context));\n }\n\n /**\n * Assemble the text using resolved placeholder values in parameter order.\n * This does not parse source or evaluate parameters.\n *\n * @example\n * ```ts\n * FormatStringExpression.parse('Hello {user.name}').render(['Sam']); // 'Hello Sam'\n * ```\n */\n render(values: readonly unknown[]): string {\n let index = 0;\n return this.tokens\n .map((token) => {\n let text: string;\n if (token instanceof TextToken) {\n text = token.decodedText;\n } else {\n text = String(values[index++] ?? '');\n }\n return text;\n })\n .join('');\n }\n\n toString(): string {\n return this.raw();\n }\n}\n\nexport abstract class AbstractFormatExpressionParser<\n T extends AbstractFormatExpression<T, P>,\n P extends AbstractExpression = AbstractExpression\n> extends ExpressionParser<T> {\n protected abstract parsePlaceholder(source: ExpressionSource, start: number): P;\n protected abstract createExpression(options: AbstractFormatExpressionOptions<P>): T;\n\n /**\n * Reparse replacements through the concrete grammar, retaining their expression kind.\n */\n placeholder(expression: AbstractExpression, start: number): PlaceholderToken<P> {\n const parsed = this.parsePlaceholder(expression.raw(), start + 1);\n if (parsed.type !== expression.type) {\n throw new SyntaxError('Unsupported expression in a format placeholder.');\n }\n parsed.start = start;\n return new PlaceholderToken(parsed, start);\n }\n\n protected validateToken(token: AbstractToken): asserts token is TextToken | PlaceholderToken<P> {\n if (token instanceof TextToken) return;\n if (token instanceof PlaceholderToken) {\n this.placeholder(token.expression, token.start);\n return;\n }\n throw new SyntaxError('Expected valid format text and placeholders.');\n }\n\n tryParse(source: ExpressionSource, start = 0): T {\n source = source ?? '';\n let tokens: (TextToken | PlaceholderToken<P>)[];\n if (typeof source === 'string') {\n tokens = this.tokens(source, start);\n } else {\n tokens = [];\n for (const token of source) {\n this.validateToken(token);\n tokens.push(token);\n }\n }\n const expression = this.createExpression({ start, tokens });\n if (!expression.isValid()) {\n throw new SyntaxError('Expected valid format text and placeholders.');\n }\n return expression;\n }\n\n tokens(source: string, offset = 0): (TextToken | PlaceholderToken<P>)[] {\n const tokens: (TextToken | PlaceholderToken<P>)[] = [];\n let start = 0;\n for (let i = 0; i < source.length; i++) {\n if (source[i] !== '{') continue;\n // Doubled braces encode literal text, so they never start a placeholder.\n if (source[i + 1] === '{') {\n i++;\n continue;\n }\n const end = placeholderEnd({ source, start: i });\n // Preserve unmatched opening braces as text.\n if (end < 0) break;\n const text = source.slice(i + 1, end);\n if (text.trim() === '') throw new SyntaxError('Expected an expression inside a placeholder.');\n const expression = this.parsePlaceholder(text, offset + i + 1);\n if (!expression) throw new SyntaxError('Expected an expression inside a placeholder.');\n if (i > start) tokens.push(new TextToken(source.slice(start, i), offset + start));\n expression.start = offset + i;\n tokens.push(new PlaceholderToken(expression, offset + i));\n start = end + 1;\n i = end;\n }\n if (start < source.length) tokens.push(new TextToken(source.slice(start), offset + start));\n return tokens;\n }\n}\n\n/**\n * Balance placeholder braces independently of the embedded language. Single, double and\n * backtick quotes are opaque spans with backslash escapes; comments, regex literals and\n * nested template interpolation have no special boundary rules.\n * Return -1 for an unmatched opening brace or unfinished quoted span.\n */\nfunction placeholderEnd({ source, start }: { source: string; start: number }): number {\n let depth = 1;\n let quote = '';\n for (let i = start + 1; i < source.length; i++) {\n const char = source[i];\n if (quote) {\n if (char === '\\\\') i++;\n else if (char === quote) quote = '';\n } else if (char === \"'\" || char === '\"' || char === '`') {\n quote = char;\n } else if (char === '{') {\n depth++;\n } else if (char === '}' && --depth === 0) {\n return i;\n }\n }\n return -1;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FormatStringExpression.js","sourceRoot":"","sources":["../../../src/expressions/text/FormatStringExpression.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAEtD,gEAAwF;AACxF,uEAA0E;AAC1E,sFAAyF;AACzF,0EAAkG;AAClG,yEAIoC;AAEpC;;GAEG;AACH,4BAAoC,SAAQ,mDAG3C;IAGC,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,4BAA4B,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;IAED,YAAY,OAAmF;QAC7F,KAAK,CAAC,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAES,SAAS;QACjB,OAAO,IAAI,4BAA4B,EAAE,CAAC;IAC5C,CAAC;CACF;;AAbiB,2BAAI,GAAG,eAAe,CAAC;AAezC,kCAA0C,SAAQ,yDAGjD;IAHD;;QAImB,iBAAY,GAAG,IAAI,+BAAc,CAA4C;YAC5F,IAAI,6CAAwB,EAAE;YAC9B,IAAI,+CAAyB,EAAE;YAC/B,IAAI,2DAA+B,EAAE;YACrC,IAAI,+CAAyB,EAAE;SAChC,CAAC,CAAC;IASL,CAAC;IAPW,gBAAgB,CAAC,MAAwB,EAAE,KAAa;QAChE,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAES,gBAAgB,CAAC,OAAmF;QAC5G,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import { CombinedParser } from '../../CombinedParser';\nimport { ExpressionSource } from '../../tokens';\nimport { EvaluatedExpression, EvaluatedExpressionParser } from '../EvaluatedExpression';\nimport { FunctionExpressionParser } from '../function/FunctionExpression';\nimport { FormatShorthandExpressionParser } from '../shorthand/FormatShorthandExpression';\nimport { ShorthandExpression, ShorthandExpressionParser } from '../shorthand/ShorthandExpression';\nimport {\n AbstractFormatExpression,\n AbstractFormatExpressionOptions,\n AbstractFormatExpressionParser\n} from './AbstractFormatExpression';\n\n/**\n * Format text supporting references, formatted references, and explicitly evaluated code.\n */\nexport class FormatStringExpression extends AbstractFormatExpression<\n FormatStringExpression,\n ShorthandExpression | EvaluatedExpression\n> {\n static readonly TYPE = 'format-string';\n\n static parse(source: ExpressionSource, start = 0): FormatStringExpression {\n return new FormatStringExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractFormatExpressionOptions<ShorthandExpression | EvaluatedExpression>) {\n super(FormatStringExpression.TYPE, options);\n }\n\n protected getParser(): FormatStringExpressionParser {\n return new FormatStringExpressionParser();\n }\n}\n\nexport class FormatStringExpressionParser extends AbstractFormatExpressionParser<\n FormatStringExpression,\n ShorthandExpression | EvaluatedExpression\n> {\n private readonly placeholders = new CombinedParser<ShorthandExpression | EvaluatedExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new FormatShorthandExpressionParser(),\n new ShorthandExpressionParser()\n ]);\n\n protected parsePlaceholder(source: ExpressionSource, start: number) {\n return this.placeholders.parse(source, start);\n }\n\n protected createExpression(options: AbstractFormatExpressionOptions<ShorthandExpression | EvaluatedExpression>) {\n return new FormatStringExpression(options);\n }\n}\n"]}
1
+ {"version":3,"file":"FormatStringExpression.js","sourceRoot":"","sources":["../../../src/expressions/text/FormatStringExpression.ts"],"names":[],"mappings":";;;AAAA,yDAAsD;AAEtD,gEAAwF;AACxF,uEAA0E;AAC1E,sFAAyF;AACzF,0EAAkG;AAClG,yEAIoC;AAEpC;;GAEG;AACH,4BAAoC,SAAQ,mDAG3C;IAGC,MAAM,CAAC,KAAK,CAAC,MAAwB,EAAE,KAAK,GAAG,CAAC;QAC9C,OAAO,IAAI,4BAA4B,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACjE,CAAC;IAED,YAAY,OAAmF;QAC7F,KAAK,CAAC,sBAAsB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9C,CAAC;IAES,SAAS;QACjB,OAAO,IAAI,4BAA4B,EAAE,CAAC;IAC5C,CAAC;CACF;;AAbiB,2BAAI,GAAG,eAAe,CAAC;AAezC,kCAA0C,SAAQ,yDAGjD;IAHD;;QAImB,iBAAY,GAAG,IAAI,+BAAc,CAA4C;YAC5F,IAAI,6CAAwB,EAAE;YAC9B,IAAI,+CAAyB,EAAE;YAC/B,IAAI,2DAA+B,EAAE;YACrC,IAAI,+CAAyB,EAAE;SAChC,CAAC,CAAC;IASL,CAAC;IAPW,gBAAgB,CAAC,MAAwB,EAAE,KAAa;QAChE,OAAO,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAChD,CAAC;IAES,gBAAgB,CAAC,OAAmF;QAC5G,OAAO,IAAI,sBAAsB,CAAC,OAAO,CAAC,CAAC;IAC7C,CAAC;CACF","sourcesContent":["import { CombinedParser } from '../../CombinedParser';\nimport { ExpressionSource } from '../../tokens/AbstractToken';\nimport { EvaluatedExpression, EvaluatedExpressionParser } from '../EvaluatedExpression';\nimport { FunctionExpressionParser } from '../function/FunctionExpression';\nimport { FormatShorthandExpressionParser } from '../shorthand/FormatShorthandExpression';\nimport { ShorthandExpression, ShorthandExpressionParser } from '../shorthand/ShorthandExpression';\nimport {\n AbstractFormatExpression,\n AbstractFormatExpressionOptions,\n AbstractFormatExpressionParser\n} from './AbstractFormatExpression';\n\n/**\n * Format text supporting references, formatted references, and explicitly evaluated code.\n */\nexport class FormatStringExpression extends AbstractFormatExpression<\n FormatStringExpression,\n ShorthandExpression | EvaluatedExpression\n> {\n static readonly TYPE = 'format-string';\n\n static parse(source: ExpressionSource, start = 0): FormatStringExpression {\n return new FormatStringExpressionParser().parse(source, start);\n }\n\n constructor(options: AbstractFormatExpressionOptions<ShorthandExpression | EvaluatedExpression>) {\n super(FormatStringExpression.TYPE, options);\n }\n\n protected getParser(): FormatStringExpressionParser {\n return new FormatStringExpressionParser();\n }\n}\n\nexport class FormatStringExpressionParser extends AbstractFormatExpressionParser<\n FormatStringExpression,\n ShorthandExpression | EvaluatedExpression\n> {\n private readonly placeholders = new CombinedParser<ShorthandExpression | EvaluatedExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new FormatShorthandExpressionParser(),\n new ShorthandExpressionParser()\n ]);\n\n protected parsePlaceholder(source: ExpressionSource, start: number) {\n return this.placeholders.parse(source, start);\n }\n\n protected createExpression(options: AbstractFormatExpressionOptions<ShorthandExpression | EvaluatedExpression>) {\n return new FormatStringExpression(options);\n }\n}\n"]}
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.formatValueAsync = exports.formatValue = void 0;
17
+ exports.leadingTrivia = exports.hasFunctionPrefix = exports.javascriptToken = exports.codeToken = exports.stringify = exports.formatValueAsync = exports.formatValue = void 0;
18
18
  __exportStar(require("./ExpressionParser"), exports);
19
19
  __exportStar(require("./CombinedParser"), exports);
20
20
  __exportStar(require("./utils/parserUtils"), exports);
@@ -23,7 +23,29 @@ __exportStar(require("./code-parsers/JavaScriptParser"), exports);
23
23
  var valueFormatting_1 = require("./utils/valueFormatting");
24
24
  Object.defineProperty(exports, "formatValue", { enumerable: true, get: function () { return valueFormatting_1.formatValue; } });
25
25
  Object.defineProperty(exports, "formatValueAsync", { enumerable: true, get: function () { return valueFormatting_1.formatValueAsync; } });
26
- __exportStar(require("./expressions"), exports);
26
+ __exportStar(require("./expressions/AbstractExpression"), exports);
27
+ __exportStar(require("./expressions/ListExpression"), exports);
28
+ __exportStar(require("./expressions/EvaluatedExpression"), exports);
29
+ __exportStar(require("./expressions/shorthand/ShorthandExpression"), exports);
30
+ __exportStar(require("./expressions/shorthand/FormatShorthandExpression"), exports);
31
+ __exportStar(require("./expressions/constant/ConstantExpression"), exports);
32
+ __exportStar(require("./expressions/function/FunctionExpression"), exports);
33
+ __exportStar(require("./expressions/text/FormatStringExpression"), exports);
34
+ __exportStar(require("./expressions/text/AbstractFormatExpression"), exports);
27
35
  __exportStar(require("./definitions/ValidationContext"), exports);
28
- __exportStar(require("./tokens"), exports);
36
+ __exportStar(require("./tokens/AbstractToken"), exports);
37
+ __exportStar(require("./tokens/DelimiterToken"), exports);
38
+ __exportStar(require("./tokens/EnumToken"), exports);
39
+ __exportStar(require("./tokens/text/TextToken"), exports);
40
+ __exportStar(require("./tokens/code/JSToken"), exports);
41
+ __exportStar(require("./tokens/code/PrefixToken"), exports);
42
+ __exportStar(require("./tokens/code/IdentifierToken"), exports);
43
+ __exportStar(require("./tokens/text/PlaceholderToken"), exports);
44
+ __exportStar(require("./tokens/code/CodeToken"), exports);
45
+ var tokenUtils_1 = require("./utils/tokenUtils");
46
+ Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return tokenUtils_1.stringify; } });
47
+ Object.defineProperty(exports, "codeToken", { enumerable: true, get: function () { return tokenUtils_1.codeToken; } });
48
+ Object.defineProperty(exports, "javascriptToken", { enumerable: true, get: function () { return tokenUtils_1.javascriptToken; } });
49
+ Object.defineProperty(exports, "hasFunctionPrefix", { enumerable: true, get: function () { return tokenUtils_1.hasFunctionPrefix; } });
50
+ Object.defineProperty(exports, "leadingTrivia", { enumerable: true, get: function () { return tokenUtils_1.leadingTrivia; } });
29
51
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AAEnC,mDAAiC;AACjC,sDAAoC;AACpC,4DAA0C;AAC1C,kEAAgD;AAChD,2DAAwE;AAA/D,8GAAA,WAAW,OAAA;AAAE,mHAAA,gBAAgB,OAAA;AAEtC,gDAA8B;AAE9B,kEAAgD;AAEhD,2CAAyB","sourcesContent":["export * from './ExpressionParser';\n\nexport * from './CombinedParser';\nexport * from './utils/parserUtils';\nexport * from './code-parsers/CodeParser';\nexport * from './code-parsers/JavaScriptParser';\nexport { formatValue, formatValueAsync } from './utils/valueFormatting';\n\nexport * from './expressions';\n\nexport * from './definitions/ValidationContext';\n\nexport * from './tokens';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,qDAAmC;AAEnC,mDAAiC;AACjC,sDAAoC;AACpC,4DAA0C;AAC1C,kEAAgD;AAChD,2DAAwE;AAA/D,8GAAA,WAAW,OAAA;AAAE,mHAAA,gBAAgB,OAAA;AAEtC,mEAAiD;AACjD,+DAA6C;AAC7C,oEAAkD;AAClD,8EAA4D;AAC5D,oFAAkE;AAClE,4EAA0D;AAC1D,4EAA0D;AAC1D,4EAA0D;AAC1D,8EAA4D;AAE5D,kEAAgD;AAEhD,yDAAuC;AACvC,0DAAwC;AACxC,qDAAmC;AACnC,0DAAwC;AACxC,wDAAsC;AACtC,4DAA0C;AAC1C,gEAA8C;AAC9C,iEAA+C;AAC/C,0DAAwC;AACxC,iDAA6G;AAApG,uGAAA,SAAS,OAAA;AAAE,uGAAA,SAAS,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAAE,2GAAA,aAAa,OAAA","sourcesContent":["export * from './ExpressionParser';\n\nexport * from './CombinedParser';\nexport * from './utils/parserUtils';\nexport * from './code-parsers/CodeParser';\nexport * from './code-parsers/JavaScriptParser';\nexport { formatValue, formatValueAsync } from './utils/valueFormatting';\n\nexport * from './expressions/AbstractExpression';\nexport * from './expressions/ListExpression';\nexport * from './expressions/EvaluatedExpression';\nexport * from './expressions/shorthand/ShorthandExpression';\nexport * from './expressions/shorthand/FormatShorthandExpression';\nexport * from './expressions/constant/ConstantExpression';\nexport * from './expressions/function/FunctionExpression';\nexport * from './expressions/text/FormatStringExpression';\nexport * from './expressions/text/AbstractFormatExpression';\n\nexport * from './definitions/ValidationContext';\n\nexport * from './tokens/AbstractToken';\nexport * from './tokens/DelimiterToken';\nexport * from './tokens/EnumToken';\nexport * from './tokens/text/TextToken';\nexport * from './tokens/code/JSToken';\nexport * from './tokens/code/PrefixToken';\nexport * from './tokens/code/IdentifierToken';\nexport * from './tokens/text/PlaceholderToken';\nexport * from './tokens/code/CodeToken';\nexport { stringify, codeToken, javascriptToken, hasFunctionPrefix, leadingTrivia } from './utils/tokenUtils';\n"]}
@@ -1 +1 @@
1
- {"version":"7.0.2","root":[[89,92],[95,96],[98,101],[113,131]],"packageJsons":["../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/package.json","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/package.json","../../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/package.json","../package.json","../../type-system/package.json"],"missingPackageJsons":["../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/lib/package.json","../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/node_modules/@babel/types/package.json","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/lib/package.json","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/node_modules/@babel/types/package.json","../../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/lib/package.json"],"fileNames":["lib.es5.d.ts","lib.es2015.d.ts","lib.es2016.d.ts","lib.es2017.d.ts","lib.es2018.d.ts","lib.es2019.d.ts","lib.es2020.d.ts","lib.es2021.d.ts","lib.es2022.d.ts","lib.es2023.d.ts","lib.es2024.d.ts","lib.es2025.d.ts","lib.esnext.d.ts","lib.dom.d.ts","lib.es2015.core.d.ts","lib.es2015.collection.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.intl.d.ts","lib.es2017.arraybuffer.d.ts","lib.es2017.date.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.intl.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2019.intl.d.ts","lib.es2020.bigint.d.ts","lib.es2020.date.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2021.intl.d.ts","lib.es2022.array.d.ts","lib.es2022.error.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.string.d.ts","lib.es2022.regexp.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.intl.d.ts","lib.es2024.arraybuffer.d.ts","lib.es2024.collection.d.ts","lib.es2024.object.d.ts","lib.es2024.promise.d.ts","lib.es2024.regexp.d.ts","lib.es2024.sharedmemory.d.ts","lib.es2024.string.d.ts","lib.es2025.collection.d.ts","lib.es2025.float16.d.ts","lib.es2025.intl.d.ts","lib.es2025.iterator.d.ts","lib.es2025.promise.d.ts","lib.es2025.regexp.d.ts","lib.esnext.array.d.ts","lib.esnext.collection.d.ts","lib.esnext.date.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.error.d.ts","lib.esnext.intl.d.ts","lib.esnext.sharedmemory.d.ts","lib.esnext.temporal.d.ts","lib.esnext.typedarrays.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","../src/tokens/AbstractToken.ts","../src/tokens/DelimiterToken.ts","../src/tokens/EnumToken.ts","../src/tokens/text/TextToken.ts","../../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/lib/index.d.ts","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/lib/index.d.ts","../src/tokens/code/CodeToken.ts","../src/code-parsers/CodeParser.ts","../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/lib/index.d.ts","../src/code-parsers/JavaScriptParser.ts","../src/tokens/code/JSToken.ts","../src/tokens/code/IdentifierToken.ts","../src/tokens/code/PrefixToken.ts","../../type-system/dist/@types/Formatter.d.ts","../../type-system/dist/@types/Type.d.ts","../../type-system/dist/@types/ObjectType.d.ts","../../type-system/dist/@types/ArrayType.d.ts","../../type-system/dist/@types/UnknownType.d.ts","../../type-system/dist/@types/ScalarType.d.ts","../../type-system/dist/@types/TextType.d.ts","../../type-system/dist/@types/NumberType.d.ts","../../type-system/dist/@types/IntegerType.d.ts","../../type-system/dist/@types/BooleanType.d.ts","../../type-system/dist/@types/index.d.ts","../src/definitions/ValidationContext.ts","../src/expressions/AbstractExpression.ts","../src/tokens/text/PlaceholderToken.ts","../src/utils/tokenUtils.ts","../src/tokens/index.ts","../src/ExpressionParser.ts","../src/CombinedParser.ts","../src/expressions/ListExpression.ts","../src/expressions/EvaluatedExpression.ts","../src/expressions/shorthand/ShorthandExpression.ts","../src/expressions/shorthand/FormatShorthandExpression.ts","../src/expressions/constant/ConstantExpression.ts","../src/expressions/function/FunctionExpression.ts","../src/expressions/text/AbstractFormatExpression.ts","../src/expressions/text/FormatStringExpression.ts","../src/expressions/index.ts","../src/utils/parserUtils.ts","../src/utils/valueFormatting.ts","../src/index.ts"],"fileInfos":[{"version":"16934abaab7026ac114da441aabea1a0","affectsGlobalScope":true,"impliedNodeFormat":1},"d4306fb2e47f74835e8674ffac07d76f","e437c5c1302869326c3bb93da85bbbcf","e4324975a566567b21d350615f1fc6ac","333b1b9a2a9ac3b8497dba5c63b5ba50","6cffacd662b6eb5fa7a36aa2ea366bfa","b4c34f9c23304dbef2d23698637ed638","e5cb86a5fc491796ecd1d2dd348d208f","feb6c6fb19cdb246a5d8acb36a6901c7","9443a7f109277ffaa79d893ed2549995","793cee405385076e27c24f409659dccd","09f69c6610266eaee1ac9e3e30df2c71","62bad718844246b8e17547f37bad6085",{"version":"aae8996e8b5684814785a42cbbefcd79","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"926204c28cd3d073865348473ae28d2e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f25e42c801b2cb3cf2b39792006a9beb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6344b55f26a4e81d9608777dbfb877dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3c0ed28e53d3695b363e256ec1c023fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4c2761daba7f17141c25baa0821ac5da","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b87656acabd63e69379ff6ffcfe52fc7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"597469522da047a5af5222cc6989f405","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1708ea4d34dc37fadadc63ca01127e80","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"55d97a8c6fbf34a30450a7b1e5f7a298","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0ee05eb59426d33e374226d8dcfa708b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e347c14030993906efcfbb88915b6a05","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b0231263857c9b6a03641acdc9280ceb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3b15c4a83b598cacb4067676e6f0abed","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b417d97b7934cef63b1889abec0bbfbf","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"09a6cf4032ebba60ce22a501e663f881","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2b056277dd138e8f5650fc04e20eaa8d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e22cc07e3f3cc242ba52fa3f8ea1fc58","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2c45da767a1bfbb220848df1bc4029e4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b44c3e0fbaf2130cdcf6ac38b120ffa1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b612fb5cf8e5d964b92063a75207632a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"02705151a5e1551b9162a9ed8ab763f7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"41025e398be9215d32e4337335da8f0b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"52684c2b1f353a5538e4f275182a54cd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6dedb6a4f90d1df3a6fbe5693e44886c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ca3f36fe3562c07e0f0d71c2bebd3f6d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"409974d6129befbb8226ddd1c6558568","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4d9cfde2a1ae1b4925f1f9bc10848e5d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7e1daecc66dd564144e3bb1a0266b5fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a8e1d9bb35fd0637f2f9fd2b2a54f2ec","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4f168501772a6543182765bfd5f2fbfe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19c80aad1b2162103496f5ba293a732","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b69afa63cd5d059851c78adb2856ee09","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ae2fc5d954e9b0f5feee3d481b953c27","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1cfd3091a071d8b6feec15277643bafe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1da2c1f258970fd3cc91184f69e91a9d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a0d87491913d843139e0c993650a3235","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4ef72aa378127e7b7abba915b0110b1e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3ec74c6a7d4463f0254db3a74cf75646","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"84c2bdfa470d075526cce6322d81b0b6","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0b3844c2b8c73e4e1ab91431411cad11","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4fc71cf4a15b8d99675a31df77f26e07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d1b49564ddaeca3df5b6dbae925d2242","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6a25be566d60ccfc2d6e8b7bfdeefa83","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8a20e27646985dfd58c57ca6566553dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9969f02ad3cdcbf4f709405cda44167f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9c9be4792a7a4f42c15ae7360bf28779","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8cf777fe00349b71ee9c4b6f3fe7fd19","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"74f96bc192530c9723f572bfff3d3078","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1df91c56b25955c56387426f378173c5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"38856f70edcd2115c355d96ec77cc09e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"de8700156c1275465bcd473c28b359aa","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d47cfdb6ede40518357bb5a4cd7cd9fb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6e5773860cd9e5b15e683113f642ab47","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"30ff5fe1682f7fcd629880476ca3c2e0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf23d7d1b40b9015b694ddc2f011752f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2cc585d42e2c548f9f24a30a1989fd33","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"713906ce9d332d2242b7f05ed9304be3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0219894bfe5042c7e1aa2d22e4a91ed0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6009ffff7e43c93318804d2d28e37fe3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"03be89b227587594fbb50509fc1c2e45","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b30df52dc24740c0bad7c55c3511df7d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ab8d3c9b5ed5c2ab8f383607eef439f0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d950ec671d0a8e07f3c1a31e94abed86","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1abef2ace5eccb02d60dd73cd5a5ee4c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f5f0a3044029d1cc081b5887eb4deb07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d57c697f1446940ec4bfe669c962e2c4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"be41035d7b941482a1e1ae6a5c5dcca5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"10f7d9da7564f27f8ddf4a162b6da6d3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1d0520af549e0c3581f15173cc713ca1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d65083f97fd741cff028472563eddb79","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"da7f24f00653ebac660ac1c0821ed33d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7cb5ae9e65516ea2235f0721f6aac43c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f64453cbf9671f28158677fa5c43967a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"33f317af5428801f944a478d2c1e38e5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1f9398f3eec050714be4f9b1c3a2317d","signature":"510b0b622fafd6eff2bf5d020de046ee","impliedNodeFormat":1},{"version":"416eeb96c107bd2015080f4249d3ee38","signature":"ae63a2414b6a326b93ee65bba693d617","impliedNodeFormat":1},{"version":"09feabedf70ed610ed9ea0425e1f97e4","signature":"57845437bcd4011990eb52478f02c4a0","impliedNodeFormat":1},{"version":"36194741ebb41739843db9a2ee86ca6f","signature":"f25290e9ca5aee09a0210e2a454437f8","impliedNodeFormat":1},{"version":"3575b2b8e50b5a5b3acce219e08900c5","impliedNodeFormat":99},{"version":"ba148a7a8b1b345b82e2255648d7a2a0","impliedNodeFormat":99},{"version":"79de825e280a92f200bf8ab73df74aaa","signature":"968dbf07ccc13a1a84f319c26e9909b3","impliedNodeFormat":1},{"version":"cbe2ad0843a3b4397021171b675d91e2","signature":"e78cf9dc5bca6011a220581f56da19cb","impliedNodeFormat":1},{"version":"436d7d9cea8d7f3e41e2ea50138ad4da","impliedNodeFormat":99},{"version":"6341abc9e164a58cd4faf7db00c2125e","signature":"25aba7d58ecafcf7098f9bcca63ea72a","impliedNodeFormat":1},{"version":"1f637dbc1f68ca19c0568ac3979a5a59","signature":"354fc88481ff608fcbbfaf7851a29043","impliedNodeFormat":1},{"version":"8c8e53d56beef78deb845941070bc387","signature":"3058c9c4ad1200a2ff62094072deed53","impliedNodeFormat":1},{"version":"72d344412c308ce31e59dd6752f5abca","signature":"bf6d579deb9596ec514083ea94789be0","impliedNodeFormat":1},"e5fb7990b84f5089ba92554ea3614810","770ee32ef332fd48bfef508442b30edb","5c1b5931ee0c894699ca56f5b573f88a","822b842ad7efa3485d65fbeb2f919865","89b6053090a8d01f57cb8f521fae777d","26302a8b72d74f944dcf8f6452e54f7c","bc95bdb594a5aece18248fbf4387dd2e","90125a76f2ae701181f7e09dea41f3ad","ac52bb76ccad935a013384d2a71ab267","2c96eeb69afb823580d4e1e5f1b188e0","c06213bcb24cd658dfcd1239777159bd",{"version":"787551f4ccf1ea187c97a6fef4a2b502","signature":"ada7f0921b6eace272ee48028595ff4e","impliedNodeFormat":1},{"version":"67323509d98791c2e9287e7b9c86c8f1","signature":"e518fcc525a72f156f4235f97e942e72","impliedNodeFormat":1},{"version":"2f588b7565009cf660e49f19128363d2","signature":"cf3121ca4479d3afdaceb690d14cf086","impliedNodeFormat":1},{"version":"4b2dcd692e0308ac4cee04202b63a5c0","signature":"d33a7d16b8bb10392237228466f959f8","impliedNodeFormat":1},"e2bb800214278396da6f4dfb9210a507",{"version":"01cb6d1d819779d9823af5890a75765a","signature":"c0cbc64b7a419382086b8d30226b8f0f","impliedNodeFormat":1},{"version":"2e3387bb780ecbc47d2cf0715f0a3d5b","signature":"bb9d86257bed6b06d027b9b561ba2c31","impliedNodeFormat":1},{"version":"e9ceb16586d83746a56dfefc8f72a4e4","signature":"ddac5ec2816a79b75ca0b28b073126c9","impliedNodeFormat":1},{"version":"ca57df7a021dd9e60b50a86359328369","signature":"e62a96adf38e2e5adbeb996a1bbb0ca6","impliedNodeFormat":1},{"version":"89c28146623ca911251a5a7c0aef31da","signature":"358284d17020fff7c8988fe49465ebce","impliedNodeFormat":1},{"version":"8585c59b42a4515d919ae67b1871b611","signature":"788ca99c9132de5f347c0c196085cc16","impliedNodeFormat":1},{"version":"f9b746229b5805be47a5e729cd0882b9","signature":"74a85c95eb3b8b1bd5c7d0822fe65312","impliedNodeFormat":1},{"version":"42149341c32f9a8c00c6c6b7f916c138","signature":"f85883c070822e429d13802a651146bc","impliedNodeFormat":1},{"version":"e5172b410a188df0e6366797579dc23a","signature":"038c82b1bfec7b11761d58241d68970f","impliedNodeFormat":1},{"version":"43287bfa29ccc772782a499966bf000e","signature":"fa4b9cdace3ba0abd1e6547b87390de6","impliedNodeFormat":1},{"version":"6aa5192b4406661ffde74ffdbeaf42c5","signature":"b5fa992ef592b85d4851433a12195162","impliedNodeFormat":1},{"version":"ee144db1b2a390284f2301277a4769d0","signature":"6844f7dcecd5297f9a25fe55fe7aeacc","impliedNodeFormat":1},{"version":"e8e9d0b6b6e01ab0a9a3b771fca4b37b","signature":"90506d77482148f93c56044616613958","impliedNodeFormat":1},{"version":"b0ffa465ccd4d217e0b238fd935d8127","signature":"3a5ea1baf065ad0e1794aeb15153114c","impliedNodeFormat":1}],"fileIdsList":[[93],[114,117,118],[114,117],[93,94,96,97],[112,117],[113,117],[112,114,117,118],[114,117,118,121],[114,120,121,122,123,124,125,126,127],[117,118,122],[112,113,114,117,118],[113,114,117,118],[117,119,121,122,123,125,126],[96,98,113,117,118,119,128,129,130],[89],[89,92,93,94,95,96,98],[89,100],[89,90,91,92,95,99,100,101,115,116],[89,114],[117,119,128],[89,95,99,101],[112],[103],[103,107],[102],[102,103,104,105,106,107,108,109,110,111]],"options":{"composite":true,"declaration":true,"declarationDir":"./@types","inlineSources":true,"module":199,"outDir":"./","rootDir":"../src","skipLibCheck":true,"strict":false,"stripInternal":true,"sourceMap":true,"target":4,"tsBuildInfoFile":"./tsconfig.tsbuildinfo","esModuleInterop":true},"referencedMap":[[97,1],[94,1],[119,2],[118,3],[98,4],[113,5],[114,6],[121,2],[120,2],[124,7],[125,8],[128,9],[123,10],[122,11],[126,12],[127,13],[131,14],[90,15],[91,15],[95,15],[100,15],[99,16],[101,17],[117,18],[115,19],[92,15],[129,20],[116,21],[130,22],[105,23],[111,24],[110,24],[109,24],[104,23],[107,23],[108,24],[103,25],[106,23],[112,26]],"latestChangedDtsFile":"./@types/index.d.ts"}
1
+ {"version":"7.0.2","root":[[89,90],[102,105],[108,109],[111,129]],"packageJsons":["../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/package.json","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/package.json","../../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/package.json","../package.json","../../type-system/package.json"],"missingPackageJsons":["../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/lib/package.json","../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/node_modules/@babel/types/package.json","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/lib/package.json","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/node_modules/@babel/types/package.json","../../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/lib/package.json"],"fileNames":["lib.es5.d.ts","lib.es2015.d.ts","lib.es2016.d.ts","lib.es2017.d.ts","lib.es2018.d.ts","lib.es2019.d.ts","lib.es2020.d.ts","lib.es2021.d.ts","lib.es2022.d.ts","lib.es2023.d.ts","lib.es2024.d.ts","lib.es2025.d.ts","lib.esnext.d.ts","lib.dom.d.ts","lib.es2015.core.d.ts","lib.es2015.collection.d.ts","lib.es2015.generator.d.ts","lib.es2015.iterable.d.ts","lib.es2015.promise.d.ts","lib.es2015.proxy.d.ts","lib.es2015.reflect.d.ts","lib.es2015.symbol.d.ts","lib.es2015.symbol.wellknown.d.ts","lib.es2016.array.include.d.ts","lib.es2016.intl.d.ts","lib.es2017.arraybuffer.d.ts","lib.es2017.date.d.ts","lib.es2017.object.d.ts","lib.es2017.sharedmemory.d.ts","lib.es2017.string.d.ts","lib.es2017.intl.d.ts","lib.es2017.typedarrays.d.ts","lib.es2018.asyncgenerator.d.ts","lib.es2018.asynciterable.d.ts","lib.es2018.intl.d.ts","lib.es2018.promise.d.ts","lib.es2018.regexp.d.ts","lib.es2019.array.d.ts","lib.es2019.object.d.ts","lib.es2019.string.d.ts","lib.es2019.symbol.d.ts","lib.es2019.intl.d.ts","lib.es2020.bigint.d.ts","lib.es2020.date.d.ts","lib.es2020.promise.d.ts","lib.es2020.sharedmemory.d.ts","lib.es2020.string.d.ts","lib.es2020.symbol.wellknown.d.ts","lib.es2020.intl.d.ts","lib.es2020.number.d.ts","lib.es2021.promise.d.ts","lib.es2021.string.d.ts","lib.es2021.weakref.d.ts","lib.es2021.intl.d.ts","lib.es2022.array.d.ts","lib.es2022.error.d.ts","lib.es2022.intl.d.ts","lib.es2022.object.d.ts","lib.es2022.string.d.ts","lib.es2022.regexp.d.ts","lib.es2023.array.d.ts","lib.es2023.collection.d.ts","lib.es2023.intl.d.ts","lib.es2024.arraybuffer.d.ts","lib.es2024.collection.d.ts","lib.es2024.object.d.ts","lib.es2024.promise.d.ts","lib.es2024.regexp.d.ts","lib.es2024.sharedmemory.d.ts","lib.es2024.string.d.ts","lib.es2025.collection.d.ts","lib.es2025.float16.d.ts","lib.es2025.intl.d.ts","lib.es2025.iterator.d.ts","lib.es2025.promise.d.ts","lib.es2025.regexp.d.ts","lib.esnext.array.d.ts","lib.esnext.collection.d.ts","lib.esnext.date.d.ts","lib.esnext.decorators.d.ts","lib.esnext.disposable.d.ts","lib.esnext.error.d.ts","lib.esnext.intl.d.ts","lib.esnext.sharedmemory.d.ts","lib.esnext.temporal.d.ts","lib.esnext.typedarrays.d.ts","lib.decorators.d.ts","lib.decorators.legacy.d.ts","../src/tokens/AbstractToken.ts","../src/tokens/code/CodeToken.ts","../../type-system/dist/@types/Formatter.d.ts","../../type-system/dist/@types/Type.d.ts","../../type-system/dist/@types/ObjectType.d.ts","../../type-system/dist/@types/ArrayType.d.ts","../../type-system/dist/@types/UnknownType.d.ts","../../type-system/dist/@types/ScalarType.d.ts","../../type-system/dist/@types/TextType.d.ts","../../type-system/dist/@types/NumberType.d.ts","../../type-system/dist/@types/IntegerType.d.ts","../../type-system/dist/@types/BooleanType.d.ts","../../type-system/dist/@types/index.d.ts","../src/definitions/ValidationContext.ts","../src/expressions/AbstractExpression.ts","../src/ExpressionParser.ts","../src/CombinedParser.ts","../../../node_modules/.pnpm/@babel+types@8.0.6/node_modules/@babel/types/lib/index.d.ts","../../../node_modules/.pnpm/@babel+traverse@8.0.7/node_modules/@babel/traverse/lib/index.d.ts","../src/tokens/text/TextToken.ts","../src/code-parsers/CodeParser.ts","../../../node_modules/.pnpm/@babel+parser@8.0.7/node_modules/@babel/parser/lib/index.d.ts","../src/code-parsers/JavaScriptParser.ts","../src/tokens/code/JSToken.ts","../src/tokens/code/IdentifierToken.ts","../src/tokens/code/PrefixToken.ts","../src/utils/tokenUtils.ts","../src/expressions/EvaluatedExpression.ts","../src/expressions/constant/ConstantExpression.ts","../src/expressions/shorthand/ShorthandExpression.ts","../src/expressions/shorthand/FormatShorthandExpression.ts","../src/expressions/function/FunctionExpression.ts","../src/utils/parserUtils.ts","../src/utils/valueFormatting.ts","../src/tokens/DelimiterToken.ts","../src/expressions/ListExpression.ts","../src/tokens/text/PlaceholderToken.ts","../src/expressions/text/AbstractFormatExpression.ts","../src/expressions/text/FormatStringExpression.ts","../src/tokens/EnumToken.ts","../src/index.ts"],"fileInfos":[{"version":"16934abaab7026ac114da441aabea1a0","affectsGlobalScope":true,"impliedNodeFormat":1},"d4306fb2e47f74835e8674ffac07d76f","e437c5c1302869326c3bb93da85bbbcf","e4324975a566567b21d350615f1fc6ac","333b1b9a2a9ac3b8497dba5c63b5ba50","6cffacd662b6eb5fa7a36aa2ea366bfa","b4c34f9c23304dbef2d23698637ed638","e5cb86a5fc491796ecd1d2dd348d208f","feb6c6fb19cdb246a5d8acb36a6901c7","9443a7f109277ffaa79d893ed2549995","793cee405385076e27c24f409659dccd","09f69c6610266eaee1ac9e3e30df2c71","62bad718844246b8e17547f37bad6085",{"version":"aae8996e8b5684814785a42cbbefcd79","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"926204c28cd3d073865348473ae28d2e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f25e42c801b2cb3cf2b39792006a9beb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6344b55f26a4e81d9608777dbfb877dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3c0ed28e53d3695b363e256ec1c023fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4c2761daba7f17141c25baa0821ac5da","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b87656acabd63e69379ff6ffcfe52fc7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"597469522da047a5af5222cc6989f405","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1708ea4d34dc37fadadc63ca01127e80","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"55d97a8c6fbf34a30450a7b1e5f7a298","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0ee05eb59426d33e374226d8dcfa708b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e347c14030993906efcfbb88915b6a05","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b0231263857c9b6a03641acdc9280ceb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3b15c4a83b598cacb4067676e6f0abed","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b417d97b7934cef63b1889abec0bbfbf","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"09a6cf4032ebba60ce22a501e663f881","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2b056277dd138e8f5650fc04e20eaa8d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"e22cc07e3f3cc242ba52fa3f8ea1fc58","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2c45da767a1bfbb220848df1bc4029e4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b44c3e0fbaf2130cdcf6ac38b120ffa1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b612fb5cf8e5d964b92063a75207632a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"02705151a5e1551b9162a9ed8ab763f7","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"41025e398be9215d32e4337335da8f0b","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"52684c2b1f353a5538e4f275182a54cd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6dedb6a4f90d1df3a6fbe5693e44886c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ca3f36fe3562c07e0f0d71c2bebd3f6d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"409974d6129befbb8226ddd1c6558568","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4d9cfde2a1ae1b4925f1f9bc10848e5d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7e1daecc66dd564144e3bb1a0266b5fd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a8e1d9bb35fd0637f2f9fd2b2a54f2ec","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4f168501772a6543182765bfd5f2fbfe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19c80aad1b2162103496f5ba293a732","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b69afa63cd5d059851c78adb2856ee09","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ae2fc5d954e9b0f5feee3d481b953c27","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1cfd3091a071d8b6feec15277643bafe","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1da2c1f258970fd3cc91184f69e91a9d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a0d87491913d843139e0c993650a3235","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4ef72aa378127e7b7abba915b0110b1e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"3ec74c6a7d4463f0254db3a74cf75646","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"84c2bdfa470d075526cce6322d81b0b6","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0b3844c2b8c73e4e1ab91431411cad11","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"4fc71cf4a15b8d99675a31df77f26e07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d1b49564ddaeca3df5b6dbae925d2242","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6a25be566d60ccfc2d6e8b7bfdeefa83","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8a20e27646985dfd58c57ca6566553dd","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9969f02ad3cdcbf4f709405cda44167f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"9c9be4792a7a4f42c15ae7360bf28779","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"8cf777fe00349b71ee9c4b6f3fe7fd19","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"74f96bc192530c9723f572bfff3d3078","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1df91c56b25955c56387426f378173c5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"38856f70edcd2115c355d96ec77cc09e","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"de8700156c1275465bcd473c28b359aa","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d47cfdb6ede40518357bb5a4cd7cd9fb","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6e5773860cd9e5b15e683113f642ab47","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"30ff5fe1682f7fcd629880476ca3c2e0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"bf23d7d1b40b9015b694ddc2f011752f","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"2cc585d42e2c548f9f24a30a1989fd33","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"713906ce9d332d2242b7f05ed9304be3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"0219894bfe5042c7e1aa2d22e4a91ed0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"6009ffff7e43c93318804d2d28e37fe3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"03be89b227587594fbb50509fc1c2e45","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"b30df52dc24740c0bad7c55c3511df7d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"ab8d3c9b5ed5c2ab8f383607eef439f0","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d950ec671d0a8e07f3c1a31e94abed86","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1abef2ace5eccb02d60dd73cd5a5ee4c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f5f0a3044029d1cc081b5887eb4deb07","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d57c697f1446940ec4bfe669c962e2c4","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"be41035d7b941482a1e1ae6a5c5dcca5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"10f7d9da7564f27f8ddf4a162b6da6d3","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1d0520af549e0c3581f15173cc713ca1","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"d65083f97fd741cff028472563eddb79","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"da7f24f00653ebac660ac1c0821ed33d","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"7cb5ae9e65516ea2235f0721f6aac43c","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"f64453cbf9671f28158677fa5c43967a","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"33f317af5428801f944a478d2c1e38e5","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"1f9398f3eec050714be4f9b1c3a2317d","signature":"510b0b622fafd6eff2bf5d020de046ee","impliedNodeFormat":1},{"version":"79de825e280a92f200bf8ab73df74aaa","signature":"968dbf07ccc13a1a84f319c26e9909b3","impliedNodeFormat":1},"e5fb7990b84f5089ba92554ea3614810","770ee32ef332fd48bfef508442b30edb","5c1b5931ee0c894699ca56f5b573f88a","822b842ad7efa3485d65fbeb2f919865","89b6053090a8d01f57cb8f521fae777d","26302a8b72d74f944dcf8f6452e54f7c","bc95bdb594a5aece18248fbf4387dd2e","90125a76f2ae701181f7e09dea41f3ad","ac52bb76ccad935a013384d2a71ab267","2c96eeb69afb823580d4e1e5f1b188e0","c06213bcb24cd658dfcd1239777159bd",{"version":"3d6cee06532f3e1ef9fc29d5fe956ff5","signature":"84519ebe510a4219ef71e5a0a973c591","impliedNodeFormat":1},{"version":"640db1f77b2da18d43b76ffabce559a9","signature":"0c68f6d853b53c3d34189f5c99c4b624","impliedNodeFormat":1},{"version":"155b9d6b514ed17bdf5948ab5b0f65cf","signature":"18408a4ba98e42e70324ba5c0b71f379","impliedNodeFormat":1},{"version":"20aa964875521a143a6b38455b528b74","signature":"d6ca1e855d5b6554555a009a40e806a2","impliedNodeFormat":1},{"version":"3575b2b8e50b5a5b3acce219e08900c5","impliedNodeFormat":99},{"version":"ba148a7a8b1b345b82e2255648d7a2a0","impliedNodeFormat":99},{"version":"36194741ebb41739843db9a2ee86ca6f","signature":"f25290e9ca5aee09a0210e2a454437f8","impliedNodeFormat":1},{"version":"cbe2ad0843a3b4397021171b675d91e2","signature":"e78cf9dc5bca6011a220581f56da19cb","impliedNodeFormat":1},{"version":"436d7d9cea8d7f3e41e2ea50138ad4da","impliedNodeFormat":99},{"version":"6341abc9e164a58cd4faf7db00c2125e","signature":"25aba7d58ecafcf7098f9bcca63ea72a","impliedNodeFormat":1},{"version":"1f637dbc1f68ca19c0568ac3979a5a59","signature":"354fc88481ff608fcbbfaf7851a29043","impliedNodeFormat":1},{"version":"8c8e53d56beef78deb845941070bc387","signature":"3058c9c4ad1200a2ff62094072deed53","impliedNodeFormat":1},{"version":"72d344412c308ce31e59dd6752f5abca","signature":"bf6d579deb9596ec514083ea94789be0","impliedNodeFormat":1},{"version":"4b2dcd692e0308ac4cee04202b63a5c0","signature":"d33a7d16b8bb10392237228466f959f8","impliedNodeFormat":1},{"version":"f3e07630161c6300fd4cf880bdab3fc3","signature":"cc36a10654ee721a890569de343ee4a0","impliedNodeFormat":1},{"version":"64fec2dff04aac9bd06613fd1896637e","signature":"c3b9b5f9be217e9fabbfc9f5b48da439","impliedNodeFormat":1},{"version":"5ff38488838238777aa56346a29f7f4a","signature":"81bde6b904e09fb337a80f52526d0c49","impliedNodeFormat":1},{"version":"49525dcd83e110eceea010cecebb179f","signature":"61b4c95d7a2ba531a5faae6b4e0694f1","impliedNodeFormat":1},{"version":"982a7904a33ce1cdfa35429f420cd65c","signature":"be6a700c7b2a3007e5ff5eccccd1e6ca","impliedNodeFormat":1},{"version":"5dc06e0d4f3ebe90cd0cedb894c16f36","signature":"92d25cb01f547225fee7d19311179220","impliedNodeFormat":1},{"version":"e8e9d0b6b6e01ab0a9a3b771fca4b37b","signature":"90506d77482148f93c56044616613958","impliedNodeFormat":1},{"version":"416eeb96c107bd2015080f4249d3ee38","signature":"ae63a2414b6a326b93ee65bba693d617","impliedNodeFormat":1},{"version":"575ffd304e1f4e1210b79571bfcc1ad8","signature":"0b41d778150d6774bc72b9e36a6c409f","impliedNodeFormat":1},{"version":"2f588b7565009cf660e49f19128363d2","signature":"cf3121ca4479d3afdaceb690d14cf086","impliedNodeFormat":1},{"version":"2fedba8910cc4596445d6e387abf7d19","signature":"c115de0a80c101e99244da31e79527d1","impliedNodeFormat":1},{"version":"9de65f540c5986bb7e0fe983bc5b25d0","signature":"cabc47d72ba300dd603c14a7bb2b7cde","impliedNodeFormat":1},{"version":"09feabedf70ed610ed9ea0425e1f97e4","signature":"57845437bcd4011990eb52478f02c4a0","impliedNodeFormat":1},{"version":"ea42ca69ffe874ebf9d6b022eaa58b87","signature":"4678acee57e4a32f080f3a53600abf18","impliedNodeFormat":1}],"fileIdsList":[[106],[89,103,104],[89,103],[106,107,109,110],[90,101],[89,102],[89,90,103,104,108,112,114,115],[89,103,104,123],[89,101,103,104,108,115],[89,90,103,104,116],[89,104,108,115,118],[89,90,101,102,103,104,112,115],[89,102,103,104,108,125],[89,105,116,118,119,120,126],[89,90,102,103,104,105,108,109,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128],[89],[89,90,106,107,108,109,111],[89,113],[89,103,105,116,117,118,119,120],[89,90,112,114],[101],[92],[92,96],[91],[91,92,93,94,95,96,97,98,99,100]],"options":{"composite":true,"declaration":true,"declarationDir":"./@types","inlineSources":true,"module":199,"outDir":"./","rootDir":"../src","skipLibCheck":true,"strict":false,"stripInternal":true,"sourceMap":true,"target":4,"tsBuildInfoFile":"./tsconfig.tsbuildinfo","esModuleInterop":true},"referencedMap":[[110,1],[107,1],[105,2],[104,3],[111,4],[102,5],[103,6],[116,7],[124,8],[117,9],[120,10],[119,11],[118,12],[126,13],[127,14],[129,15],[123,16],[128,16],[90,16],[113,16],[112,17],[114,18],[125,3],[108,16],[121,19],[115,20],[122,21],[94,22],[100,23],[99,23],[98,23],[93,22],[96,22],[97,23],[92,24],[95,22],[101,25]],"latestChangedDtsFile":"./@types/index.d.ts"}
@@ -2,18 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseExpression = parseExpression;
4
4
  const CombinedParser_1 = require("../CombinedParser");
5
- const expressions_1 = require("../expressions");
5
+ const EvaluatedExpression_1 = require("../expressions/EvaluatedExpression");
6
+ const ConstantExpression_1 = require("../expressions/constant/ConstantExpression");
7
+ const FormatShorthandExpression_1 = require("../expressions/shorthand/FormatShorthandExpression");
8
+ const FunctionExpression_1 = require("../expressions/function/FunctionExpression");
9
+ const ShorthandExpression_1 = require("../expressions/shorthand/ShorthandExpression");
6
10
  /**
7
11
  * Recognize evaluated code and references before preserving remaining input as constant text.
8
12
  * Callers can compose their own parser order instead.
9
13
  */
10
14
  function parseExpression(source, start = 0) {
11
15
  return new CombinedParser_1.CombinedParser([
12
- new expressions_1.FunctionExpressionParser(),
13
- new expressions_1.EvaluatedExpressionParser(),
14
- new expressions_1.FormatShorthandExpressionParser(),
15
- new expressions_1.ShorthandExpressionParser(),
16
- new expressions_1.ConstantExpressionParser()
16
+ new FunctionExpression_1.FunctionExpressionParser(),
17
+ new EvaluatedExpression_1.EvaluatedExpressionParser(),
18
+ new FormatShorthandExpression_1.FormatShorthandExpressionParser(),
19
+ new ShorthandExpression_1.ShorthandExpressionParser(),
20
+ new ConstantExpression_1.ConstantExpressionParser()
17
21
  ]).tryParse(source, start);
18
22
  }
19
23
  //# sourceMappingURL=parserUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"parserUtils.js","sourceRoot":"","sources":["../../src/utils/parserUtils.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AACnD,gDAOwB;AAGxB;;;GAGG;AACH,yBAAgC,MAAwB,EAAE,KAAK,GAAG,CAAC;IACjE,OAAO,IAAI,+BAAc,CAAqB;QAC5C,IAAI,sCAAwB,EAAE;QAC9B,IAAI,uCAAyB,EAAE;QAC/B,IAAI,6CAA+B,EAAE;QACrC,IAAI,uCAAyB,EAAE;QAC/B,IAAI,sCAAwB,EAAE;KAC/B,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { CombinedParser } from '../CombinedParser';\nimport {\n AbstractExpression,\n EvaluatedExpressionParser,\n ConstantExpressionParser,\n FormatShorthandExpressionParser,\n FunctionExpressionParser,\n ShorthandExpressionParser\n} from '../expressions';\nimport { ExpressionSource } from '../tokens';\n\n/**\n * Recognize evaluated code and references before preserving remaining input as constant text.\n * Callers can compose their own parser order instead.\n */\nexport function parseExpression(source: ExpressionSource, start = 0): AbstractExpression | null {\n return new CombinedParser<AbstractExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new FormatShorthandExpressionParser(),\n new ShorthandExpressionParser(),\n new ConstantExpressionParser()\n ]).tryParse(source, start);\n}\n"]}
1
+ {"version":3,"file":"parserUtils.js","sourceRoot":"","sources":["../../src/utils/parserUtils.ts"],"names":[],"mappings":";;;AAAA,sDAAmD;AAEnD,4EAA+E;AAC/E,mFAAsF;AACtF,kGAAqG;AACrG,mFAAsF;AACtF,sFAAyF;AAGzF;;;GAGG;AACH,yBAAgC,MAAwB,EAAE,KAAK,GAAG,CAAC;IACjE,OAAO,IAAI,+BAAc,CAAqB;QAC5C,IAAI,6CAAwB,EAAE;QAC9B,IAAI,+CAAyB,EAAE;QAC/B,IAAI,2DAA+B,EAAE;QACrC,IAAI,+CAAyB,EAAE;QAC/B,IAAI,6CAAwB,EAAE;KAC/B,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["import { CombinedParser } from '../CombinedParser';\nimport { AbstractExpression } from '../expressions/AbstractExpression';\nimport { EvaluatedExpressionParser } from '../expressions/EvaluatedExpression';\nimport { ConstantExpressionParser } from '../expressions/constant/ConstantExpression';\nimport { FormatShorthandExpressionParser } from '../expressions/shorthand/FormatShorthandExpression';\nimport { FunctionExpressionParser } from '../expressions/function/FunctionExpression';\nimport { ShorthandExpressionParser } from '../expressions/shorthand/ShorthandExpression';\nimport { ExpressionSource } from '../tokens/AbstractToken';\n\n/**\n * Recognize evaluated code and references before preserving remaining input as constant text.\n * Callers can compose their own parser order instead.\n */\nexport function parseExpression(source: ExpressionSource, start = 0): AbstractExpression | null {\n return new CombinedParser<AbstractExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new FormatShorthandExpressionParser(),\n new ShorthandExpressionParser(),\n new ConstantExpressionParser()\n ]).tryParse(source, start);\n}\n"]}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "engines": {
4
4
  "node": "^22.19.0 || ^24.11.0 || >=26.0.0"
5
5
  },
6
- "version": "0.0.0-dev-20261021200117",
6
+ "version": "0.0.0-dev-20261021213526",
7
7
  "description": "JourneyApps Platform expression parsing, representation and reference analysis",
8
8
  "main": "./dist/index.js",
9
9
  "typings": "./dist/@types/index.d.ts",
@@ -14,7 +14,7 @@
14
14
  "@babel/parser": "^8.0.7",
15
15
  "@babel/traverse": "^8.0.7",
16
16
  "@babel/types": "^8.0.6",
17
- "@ja-platform/parser-type-system": "0.0.0-dev-20261021200117"
17
+ "@ja-platform/parser-type-system": "0.0.0-dev-20261021213526"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@types/babel__traverse": "^7.28.0",
@@ -1,9 +0,0 @@
1
- export * from './AbstractExpression';
2
- export * from './ListExpression';
3
- export * from './EvaluatedExpression';
4
- export * from './shorthand/ShorthandExpression';
5
- export * from './shorthand/FormatShorthandExpression';
6
- export * from './constant/ConstantExpression';
7
- export * from './function/FunctionExpression';
8
- export * from './text/FormatStringExpression';
9
- export * from './text/AbstractFormatExpression';
@@ -1,10 +0,0 @@
1
- export * from './AbstractToken';
2
- export * from './DelimiterToken';
3
- export * from './EnumToken';
4
- export * from './text/TextToken';
5
- export * from './code/JSToken';
6
- export * from './code/PrefixToken';
7
- export * from './code/IdentifierToken';
8
- export * from './text/PlaceholderToken';
9
- export * from './code/CodeToken';
10
- export { stringify, codeToken, javascriptToken, hasFunctionPrefix, leadingTrivia } from '../utils/tokenUtils';
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./AbstractExpression"), exports);
18
- __exportStar(require("./ListExpression"), exports);
19
- __exportStar(require("./EvaluatedExpression"), exports);
20
- __exportStar(require("./shorthand/ShorthandExpression"), exports);
21
- __exportStar(require("./shorthand/FormatShorthandExpression"), exports);
22
- __exportStar(require("./constant/ConstantExpression"), exports);
23
- __exportStar(require("./function/FunctionExpression"), exports);
24
- __exportStar(require("./text/FormatStringExpression"), exports);
25
- __exportStar(require("./text/AbstractFormatExpression"), exports);
26
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/expressions/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,mDAAiC;AAEjC,wDAAsC;AAEtC,kEAAgD;AAChD,wEAAsD;AAEtD,gEAA8C;AAE9C,gEAA8C;AAE9C,gEAA8C;AAE9C,kEAAgD","sourcesContent":["export * from './AbstractExpression';\nexport * from './ListExpression';\n\nexport * from './EvaluatedExpression';\n\nexport * from './shorthand/ShorthandExpression';\nexport * from './shorthand/FormatShorthandExpression';\n\nexport * from './constant/ConstantExpression';\n\nexport * from './function/FunctionExpression';\n\nexport * from './text/FormatStringExpression';\n\nexport * from './text/AbstractFormatExpression';\n"]}
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.leadingTrivia = exports.hasFunctionPrefix = exports.javascriptToken = exports.codeToken = exports.stringify = void 0;
18
- __exportStar(require("./AbstractToken"), exports);
19
- __exportStar(require("./DelimiterToken"), exports);
20
- __exportStar(require("./EnumToken"), exports);
21
- __exportStar(require("./text/TextToken"), exports);
22
- __exportStar(require("./code/JSToken"), exports);
23
- __exportStar(require("./code/PrefixToken"), exports);
24
- __exportStar(require("./code/IdentifierToken"), exports);
25
- __exportStar(require("./text/PlaceholderToken"), exports);
26
- __exportStar(require("./code/CodeToken"), exports);
27
- var tokenUtils_1 = require("../utils/tokenUtils");
28
- Object.defineProperty(exports, "stringify", { enumerable: true, get: function () { return tokenUtils_1.stringify; } });
29
- Object.defineProperty(exports, "codeToken", { enumerable: true, get: function () { return tokenUtils_1.codeToken; } });
30
- Object.defineProperty(exports, "javascriptToken", { enumerable: true, get: function () { return tokenUtils_1.javascriptToken; } });
31
- Object.defineProperty(exports, "hasFunctionPrefix", { enumerable: true, get: function () { return tokenUtils_1.hasFunctionPrefix; } });
32
- Object.defineProperty(exports, "leadingTrivia", { enumerable: true, get: function () { return tokenUtils_1.leadingTrivia; } });
33
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tokens/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,mDAAiC;AACjC,8CAA4B;AAC5B,mDAAiC;AACjC,iDAA+B;AAC/B,qDAAmC;AACnC,yDAAuC;AACvC,0DAAwC;AACxC,mDAAiC;AACjC,kDAA8G;AAArG,uGAAA,SAAS,OAAA;AAAE,uGAAA,SAAS,OAAA;AAAE,6GAAA,eAAe,OAAA;AAAE,+GAAA,iBAAiB,OAAA;AAAE,2GAAA,aAAa,OAAA","sourcesContent":["export * from './AbstractToken';\nexport * from './DelimiterToken';\nexport * from './EnumToken';\nexport * from './text/TextToken';\nexport * from './code/JSToken';\nexport * from './code/PrefixToken';\nexport * from './code/IdentifierToken';\nexport * from './text/PlaceholderToken';\nexport * from './code/CodeToken';\nexport { stringify, codeToken, javascriptToken, hasFunctionPrefix, leadingTrivia } from '../utils/tokenUtils';\n"]}