import { DeepReadonly } from './Types.js'; /** * Lists well known config property names and their types. */ interface WellknownConfigKeys { /** * True if deprecation messages shall be logged. */ "log-deprecations": boolean; /** * Is the debug mode enabled */ "debug": boolean; /** * The configured locale. * Use `apprt-core/Locale.getCurrent()` to access the value. */ "locale": string; /** * The globally supported locales. */ "supported-locales": string[]; /** * May show a warning to the user if the device is unlikely to render * a graphical application with acceptable performance. * Setting this to `false` disables the warning for all users. */ "warn-on-slow-graphics-performance": boolean; /** * URL pointing to the current app directory. */ "app-base-url": string; /** * The global logging configuration. * A string of the format `logger:LEVEL,other:LEVEL`. * Level = DEBUG, INFO, WARN, ERROR, OFF * Is interpreted by apprt-core/Logger */ "logging": string; /** * URL to the js-registry providing the test bundles. * Only available during test execution. */ "testing-jsregistry-url": string; /** * Registry URL used to fetch the apprt system. */ "apprt-jsregistry-url": string; /** * The name of the default application. */ "app-launch-default-app": string; /** * Defines that pre-fetching of module.js files via registry/layer.js is enabled. */ "app-launch-prefetch-enabled": boolean; /** * Defines that during the pre-fetching main.js files should be included. * @deprecated the settings is obsolete. */ "app-launch-prefetch-main": boolean; /** * Defines that switching to HTTP POST is allowed during layer.js pre-fetching. */ "app-launch-prefetch-with-post-enabled": boolean; /** * Instead of switching to post, the pre-fetching is using mulitple get requests if the url is to long. */ "app-launch-prefetch-with-get-split": boolean; /** * Defines that the layer.js request is using gzip encoded parameters to keep the parameter size short. */ "app-launch-prefetch-params-compressed": boolean; /** * Defines that the app.json and bundles.json requests should use jsonp. * @deprecated this support will be dropped for security reasons. */ "app-launch-jsonp-enabled": boolean; /** * Enables statistics calculation during app start. */ "app-launch-statistics-enabled": boolean; /** * Information of apprt-boot for the Launcher. */ "apprt-boot-loader-info": any; /** * A globally configured Enterprise-Portal URL. */ "arcgis-portal-url": string; /** * The globally configured ArcGIS API key. */ "esri-api-key": string; /** * URL to the /agol/token endpoint of map.apps. * Which provides an technical user token to e.g. consume a geolocation service as anonymous app user. */ "esri-identity-app-token-url": string; /** * Enables the use of the /agol/token endpoint. */ "esri-identity-app-token-enabled": boolean; /** * Enables the persistence of the @arcgis/core/identity/IdentityManager state in the local storage. */ "esri-identity-state-persist": boolean; /** * The name of the state in the local storage. */ "esri-identity-state-name": string; /** * The prefix of the state in the local storage. * If this is not configured then the default prefix is the app location. * This should prevent interferences between apps. */ "esri-identity-state-name-prefix": string; /** * Allows the @arcgis/core/IdentityManager to send credentials via http. * Note this is only intended for development purpose * and should never be enabled during production. */ "esri-identity-allow-credentials-over-http": boolean; /** * Enables client side oauth for the application. */ "oauth-enabled": boolean; /** * Which expiration should the requested oauth token have. */ "oauth-access-token-expiration": number; /** * The client-id or app-id to authenticated with. */ "oauth-app-id": string; "oauth-namespace": string; /** * Should the login dialog be shown inside a popup. */ "oauth-use-popup": boolean; /** * URL to a callback page which consumes the access token. * Only of interest if oauth-use-popup is true. */ "oauth-popup-callback-page": string; "oauth-force-login": string; /** * Refresh interval for geo-location updates. */ "geolocation-update-interval": number; /** * Maximal allowed URL length before automatically switching to POST. */ "request-max-url-length": number; /** * Default request timeout. */ "request-timeout": number; /** * Disables automatic CORS proxy fallback. */ "request-proxy-disabled": boolean; /** * The default proxy URL. */ "request-proxy-url": string; /** * Proxy use rules. */ "request-proxy-rules": { origin: string; proxyUrl?: string; }[]; /** * The trusted servers. * Required for secure CORS communication. */ "request-trusted-servers": string[]; /** * Plain esri key, provides a way to configure the properties in @arcgis/core/config. * Used by apprt-esri-init. */ "esri-conf": { [prop: string]: SupportedValueTypes; }; /** * Is an algorithm to re-calculate the viewport size for mobile enabled. */ "mobile-fix-viewport": boolean; /** * Should the use of the fix algorithm be enforced. */ "mobile-fix-viewport-force": boolean; /** * Is touch scroll enabled for dgrid. */ "dgrid-touchscroll": boolean; } /** Valid configuration property names. */ type ConfigKey = keyof WellknownConfigKeys; /** * Lists well known environment property names and their types. */ interface WellknownEnvKeys { /** * True if content security policy settings prevent eval() etc. */ "csp-restrictions": boolean; /** * True if WebAssembly is enabled. */ "webassembly": boolean; /** * True if the browser supports WebGL 2, like required for the esri js api. */ "webgl": boolean; /** * True if WebGL 2 is only supported with degraded performance, e.g. due to software rendering. * See flag `failIfMajorPerformanceCaveat` for https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext */ "webgl-performance-caveats": boolean; /** * Detection if the client device is touch enabled. */ "touch": boolean; /** * Detection if the client is a mobile device. */ "mobile": boolean; /** * Whether the client is an ipad. */ "ipad": boolean; /** * Detection if the client is the Internet Explorer. */ "ie": number; /** * Detection if the client is FireFox. */ "ff": number; /** * Detection if the client is Safari. */ "safari": number; /** * Detection if the client is an Android device. */ "android": number; } /** Valid environment property names. */ type EnvKey = keyof WellknownEnvKeys; /** Supported value types. */ type SupportedValueTypes = undefined | null | boolean | number | string | SupportedValueTypes[] | { [prop: string]: SupportedValueTypes; }; /** * A function producing a result for a given key. */ type ValueProvider = (key: KeyType) => ResultType | undefined; /** * Type used by the register functions to * distinguish a plain value or a function providing the value. */ type ValueOrValueProvider = ResultType | ValueProvider; /** * Options accepted by the register* functions. */ interface RegisterOptions { /** * If `true` and the value is a provider function, it is only invoked once. * Otherwise the function is invoked for every call for key. * Default is `true`. */ cacheProvidedValue?: boolean; /** * If `true` and there is a provider already, the existing provider is replaced. * Otherwise an error is thrown. */ overwrite?: boolean; } /** * A value interceptor. */ interface Interceptor { /** * An interceptor is informed about any config key access. * The lookupValue function can be used to fetch the original configuration value. * An interceptor may return custom values. * * @param key config key * @param lookupValue a function providing the original config value * @returns the intercepted config value or undefined */ (key: string, lookupValue: () => SupportedValueTypes): SupportedValueTypes | undefined; } /** * This class implements the internal lazy configuration state. * It is exported for test purpose only. * * @internal */ declare class LazyValues { #private; interceptor: Interceptor | undefined; get(key: K): DeepReadonly | undefined; registeredKeys(): Set; register(key: Key, valueProvider: ValueOrValueProvider, { cacheProvidedValue, overwrite }?: RegisterOptions): void; isRegistered(key: Key): boolean; unregister(key: Key): boolean; } /** * Returns the configuration value associated with the given key. * Returns `undefined` if the key is unknown. * * @param key one of the WellknownConfigKeys * @returns the config value matching the key. */ declare function configValue(key: Key): DeepReadonly | undefined; /** * Registers a new key with the configuration. * Keys and values must also be declared at the type-level by extending the `WellknownConfigKeys` interface. * * Throws an exception if the key was already registered. * * @param key the configuration key * @param valueOrProvider the value or a function returning the value (for lazy evaluation). * @param options registration flags */ declare function registerConfigValue(key: ConfigKey, valueOrProvider: ValueOrValueProvider, options?: RegisterOptions): void; /** * The intention of this function is to make testing simpler. * A test can register a config value and unregister it afterwards. * * @param key a config key * @returns true if conf value was un-registered(previously registered) */ declare function unregisterConfigValue(key: ConfigKey): boolean; /** * The intention of this function is to make testing simpler. * * Do not forget to unset your interceptor after the tests by invoking this function with no arguments. * @param interceptor a callback informed about any config value access. */ declare function setConfigValueInterceptor(interceptor?: Interceptor): void; /** * Returns the environment value associated with the given key. * Returns `undefined` if the key is not known. * * @param key one of the WellknownEnvKeys * @returns the environment value matching the key. */ declare function envValue(key: Key): DeepReadonly | undefined; /** * Registers a new environment key with the configuration. * Keys and values must also be declared at the type-level by extending the `WellknownEnvKeys` interface. * * Throws an exception if the key was already registered. * * @param key the env key * @param valueOrProvider the value or a function returning the value (for lazy evaluation). * @param options registration flags */ declare function registerEnvValue(key: EnvKey, valueOrProvider: ValueOrValueProvider, options?: RegisterOptions): void; /** * The intention of this function is to make testing simpler. * A test can register a env value and unregister it afterwards. * @param key a env key * @returns true if env value was un-registered(previously registered) */ declare function unregisterEnvValue(key: EnvKey): boolean; /** * The intention of this function is to make testing simpler. * * Do not forget to unset the interceptor after the tests. * @param interceptor a callback informed about any env value access. */ declare function setEnvValueInterceptor(interceptor?: Interceptor): void; export { LazyValues, configValue, envValue, registerConfigValue, registerEnvValue, setConfigValueInterceptor, setEnvValueInterceptor, unregisterConfigValue, unregisterEnvValue }; export type { ConfigKey, EnvKey, Interceptor, RegisterOptions, SupportedValueTypes, ValueOrValueProvider, ValueProvider, WellknownConfigKeys, WellknownEnvKeys };