UNPKG

@soleil-se/app-util

Version:

Utility functions for WebApps, RESTApps and Widgets in Sitevision.

85 lines (84 loc) 2.76 kB
/** * Get a prefixed namespace unique for app. * @param {string} [prefix='app'] * @return {string} - Prefixed namespace. */ export function getNamespace(prefix?: string): string; /** * Generate a unique identifier with a random UUID without dashes. * @param {string} prefix Prefix for the identifier. * @returns {string} Unique identifier. */ export function generateId(prefix?: string): string; /** * Stringify an object to a query string compatible with Sitevision. * @param {Object} params Object with parameters to stringify. * @param {Object} [options] Optional options. * @param {Boolean} [options.addQueryPrefix = false] If a leading ? should be added to the string. * @returns Stringified parameters. */ export function stringifyParams(params?: any, { addQueryPrefix }?: { addQueryPrefix?: boolean; }): string; /** * Parse an URL or URI to an object containing its query parameters. * @param {String} url URL or URI to be parsed, must start with or contain "?". * @returns Object with parsed parameters. */ export function parseParams(url?: string): {}; /** * Get URI for a route, same as `getStandaloneUrl` in Sitevision router. * @param {string} route A route. * @param {object} params Query parameters. * @returns {string} URI for route. */ export function getRouteUri(route?: string, params?: object): string; /** * Get URI for a view, same as `getUrl` in Sitevision router. * @deprecated Not used in WebApps 2. * @param {string} route A route. * @returns {string} URI for view. */ export function getViewUri(route?: string, params?: any): string; /** * Get URI for a resource. * @param {string} resource A resource. * @returns {string} URI for a resource. */ export function getResourceUri(resource?: string): string; export function setAppProps(data: any): void; /** * Get appData value or object that is passed to app when rendering. * @export * @param {string} [key] - Key for value. * @return {*|object} - Value or object. */ export function getAppProps(key?: string): any | object; /** * If the current code is running on the server. * @constant {boolean} */ export const isServer: any; /** * If the current code is running in the browser. * @constant {boolean} */ export const isBrowser: boolean; /** * DOM friendly unique identifier for the WebApp. * @constant {string} */ export const appId: string; /** * If the WebApp is running in offline mode or not. * @constant {boolean} */ export const isOffline: boolean; /** * If the WebApp is running in online mode or not. * @constant {boolean} */ export const isOnline: boolean; import { localizedCompare } from "./localized-compare"; import { localizedCompareBy } from "./localized-compare"; export { localizedCompare, localizedCompareBy };