@ja-platform/parser-expressions 0.0.0-dev-20261019214152 → 0.0.0-stage

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 (81) hide show
  1. package/README.md +2 -111
  2. package/package.json +3 -37
  3. package/dist/@types/CombinedParser.d.ts +0 -11
  4. package/dist/@types/ExpressionParser.d.ts +0 -12
  5. package/dist/@types/code-parsers/CodeParser.d.ts +0 -25
  6. package/dist/@types/code-parsers/JavaScriptParser.d.ts +0 -18
  7. package/dist/@types/definitions/ValidationContext.d.ts +0 -8
  8. package/dist/@types/expressions/AbstractExpression.d.ts +0 -42
  9. package/dist/@types/expressions/EvaluatedExpression.d.ts +0 -34
  10. package/dist/@types/expressions/constant/ConstantExpression.d.ts +0 -28
  11. package/dist/@types/expressions/function/FunctionExpression.d.ts +0 -37
  12. package/dist/@types/expressions/index.d.ts +0 -8
  13. package/dist/@types/expressions/shorthand/FormatShorthandExpression.d.ts +0 -31
  14. package/dist/@types/expressions/shorthand/ShorthandExpression.d.ts +0 -42
  15. package/dist/@types/expressions/text/AbstractFormatExpression.d.ts +0 -43
  16. package/dist/@types/expressions/text/FormatStringExpression.d.ts +0 -18
  17. package/dist/@types/index.d.ts +0 -9
  18. package/dist/@types/tokens/AbstractToken.d.ts +0 -12
  19. package/dist/@types/tokens/code/CodeToken.d.ts +0 -142
  20. package/dist/@types/tokens/code/IdentifierToken.d.ts +0 -12
  21. package/dist/@types/tokens/code/JSToken.d.ts +0 -31
  22. package/dist/@types/tokens/code/PrefixToken.d.ts +0 -9
  23. package/dist/@types/tokens/index.d.ts +0 -8
  24. package/dist/@types/tokens/text/PlaceholderToken.d.ts +0 -12
  25. package/dist/@types/tokens/text/TextToken.d.ts +0 -12
  26. package/dist/@types/utils/parserUtils.d.ts +0 -7
  27. package/dist/@types/utils/tokenUtils.d.ts +0 -11
  28. package/dist/@types/utils/valueFormatting.d.ts +0 -9
  29. package/dist/CombinedParser.js +0 -24
  30. package/dist/CombinedParser.js.map +0 -1
  31. package/dist/ExpressionParser.js +0 -20
  32. package/dist/ExpressionParser.js.map +0 -1
  33. package/dist/code-parsers/CodeParser.js +0 -45
  34. package/dist/code-parsers/CodeParser.js.map +0 -1
  35. package/dist/code-parsers/JavaScriptParser.js +0 -56
  36. package/dist/code-parsers/JavaScriptParser.js.map +0 -1
  37. package/dist/definitions/ValidationContext.js +0 -3
  38. package/dist/definitions/ValidationContext.js.map +0 -1
  39. package/dist/expressions/AbstractExpression.js +0 -47
  40. package/dist/expressions/AbstractExpression.js.map +0 -1
  41. package/dist/expressions/EvaluatedExpression.js +0 -102
  42. package/dist/expressions/EvaluatedExpression.js.map +0 -1
  43. package/dist/expressions/constant/ConstantExpression.js +0 -53
  44. package/dist/expressions/constant/ConstantExpression.js.map +0 -1
  45. package/dist/expressions/function/FunctionExpression.js +0 -79
  46. package/dist/expressions/function/FunctionExpression.js.map +0 -1
  47. package/dist/expressions/index.js +0 -25
  48. package/dist/expressions/index.js.map +0 -1
  49. package/dist/expressions/shorthand/FormatShorthandExpression.js +0 -60
  50. package/dist/expressions/shorthand/FormatShorthandExpression.js.map +0 -1
  51. package/dist/expressions/shorthand/ShorthandExpression.js +0 -90
  52. package/dist/expressions/shorthand/ShorthandExpression.js.map +0 -1
  53. package/dist/expressions/text/AbstractFormatExpression.js +0 -178
  54. package/dist/expressions/text/AbstractFormatExpression.js.map +0 -1
  55. package/dist/expressions/text/FormatStringExpression.js +0 -44
  56. package/dist/expressions/text/FormatStringExpression.js.map +0 -1
  57. package/dist/index.js +0 -29
  58. package/dist/index.js.map +0 -1
  59. package/dist/tokens/AbstractToken.js +0 -22
  60. package/dist/tokens/AbstractToken.js.map +0 -1
  61. package/dist/tokens/code/CodeToken.js +0 -33
  62. package/dist/tokens/code/CodeToken.js.map +0 -1
  63. package/dist/tokens/code/IdentifierToken.js +0 -28
  64. package/dist/tokens/code/IdentifierToken.js.map +0 -1
  65. package/dist/tokens/code/JSToken.js +0 -251
  66. package/dist/tokens/code/JSToken.js.map +0 -1
  67. package/dist/tokens/code/PrefixToken.js +0 -24
  68. package/dist/tokens/code/PrefixToken.js.map +0 -1
  69. package/dist/tokens/index.js +0 -31
  70. package/dist/tokens/index.js.map +0 -1
  71. package/dist/tokens/text/PlaceholderToken.js +0 -25
  72. package/dist/tokens/text/PlaceholderToken.js.map +0 -1
  73. package/dist/tokens/text/TextToken.js +0 -28
  74. package/dist/tokens/text/TextToken.js.map +0 -1
  75. package/dist/tsconfig.tsbuildinfo +0 -1
  76. package/dist/utils/parserUtils.js +0 -19
  77. package/dist/utils/parserUtils.js.map +0 -1
  78. package/dist/utils/tokenUtils.js +0 -43
  79. package/dist/utils/tokenUtils.js.map +0 -1
  80. package/dist/utils/valueFormatting.js +0 -34
  81. package/dist/utils/valueFormatting.js.map +0 -1
@@ -1,43 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.stringify = stringify;
4
- exports.codeToken = codeToken;
5
- exports.javascriptToken = javascriptToken;
6
- exports.hasFunctionPrefix = hasFunctionPrefix;
7
- exports.leadingTrivia = leadingTrivia;
8
- const CodeToken_1 = require("../tokens/code/CodeToken");
9
- const JSToken_1 = require("../tokens/code/JSToken");
10
- const PrefixToken_1 = require("../tokens/code/PrefixToken");
11
- function stringify(source) {
12
- let text;
13
- if (typeof source === 'string') {
14
- text = source;
15
- }
16
- else {
17
- text = source.map((token) => token.raw()).join('');
18
- }
19
- return text;
20
- }
21
- function codeToken(tokens) {
22
- const code = tokens.filter((token) => token instanceof CodeToken_1.CodeToken);
23
- if (code.length !== 1)
24
- throw new SyntaxError('Expected one code token.');
25
- return code[0];
26
- }
27
- function javascriptToken(tokens) {
28
- const javascript = tokens.filter((token) => token instanceof JSToken_1.JSToken);
29
- if (javascript.length !== 1) {
30
- throw new SyntaxError('Expected one JavaScript token.');
31
- }
32
- return javascript[0];
33
- }
34
- function hasFunctionPrefix(source) {
35
- return source.slice(leadingTrivia(source).length).startsWith(PrefixToken_1.FUNCTION_PREFIX);
36
- }
37
- /**
38
- * Whitespace and comments before a Journey prefix remain original source text.
39
- */
40
- function leadingTrivia(source) {
41
- return source.match(/^(?:\s+|\/\*[\s\S]*?\*\/|\/\/[^\r\n]*(?:\r?\n|$))*/)[0];
42
- }
43
- //# sourceMappingURL=tokenUtils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"tokenUtils.js","sourceRoot":"","sources":["../../src/utils/tokenUtils.ts"],"names":[],"mappings":";;;;;;;AACA,wDAAqD;AACrD,oDAAiD;AACjD,4DAA6D;AAE7D,mBAA0B,MAAwB;IAChD,IAAI,IAAY,CAAC;IACjB,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,IAAI,GAAG,MAAM,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACrD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,mBAA0B,MAAgC;IACxD,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAsB,EAAE,CAAC,KAAK,YAAY,qBAAS,CAAC,CAAC;IACtF,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,WAAW,CAAC,0BAA0B,CAAC,CAAC;IACzE,OAAO,IAAI,CAAC,CAAC,CAAC,CAAC;AACjB,CAAC;AAED,yBAAgC,MAAgC;IAC9D,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAoB,EAAE,CAAC,KAAK,YAAY,iBAAO,CAAC,CAAC;IACxF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,WAAW,CAAC,gCAAgC,CAAC,CAAC;IAC1D,CAAC;IACD,OAAO,UAAU,CAAC,CAAC,CAAC,CAAC;AACvB,CAAC;AAED,2BAAkC,MAAc;IAC9C,OAAO,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,UAAU,CAAC,6BAAe,CAAC,CAAC;AAChF,CAAC;AAED;;GAEG;AACH,uBAA8B,MAAc;IAC1C,OAAO,MAAM,CAAC,KAAK,CAAC,oDAAoD,CAAC,CAAC,CAAC,CAAC,CAAC;AAC/E,CAAC","sourcesContent":["import { AbstractToken, ExpressionSource } from '../tokens/AbstractToken';\nimport { CodeToken } from '../tokens/code/CodeToken';\nimport { JSToken } from '../tokens/code/JSToken';\nimport { FUNCTION_PREFIX } from '../tokens/code/PrefixToken';\n\nexport function stringify(source: ExpressionSource): string {\n let text: string;\n if (typeof source === 'string') {\n text = source;\n } else {\n text = source.map((token) => token.raw()).join('');\n }\n return text;\n}\n\nexport function codeToken(tokens: readonly AbstractToken[]): CodeToken {\n const code = tokens.filter((token): token is CodeToken => token instanceof CodeToken);\n if (code.length !== 1) throw new SyntaxError('Expected one code token.');\n return code[0];\n}\n\nexport function javascriptToken(tokens: readonly AbstractToken[]): JSToken {\n const javascript = tokens.filter((token): token is JSToken => token instanceof JSToken);\n if (javascript.length !== 1) {\n throw new SyntaxError('Expected one JavaScript token.');\n }\n return javascript[0];\n}\n\nexport function hasFunctionPrefix(source: string): boolean {\n return source.slice(leadingTrivia(source).length).startsWith(FUNCTION_PREFIX);\n}\n\n/**\n * Whitespace and comments before a Journey prefix remain original source text.\n */\nexport function leadingTrivia(source: string): string {\n return source.match(/^(?:\\s+|\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\r\\n]*(?:\\r?\\n|$))*/)[0];\n}\n"]}
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formatValue = formatValue;
4
- exports.formatValueAsync = formatValueAsync;
5
- /**
6
- * Format an expression with a specific format.
7
- */
8
- function formatValue(value, formatter, format) {
9
- if (value == null) {
10
- return '';
11
- }
12
- else if ((formatter === null || formatter === void 0 ? void 0 : formatter.format) != null) {
13
- return formatter.format(value, format !== null && format !== void 0 ? format : undefined);
14
- }
15
- else {
16
- // This should generally not happen. However, we still try to handle it gracefully.
17
- // This is useful for tests where we don't want to define the type for every variable.
18
- return value.toString();
19
- }
20
- }
21
- /**
22
- * Resolve an object's asynchronous display value before falling back to its type formatter.
23
- */
24
- async function formatValueAsync(value, formatter, format) {
25
- let formatted;
26
- if (value != null && typeof value._display === 'function') {
27
- formatted = await value._display();
28
- }
29
- else {
30
- formatted = formatValue(value, formatter, format);
31
- }
32
- return formatted;
33
- }
34
- //# sourceMappingURL=valueFormatting.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"valueFormatting.js","sourceRoot":"","sources":["../../src/utils/valueFormatting.ts"],"names":[],"mappings":";;;;AAEA;;GAEG;AACH,qBAA4B,KAAU,EAAE,SAA2B,EAAE,MAAsB;IACzF,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;QAClB,OAAO,EAAE,CAAC;IACZ,CAAC;SAAM,IAAI,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,KAAI,IAAI,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,aAAN,MAAM,cAAN,MAAM,GAAI,SAAS,CAAC,CAAC;IACtD,CAAC;SAAM,CAAC;QACN,mFAAmF;QACnF,sFAAsF;QACtF,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;IAC1B,CAAC;AACH,CAAC;AAED;;GAEG;AACI,KAAK,2BACV,KAAU,EACV,SAA2B,EAC3B,MAAsB;IAEtB,IAAI,SAAiB,CAAC;IACtB,IAAI,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,CAAC,QAAQ,KAAK,UAAU,EAAE,CAAC;QAC1D,SAAS,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,CAAC;IACrC,CAAC;SAAM,CAAC;QACN,SAAS,GAAG,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import type { Formatter } from '@ja-platform/parser-type-system';\n\n/**\n * Format an expression with a specific format.\n */\nexport function formatValue(value: any, formatter: Formatter | null, format?: string | null): string {\n if (value == null) {\n return '';\n } else if (formatter?.format != null) {\n return formatter.format(value, format ?? undefined);\n } else {\n // This should generally not happen. However, we still try to handle it gracefully.\n // This is useful for tests where we don't want to define the type for every variable.\n return value.toString();\n }\n}\n\n/**\n * Resolve an object's asynchronous display value before falling back to its type formatter.\n */\nexport async function formatValueAsync(\n value: any,\n formatter: Formatter | null,\n format?: string | null\n): Promise<string> {\n let formatted: string;\n if (value != null && typeof value._display === 'function') {\n formatted = await value._display();\n } else {\n formatted = formatValue(value, formatter, format);\n }\n return formatted;\n}\n"]}