@journeyapps/evaluator
Advanced tools
Comparing version 0.0.0-dev.e23f87d to 0.0.0-dev.e413148
@@ -8,2 +8,3 @@ import { Statement } from '@babel/types'; | ||
getFormatSpecifier(stm: Statement | null): string | null; | ||
static isEnclosedInSingleCurlyBrackets(source: string): boolean; | ||
} | ||
@@ -10,0 +11,0 @@ export declare class FormatStringContextFactory extends ParseContextFactory<FormatStringContext> { |
export * from './parsers'; | ||
export * from './TokenExpressionParser'; | ||
export * from './context/ParseContext'; | ||
export * from './context/FormatStringContext'; | ||
export * from './context/FunctionExpressionContext'; | ||
export * from './FormatString'; | ||
@@ -4,0 +7,0 @@ export * from './token-expressions'; |
@@ -5,3 +5,7 @@ import { CallExpression } from '@babel/types'; | ||
export declare class CallExpressionParser extends AbstractExpressionParser<CallExpression, FunctionTokenExpression> { | ||
parse(event: ExpressionNodeParseEvent<CallExpression>): FunctionTokenExpression; | ||
parse(event: ExpressionNodeParseEvent<CallExpression>): FunctionTokenExpression<{ | ||
expression: string; | ||
name: string; | ||
arguments: import("../token-expressions").TokenExpression<import("../token-expressions").TokenExpressionOptions, any>[]; | ||
}>; | ||
} | ||
@@ -8,0 +12,0 @@ export declare class CallExpressionParserFactory extends ExpressionParserFactory<CallExpressionParser> { |
@@ -6,4 +6,6 @@ import { Identifier } from '@babel/types'; | ||
export declare class IdentifierExpressionParser extends AbstractExpressionParser<Identifier, ParsedIdentifierExpressionType> { | ||
parse(event: ExpressionNodeParseEvent<Identifier>): FunctionTokenExpression | ShorthandTokenExpression<{ | ||
parse(event: ExpressionNodeParseEvent<Identifier>): FunctionTokenExpression<{ | ||
expression: string; | ||
}> | ShorthandTokenExpression<{ | ||
expression: string; | ||
}>; | ||
@@ -10,0 +12,0 @@ } |
@@ -7,4 +7,6 @@ import { DirectiveLiteral, Literal } from '@babel/types'; | ||
export declare class LiteralExpressionParser extends AbstractExpressionParser<LiteralExpression, ParsedLiteralExpressionType> { | ||
parse(event: ExpressionNodeParseEvent<LiteralExpression>): FunctionTokenExpression | PrimitiveConstantTokenExpression | ConstantTokenExpression<{ | ||
parse(event: ExpressionNodeParseEvent<LiteralExpression>): PrimitiveConstantTokenExpression | FunctionTokenExpression<{ | ||
expression: string; | ||
}> | ConstantTokenExpression<{ | ||
expression: string; | ||
}>; | ||
@@ -11,0 +13,0 @@ } |
import { LogicalExpression, UnaryExpression, BinaryExpression } from '@babel/types'; | ||
import { FunctionTokenExpression } from '../token-expressions'; | ||
import { FunctionTokenExpression, FunctionTokenExpressionOptions } from '../token-expressions'; | ||
import { AbstractExpressionParser, ExpressionParserFactory, ExpressionNodeParseEvent } from './AbstractExpressionParser'; | ||
export type LogicalExpressionType = LogicalExpression | UnaryExpression | BinaryExpression; | ||
export declare class LogicalExpressionParser extends AbstractExpressionParser<LogicalExpressionType, FunctionTokenExpression> { | ||
parse(event: ExpressionNodeParseEvent<LogicalExpressionType>): FunctionTokenExpression; | ||
parse(event: ExpressionNodeParseEvent<LogicalExpressionType>): FunctionTokenExpression<FunctionTokenExpressionOptions>; | ||
} | ||
@@ -8,0 +8,0 @@ export declare class LogicalExpressionParserFactory extends ExpressionParserFactory<LogicalExpressionParser> { |
@@ -6,4 +6,6 @@ import { MemberExpression } from '@babel/types'; | ||
export declare class MemberExpressionParser extends AbstractExpressionParser<MemberExpression, MemberExpressionParsedType> { | ||
parse(event: ExpressionNodeParseEvent<MemberExpression>): FunctionTokenExpression | ShorthandTokenExpression<{ | ||
parse(event: ExpressionNodeParseEvent<MemberExpression>): FunctionTokenExpression<{ | ||
expression: string; | ||
}> | ShorthandTokenExpression<{ | ||
expression: string; | ||
}>; | ||
@@ -10,0 +12,0 @@ } |
@@ -20,2 +20,3 @@ /** | ||
stringify(): string; | ||
clone(): this; | ||
} |
@@ -20,2 +20,3 @@ /** | ||
stringify(): string; | ||
clone(): this; | ||
} |
@@ -8,3 +8,3 @@ import { TokenExpression, TokenExpressionOptions } from '../TokenExpression'; | ||
} | ||
export declare class FunctionTokenExpression extends TokenExpression<FunctionTokenExpressionOptions> { | ||
export declare class FunctionTokenExpression<T extends FunctionTokenExpressionOptions = FunctionTokenExpressionOptions> extends TokenExpression<T> { | ||
static TYPE: string; | ||
@@ -16,4 +16,4 @@ static isInstanceOf(obj: any): obj is FunctionTokenExpression; | ||
static PREFIX: string; | ||
static parse(source: string): FunctionTokenExpression; | ||
constructor(options: FunctionTokenExpressionOptions); | ||
static parse(source: string): FunctionTokenExpression<FunctionTokenExpressionOptions>; | ||
constructor(options: T); | ||
get arguments(): TokenExpression[] | null; | ||
@@ -30,4 +30,5 @@ functionName(): string; | ||
stringify(): string; | ||
clone(): this; | ||
static trimPrefix(expression: string): string; | ||
static hasPrefix(expression: string): boolean; | ||
} |
@@ -16,2 +16,3 @@ /** | ||
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>; | ||
clone(): this; | ||
} |
import { TokenExpression } from '../TokenExpression'; | ||
import { FunctionTokenExpression, FunctionTokenExpressionOptions } from './FunctionTokenExpression'; | ||
export interface TernaryFunctionTokenExpressionOptions extends Omit<FunctionTokenExpressionOptions, 'name' | 'arguments'> { | ||
test: TokenExpression; | ||
consequent: TokenExpression; | ||
alternate: TokenExpression; | ||
arguments: TokenExpression[]; | ||
} | ||
export declare class TernaryFunctionTokenExpression extends FunctionTokenExpression { | ||
export declare class TernaryFunctionTokenExpression extends FunctionTokenExpression<TernaryFunctionTokenExpressionOptions> { | ||
constructor(options: TernaryFunctionTokenExpressionOptions); | ||
stringify(): string; | ||
clone(): this; | ||
} |
@@ -6,6 +6,7 @@ import { FormatStringScope } from '../../definitions/FormatStringScope'; | ||
} | ||
export declare class ArrayTokenExpression extends TokenExpression { | ||
export declare class ArrayTokenExpression extends TokenExpression<ArrayExpressionTokenOptions> { | ||
static readonly TYPE = "array-expression"; | ||
constructor(options: ArrayExpressionTokenOptions); | ||
tokenEvaluatePromise(scope: FormatStringScope): Promise<any>; | ||
clone(): this; | ||
} |
@@ -15,2 +15,3 @@ import { FormatStringScope } from '../../definitions/FormatStringScope'; | ||
tokenEvaluatePromise(scope: FormatStringScope): Promise<any>; | ||
clone(): this; | ||
} |
@@ -11,3 +11,4 @@ import { FormatStringScope } from '../../definitions/FormatStringScope'; | ||
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>; | ||
clone(): this; | ||
} | ||
export declare function formatValueAsync(value: any, type: TypeInterface, format: string): Promise<string>; |
@@ -21,2 +21,3 @@ import { FormatStringScope } from '../definitions/FormatStringScope'; | ||
abstract tokenEvaluatePromise(scope: FormatStringScope): Promise<V>; | ||
abstract clone(): this; | ||
get start(): number | null; | ||
@@ -23,0 +24,0 @@ set start(start: number); |
@@ -11,3 +11,3 @@ import { TypeInterface } from './definitions/TypeInterface'; | ||
*/ | ||
export declare function functionTokenExpression(expression: string, allowLegacy?: boolean): FunctionTokenExpression | LegacyFunctionTokenExpression; | ||
export declare function functionTokenExpression(expression: string, allowLegacy?: boolean): FunctionTokenExpression<import("./token-expressions").FunctionTokenExpressionOptions> | LegacyFunctionTokenExpression; | ||
/** | ||
@@ -14,0 +14,0 @@ * Create a token expression that can be evaluated. |
@@ -26,2 +26,12 @@ "use strict"; | ||
} | ||
static isEnclosedInSingleCurlyBrackets(source) { | ||
// Check if the source is enclosed in curly braces and not in double curly braces | ||
const trimmed = source.trim(); | ||
if (trimmed.indexOf('{') === 0 && trimmed.lastIndexOf('}') === trimmed.length - 1) { | ||
if (trimmed.charAt(1) != '{') { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} | ||
@@ -32,8 +42,4 @@ exports.FormatStringContext = FormatStringContext; | ||
inferParseContext(source) { | ||
const trimmed = source.trim(); | ||
// Check if the source is enclosed in curly braces and not in double curly braces | ||
if (trimmed.indexOf('{') === 0 && trimmed.lastIndexOf('}') === trimmed.length - 1) { | ||
if (trimmed.charAt(1) != '{') { | ||
return new FormatStringContext(); | ||
} | ||
if (FormatStringContext.isEnclosedInSingleCurlyBrackets(source)) { | ||
return new FormatStringContext(); | ||
} | ||
@@ -40,0 +46,0 @@ return null; |
@@ -100,3 +100,3 @@ "use strict"; | ||
const token = tokens[j]; | ||
if (token instanceof token_expressions_1.ConstantTokenExpression) { | ||
if (token_expressions_1.ConstantTokenExpression.isInstanceOf(token) || token_expressions_1.PrimitiveConstantTokenExpression.isInstanceOf(token)) { | ||
if (last == null) { | ||
@@ -103,0 +103,0 @@ last = token; |
@@ -19,2 +19,5 @@ "use strict"; | ||
__exportStar(require("./TokenExpressionParser"), exports); | ||
__exportStar(require("./context/ParseContext"), exports); | ||
__exportStar(require("./context/FormatStringContext"), exports); | ||
__exportStar(require("./context/FunctionExpressionContext"), exports); | ||
__exportStar(require("./FormatString"), exports); | ||
@@ -21,0 +24,0 @@ __exportStar(require("./token-expressions"), exports); |
@@ -13,5 +13,3 @@ "use strict"; | ||
expression: source.slice(node.start, node.end), | ||
test: args[0], | ||
consequent: args[1], | ||
alternate: args[2] | ||
arguments: [args[0], args[1], args[2]] | ||
}); | ||
@@ -18,0 +16,0 @@ } |
@@ -34,2 +34,5 @@ "use strict"; | ||
} | ||
clone() { | ||
return new ConstantTokenExpression(this.options); | ||
} | ||
} | ||
@@ -36,0 +39,0 @@ exports.ConstantTokenExpression = ConstantTokenExpression; |
@@ -33,2 +33,5 @@ "use strict"; | ||
} | ||
clone() { | ||
return new PrimitiveConstantTokenExpression(this.options); | ||
} | ||
} | ||
@@ -35,0 +38,0 @@ exports.PrimitiveConstantTokenExpression = PrimitiveConstantTokenExpression; |
@@ -59,2 +59,5 @@ "use strict"; | ||
} | ||
clone() { | ||
return new FunctionTokenExpression(Object.assign(Object.assign({}, this.options), { arguments: this.arguments != null ? [...this.arguments.map((a) => a.clone())] : undefined })); | ||
} | ||
static trimPrefix(expression) { | ||
@@ -61,0 +64,0 @@ // remove indicator prefix from expression |
@@ -27,2 +27,5 @@ "use strict"; | ||
} | ||
clone() { | ||
return new LegacyFunctionTokenExpression(this.options); | ||
} | ||
} | ||
@@ -29,0 +32,0 @@ exports.LegacyFunctionTokenExpression = LegacyFunctionTokenExpression; |
@@ -7,3 +7,4 @@ "use strict"; | ||
constructor(options) { | ||
super(Object.assign(Object.assign({}, options), { arguments: [options.test, options.consequent, options.alternate] })); | ||
super(Object.assign({}, options)); | ||
this.setFunctionName(''); | ||
} | ||
@@ -14,4 +15,7 @@ stringify() { | ||
} | ||
clone() { | ||
return new TernaryFunctionTokenExpression(Object.assign(Object.assign({}, this.options), { arguments: this.arguments.map((arg) => arg.clone()) })); | ||
} | ||
} | ||
exports.TernaryFunctionTokenExpression = TernaryFunctionTokenExpression; | ||
//# sourceMappingURL=TernaryFunctionTokenExpression.js.map |
@@ -12,2 +12,5 @@ "use strict"; | ||
} | ||
clone() { | ||
return new ArrayTokenExpression(Object.assign(Object.assign({}, this.options), { elements: [...this.options.elements.map((e) => e.clone())] })); | ||
} | ||
} | ||
@@ -14,0 +17,0 @@ exports.ArrayTokenExpression = ArrayTokenExpression; |
@@ -19,2 +19,6 @@ "use strict"; | ||
} | ||
clone() { | ||
const cloneProps = Object.fromEntries(Object.entries(this.properties).map(([key, value]) => [key, value.clone()])); | ||
return new ObjectTokenExpression(Object.assign(Object.assign({}, this.options), { properties: cloneProps })); | ||
} | ||
} | ||
@@ -21,0 +25,0 @@ exports.ObjectTokenExpression = ObjectTokenExpression; |
@@ -22,2 +22,5 @@ "use strict"; | ||
} | ||
clone() { | ||
return new ShorthandTokenExpression(this.options); | ||
} | ||
} | ||
@@ -24,0 +27,0 @@ exports.ShorthandTokenExpression = ShorthandTokenExpression; |
@@ -75,2 +75,5 @@ "use strict"; | ||
var _a; | ||
if (event.source.trim() === '') { | ||
return null; | ||
} | ||
if (!event.context) { | ||
@@ -77,0 +80,0 @@ event.context = this.inferContext(event.source); |
{ | ||
"name": "@journeyapps/evaluator", | ||
"version": "0.0.0-dev.e23f87d", | ||
"version": "0.0.0-dev.e413148", | ||
"description": "Journey Evaluator library", | ||
@@ -15,3 +15,3 @@ "main": "./dist/index.js", | ||
"lodash": "^4.17.21", | ||
"@journeyapps/core-xml": "0.0.0-dev.e23f87d" | ||
"@journeyapps/core-xml": "0.0.0-dev.e413148" | ||
}, | ||
@@ -18,0 +18,0 @@ "devDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
280095
2271
0
+ Added@journeyapps/core-xml@0.0.0-dev.e413148(transitive)
- Removed@journeyapps/core-xml@0.0.0-dev.e23f87d(transitive)