1 | import { StylableMeta } from './stylable-meta';
|
2 | import { StylableResolver } from './stylable-resolver';
|
3 | import { ParsedValue } from './types';
|
4 | export interface Box<Type extends string, Value extends any> {
|
5 | type: Type;
|
6 | value: Value;
|
7 | }
|
8 | export declare function box<Type extends string, Value extends any>(type: Type, value: Value): Box<Type, Value>;
|
9 | export declare function unbox<B extends Box<string, unknown>>(boxed: B | string): any;
|
10 | export interface BoxedValueMap {
|
11 | [k: string]: string | Box<string, unknown>;
|
12 | }
|
13 | export declare type BoxedValueArray = Array<string | Box<string, unknown>>;
|
14 | declare type CustomTypes = Record<string, CustomValueExtension<any>>;
|
15 | export interface CustomValueExtension<T> {
|
16 | evalVarAst(valueAst: ParsedValue, customTypes: {
|
17 | [typeID: string]: CustomValueExtension<unknown>;
|
18 | }): Box<string, T>;
|
19 | getValue(path: string[], value: Box<string, T>, node: ParsedValue, customTypes: CustomTypes): string;
|
20 | }
|
21 | export declare const stTypes: CustomTypes;
|
22 | export declare const CustomValueStrategy: {
|
23 | args: (fnNode: ParsedValue, customTypes: CustomTypes) => (string | Box<string, any>)[];
|
24 | named: (fnNode: ParsedValue, customTypes: CustomTypes) => BoxedValueMap;
|
25 | };
|
26 | export interface JSValueExtension<Value> {
|
27 | _kind: 'CustomValue';
|
28 | register(localTypeSymbol: string): CustomValueExtension<Value>;
|
29 | }
|
30 | interface ExtensionApi<Value, Args> {
|
31 | processArgs: (fnNode: ParsedValue, customTypes: CustomTypes) => Args;
|
32 | createValue: (args: Args) => Value;
|
33 | getValue: (v: Value, key: string) => string | Box<string, unknown>;
|
34 | flattenValue?: (v: Box<string, Value>) => {
|
35 | parts: Array<string | Box<string, unknown>>;
|
36 | delimiter: ',' | ' ';
|
37 | };
|
38 | }
|
39 | export declare function resolveCustomValues(meta: StylableMeta, resolver: StylableResolver): {
|
40 | [x: string]: CustomValueExtension<any>;
|
41 | };
|
42 | export declare function createCustomValue<Value, Args>({ processArgs, createValue, flattenValue, getValue, }: ExtensionApi<Value, Args>): JSValueExtension<Value>;
|
43 | export declare function getBoxValue(path: string[], value: string | Box<string, unknown>, node: ParsedValue, customTypes: CustomTypes): string;
|
44 | export declare function isCustomValue(symbol: any): symbol is JSValueExtension<unknown>;
|
45 | export {};
|
46 |
|
\ | No newline at end of file |