Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@journeyapps/evaluator

Package Overview
Dependencies
Maintainers
2
Versions
266
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@journeyapps/evaluator - npm Package Compare versions

Comparing version 0.0.0-dev.61472d2.0a3ef77 to 0.0.0-dev.64701c3.1585332

dist/@types/src/FormatStringScope.d.ts

12

dist/@types/src/FormatString.d.ts
import { TokenExpression } from './token-expressions/TokenExpression';
import { AttributeValidationError } from '@journeyapps/core-xml';
import { TypeInterface } from './TypeInterface';
import { FormatStringScope } from './FormatStringScope';
/**

@@ -16,4 +17,4 @@ * Construct a new format string expression.

isConstant(): boolean;
extractRelationshipStructure(type: any, depth?: number, into?: any): any;
validate(scopeType: any): AttributeValidationError[];
extractRelationshipStructure(type: TypeInterface, depth?: number, into?: any): any;
validate(scopeType: TypeInterface): AttributeValidationError[];
validateAndReturnRecordings(scopeType: TypeInterface): {

@@ -26,4 +27,7 @@ type: string;

valueOf(): string;
evaluatePromise(scope: any, args?: any[]): Promise<string>;
evaluate(scope: any): string;
evaluatePromise(scope: FormatStringScope): Promise<string>;
/**
* If not all values are loaded yet, null is returned.
*/
evaluate(scope: FormatStringScope): string;
}

@@ -12,1 +12,3 @@ export * from './token-expressions/ConstantTokenExpression';

export * from './ObjectRefInterface';
export * from './FormatStringScope';
export * from './VariableFormatStringScope';

@@ -5,2 +5,3 @@ /**

import { TokenExpression } from './TokenExpression';
import { FormatStringScope } from '../FormatStringScope';
export declare class ConstantTokenExpression extends TokenExpression {

@@ -17,2 +18,3 @@ constructor(expression: string, start?: number);

valueOf(): string;
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}

@@ -6,2 +6,3 @@ /**

import { TokenExpression } from './TokenExpression';
import { FormatStringScope } from '../FormatStringScope';
export declare class FormatShorthandTokenExpression extends TokenExpression {

@@ -12,2 +13,3 @@ inner: ShorthandTokenExpression;

toString(): string;
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}

@@ -6,2 +6,3 @@ /**

import { ConstantTokenExpression } from './ConstantTokenExpression';
import { FormatStringScope } from '../FormatStringScope';
export declare class FunctionTokenExpression extends TokenExpression {

@@ -23,2 +24,3 @@ /**

toConstant(includeEscapeTags?: boolean): ConstantTokenExpression;
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}

@@ -6,2 +6,3 @@ /**

import { ConstantTokenExpression } from './ConstantTokenExpression';
import { FormatStringScope } from '../FormatStringScope';
export declare class LegacyFunctionTokenExpression extends TokenExpression {

@@ -15,2 +16,3 @@ constructor(expression: string, start?: number);

toConstant(includeEscapeTags?: boolean): ConstantTokenExpression;
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}

@@ -5,2 +5,3 @@ /**

import { TokenExpression } from './TokenExpression';
import { FormatStringScope } from '../FormatStringScope';
export declare class PrimitiveConstantTokenExpression extends TokenExpression {

@@ -17,2 +18,3 @@ constructor(expression: any, start?: number);

valueOf(): any;
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}

@@ -5,5 +5,7 @@ /**

import { TokenExpression } from './TokenExpression';
import { FormatStringScope } from '../FormatStringScope';
export declare class ShorthandTokenExpression extends TokenExpression {
constructor(expression: string, start?: number);
isShorthand(): boolean;
tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}
/**
* Abstract base token expression class.
*/
export declare class TokenExpression {
import { FormatStringScope } from '../FormatStringScope';
export declare abstract class TokenExpression {
expression: string;

@@ -9,3 +10,3 @@ start: number | undefined;

isPrimitive: boolean;
constructor(expression: string, start?: number);
protected constructor(expression: string, start?: number);
toString(): string;

@@ -18,2 +19,3 @@ isConstant(): boolean;

isFunction(): boolean;
abstract tokenEvaluatePromise(scope: FormatStringScope): Promise<string>;
}

@@ -5,4 +5,5 @@ import { TokenExpression } from './token-expressions/TokenExpression';

import { FormatShorthandTokenExpression } from './token-expressions/FormatShorthandTokenExpression';
import { FormatString } from './FormatString';
import { TypeInterface } from './TypeInterface';
import { LegacyFunctionTokenExpression } from './token-expressions/LegacyFunctionTokenExpression';
import { FormatString } from './FormatString';
export declare function unescape(s: string): string;

@@ -36,2 +37,4 @@ export declare function parseEnclosingBraces(format: string): {

export declare function actionableTokenExpression(expression: string): FunctionTokenExpression | ShorthandTokenExpression | FormatShorthandTokenExpression;
export declare function formatValue(value: any, type: TypeInterface, format: string): string;
export declare function formatValueAsync(value: any, type: TypeInterface, format: string): Promise<string>;
export { compile as _compile, deepMerge as _deepMerge };

@@ -5,5 +5,6 @@ export interface TypeInterface {

getVariableTypeAndNameWithParent(expression: string): any;
getType(variable: any): any;
getType(expression: string): TypeInterface | null;
toJSON(): any;
format(value: any, format?: string): string;
options: object;
}
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tools_1 = require("./tools");
;
/**

@@ -56,3 +57,3 @@ * Construct a new format string expression.

}
var type = scopeType.getVariable(expression);
var type = scopeType.getType(expression);
if (type == null) {

@@ -115,9 +116,64 @@ results.push({

}
;
// Implemented elsewhere
evaluatePromise(scope, args) {
throw new Error('Not implemented');
evaluatePromise(scope) {
const tokens = this.tokens;
let promises = [];
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.isConstant()) {
// Nothing
}
else {
const promise = token.tokenEvaluatePromise(scope);
promises.push(promise);
}
}
return Promise.all(promises).then(function (results) {
let result = '';
let promiseIndex = 0;
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.isConstant()) {
result += token.valueOf();
}
else {
result += results[promiseIndex];
promiseIndex += 1;
}
}
return result;
});
}
/**
* If not all values are loaded yet, null is returned.
*/
evaluate(scope) {
throw new Error('Not implemented');
const tokens = this.tokens;
let result = '';
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.isConstant()) {
result += token.valueOf();
}
else if (token.isFunction()) {
// Not supported - return the original expression
result += token.toConstant(true).valueOf();
}
else {
let expression = token.expression;
if (expression.length > 0 && expression[0] == '?') {
expression = expression.substring(1);
}
const value = scope.getValue(expression);
if (value === undefined) {
// Still loading
return null;
}
else {
const type = scope.getExpressionType(expression);
const text = tools_1.formatValue(value, type, token.format);
result += text;
}
}
}
return result;
}

@@ -124,0 +180,0 @@ }

@@ -15,2 +15,3 @@ "use strict";

__export(require("./tools"));
__export(require("./VariableFormatStringScope"));
//# sourceMappingURL=index.js.map

@@ -27,4 +27,7 @@ "use strict";

}
async tokenEvaluatePromise(scope) {
return this.expression;
}
}
exports.ConstantTokenExpression = ConstantTokenExpression;
//# sourceMappingURL=ConstantTokenExpression.js.map

@@ -8,2 +8,3 @@ "use strict";

const TokenExpression_1 = require("./TokenExpression");
const tools_1 = require("../tools");
class FormatShorthandTokenExpression extends TokenExpression_1.TokenExpression {

@@ -30,4 +31,13 @@ constructor(expression, format, start) {

}
async tokenEvaluatePromise(scope) {
let expression = this.expression;
if (expression.length > 0 && expression[0] == '?') {
expression = expression.substring(1);
}
const value = await scope.getValuePromise(expression);
const type = scope.getExpressionType(expression);
return tools_1.formatValueAsync(value, type, this.format);
}
}
exports.FormatShorthandTokenExpression = FormatShorthandTokenExpression;
//# sourceMappingURL=FormatShorthandTokenExpression.js.map

@@ -11,4 +11,4 @@ "use strict";

// remove indicator prefix from expression
var prefix = FunctionTokenExpression.PREFIX;
var processedExpression = expression.trim();
const prefix = FunctionTokenExpression.PREFIX;
let processedExpression = expression.trim();
if (processedExpression.indexOf(prefix) === 0) {

@@ -37,3 +37,3 @@ processedExpression = processedExpression.substr(prefix.length);

}
var constantExpression = FunctionTokenExpression.PREFIX + this.expression;
let constantExpression = FunctionTokenExpression.PREFIX + this.expression;
if (includeEscapeTags) {

@@ -44,2 +44,9 @@ constantExpression = '{' + constantExpression + '}';

}
async tokenEvaluatePromise(scope) {
const value = await scope.evaluateFunctionExpression(this.expression);
// FIXME: FunctionTokenExpression is not only used for FormatStrings, but
// also for other attributes, e.g. show-if. For those cases, we need the
// original value, not a string, so we can't convert to a string here.
return value;
}
}

@@ -46,0 +53,0 @@ /**

@@ -29,4 +29,7 @@ "use strict";

}
tokenEvaluatePromise(scope) {
throw new Error('not implemented');
}
}
exports.LegacyFunctionTokenExpression = LegacyFunctionTokenExpression;
//# sourceMappingURL=LegacyFunctionTokenExpression.js.map

@@ -28,4 +28,7 @@ "use strict";

}
async tokenEvaluatePromise(scope) {
return this.expression;
}
}
exports.PrimitiveConstantTokenExpression = PrimitiveConstantTokenExpression;
//# sourceMappingURL=PrimitiveConstantTokenExpression.js.map

@@ -7,2 +7,3 @@ "use strict";

const TokenExpression_1 = require("./TokenExpression");
const tools_1 = require("../tools");
class ShorthandTokenExpression extends TokenExpression_1.TokenExpression {

@@ -15,4 +16,13 @@ constructor(expression, start) {

}
async tokenEvaluatePromise(scope) {
let expression = this.expression;
if (expression.length > 0 && expression[0] == '?') {
expression = expression.substring(1);
}
const value = await scope.getValuePromise(expression);
const type = scope.getExpressionType(expression);
return tools_1.formatValueAsync(value, type, this.format);
}
}
exports.ShorthandTokenExpression = ShorthandTokenExpression;
//# sourceMappingURL=ShorthandTokenExpression.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
* Abstract base token expression class.
*/
class TokenExpression {

@@ -7,0 +4,0 @@ constructor(expression, start) {

@@ -7,4 +7,4 @@ "use strict";

const FormatShorthandTokenExpression_1 = require("./token-expressions/FormatShorthandTokenExpression");
const FormatString_1 = require("./FormatString");
const LegacyFunctionTokenExpression_1 = require("./token-expressions/LegacyFunctionTokenExpression");
const FormatString_1 = require("./FormatString");
function unescape(s) {

@@ -262,2 +262,28 @@ var start = 0;

exports.actionableTokenExpression = actionableTokenExpression;
// Format an expression with a specific format.
// Return a promise resolving with the formatted value.
function formatValue(value, type, format) {
if (value == null) {
return '';
}
else if (type != null) {
return type.format(value, format);
}
else {
// This should generally not happen. However, we still try to handle it gracefully.
// This is useful for tests where we don't want to define the type for every variable.
return value.toString();
}
}
exports.formatValue = formatValue;
async function formatValueAsync(value, type, format) {
if (value != null && typeof value._display == 'function') {
// Object - recursive promise-based formatting.
return value._display();
}
else {
return formatValue(value, type, format);
}
}
exports.formatValueAsync = formatValueAsync;
//# sourceMappingURL=tools.js.map
{
"name": "@journeyapps/evaluator",
"version": "0.0.0-dev.61472d2.0a3ef77",
"version": "0.0.0-dev.64701c3.1585332",
"description": "Journey JS library",

@@ -14,3 +14,3 @@ "main": "./dist/src/index.js",

"dependencies": {
"@journeyapps/core-xml": "0.0.0-dev.61472d2.0a3ef77"
"@journeyapps/core-xml": "0.0.0-dev.64701c3.1585332"
},

@@ -21,3 +21,3 @@ "files": [

],
"gitHead": "ef21921a0f0c800a891a7402158a8be9b0195221"
"gitHead": "111f5824b991b988ca7defa1cf9b51967587ed37"
}

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc