@atlaskit/platform-feature-flags
Advanced tools
Comparing version 0.2.3 to 0.2.4
# @atlaskit/platform-feature-flags | ||
## 0.2.4 | ||
### Patch Changes | ||
- [`d6a9413f008`](https://bitbucket.org/atlassian/atlassian-frontend/commits/d6a9413f008) - Store the Platform Feaature Flags booleanFeatureFlagResolver on the global so that it won't matter if multiple different versions of the library are installed | ||
## 0.2.3 | ||
@@ -4,0 +10,0 @@ |
@@ -10,3 +10,5 @@ "use strict"; | ||
/** | ||
* Sets the flag resolver for boolean flags. | ||
* This creates a boolean flag resolver that allows calls to `getBooleanFF` inside of Platform components to use a Product's | ||
* feature flag client and LD project, rather than installing a feature flag client of their own, or passing those flags in via props. | ||
* | ||
* @param flagResolver | ||
@@ -20,2 +22,3 @@ */ | ||
* Returns the value of a feature flag. If the flag does not resolve, it returns the "false" as a default value. | ||
* | ||
* @param name | ||
@@ -22,0 +25,0 @@ */ |
@@ -6,2 +6,3 @@ "use strict"; | ||
}); | ||
exports.PFF_GLOBAL_KEY = void 0; | ||
exports.resolveBooleanFlag = resolveBooleanFlag; | ||
@@ -11,2 +12,4 @@ exports.setBooleanResolver = setBooleanResolver; | ||
var pkgName = '@atlaskit/platform-feature-flags'; | ||
var PFF_GLOBAL_KEY = '__PLATFORM_FEATURE_FLAGS__'; | ||
exports.PFF_GLOBAL_KEY = PFF_GLOBAL_KEY; | ||
var hasProcessEnv = typeof process !== 'undefined' && typeof process.env !== 'undefined'; | ||
@@ -26,19 +29,23 @@ | ||
var ENABLE_GLOBAL_PLATFORM_FF_OVERRIDE = ENV_ENABLE_PLATFORM_FF || ENV_STORYBOOK_ENABLE_PLATFORM_FF; | ||
// In development mode we want to capture any feature flag checks that happen using the default resolver and log this result when the resolver is replaced. | ||
// This is because evaluating feature flags when the resolver/FF client is loaded asynchronously could cause unexpected issues. | ||
var flagsResolvedEarly = new Map(); | ||
var booleanResolver = function booleanResolver(flagKey) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var _flagsResolvedEarly$g; | ||
var unresolvedFlagCount = (_flagsResolvedEarly$g = flagsResolvedEarly.get(flagKey)) !== null && _flagsResolvedEarly$g !== void 0 ? _flagsResolvedEarly$g : 0; | ||
flagsResolvedEarly.set(flagKey, unresolvedFlagCount + 1); | ||
var DEFAULT_PFF_GLOBAL = { | ||
// In development mode we want to capture any feature flag checks that happen using the default resolver and log this result when the resolver is replaced. | ||
// This is because evaluating feature flags when the resolver/FF client is loaded asynchronously could cause unexpected issues. | ||
earlyResolvedFlags: new Map(), | ||
booleanResolver: function booleanResolver(flagKey) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var unresolvedFlagCount = this.earlyResolvedFlags.get(flagKey) || 0; | ||
this.earlyResolvedFlags.set(flagKey, unresolvedFlagCount + 1); | ||
} | ||
return false; | ||
} | ||
return false; | ||
}; | ||
var globalVar = typeof window !== 'undefined' ? window : globalThis; | ||
globalVar[PFF_GLOBAL_KEY] = globalVar[PFF_GLOBAL_KEY] || DEFAULT_PFF_GLOBAL; | ||
function setBooleanResolver(resolver) { | ||
booleanResolver = resolver; | ||
globalVar[PFF_GLOBAL_KEY].booleanResolver = resolver; | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (flagsResolvedEarly.size > 0) { | ||
(0, _debug.debug)("[%s]: The following list of Feature Flags were called, the following number of times, before setBooleanResolver.", pkgName, Array.from(flagsResolvedEarly.entries())); | ||
flagsResolvedEarly.clear(); | ||
var _globalVar$PFF_GLOBAL, _globalVar$PFF_GLOBAL2; | ||
if (((_globalVar$PFF_GLOBAL = globalVar[PFF_GLOBAL_KEY]) === null || _globalVar$PFF_GLOBAL === void 0 ? void 0 : (_globalVar$PFF_GLOBAL2 = _globalVar$PFF_GLOBAL.earlyResolvedFlags) === null || _globalVar$PFF_GLOBAL2 === void 0 ? void 0 : _globalVar$PFF_GLOBAL2.size) > 0) { | ||
(0, _debug.debug)("[%s]: The following list of Feature Flags were called, the following number of times, before setBooleanResolver.", pkgName, Array.from(globalVar[PFF_GLOBAL_KEY].earlyResolvedFlags.entries())); | ||
globalVar[PFF_GLOBAL_KEY].earlyResolvedFlags.clear(); | ||
} | ||
@@ -53,3 +60,4 @@ } | ||
try { | ||
var result = booleanResolver(flagKey); | ||
var _globalVar$PFF_GLOBAL3; | ||
var result = (_globalVar$PFF_GLOBAL3 = globalVar[PFF_GLOBAL_KEY]) === null || _globalVar$PFF_GLOBAL3 === void 0 ? void 0 : _globalVar$PFF_GLOBAL3.booleanResolver(flagKey); | ||
if (typeof result !== 'boolean') { | ||
@@ -56,0 +64,0 @@ // eslint-disable-next-line no-console |
{ | ||
"name": "@atlaskit/platform-feature-flags", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"sideEffects": false | ||
} |
import { setBooleanResolver, resolveBooleanFlag } from './resolvers'; | ||
/** | ||
* Sets the flag resolver for boolean flags. | ||
* This creates a boolean flag resolver that allows calls to `getBooleanFF` inside of Platform components to use a Product's | ||
* feature flag client and LD project, rather than installing a feature flag client of their own, or passing those flags in via props. | ||
* | ||
* @param flagResolver | ||
@@ -13,2 +15,3 @@ */ | ||
* Returns the value of a feature flag. If the flag does not resolve, it returns the "false" as a default value. | ||
* | ||
* @param name | ||
@@ -15,0 +18,0 @@ */ |
import { debug } from './debug'; | ||
const pkgName = '@atlaskit/platform-feature-flags'; | ||
export const PFF_GLOBAL_KEY = '__PLATFORM_FEATURE_FLAGS__'; | ||
const hasProcessEnv = typeof process !== 'undefined' && typeof process.env !== 'undefined'; | ||
@@ -17,19 +18,23 @@ | ||
const ENABLE_GLOBAL_PLATFORM_FF_OVERRIDE = ENV_ENABLE_PLATFORM_FF || ENV_STORYBOOK_ENABLE_PLATFORM_FF; | ||
// In development mode we want to capture any feature flag checks that happen using the default resolver and log this result when the resolver is replaced. | ||
// This is because evaluating feature flags when the resolver/FF client is loaded asynchronously could cause unexpected issues. | ||
const flagsResolvedEarly = new Map(); | ||
let booleanResolver = flagKey => { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var _flagsResolvedEarly$g; | ||
const unresolvedFlagCount = (_flagsResolvedEarly$g = flagsResolvedEarly.get(flagKey)) !== null && _flagsResolvedEarly$g !== void 0 ? _flagsResolvedEarly$g : 0; | ||
flagsResolvedEarly.set(flagKey, unresolvedFlagCount + 1); | ||
const DEFAULT_PFF_GLOBAL = { | ||
// In development mode we want to capture any feature flag checks that happen using the default resolver and log this result when the resolver is replaced. | ||
// This is because evaluating feature flags when the resolver/FF client is loaded asynchronously could cause unexpected issues. | ||
earlyResolvedFlags: new Map(), | ||
booleanResolver: function (flagKey) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
const unresolvedFlagCount = this.earlyResolvedFlags.get(flagKey) || 0; | ||
this.earlyResolvedFlags.set(flagKey, unresolvedFlagCount + 1); | ||
} | ||
return false; | ||
} | ||
return false; | ||
}; | ||
const globalVar = typeof window !== 'undefined' ? window : globalThis; | ||
globalVar[PFF_GLOBAL_KEY] = globalVar[PFF_GLOBAL_KEY] || DEFAULT_PFF_GLOBAL; | ||
export function setBooleanResolver(resolver) { | ||
booleanResolver = resolver; | ||
globalVar[PFF_GLOBAL_KEY].booleanResolver = resolver; | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (flagsResolvedEarly.size > 0) { | ||
debug(`[%s]: The following list of Feature Flags were called, the following number of times, before setBooleanResolver.`, pkgName, Array.from(flagsResolvedEarly.entries())); | ||
flagsResolvedEarly.clear(); | ||
var _globalVar$PFF_GLOBAL, _globalVar$PFF_GLOBAL2; | ||
if (((_globalVar$PFF_GLOBAL = globalVar[PFF_GLOBAL_KEY]) === null || _globalVar$PFF_GLOBAL === void 0 ? void 0 : (_globalVar$PFF_GLOBAL2 = _globalVar$PFF_GLOBAL.earlyResolvedFlags) === null || _globalVar$PFF_GLOBAL2 === void 0 ? void 0 : _globalVar$PFF_GLOBAL2.size) > 0) { | ||
debug(`[%s]: The following list of Feature Flags were called, the following number of times, before setBooleanResolver.`, pkgName, Array.from(globalVar[PFF_GLOBAL_KEY].earlyResolvedFlags.entries())); | ||
globalVar[PFF_GLOBAL_KEY].earlyResolvedFlags.clear(); | ||
} | ||
@@ -44,3 +49,4 @@ } | ||
try { | ||
const result = booleanResolver(flagKey); | ||
var _globalVar$PFF_GLOBAL3; | ||
const result = (_globalVar$PFF_GLOBAL3 = globalVar[PFF_GLOBAL_KEY]) === null || _globalVar$PFF_GLOBAL3 === void 0 ? void 0 : _globalVar$PFF_GLOBAL3.booleanResolver(flagKey); | ||
if (typeof result !== 'boolean') { | ||
@@ -47,0 +53,0 @@ // eslint-disable-next-line no-console |
{ | ||
"name": "@atlaskit/platform-feature-flags", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"sideEffects": false | ||
} |
import { setBooleanResolver, resolveBooleanFlag } from './resolvers'; | ||
/** | ||
* Sets the flag resolver for boolean flags. | ||
* This creates a boolean flag resolver that allows calls to `getBooleanFF` inside of Platform components to use a Product's | ||
* feature flag client and LD project, rather than installing a feature flag client of their own, or passing those flags in via props. | ||
* | ||
* @param flagResolver | ||
@@ -13,2 +15,3 @@ */ | ||
* Returns the value of a feature flag. If the flag does not resolve, it returns the "false" as a default value. | ||
* | ||
* @param name | ||
@@ -15,0 +18,0 @@ */ |
import { debug } from './debug'; | ||
var pkgName = '@atlaskit/platform-feature-flags'; | ||
export var PFF_GLOBAL_KEY = '__PLATFORM_FEATURE_FLAGS__'; | ||
var hasProcessEnv = typeof process !== 'undefined' && typeof process.env !== 'undefined'; | ||
@@ -17,19 +18,23 @@ | ||
var ENABLE_GLOBAL_PLATFORM_FF_OVERRIDE = ENV_ENABLE_PLATFORM_FF || ENV_STORYBOOK_ENABLE_PLATFORM_FF; | ||
// In development mode we want to capture any feature flag checks that happen using the default resolver and log this result when the resolver is replaced. | ||
// This is because evaluating feature flags when the resolver/FF client is loaded asynchronously could cause unexpected issues. | ||
var flagsResolvedEarly = new Map(); | ||
var booleanResolver = function booleanResolver(flagKey) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var _flagsResolvedEarly$g; | ||
var unresolvedFlagCount = (_flagsResolvedEarly$g = flagsResolvedEarly.get(flagKey)) !== null && _flagsResolvedEarly$g !== void 0 ? _flagsResolvedEarly$g : 0; | ||
flagsResolvedEarly.set(flagKey, unresolvedFlagCount + 1); | ||
var DEFAULT_PFF_GLOBAL = { | ||
// In development mode we want to capture any feature flag checks that happen using the default resolver and log this result when the resolver is replaced. | ||
// This is because evaluating feature flags when the resolver/FF client is loaded asynchronously could cause unexpected issues. | ||
earlyResolvedFlags: new Map(), | ||
booleanResolver: function booleanResolver(flagKey) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
var unresolvedFlagCount = this.earlyResolvedFlags.get(flagKey) || 0; | ||
this.earlyResolvedFlags.set(flagKey, unresolvedFlagCount + 1); | ||
} | ||
return false; | ||
} | ||
return false; | ||
}; | ||
var globalVar = typeof window !== 'undefined' ? window : globalThis; | ||
globalVar[PFF_GLOBAL_KEY] = globalVar[PFF_GLOBAL_KEY] || DEFAULT_PFF_GLOBAL; | ||
export function setBooleanResolver(resolver) { | ||
booleanResolver = resolver; | ||
globalVar[PFF_GLOBAL_KEY].booleanResolver = resolver; | ||
if (process.env.NODE_ENV !== 'production') { | ||
if (flagsResolvedEarly.size > 0) { | ||
debug("[%s]: The following list of Feature Flags were called, the following number of times, before setBooleanResolver.", pkgName, Array.from(flagsResolvedEarly.entries())); | ||
flagsResolvedEarly.clear(); | ||
var _globalVar$PFF_GLOBAL, _globalVar$PFF_GLOBAL2; | ||
if (((_globalVar$PFF_GLOBAL = globalVar[PFF_GLOBAL_KEY]) === null || _globalVar$PFF_GLOBAL === void 0 ? void 0 : (_globalVar$PFF_GLOBAL2 = _globalVar$PFF_GLOBAL.earlyResolvedFlags) === null || _globalVar$PFF_GLOBAL2 === void 0 ? void 0 : _globalVar$PFF_GLOBAL2.size) > 0) { | ||
debug("[%s]: The following list of Feature Flags were called, the following number of times, before setBooleanResolver.", pkgName, Array.from(globalVar[PFF_GLOBAL_KEY].earlyResolvedFlags.entries())); | ||
globalVar[PFF_GLOBAL_KEY].earlyResolvedFlags.clear(); | ||
} | ||
@@ -44,3 +49,4 @@ } | ||
try { | ||
var result = booleanResolver(flagKey); | ||
var _globalVar$PFF_GLOBAL3; | ||
var result = (_globalVar$PFF_GLOBAL3 = globalVar[PFF_GLOBAL_KEY]) === null || _globalVar$PFF_GLOBAL3 === void 0 ? void 0 : _globalVar$PFF_GLOBAL3.booleanResolver(flagKey); | ||
if (typeof result !== 'boolean') { | ||
@@ -47,0 +53,0 @@ // eslint-disable-next-line no-console |
{ | ||
"name": "@atlaskit/platform-feature-flags", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"sideEffects": false | ||
} |
import { FeatureFlagResolverBoolean } from './resolvers'; | ||
/** | ||
* Sets the flag resolver for boolean flags. | ||
* This creates a boolean flag resolver that allows calls to `getBooleanFF` inside of Platform components to use a Product's | ||
* feature flag client and LD project, rather than installing a feature flag client of their own, or passing those flags in via props. | ||
* | ||
* @param flagResolver | ||
@@ -9,4 +11,5 @@ */ | ||
* Returns the value of a feature flag. If the flag does not resolve, it returns the "false" as a default value. | ||
* | ||
* @param name | ||
*/ | ||
export declare function getBooleanFF(name: string): boolean; |
@@ -0,3 +1,4 @@ | ||
export declare const PFF_GLOBAL_KEY: "__PLATFORM_FEATURE_FLAGS__"; | ||
export type FeatureFlagResolverBoolean = (key: string) => boolean; | ||
export declare function setBooleanResolver(resolver: FeatureFlagResolverBoolean): void; | ||
export declare function resolveBooleanFlag(flagKey: string): boolean; |
import { FeatureFlagResolverBoolean } from './resolvers'; | ||
/** | ||
* Sets the flag resolver for boolean flags. | ||
* This creates a boolean flag resolver that allows calls to `getBooleanFF` inside of Platform components to use a Product's | ||
* feature flag client and LD project, rather than installing a feature flag client of their own, or passing those flags in via props. | ||
* | ||
* @param flagResolver | ||
@@ -9,4 +11,5 @@ */ | ||
* Returns the value of a feature flag. If the flag does not resolve, it returns the "false" as a default value. | ||
* | ||
* @param name | ||
*/ | ||
export declare function getBooleanFF(name: string): boolean; |
@@ -0,3 +1,4 @@ | ||
export declare const PFF_GLOBAL_KEY: "__PLATFORM_FEATURE_FLAGS__"; | ||
export type FeatureFlagResolverBoolean = (key: string) => boolean; | ||
export declare function setBooleanResolver(resolver: FeatureFlagResolverBoolean): void; | ||
export declare function resolveBooleanFlag(flagKey: string): boolean; |
{ | ||
"name": "@atlaskit/platform-feature-flags", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"description": "Platform Feature Flags", | ||
@@ -5,0 +5,0 @@ "publishConfig": { |
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
25618
341