haystack-core
Advanced tools
Comparing version 2.0.20 to 2.0.21
@@ -9,2 +9,3 @@ import { EvalContext } from '../filter/EvalContext'; | ||
import { Kind } from './Kind'; | ||
import { LocalizedCallback } from './util'; | ||
/** | ||
@@ -424,2 +425,33 @@ * An object composed of haystack values. | ||
/** | ||
* Get the display string for the dict or the given tag. If 'name' | ||
* is undefined, then return display text for the entire dict. If 'name' | ||
* is non-null then format the tag value. If 'name' is not defined | ||
* by this dict then return 'def'. | ||
* | ||
* ```typescript | ||
* // Returns the record's dis tag string value... | ||
* myDict.toDis() | ||
* | ||
* // Returns the record's tag value string value for foo... | ||
* myDict.toDis({ name: 'foo' }) | ||
* | ||
* // Returns a localized string based on `disKey`... | ||
* myDict.toDis({ | ||
* i18n: (pod: string, key: string): string | undefined => pods.get(pod)?.key(key) | ||
* }) | ||
* ``` | ||
* | ||
* @see {@link dictToDis} | ||
* | ||
* @param options.name Optional tag name. | ||
* @param options.def Optional default value. | ||
* @param options.i18n Optional function to get localized strings. | ||
* @returns The display string | ||
*/ | ||
toDis({ name, def, i18n, }?: { | ||
name?: string; | ||
def?: string; | ||
i18n?: LocalizedCallback; | ||
}): string; | ||
/** | ||
* Dump the value to the local console output. | ||
@@ -426,0 +458,0 @@ * |
import { HVal, OptionalHVal } from './HVal'; | ||
import { HDict } from './HDict'; | ||
import { HaysonVal } from './hayson'; | ||
@@ -44,1 +45,64 @@ /** | ||
export declare const IMPLIED_BY = "impliedBy"; | ||
/** | ||
* A function used for accessing localized display strings. | ||
* | ||
* Return undefined if the translated value can't be found. | ||
* | ||
* @param pod The pod/library name. | ||
* @param key The key. | ||
* @returns The translated value or undefined if it can't be found. | ||
*/ | ||
export interface LocalizedCallback { | ||
(pod: string, key: string): string | undefined; | ||
} | ||
/** | ||
* Return a display string from the dict... | ||
* | ||
* 1. 'dis' tag. | ||
* 2. 'disMacro' tag returns macro using dict as scope. | ||
* 3. 'disKey' maps to qname locale key. | ||
* 4. 'name' tag. | ||
* 5. 'tag' tag. | ||
* 6. 'id' tag. | ||
* 7. default | ||
* | ||
* @see {@link HDict.toDis} | ||
* @see {@link macro} | ||
* @see {@link disKey} | ||
* | ||
* @param dict The dict to use. | ||
* @param def The default fallback value. | ||
* @param i18n The localization callback. | ||
* @return The display string value. | ||
*/ | ||
export declare function dictToDis(dict: HDict, def?: string, i18n?: LocalizedCallback): string; | ||
/** | ||
* Process a macro pattern with the given scope of variable name/value pairs. | ||
* The pattern is a unicode string with embedded expressions: | ||
* * '$tag': resolve tag name from scope, variable name ends with first non-tag character. | ||
* * '${tag}': resolve tag name from scope. | ||
* * '$<pod::key> localization key. | ||
* | ||
* Any variables which cannot be resolved in the scope are returned as-is (i.e. $name) in | ||
* the result string. | ||
* | ||
* If a tag resolves to Ref, then we use Ref.dis for the string. | ||
* | ||
* @see {@link dictToDis} | ||
* | ||
* @param pattern The pattern to process. | ||
* @param getValue Gets a value based on a name (returns undefined if not found). | ||
* @param i18n Optional localization callback. | ||
* @returns The processed output string. | ||
*/ | ||
export declare function macro(pattern: string, getValue: (key: string) => HVal | undefined, i18n?: LocalizedCallback): string; | ||
/** | ||
* Map a display key to a localized string. | ||
* | ||
* @see {@link dictToDis} | ||
* | ||
* @param key The display key. | ||
* @param i18n Localization callback. | ||
* @returns The value or undefined if the value can't be found. | ||
*/ | ||
export declare function disKey(key: string, i18n: LocalizedCallback): string | undefined; |
@@ -14,3 +14,3 @@ { | ||
"email": "support@j2inn.com", | ||
"version": "2.0.20", | ||
"version": "2.0.21", | ||
"module": "dist/index.es.js", | ||
@@ -47,38 +47,38 @@ "main": "dist/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^26.0.22", | ||
"@types/lodash": "^4.14.168", | ||
"@types/luxon": "^1.26.3", | ||
"@types/jest": "^27.0.2", | ||
"@types/lodash": "^4.14.175", | ||
"@types/luxon": "^2.0.5", | ||
"@types/moment-range": "^4.0.0", | ||
"@types/moment-timezone": "^0.5.30", | ||
"@types/node": "^14.14.39", | ||
"@typescript-eslint/eslint-plugin": "^4.22.0", | ||
"@typescript-eslint/parser": "^4.22.0", | ||
"@types/node": "^16.10.3", | ||
"@typescript-eslint/eslint-plugin": "^4.33.0", | ||
"@typescript-eslint/parser": "^4.33.0", | ||
"copyfiles": "^2.4.1", | ||
"eslint": "^7.24.0", | ||
"eslint-config-prettier": "^8.2.0", | ||
"eslint-plugin-prettier": "^3.4.0", | ||
"http-server": "^0.12.3", | ||
"jest": "^26.6.3", | ||
"eslint": "^7.32.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint-plugin-prettier": "^4.0.0", | ||
"http-server": "^13.0.2", | ||
"jest": "^27.2.5", | ||
"lodash": "^4.17.21", | ||
"luxon": "^1.26.0", | ||
"madge": "^4.0.2", | ||
"luxon": "^2.0.2", | ||
"madge": "^5.0.1", | ||
"moment-range": "^4.0.2", | ||
"moment-timezone": "^0.5.33", | ||
"nodemon": "^2.0.7", | ||
"npm-dts": "^1.3.9", | ||
"npm-dts-webpack-plugin": "^1.3.7", | ||
"prettier": "^2.2.1", | ||
"prettier-eslint": "^12.0.0", | ||
"nodemon": "^2.0.13", | ||
"npm-dts": "^1.3.10", | ||
"npm-dts-webpack-plugin": "^1.3.10", | ||
"prettier": "^2.4.1", | ||
"prettier-eslint": "^13.0.0", | ||
"prettier-eslint-cli": "^5.0.1", | ||
"rimraf": "^3.0.2", | ||
"rollup": "^2.45.2", | ||
"ts-jest": "^26.5.4", | ||
"ts-loader": "^8.1.0", | ||
"ts-node": "^9.1.1", | ||
"typedoc": "^0.20.35", | ||
"typescript": "^4.2.4", | ||
"rollup": "^2.58.0", | ||
"ts-jest": "^27.0.5", | ||
"ts-loader": "^9.2.6", | ||
"ts-node": "^10.2.1", | ||
"typedoc": "^0.22.5", | ||
"typescript": "^4.4.3", | ||
"typescript-eslint-parser": "^22.0.0", | ||
"webpack": "^5.33.2", | ||
"webpack-cli": "^4.6.0" | ||
"webpack": "^5.58.1", | ||
"webpack-cli": "^4.9.0" | ||
} | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1148629
37183