@player-ui/player
Version:
30 lines • 1.33 kB
TypeScript
import type { Expression } from "@player-ui/types";
import type { DataModelWithParser } from "../data";
export interface Options {
/**
* The model to use when resolving refs
* Passing `false` will skip trying to resolve any direct model refs ({{foo}})
*/
model: false | DataModelWithParser;
/**
* A function to evaluate an expression
* Passing `false` will skip trying to evaluate any expressions (@[ foo() ]@)
*/
evaluate: false | ((exp: Expression) => any);
/**
* Optionaly resolve binding without formatting in case Type format applies
*/
formatted?: boolean;
}
/** Search the given string for the coordinates of the next expression to resolve */
export declare function findNextExp(str: string): {
start: number;
end: number;
} | undefined;
/** Finds any subset of the string wrapped in @[]@ and evaluates it as an expression */
export declare function resolveExpressionsInString(val: string, { evaluate }: Options): string;
/** Return a string with all data model references resolved */
export declare function resolveDataRefsInString(val: string, options: Options): string;
/** Recursively resolve all model refs in whatever you pass in */
export declare function resolveDataRefs<T>(val: T, options: Options): T;
//# sourceMappingURL=index.d.ts.map