configcat-react
Advanced tools
Comparing version 2.3.0 to 3.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.LocalStorageCache = void 0; | ||
var configcat_common_1 = require("configcat-common"); | ||
var LocalStorageCache = /** @class */ (function () { | ||
function LocalStorageCache() { | ||
this.cache = {}; | ||
} | ||
LocalStorageCache.prototype.set = function (key, config) { | ||
this.cache[key] = config; | ||
LocalStorageCache.prototype.set = function (key, value) { | ||
try { | ||
localStorage.setItem(key, btoa(JSON.stringify(config))); | ||
localStorage.setItem(key, btoa(value)); | ||
} | ||
@@ -19,17 +16,6 @@ catch (ex) { | ||
LocalStorageCache.prototype.get = function (key) { | ||
var config = this.cache[key]; | ||
if (config) { | ||
return config; | ||
} | ||
try { | ||
var configString = localStorage.getItem(key); | ||
if (configString) { | ||
var config_1 = JSON.parse(atob(configString)); | ||
// JSON.parse creates a plain object instance, so we need to manually restore the prototype | ||
// (so we don't run into ""... is not a function" errors). | ||
(Object.setPrototypeOf || (function (o, proto) { return o["__proto__"] = proto; }))(config_1, configcat_common_1.ProjectConfig.prototype); | ||
if (config_1) { | ||
this.cache[key] = config_1; | ||
return config_1; | ||
} | ||
return atob(configString); | ||
} | ||
@@ -40,3 +26,3 @@ } | ||
} | ||
return null; | ||
return void 0; | ||
}; | ||
@@ -43,0 +29,0 @@ return LocalStorageCache; |
@@ -56,3 +56,3 @@ "use strict"; | ||
var getValueFunction = function (client) { | ||
return function name(key, defaultValue, user) { | ||
return function (key, defaultValue, user) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -59,0 +59,0 @@ return __generator(this, function (_a) { |
@@ -44,4 +44,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var configcat_common_1 = require("configcat-common"); | ||
var configcatcommon = __importStar(require("configcat-common")); | ||
var configcat_common_1 = require("configcat-common"); | ||
var react_1 = __importStar(require("react")); | ||
@@ -84,5 +84,5 @@ var Cache_1 = require("./Cache"); | ||
configFetcher: new ConfigFetcher_1.HttpConfigFetcher(), | ||
cache: new Cache_1.LocalStorageCache(), | ||
sdkType: "ConfigCat-React", | ||
sdkVersion: Version_1.default | ||
sdkVersion: Version_1.default, | ||
defaultCacheFactory: function (options) { return new configcat_common_1.ExternalConfigCache(new Cache_1.LocalStorageCache(), options.logger); } | ||
}; | ||
@@ -92,4 +92,4 @@ initializedClients.set(sdkKey, ((_a = initializedClients.get(sdkKey)) !== null && _a !== void 0 ? _a : 0) + 1); | ||
}; | ||
ConfigCatProvider.prototype.reactConfigChanged = function (newConfig) { | ||
this.setState({ lastUpdated: new Date(newConfig.Timestamp) }); | ||
ConfigCatProvider.prototype.reactConfigChanged = function (_newConfig) { | ||
this.setState({ lastUpdated: new Date() }); | ||
}; | ||
@@ -96,0 +96,0 @@ ConfigCatProvider.prototype.clientReady = function () { |
@@ -29,3 +29,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.RefreshResult = exports.OverrideBehaviour = exports.MapOverrideDataSource = exports.FlagOverrides = exports.User = exports.SettingKeyValue = exports.Setting = exports.RolloutPercentageItem = exports.RolloutRule = exports.ProjectConfig = exports.LogLevel = exports.DataGovernance = exports.PollingMode = exports.withConfigCatClient = exports.useConfigCatClient = exports.useFeatureFlag = exports.ConfigCatProvider = exports.createFlagOverridesFromMap = exports.createConsoleLogger = void 0; | ||
exports.RefreshResult = exports.OverrideBehaviour = exports.User = exports.SettingKeyValue = exports.Comparator = exports.SettingType = exports.FormattableLogMessage = exports.LogLevel = exports.DataGovernance = exports.PollingMode = exports.withConfigCatClient = exports.useConfigCatClient = exports.useFeatureFlag = exports.ConfigCatProvider = exports.createFlagOverridesFromMap = exports.createConsoleLogger = void 0; | ||
var configcatcommon = __importStar(require("configcat-common")); | ||
@@ -40,2 +40,6 @@ var configcat_common_1 = require("configcat-common"); | ||
exports.ConfigCatProvider = ConfigCatProvider_1.default; | ||
/** | ||
* Creates an instance of `ConfigCatConsoleLogger`. | ||
* @param logLevel Log level (the minimum level to use for filtering log events). | ||
*/ | ||
function createConsoleLogger(logLevel) { | ||
@@ -45,2 +49,10 @@ return configcatcommon.createConsoleLogger(logLevel); | ||
exports.createConsoleLogger = createConsoleLogger; | ||
/** | ||
* Creates an instance of `FlagOverrides` that uses a map data source. | ||
* @param map The map that contains the overrides. | ||
* @param behaviour The override behaviour. | ||
* Specifies whether the local values should override the remote values | ||
* or local values should only be used when a remote value doesn't exist | ||
* or the local values should be used only. | ||
*/ | ||
function createFlagOverridesFromMap(map, behaviour) { | ||
@@ -59,15 +71,13 @@ return new configcat_common_1.FlagOverrides(new configcat_common_1.MapOverrideDataSource(map), behaviour); | ||
var configcat_common_5 = require("configcat-common"); | ||
Object.defineProperty(exports, "ProjectConfig", { enumerable: true, get: function () { return configcat_common_5.ProjectConfig; } }); | ||
Object.defineProperty(exports, "RolloutRule", { enumerable: true, get: function () { return configcat_common_5.RolloutRule; } }); | ||
Object.defineProperty(exports, "RolloutPercentageItem", { enumerable: true, get: function () { return configcat_common_5.RolloutPercentageItem; } }); | ||
Object.defineProperty(exports, "Setting", { enumerable: true, get: function () { return configcat_common_5.Setting; } }); | ||
Object.defineProperty(exports, "FormattableLogMessage", { enumerable: true, get: function () { return configcat_common_5.FormattableLogMessage; } }); | ||
var configcat_common_6 = require("configcat-common"); | ||
Object.defineProperty(exports, "SettingKeyValue", { enumerable: true, get: function () { return configcat_common_6.SettingKeyValue; } }); | ||
Object.defineProperty(exports, "SettingType", { enumerable: true, get: function () { return configcat_common_6.SettingType; } }); | ||
Object.defineProperty(exports, "Comparator", { enumerable: true, get: function () { return configcat_common_6.Comparator; } }); | ||
var configcat_common_7 = require("configcat-common"); | ||
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return configcat_common_7.User; } }); | ||
Object.defineProperty(exports, "SettingKeyValue", { enumerable: true, get: function () { return configcat_common_7.SettingKeyValue; } }); | ||
var configcat_common_8 = require("configcat-common"); | ||
Object.defineProperty(exports, "FlagOverrides", { enumerable: true, get: function () { return configcat_common_8.FlagOverrides; } }); | ||
Object.defineProperty(exports, "MapOverrideDataSource", { enumerable: true, get: function () { return configcat_common_8.MapOverrideDataSource; } }); | ||
Object.defineProperty(exports, "OverrideBehaviour", { enumerable: true, get: function () { return configcat_common_8.OverrideBehaviour; } }); | ||
Object.defineProperty(exports, "User", { enumerable: true, get: function () { return configcat_common_8.User; } }); | ||
var configcat_common_9 = require("configcat-common"); | ||
Object.defineProperty(exports, "RefreshResult", { enumerable: true, get: function () { return configcat_common_9.RefreshResult; } }); | ||
Object.defineProperty(exports, "OverrideBehaviour", { enumerable: true, get: function () { return configcat_common_9.OverrideBehaviour; } }); | ||
var configcat_common_10 = require("configcat-common"); | ||
Object.defineProperty(exports, "RefreshResult", { enumerable: true, get: function () { return configcat_common_10.RefreshResult; } }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.default = "2.3.0"; | ||
exports.default = "3.0.0"; |
@@ -1,10 +0,7 @@ | ||
import { ProjectConfig } from "configcat-common"; | ||
var LocalStorageCache = /** @class */ (function () { | ||
function LocalStorageCache() { | ||
this.cache = {}; | ||
} | ||
LocalStorageCache.prototype.set = function (key, config) { | ||
this.cache[key] = config; | ||
LocalStorageCache.prototype.set = function (key, value) { | ||
try { | ||
localStorage.setItem(key, btoa(JSON.stringify(config))); | ||
localStorage.setItem(key, btoa(value)); | ||
} | ||
@@ -16,17 +13,6 @@ catch (ex) { | ||
LocalStorageCache.prototype.get = function (key) { | ||
var config = this.cache[key]; | ||
if (config) { | ||
return config; | ||
} | ||
try { | ||
var configString = localStorage.getItem(key); | ||
if (configString) { | ||
var config_1 = JSON.parse(atob(configString)); | ||
// JSON.parse creates a plain object instance, so we need to manually restore the prototype | ||
// (so we don't run into ""... is not a function" errors). | ||
(Object.setPrototypeOf || (function (o, proto) { return o["__proto__"] = proto; }))(config_1, ProjectConfig.prototype); | ||
if (config_1) { | ||
this.cache[key] = config_1; | ||
return config_1; | ||
} | ||
return atob(configString); | ||
} | ||
@@ -37,3 +23,3 @@ } | ||
} | ||
return null; | ||
return void 0; | ||
}; | ||
@@ -40,0 +26,0 @@ return LocalStorageCache; |
@@ -51,3 +51,3 @@ var __assign = (this && this.__assign) || function () { | ||
var getValueFunction = function (client) { | ||
return function name(key, defaultValue, user) { | ||
return function (key, defaultValue, user) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -54,0 +54,0 @@ return __generator(this, function (_a) { |
@@ -16,4 +16,4 @@ var __extends = (this && this.__extends) || (function () { | ||
})(); | ||
import { ExternalConfigCache, PollingMode } from "configcat-common"; | ||
import * as configcatcommon from "configcat-common"; | ||
import { PollingMode } from "configcat-common"; | ||
import React, { Component } from "react"; | ||
@@ -56,5 +56,5 @@ import { LocalStorageCache } from "./Cache"; | ||
configFetcher: new HttpConfigFetcher(), | ||
cache: new LocalStorageCache(), | ||
sdkType: "ConfigCat-React", | ||
sdkVersion: CONFIGCAT_SDK_VERSION | ||
sdkVersion: CONFIGCAT_SDK_VERSION, | ||
defaultCacheFactory: function (options) { return new ExternalConfigCache(new LocalStorageCache(), options.logger); } | ||
}; | ||
@@ -64,4 +64,4 @@ initializedClients.set(sdkKey, ((_a = initializedClients.get(sdkKey)) !== null && _a !== void 0 ? _a : 0) + 1); | ||
}; | ||
ConfigCatProvider.prototype.reactConfigChanged = function (newConfig) { | ||
this.setState({ lastUpdated: new Date(newConfig.Timestamp) }); | ||
ConfigCatProvider.prototype.reactConfigChanged = function (_newConfig) { | ||
this.setState({ lastUpdated: new Date() }); | ||
}; | ||
@@ -68,0 +68,0 @@ ConfigCatProvider.prototype.clientReady = function () { |
@@ -6,5 +6,17 @@ import * as configcatcommon from "configcat-common"; | ||
import ConfigCatProvider from "./ConfigCatProvider"; | ||
/** | ||
* Creates an instance of `ConfigCatConsoleLogger`. | ||
* @param logLevel Log level (the minimum level to use for filtering log events). | ||
*/ | ||
export function createConsoleLogger(logLevel) { | ||
return configcatcommon.createConsoleLogger(logLevel); | ||
} | ||
/** | ||
* Creates an instance of `FlagOverrides` that uses a map data source. | ||
* @param map The map that contains the overrides. | ||
* @param behaviour The override behaviour. | ||
* Specifies whether the local values should override the remote values | ||
* or local values should only be used when a remote value doesn't exist | ||
* or the local values should be used only. | ||
*/ | ||
export function createFlagOverridesFromMap(map, behaviour) { | ||
@@ -19,6 +31,7 @@ return new FlagOverrides(new MapOverrideDataSource(map), behaviour); | ||
export { LogLevel } from "configcat-common"; | ||
export { ProjectConfig, RolloutRule, RolloutPercentageItem, Setting } from "configcat-common"; | ||
export { FormattableLogMessage } from "configcat-common"; | ||
export { SettingType, Comparator } from "configcat-common"; | ||
export { SettingKeyValue } from "configcat-common"; | ||
export { User } from "configcat-common"; | ||
export { FlagOverrides, MapOverrideDataSource, OverrideBehaviour } from "configcat-common"; | ||
export { OverrideBehaviour } from "configcat-common"; | ||
export { RefreshResult } from "configcat-common"; |
@@ -1,1 +0,1 @@ | ||
export default "2.3.0"; | ||
export default "3.0.0"; |
@@ -1,10 +0,6 @@ | ||
import type { ICache } from "configcat-common"; | ||
import { ProjectConfig } from "configcat-common"; | ||
export declare class LocalStorageCache implements ICache { | ||
cache: { | ||
[key: string]: ProjectConfig; | ||
}; | ||
set(key: string, config: ProjectConfig): void; | ||
get(key: string): ProjectConfig | null; | ||
import type { IConfigCatCache } from "configcat-common"; | ||
export declare class LocalStorageCache implements IConfigCatCache { | ||
set(key: string, value: string): void; | ||
get(key: string): string | undefined; | ||
} | ||
//# sourceMappingURL=Cache.d.ts.map |
@@ -1,4 +0,4 @@ | ||
import type { IConfigCatClient, User } from "configcat-common"; | ||
import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "configcat-common"; | ||
import React from "react"; | ||
export type GetValueType = (key: string, defaultValue: any, user?: User) => Promise<any>; | ||
export type GetValueType = <T extends SettingValue>(key: string, defaultValue: T, user?: User) => Promise<SettingTypeOf<T>>; | ||
export interface WithConfigCatClientProps { | ||
@@ -5,0 +5,0 @@ configCatClient: IConfigCatClient; |
@@ -1,4 +0,4 @@ | ||
import type { IConfigCatClient, User } from "configcat-common"; | ||
declare function useFeatureFlag(key: string, defaultValue: any, user?: User | undefined): { | ||
value: any; | ||
import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "configcat-common"; | ||
declare function useFeatureFlag<T extends SettingValue>(key: string, defaultValue: T, user?: User): { | ||
value: SettingTypeOf<T>; | ||
loading: boolean; | ||
@@ -5,0 +5,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import type { IConfigCatClient, ProjectConfig } from "configcat-common"; | ||
import type { IConfig, IConfigCatClient } from "configcat-common"; | ||
import { PollingMode } from "configcat-common"; | ||
@@ -20,3 +20,3 @@ import type { PropsWithChildren } from "react"; | ||
private initializeConfigCatClient; | ||
reactConfigChanged(newConfig: ProjectConfig): void; | ||
reactConfigChanged(_newConfig: IConfig): void; | ||
clientReady(): void; | ||
@@ -23,0 +23,0 @@ render(): JSX.Element; |
@@ -1,2 +0,2 @@ | ||
import type { IAutoPollOptions, IConfigCatLogger, ILazyLoadingOptions, IManualPollOptions, LogLevel } from "configcat-common"; | ||
import type { IAutoPollOptions, IConfigCatLogger, ILazyLoadingOptions, IManualPollOptions, LogLevel, OverrideBehaviour, SettingValue } from "configcat-common"; | ||
import { FlagOverrides } from "configcat-common"; | ||
@@ -7,8 +7,23 @@ import type { GetValueType, WithConfigCatClientProps } from "./ConfigCatHOC"; | ||
import ConfigCatProvider from "./ConfigCatProvider"; | ||
/** | ||
* Creates an instance of `ConfigCatConsoleLogger`. | ||
* @param logLevel Log level (the minimum level to use for filtering log events). | ||
*/ | ||
export declare function createConsoleLogger(logLevel: LogLevel): IConfigCatLogger; | ||
/** | ||
* Creates an instance of `FlagOverrides` that uses a map data source. | ||
* @param map The map that contains the overrides. | ||
* @param behaviour The override behaviour. | ||
* Specifies whether the local values should override the remote values | ||
* or local values should only be used when a remote value doesn't exist | ||
* or the local values should be used only. | ||
*/ | ||
export declare function createFlagOverridesFromMap(map: { | ||
[name: string]: any; | ||
}, behaviour: number): FlagOverrides; | ||
[name: string]: NonNullable<SettingValue>; | ||
}, behaviour: OverrideBehaviour): FlagOverrides; | ||
/** Options used to configure the ConfigCat SDK in the case of Auto Polling mode. */ | ||
export type IReactAutoPollOptions = IAutoPollOptions; | ||
/** Options used to configure the ConfigCat SDK in the case of Lazy Loading mode. */ | ||
export type IReactLazyLoadingOptions = ILazyLoadingOptions; | ||
/** Options used to configure the ConfigCat SDK in the case of Manual Polling mode. */ | ||
export type IReactManualPollOptions = IManualPollOptions; | ||
@@ -23,13 +38,16 @@ export type IReactConfigCatLogger = IConfigCatLogger; | ||
export type { IConfigCatLogger } from "configcat-common"; | ||
export type { LogEventId, LogMessage } from "configcat-common"; | ||
export { LogLevel } from "configcat-common"; | ||
export type { ICache } from "configcat-common"; | ||
export { ProjectConfig, RolloutRule, RolloutPercentageItem, Setting } from "configcat-common"; | ||
export { FormattableLogMessage } from "configcat-common"; | ||
export type { IConfigCatCache } from "configcat-common"; | ||
export type { IConfig, ISetting, ITargetingRule, IPercentageOption, SettingValue, VariationIdValue } from "configcat-common"; | ||
export { SettingType, Comparator } from "configcat-common"; | ||
export type { IConfigCatClient } from "configcat-common"; | ||
export { SettingKeyValue } from "configcat-common"; | ||
export type { IEvaluationDetails, SettingTypeOf, SettingValue, VariationIdTypeOf, VariationIdValue } from "configcat-common"; | ||
export type { IEvaluationDetails, SettingTypeOf } from "configcat-common"; | ||
export { User } from "configcat-common"; | ||
export type { IOverrideDataSource } from "configcat-common"; | ||
export { FlagOverrides, MapOverrideDataSource, OverrideBehaviour } from "configcat-common"; | ||
export type { FlagOverrides } from "configcat-common"; | ||
export { OverrideBehaviour } from "configcat-common"; | ||
export { RefreshResult } from "configcat-common"; | ||
export type { IProvidesHooks, HookEvents } from "configcat-common"; | ||
//# sourceMappingURL=index.d.ts.map |
{ | ||
"name": "configcat-react", | ||
"version": "2.3.0", | ||
"version": "3.0.0", | ||
"scripts": { | ||
@@ -36,3 +36,3 @@ "build": "npm run build:esm && npm run build:cjs", | ||
"dependencies": { | ||
"configcat-common": "^7.0.1", | ||
"configcat-common": "^8.0.0", | ||
"tslib": "^2.4.1" | ||
@@ -39,0 +39,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57771
37
765
+ Addedconfigcat-common@8.2.0(transitive)
- Removedconfigcat-common@7.0.1(transitive)
Updatedconfigcat-common@^8.0.0