@atlaskit/tmp-editor-statsig 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -1
- package/dist/cjs/experiments-config.js +56 -0
- package/dist/cjs/experiments.js +123 -0
- package/dist/cjs/index.js +5 -0
- package/dist/cjs/test-runner.js +83 -0
- package/dist/es2019/experiments-config.js +50 -0
- package/dist/es2019/experiments.js +110 -0
- package/dist/es2019/index.js +1 -0
- package/dist/es2019/test-runner.js +65 -0
- package/dist/esm/experiments-config.js +50 -0
- package/dist/esm/experiments.js +115 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/test-runner.js +77 -0
- package/dist/types/experiments-config.d.ts +43 -0
- package/dist/types/experiments.d.ts +66 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/test-runner.d.ts +41 -0
- package/dist/types-ts4.5/experiments-config.d.ts +43 -0
- package/dist/types-ts4.5/experiments.d.ts +66 -0
- package/dist/types-ts4.5/index.d.ts +1 -0
- package/dist/types-ts4.5/test-runner.d.ts +41 -0
- package/experiments/package.json +14 -0
- package/package.json +9 -9
- package/test-runner/package.json +14 -0
- package/dist/cjs/feature-gate-js-client.js +0 -21
- package/dist/cjs/feature-gates-react.js +0 -110
- package/dist/es2019/feature-gate-js-client.js +0 -14
- package/dist/es2019/feature-gates-react.js +0 -84
- package/dist/esm/feature-gate-js-client.js +0 -14
- package/dist/esm/feature-gates-react.js +0 -101
- package/dist/types/feature-gate-js-client.d.ts +0 -12
- package/dist/types/feature-gates-react.d.ts +0 -19
- package/dist/types-ts4.5/feature-gate-js-client.d.ts +0 -12
- package/dist/types-ts4.5/feature-gates-react.d.ts +0 -19
- package/feature-gate-js-client/package.json +0 -14
- package/feature-gates-react/package.json +0 -14
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* This component initializes the @atlassian/feature-flag-js-client by fetching the gate and experiment
|
|
6
|
-
* evaluations for the given user, and blocks rendering of the children until the rendering is complete.
|
|
7
|
-
*
|
|
8
|
-
* This is based on the private dependency @atlassian/feature-gates-react, which is not intended for public use.
|
|
9
|
-
*
|
|
10
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/FeatureGatesInitialization.tsx
|
|
11
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/utils.tsx
|
|
12
|
-
*/
|
|
13
|
-
export const EditorFeatureGatesInitialization = ({
|
|
14
|
-
children,
|
|
15
|
-
overrides
|
|
16
|
-
}) => {
|
|
17
|
-
// Rather than checking the state of all overrides, we can just assume that if overrides are provided
|
|
18
|
-
// then some sort of update will need to be performed, and hold off rendering until the useEffect is run.
|
|
19
|
-
const [isInitialized, setInitialized] = useState(!overrides && isClientAlreadyInCorrectState());
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const _overrides = {
|
|
22
|
-
configs: {},
|
|
23
|
-
layers: {},
|
|
24
|
-
...overrides
|
|
25
|
-
};
|
|
26
|
-
if (isClientAlreadyInCorrectState()) {
|
|
27
|
-
applyOverrides(_overrides);
|
|
28
|
-
setInitialized(true);
|
|
29
|
-
} else {
|
|
30
|
-
setInitialized(false);
|
|
31
|
-
const initPromise = FeatureGates.initialize({}, {}, {});
|
|
32
|
-
void initPromise.then(() => applyOverrides(_overrides)).catch(err => toError(err)).then(err => {
|
|
33
|
-
setInitialized(true);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return () => clearOverrides(_overrides);
|
|
37
|
-
}, [overrides]);
|
|
38
|
-
if (!isInitialized) {
|
|
39
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, "loading feature flags");
|
|
40
|
-
}
|
|
41
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
42
|
-
};
|
|
43
|
-
let hasWarnedAboutMissingOverrideSupport = false;
|
|
44
|
-
function applyOverrides(overrides) {
|
|
45
|
-
// Allow newer versions of the React SDK to be used with older v3.x JS client versions,
|
|
46
|
-
// provided the caller does not try to leverage the overrides which were introduced in v4.
|
|
47
|
-
if (overrides && (!FeatureGates.overrideGate || !FeatureGates.overrideConfig)) {
|
|
48
|
-
if (!hasWarnedAboutMissingOverrideSupport) {
|
|
49
|
-
// eslint-disable-next-line no-console
|
|
50
|
-
console.warn('Overrides are only supported in @atlaskit/feature-gate-js-client v4.0.0+');
|
|
51
|
-
hasWarnedAboutMissingOverrideSupport = true;
|
|
52
|
-
}
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
Object.entries((overrides === null || overrides === void 0 ? void 0 : overrides.gates) || {}).forEach(([gateName, value]) => {
|
|
56
|
-
var _FeatureGates$overrid;
|
|
57
|
-
(_FeatureGates$overrid = FeatureGates.overrideGate) === null || _FeatureGates$overrid === void 0 ? void 0 : _FeatureGates$overrid.call(FeatureGates, gateName, value);
|
|
58
|
-
});
|
|
59
|
-
Object.entries((overrides === null || overrides === void 0 ? void 0 : overrides.configs) || {}).forEach(([configName, values]) => {
|
|
60
|
-
var _FeatureGates$overrid2;
|
|
61
|
-
(_FeatureGates$overrid2 = FeatureGates.overrideConfig) === null || _FeatureGates$overrid2 === void 0 ? void 0 : _FeatureGates$overrid2.call(FeatureGates, configName, values);
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function isClientAlreadyInCorrectState() {
|
|
65
|
-
var _FeatureGates$initial;
|
|
66
|
-
// If either of these methods don't exist (ie. if the product is using <v4.2.0), then this method will always return false
|
|
67
|
-
return (_FeatureGates$initial = FeatureGates.initializeCompleted) === null || _FeatureGates$initial === void 0 ? void 0 : _FeatureGates$initial.call(FeatureGates);
|
|
68
|
-
}
|
|
69
|
-
function toError(err) {
|
|
70
|
-
if (err instanceof Error) {
|
|
71
|
-
return err;
|
|
72
|
-
}
|
|
73
|
-
return new Error(err === null || err === void 0 ? void 0 : err.toString());
|
|
74
|
-
}
|
|
75
|
-
function clearOverrides(overrides) {
|
|
76
|
-
Object.keys((overrides === null || overrides === void 0 ? void 0 : overrides.gates) || {}).forEach(gateName => {
|
|
77
|
-
var _FeatureGates$clearGa;
|
|
78
|
-
(_FeatureGates$clearGa = FeatureGates.clearGateOverride) === null || _FeatureGates$clearGa === void 0 ? void 0 : _FeatureGates$clearGa.call(FeatureGates, gateName);
|
|
79
|
-
});
|
|
80
|
-
Object.keys((overrides === null || overrides === void 0 ? void 0 : overrides.configs) || {}).forEach(configName => {
|
|
81
|
-
var _FeatureGates$clearCo;
|
|
82
|
-
(_FeatureGates$clearCo = FeatureGates.clearConfigOverride) === null || _FeatureGates$clearCo === void 0 ? void 0 : _FeatureGates$clearCo.call(FeatureGates, configName);
|
|
83
|
-
});
|
|
84
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
2
|
-
var EditorFeatureGates = {
|
|
3
|
-
checkGate: function checkGate(key) {
|
|
4
|
-
return FeatureGates.checkGate(key);
|
|
5
|
-
},
|
|
6
|
-
/**
|
|
7
|
-
*
|
|
8
|
-
* Warning -- this is not yet implemented
|
|
9
|
-
*
|
|
10
|
-
* When implemented -- please update docs/0-intro.tsx
|
|
11
|
-
*/
|
|
12
|
-
getExperimentValue: function () {}
|
|
13
|
-
};
|
|
14
|
-
export default EditorFeatureGates;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
-
import React, { useEffect, useState } from 'react';
|
|
6
|
-
import FeatureGates from '@atlaskit/feature-gate-js-client';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* This component initializes the @atlassian/feature-flag-js-client by fetching the gate and experiment
|
|
10
|
-
* evaluations for the given user, and blocks rendering of the children until the rendering is complete.
|
|
11
|
-
*
|
|
12
|
-
* This is based on the private dependency @atlassian/feature-gates-react, which is not intended for public use.
|
|
13
|
-
*
|
|
14
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/FeatureGatesInitialization.tsx
|
|
15
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/utils.tsx
|
|
16
|
-
*/
|
|
17
|
-
export var EditorFeatureGatesInitialization = function EditorFeatureGatesInitialization(_ref) {
|
|
18
|
-
var children = _ref.children,
|
|
19
|
-
overrides = _ref.overrides;
|
|
20
|
-
// Rather than checking the state of all overrides, we can just assume that if overrides are provided
|
|
21
|
-
// then some sort of update will need to be performed, and hold off rendering until the useEffect is run.
|
|
22
|
-
var _useState = useState(!overrides && isClientAlreadyInCorrectState()),
|
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
-
isInitialized = _useState2[0],
|
|
25
|
-
setInitialized = _useState2[1];
|
|
26
|
-
useEffect(function () {
|
|
27
|
-
var _overrides = _objectSpread({
|
|
28
|
-
configs: {},
|
|
29
|
-
layers: {}
|
|
30
|
-
}, overrides);
|
|
31
|
-
if (isClientAlreadyInCorrectState()) {
|
|
32
|
-
applyOverrides(_overrides);
|
|
33
|
-
setInitialized(true);
|
|
34
|
-
} else {
|
|
35
|
-
setInitialized(false);
|
|
36
|
-
var initPromise = FeatureGates.initialize({}, {}, {});
|
|
37
|
-
void initPromise.then(function () {
|
|
38
|
-
return applyOverrides(_overrides);
|
|
39
|
-
}).catch(function (err) {
|
|
40
|
-
return toError(err);
|
|
41
|
-
}).then(function (err) {
|
|
42
|
-
setInitialized(true);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
return function () {
|
|
46
|
-
return clearOverrides(_overrides);
|
|
47
|
-
};
|
|
48
|
-
}, [overrides]);
|
|
49
|
-
if (!isInitialized) {
|
|
50
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, "loading feature flags");
|
|
51
|
-
}
|
|
52
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
53
|
-
};
|
|
54
|
-
var hasWarnedAboutMissingOverrideSupport = false;
|
|
55
|
-
function applyOverrides(overrides) {
|
|
56
|
-
// Allow newer versions of the React SDK to be used with older v3.x JS client versions,
|
|
57
|
-
// provided the caller does not try to leverage the overrides which were introduced in v4.
|
|
58
|
-
if (overrides && (!FeatureGates.overrideGate || !FeatureGates.overrideConfig)) {
|
|
59
|
-
if (!hasWarnedAboutMissingOverrideSupport) {
|
|
60
|
-
// eslint-disable-next-line no-console
|
|
61
|
-
console.warn('Overrides are only supported in @atlaskit/feature-gate-js-client v4.0.0+');
|
|
62
|
-
hasWarnedAboutMissingOverrideSupport = true;
|
|
63
|
-
}
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
Object.entries((overrides === null || overrides === void 0 ? void 0 : overrides.gates) || {}).forEach(function (_ref2) {
|
|
67
|
-
var _FeatureGates$overrid;
|
|
68
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
69
|
-
gateName = _ref3[0],
|
|
70
|
-
value = _ref3[1];
|
|
71
|
-
(_FeatureGates$overrid = FeatureGates.overrideGate) === null || _FeatureGates$overrid === void 0 || _FeatureGates$overrid.call(FeatureGates, gateName, value);
|
|
72
|
-
});
|
|
73
|
-
Object.entries((overrides === null || overrides === void 0 ? void 0 : overrides.configs) || {}).forEach(function (_ref4) {
|
|
74
|
-
var _FeatureGates$overrid2;
|
|
75
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
76
|
-
configName = _ref5[0],
|
|
77
|
-
values = _ref5[1];
|
|
78
|
-
(_FeatureGates$overrid2 = FeatureGates.overrideConfig) === null || _FeatureGates$overrid2 === void 0 || _FeatureGates$overrid2.call(FeatureGates, configName, values);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
function isClientAlreadyInCorrectState() {
|
|
82
|
-
var _FeatureGates$initial;
|
|
83
|
-
// If either of these methods don't exist (ie. if the product is using <v4.2.0), then this method will always return false
|
|
84
|
-
return (_FeatureGates$initial = FeatureGates.initializeCompleted) === null || _FeatureGates$initial === void 0 ? void 0 : _FeatureGates$initial.call(FeatureGates);
|
|
85
|
-
}
|
|
86
|
-
function toError(err) {
|
|
87
|
-
if (err instanceof Error) {
|
|
88
|
-
return err;
|
|
89
|
-
}
|
|
90
|
-
return new Error(err === null || err === void 0 ? void 0 : err.toString());
|
|
91
|
-
}
|
|
92
|
-
function clearOverrides(overrides) {
|
|
93
|
-
Object.keys((overrides === null || overrides === void 0 ? void 0 : overrides.gates) || {}).forEach(function (gateName) {
|
|
94
|
-
var _FeatureGates$clearGa;
|
|
95
|
-
(_FeatureGates$clearGa = FeatureGates.clearGateOverride) === null || _FeatureGates$clearGa === void 0 || _FeatureGates$clearGa.call(FeatureGates, gateName);
|
|
96
|
-
});
|
|
97
|
-
Object.keys((overrides === null || overrides === void 0 ? void 0 : overrides.configs) || {}).forEach(function (configName) {
|
|
98
|
-
var _FeatureGates$clearCo;
|
|
99
|
-
(_FeatureGates$clearCo = FeatureGates.clearConfigOverride) === null || _FeatureGates$clearCo === void 0 || _FeatureGates$clearCo.call(FeatureGates, configName);
|
|
100
|
-
});
|
|
101
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type EditorFeatureGateKeys = 'platform_editor_inline_comments_on_inline_nodes';
|
|
2
|
-
declare const EditorFeatureGates: {
|
|
3
|
-
checkGate: (key: EditorFeatureGateKeys) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Warning -- this is not yet implemented
|
|
7
|
-
*
|
|
8
|
-
* When implemented -- please update docs/0-intro.tsx
|
|
9
|
-
*/
|
|
10
|
-
getExperimentValue: never;
|
|
11
|
-
};
|
|
12
|
-
export default EditorFeatureGates;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type EditorFeatureGateKeys } from './feature-gate-js-client';
|
|
3
|
-
/**
|
|
4
|
-
* This component initializes the @atlassian/feature-flag-js-client by fetching the gate and experiment
|
|
5
|
-
* evaluations for the given user, and blocks rendering of the children until the rendering is complete.
|
|
6
|
-
*
|
|
7
|
-
* This is based on the private dependency @atlassian/feature-gates-react, which is not intended for public use.
|
|
8
|
-
*
|
|
9
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/FeatureGatesInitialization.tsx
|
|
10
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/utils.tsx
|
|
11
|
-
*/
|
|
12
|
-
export declare const EditorFeatureGatesInitialization: ({ children, overrides, }: {
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
overrides: {
|
|
15
|
-
gates: {
|
|
16
|
-
platform_editor_inline_comments_on_inline_nodes: boolean;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}) => JSX.Element;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export type EditorFeatureGateKeys = 'platform_editor_inline_comments_on_inline_nodes';
|
|
2
|
-
declare const EditorFeatureGates: {
|
|
3
|
-
checkGate: (key: EditorFeatureGateKeys) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* Warning -- this is not yet implemented
|
|
7
|
-
*
|
|
8
|
-
* When implemented -- please update docs/0-intro.tsx
|
|
9
|
-
*/
|
|
10
|
-
getExperimentValue: never;
|
|
11
|
-
};
|
|
12
|
-
export default EditorFeatureGates;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { type EditorFeatureGateKeys } from './feature-gate-js-client';
|
|
3
|
-
/**
|
|
4
|
-
* This component initializes the @atlassian/feature-flag-js-client by fetching the gate and experiment
|
|
5
|
-
* evaluations for the given user, and blocks rendering of the children until the rendering is complete.
|
|
6
|
-
*
|
|
7
|
-
* This is based on the private dependency @atlassian/feature-gates-react, which is not intended for public use.
|
|
8
|
-
*
|
|
9
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/FeatureGatesInitialization.tsx
|
|
10
|
-
* https://bitbucket.org/atlassian/feature-gate-clients/src/main/packages/react-sdk/src/utils.tsx
|
|
11
|
-
*/
|
|
12
|
-
export declare const EditorFeatureGatesInitialization: ({ children, overrides, }: {
|
|
13
|
-
children: React.ReactNode;
|
|
14
|
-
overrides: {
|
|
15
|
-
gates: {
|
|
16
|
-
platform_editor_inline_comments_on_inline_nodes: boolean;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}) => JSX.Element;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/tmp-editor-statsig/feature-gate-js-client",
|
|
3
|
-
"main": "../dist/cjs/feature-gate-js-client.js",
|
|
4
|
-
"module": "../dist/esm/feature-gate-js-client.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/feature-gate-js-client.js",
|
|
6
|
-
"types": "../dist/types/feature-gate-js-client.d.ts",
|
|
7
|
-
"typesVersions": {
|
|
8
|
-
">=4.5 <5.4": {
|
|
9
|
-
"*": [
|
|
10
|
-
"../dist/types-ts4.5/feature-gate-js-client.d.ts"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@atlaskit/tmp-editor-statsig/feature-gates-react",
|
|
3
|
-
"main": "../dist/cjs/feature-gates-react.js",
|
|
4
|
-
"module": "../dist/esm/feature-gates-react.js",
|
|
5
|
-
"module:es2019": "../dist/es2019/feature-gates-react.js",
|
|
6
|
-
"types": "../dist/types/feature-gates-react.d.ts",
|
|
7
|
-
"typesVersions": {
|
|
8
|
-
">=4.5 <5.4": {
|
|
9
|
-
"*": [
|
|
10
|
-
"../dist/types-ts4.5/feature-gates-react.d.ts"
|
|
11
|
-
]
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|