@flagship.io/react-sdk 4.0.0-alpha.1 → 4.0.0-alpha.2

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.
@@ -0,0 +1,154 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ // eslint-disable-next-line no-use-before-define
4
+ import { useState, useRef, useEffect } from 'react';
5
+ import Flagship, { DecisionMode, FSSdkStatus } from '@flagship.io/js-sdk';
6
+ import { FlagshipContext, initStat } from './FlagshipContext';
7
+ import { INTERNAL_EVENTS } from './internalType';
8
+ import { version as SDK_VERSION } from './sdkVersion';
9
+ import { useNonInitialEffect, logError, extractFlagsMap } from './utils';
10
+ export function FlagshipProvider({ children, envId, apiKey, decisionMode = DecisionMode.DECISION_API, visitorData, loadingComponent, onSdkStatusChanged, onBucketingUpdated, initialCampaigns, initialFlagsData, fetchFlagsOnBucketingUpdated, hitDeduplicationTime = 2, fetchNow = true, language = 1, sdkVersion = SDK_VERSION, onFetchFlagsStatusChanged, shouldSaveInstance, ...props }) {
11
+ const flags = extractFlagsMap(initialFlagsData, initialCampaigns);
12
+ const [state, setState] = useState({
13
+ ...initStat,
14
+ flags,
15
+ hasVisitorData: !!visitorData
16
+ });
17
+ const [lastModified, setLastModified] = useState();
18
+ const stateRef = useRef();
19
+ stateRef.current = state;
20
+ // #region functions
21
+ const onBucketingLastModified = (lastUpdate) => {
22
+ if (onBucketingUpdated) {
23
+ onBucketingUpdated(lastUpdate);
24
+ }
25
+ setLastModified(lastUpdate);
26
+ };
27
+ const statusChanged = (status) => {
28
+ if (onSdkStatusChanged) {
29
+ onSdkStatusChanged(status);
30
+ }
31
+ switch (status) {
32
+ case FSSdkStatus.SDK_PANIC:
33
+ case FSSdkStatus.SDK_INITIALIZED:
34
+ createVisitor();
35
+ break;
36
+ case FSSdkStatus.SDK_NOT_INITIALIZED:
37
+ setState((prev) => ({
38
+ ...prev,
39
+ config: Flagship.getConfig(),
40
+ isInitializing: false
41
+ }));
42
+ break;
43
+ }
44
+ };
45
+ const initSdk = () => {
46
+ Flagship.start(envId, apiKey, {
47
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
+ decisionMode: decisionMode,
49
+ fetchNow,
50
+ onSdkStatusChanged: statusChanged,
51
+ onBucketingUpdated: onBucketingLastModified,
52
+ hitDeduplicationTime,
53
+ language,
54
+ sdkVersion,
55
+ ...props
56
+ });
57
+ };
58
+ function initializeState(param) {
59
+ setState((currentState) => ({
60
+ ...currentState,
61
+ visitor: param.fsVisitor,
62
+ config: Flagship.getConfig(),
63
+ isInitializing: false,
64
+ hasVisitorData: !!visitorData
65
+ }));
66
+ }
67
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
68
+ const onVisitorReady = (fsVisitor, error) => {
69
+ if (error) {
70
+ logError(Flagship.getConfig(), error.message || error, 'onReady');
71
+ }
72
+ initializeState({ fsVisitor });
73
+ };
74
+ const createVisitor = () => {
75
+ if (!visitorData) {
76
+ return;
77
+ }
78
+ const fsVisitor = Flagship.newVisitor({
79
+ visitorId: visitorData.id,
80
+ context: visitorData.context,
81
+ isAuthenticated: visitorData.isAuthenticated,
82
+ hasConsented: visitorData.hasConsented,
83
+ initialCampaigns,
84
+ initialFlagsData,
85
+ onFetchFlagsStatusChanged,
86
+ shouldSaveInstance
87
+ });
88
+ fsVisitor?.on('ready', (error) => {
89
+ onVisitorReady(fsVisitor, error);
90
+ });
91
+ if (!fetchNow) {
92
+ initializeState({ fsVisitor });
93
+ }
94
+ };
95
+ function updateVisitor() {
96
+ if (!visitorData) {
97
+ return;
98
+ }
99
+ if (!state.visitor ||
100
+ (state.visitor.visitorId !== visitorData.id &&
101
+ (!visitorData.isAuthenticated || (visitorData.isAuthenticated && state.visitor.anonymousId)))) {
102
+ createVisitor();
103
+ return;
104
+ }
105
+ if (visitorData.hasConsented !== state.visitor.hasConsented) {
106
+ state.visitor.setConsent(visitorData.hasConsented ?? true);
107
+ }
108
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
109
+ state.visitor.updateContext(visitorData.context);
110
+ if (!state.visitor.anonymousId && visitorData.isAuthenticated) {
111
+ state.visitor.authenticate(visitorData.id);
112
+ }
113
+ if (state.visitor.anonymousId && !visitorData.isAuthenticated) {
114
+ state.visitor.unauthenticate();
115
+ }
116
+ state.visitor.fetchFlags();
117
+ }
118
+ // #endregion
119
+ useNonInitialEffect(() => {
120
+ if (fetchFlagsOnBucketingUpdated) {
121
+ state.visitor?.fetchFlags();
122
+ }
123
+ }, [lastModified]);
124
+ useNonInitialEffect(() => {
125
+ updateVisitor();
126
+ }, [JSON.stringify(visitorData)]);
127
+ useEffect(() => {
128
+ initSdk();
129
+ }, [envId, apiKey, decisionMode]);
130
+ const handleDisplay = () => {
131
+ const isFirstInit = !state.visitor;
132
+ if (state.isInitializing &&
133
+ loadingComponent &&
134
+ isFirstInit &&
135
+ fetchNow) {
136
+ return _jsx(_Fragment, { children: loadingComponent });
137
+ }
138
+ return _jsx(_Fragment, { children: children });
139
+ };
140
+ useEffect(() => {
141
+ window.addEventListener(INTERNAL_EVENTS.FsTriggerRendering, onVariationsForced);
142
+ return () => window.removeEventListener(INTERNAL_EVENTS.FsTriggerRendering, onVariationsForced);
143
+ }, [state.config?.isQAModeEnabled]);
144
+ const onVariationsForced = (e) => {
145
+ const { detail } = e;
146
+ if (detail.forcedReFetchFlags) {
147
+ stateRef.current?.visitor?.fetchFlags();
148
+ }
149
+ else {
150
+ setState(state => ({ ...state, toggleForcedVariations: !state.toggleForcedVariations }));
151
+ }
152
+ };
153
+ return (_jsx(FlagshipContext.Provider, { value: { state, setState }, children: handleDisplay() }));
154
+ }
@@ -1,5 +1,6 @@
1
- import { FlagshipProvider } from './FlagshipContext';
2
- export * from './FlagshipContext';
1
+ import { FlagshipProvider } from './FlagshipProvider';
3
2
  export * from '@flagship.io/js-sdk';
4
3
  export * from './FlagshipHooks';
4
+ export * from './type';
5
+ export { FlagshipProvider } from './FlagshipProvider';
5
6
  export default FlagshipProvider;
package/dist/src/index.js CHANGED
@@ -1,5 +1,6 @@
1
- import { FlagshipProvider } from './FlagshipContext';
2
- export * from './FlagshipContext';
1
+ import { FlagshipProvider } from './FlagshipProvider';
3
2
  export * from '@flagship.io/js-sdk';
4
3
  export * from './FlagshipHooks';
4
+ export * from './type';
5
+ export { FlagshipProvider } from './FlagshipProvider';
5
6
  export default FlagshipProvider;
@@ -1 +1 @@
1
- export declare const version = "4.0.0-alpha.1";
1
+ export declare const version = "4.0.0-alpha.2";
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '4.0.0-alpha.1';
2
+ export const version = '4.0.0-alpha.2';
@@ -0,0 +1,158 @@
1
+ import { Dispatch, ReactNode, SetStateAction } from 'react';
2
+ import { Visitor, IFlagshipConfig, FlagDTO, CampaignDTO, primitive, BucketingDTO, FetchFlagsStatus, FSSdkStatus, IHit, IFSFlag, IFSFlagCollection, SerializedFlagMetadata } from '@flagship.io/js-sdk';
3
+ export interface FsContextState {
4
+ visitor?: Visitor;
5
+ config?: IFlagshipConfig;
6
+ flags?: Map<string, FlagDTO>;
7
+ initialCampaigns?: CampaignDTO[];
8
+ initialFlags?: Map<string, FlagDTO> | FlagDTO[];
9
+ isInitializing: boolean;
10
+ hasVisitorData?: boolean;
11
+ toggleForcedVariations?: boolean;
12
+ }
13
+ export type VisitorData = {
14
+ id?: string;
15
+ context?: Record<string, primitive>;
16
+ isAuthenticated?: boolean;
17
+ hasConsented: boolean;
18
+ };
19
+ export interface FsContext {
20
+ state: FsContextState;
21
+ setState?: Dispatch<SetStateAction<FsContextState>>;
22
+ }
23
+ /**
24
+ * Props for the FlagshipProvider component.
25
+ */
26
+ export interface FlagshipProviderProps extends IFlagshipConfig {
27
+ /**
28
+ * This is the data to identify the current visitor using your app.
29
+ */
30
+ visitorData: VisitorData | null;
31
+ /**
32
+ * The environment ID for your Flagship project.
33
+ */
34
+ envId: string;
35
+ /**
36
+ * The API key for your Flagship project.
37
+ */
38
+ apiKey: string;
39
+ /**
40
+ * This component will be rendered when Flagship is loading at first initialization only.
41
+ * By default, the value is undefined. It means it will display your app and it might
42
+ * display default modifications value for a very short moment.
43
+ */
44
+ loadingComponent?: ReactNode;
45
+ /**
46
+ * The child components to be rendered within the FlagshipProvider.
47
+ */
48
+ children?: ReactNode;
49
+ /**
50
+ * This is an object of the data received when fetching bucketing endpoint.
51
+ * Providing this prop will make bucketing ready to use and the first polling will immediately check for an update.
52
+ * If the shape of an element is not correct, an error log will give the reason why.
53
+ */
54
+ initialBucketing?: BucketingDTO;
55
+ /**
56
+ * An array of initial campaigns to be used by the SDK.
57
+ */
58
+ initialCampaigns?: CampaignDTO[];
59
+ /**
60
+ * This is a set of flag data provided to avoid the SDK to have an empty cache during the first initialization.
61
+ */
62
+ initialFlagsData?: SerializedFlagMetadata[];
63
+ /**
64
+ * If true, it'll automatically call fetchFlags when the bucketing file has updated.
65
+ */
66
+ fetchFlagsOnBucketingUpdated?: boolean;
67
+ /**
68
+ * Callback function that will be called when the fetch flags status changes.
69
+ *
70
+ * @param newStatus - The new status of the flags fetch.
71
+ * @param reason - The reason for the status change.
72
+ */
73
+ onFetchFlagsStatusChanged?: ({ status, reason }: FetchFlagsStatus) => void;
74
+ /**
75
+ * If true, the newly created visitor instance won't be saved and will simply be returned. Otherwise, the newly created visitor instance will be returned and saved into the Flagship.
76
+ *
77
+ * Note: By default, it is false on server-side and true on client-side.
78
+ */
79
+ shouldSaveInstance?: boolean;
80
+ }
81
+ /**
82
+ * Represents the output of the `useFlagship` hook.
83
+ */
84
+ export type UseFlagshipOutput = {
85
+ /**
86
+ * The visitor ID.
87
+ */
88
+ visitorId?: string;
89
+ /**
90
+ * The anonymous ID.
91
+ */
92
+ anonymousId?: string | null;
93
+ /**
94
+ * The visitor context.
95
+ */
96
+ context?: Record<string, primitive>;
97
+ /**
98
+ * Indicates whether the visitor has consented for protected data usage.
99
+ */
100
+ hasConsented?: boolean;
101
+ /**
102
+ * Sets whether the visitor has consented for protected data usage.
103
+ * @param hasConsented - True if the visitor has consented, false otherwise.
104
+ */
105
+ setConsent: (hasConsented: boolean) => void;
106
+ readonly sdkStatus: FSSdkStatus;
107
+ readonly fetchStatus?: FetchFlagsStatus;
108
+ /**
109
+ * Updates the visitor context values, matching the given keys, used for targeting.
110
+ * A new context value associated with this key will be created if there is no previous matching value.
111
+ * Context keys must be strings, and value types must be one of the following: number, boolean, string.
112
+ * @param context - A collection of keys and values.
113
+ */
114
+ updateContext(context: Record<string, primitive>): void;
115
+ /**
116
+ * Clears the actual visitor context.
117
+ */
118
+ clearContext(): void;
119
+ /**
120
+ * Authenticates an anonymous visitor.
121
+ * @param visitorId - The visitor ID.
122
+ */
123
+ authenticate(visitorId: string): void;
124
+ /**
125
+ * Changes an authenticated visitor to an anonymous visitor.
126
+ */
127
+ unauthenticate(): void;
128
+ /**
129
+ * Sends a hit or multiple hits to the Flagship server.
130
+ * @param hit - The hit or array of hits to send.
131
+ */
132
+ sendHits(hit: IHit): Promise<void>;
133
+ sendHits(hits: IHit[]): Promise<void>;
134
+ sendHits(hits: IHit | IHit[]): Promise<void>;
135
+ /**
136
+ * Return a [Flag](#flag-class) object by its key.
137
+ * If no flag matches the given key, an empty flag will be returned.
138
+ * Call exists() to check if the flag has been found.
139
+ * @param key - The flag key.
140
+ * @param defaultValue - The default value.
141
+ * @returns The flag object.
142
+ */
143
+ getFlag(key: string): IFSFlag;
144
+ /**
145
+ * Invokes the `decision API` or refers to the `bucketing file` to refresh all campaign flags based on the visitor's context.
146
+ */
147
+ fetchFlags: () => Promise<void>;
148
+ /**
149
+ * Batches and sends all hits that are in the pool before the application is closed.
150
+ * @returns A promise that resolves when all hits are sent.
151
+ */
152
+ close(): Promise<void>;
153
+ /**
154
+ * Returns a collection of all flags fetched for the visitor.
155
+ * @returns An IFSFlagCollection object.
156
+ */
157
+ getFlags(): IFSFlagCollection;
158
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,10 +1,14 @@
1
- import { CampaignDTO, IFlagshipConfig, Modification } from '@flagship.io/js-sdk';
2
1
  import { EffectCallback, DependencyList } from 'react';
2
+ import { CampaignDTO, FlagDTO, IFlagshipConfig, SerializedFlagMetadata } from '@flagship.io/js-sdk';
3
3
  export declare function logError(config: IFlagshipConfig | undefined, message: string, tag: string): void;
4
4
  export declare function logInfo(config: IFlagshipConfig | undefined, message: string, tag: string): void;
5
5
  export declare function logWarn(config: IFlagshipConfig | undefined, message: string, tag: string): void;
6
- export declare const getModificationsFromCampaigns: (campaigns: Array<CampaignDTO>) => Map<string, Modification>;
6
+ export declare const getFlagsFromCampaigns: (campaigns: Array<CampaignDTO>) => Map<string, FlagDTO>;
7
7
  export declare function uuidV4(): string;
8
8
  export declare function useNonInitialEffect(effect: EffectCallback, deps?: DependencyList): void;
9
9
  export declare function hasSameType(flagValue: unknown, defaultValue: unknown): boolean;
10
10
  export declare function sprintf(format: string, ...value: any[]): string;
11
+ export declare function hexToValue(hex: string, config: IFlagshipConfig): {
12
+ v: unknown;
13
+ } | null;
14
+ export declare function extractFlagsMap(initialFlagsData?: SerializedFlagMetadata[], initialCampaigns?: CampaignDTO[]): Map<string, FlagDTO>;
package/dist/src/utils.js CHANGED
@@ -1,46 +1,49 @@
1
1
  'use client';
2
- import { LogLevel } from '@flagship.io/js-sdk';
3
2
  import { useEffect, useRef } from 'react';
3
+ import Flagship, { LogLevel } from '@flagship.io/js-sdk';
4
4
  export function logError(config, message, tag) {
5
- if (!config ||
6
- !config.logManager ||
7
- typeof config.logManager.error !== 'function' ||
8
- !config.logLevel ||
9
- config.logLevel < LogLevel.ERROR) {
5
+ if (!config || !config.logLevel || config.logLevel < LogLevel.ERROR) {
10
6
  return;
11
7
  }
12
- config.logManager.error(message, tag);
8
+ if (typeof config.onLog === 'function') {
9
+ config.onLog(LogLevel.ERROR, tag, message);
10
+ }
11
+ if (config.logManager && typeof config.logManager.error === 'function') {
12
+ config.logManager.error(message, tag);
13
+ }
13
14
  }
14
15
  export function logInfo(config, message, tag) {
15
- if (!config ||
16
- !config.logManager ||
17
- typeof config.logManager.info !== 'function' ||
18
- !config.logLevel ||
19
- config.logLevel < LogLevel.INFO) {
16
+ if (!config || !config.logLevel || config.logLevel < LogLevel.INFO) {
20
17
  return;
21
18
  }
22
- config.logManager.info(message, tag);
19
+ if (typeof config.onLog === 'function') {
20
+ config.onLog(LogLevel.INFO, tag, message);
21
+ }
22
+ if (config.logManager && typeof config.logManager.info === 'function') {
23
+ config.logManager.info(message, tag);
24
+ }
23
25
  }
24
26
  export function logWarn(config, message, tag) {
25
- if (!config ||
26
- !config.logManager ||
27
- typeof config.logManager.warning !== 'function' ||
28
- !config.logLevel ||
29
- config.logLevel < LogLevel.WARNING) {
27
+ if (!config || !config.logLevel || config.logLevel < LogLevel.WARNING) {
30
28
  return;
31
29
  }
32
- config.logManager.warning(message, tag);
30
+ if (typeof config.onLog === 'function') {
31
+ config.onLog(LogLevel.WARNING, tag, message);
32
+ }
33
+ if (config.logManager && typeof config.logManager.warning === 'function') {
34
+ config.logManager.warning(message, tag);
35
+ }
33
36
  }
34
- export const getModificationsFromCampaigns = (campaigns) => {
35
- const modifications = new Map();
37
+ export const getFlagsFromCampaigns = (campaigns) => {
38
+ const flags = new Map();
36
39
  if (!campaigns || !Array.isArray(campaigns)) {
37
- return modifications;
40
+ return flags;
38
41
  }
39
42
  campaigns.forEach((campaign) => {
40
43
  const object = campaign.variation.modifications.value;
41
44
  for (const key in object) {
42
45
  const value = object[key];
43
- modifications.set(key, {
46
+ flags.set(key, {
44
47
  key,
45
48
  campaignId: campaign.id,
46
49
  campaignName: campaign.name || '',
@@ -49,11 +52,12 @@ export const getModificationsFromCampaigns = (campaigns) => {
49
52
  variationId: campaign.variation.id,
50
53
  variationName: campaign.variation.name || '',
51
54
  isReference: campaign.variation.reference,
55
+ slug: campaign.slug || '',
52
56
  value
53
57
  });
54
58
  }
55
59
  });
56
- return modifications;
60
+ return flags;
57
61
  };
58
62
  export function uuidV4() {
59
63
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
@@ -93,3 +97,52 @@ export function sprintf(format, ...value) {
93
97
  }
94
98
  return formatted;
95
99
  }
100
+ export function hexToValue(hex, config) {
101
+ if (typeof hex !== 'string') {
102
+ logError(config, `Invalid hex string: ${hex}`, 'hexToValue');
103
+ return null;
104
+ }
105
+ let jsonString = '';
106
+ for (let i = 0; i < hex.length; i += 2) {
107
+ const hexChar = hex.slice(i, i + 2);
108
+ const charCode = parseInt(hexChar, 16);
109
+ if (isNaN(charCode)) {
110
+ logError(config, `Invalid hex character: ${hexChar}`, 'hexToValue');
111
+ return null;
112
+ }
113
+ jsonString += String.fromCharCode(charCode);
114
+ }
115
+ try {
116
+ const value = JSON.parse(jsonString);
117
+ return value;
118
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
119
+ }
120
+ catch (error) {
121
+ logError(config, `Error while parsing JSON: ${error?.message}`, 'hexToValue');
122
+ return null;
123
+ }
124
+ }
125
+ export function extractFlagsMap(initialFlagsData, initialCampaigns) {
126
+ let flags = new Map();
127
+ if (Array.isArray(initialFlagsData)) {
128
+ initialFlagsData.forEach((flag) => {
129
+ flags.set(flag.key, {
130
+ key: flag.key,
131
+ campaignId: flag.campaignId,
132
+ campaignName: flag.campaignName,
133
+ variationGroupId: flag.variationGroupId,
134
+ variationGroupName: flag.variationGroupName,
135
+ variationId: flag.variationId,
136
+ variationName: flag.variationName,
137
+ isReference: flag.isReference,
138
+ campaignType: flag.campaignType,
139
+ slug: flag.slug,
140
+ value: hexToValue(flag.hex, Flagship.getConfig())?.v
141
+ });
142
+ });
143
+ }
144
+ else if (initialCampaigns) {
145
+ flags = getFlagsFromCampaigns(initialCampaigns);
146
+ }
147
+ return flags;
148
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@flagship.io/react-sdk",
3
3
  "sideEffects": false,
4
- "version": "4.0.0-alpha.1",
4
+ "version": "4.0.0-alpha.2",
5
5
  "license": "Apache-2.0",
6
6
  "description": "Flagship REACT SDK",
7
7
  "main": "dist/index.node.js",
@@ -20,7 +20,7 @@
20
20
  "react-native": "./dist/src/index.js"
21
21
  },
22
22
  "dependencies": {
23
- "@flagship.io/js-sdk": "^4.0.0-alpha.1",
23
+ "@flagship.io/js-sdk": "^4.0.0-alpha.2",
24
24
  "encoding": "^0.1.13"
25
25
  },
26
26
  "peerDependencies": {
@@ -38,49 +38,52 @@
38
38
  "sdk"
39
39
  ],
40
40
  "devDependencies": {
41
- "@babel/cli": "^7.14.6",
42
- "@babel/core": "^7.14.6",
43
- "@babel/preset-env": "^7.14.7",
44
- "@babel/preset-react": "^7.14.5",
45
- "@babel/preset-typescript": "^7.14.5",
46
- "@testing-library/jest-dom": "^5.11.4",
47
- "@testing-library/react": "^11.1.0",
48
- "@testing-library/react-hooks": "^7.0.1",
49
- "@testing-library/user-event": "^12.1.10",
50
- "@types/jest": "^26.0.15",
51
- "@types/node": "^12.0.0",
52
- "@types/react": "^17.0.0",
53
- "@types/react-dom": "^17.0.0",
54
- "@typescript-eslint/eslint-plugin": "^4.32.0",
55
- "@typescript-eslint/parser": "^4.32.0",
56
- "babel-loader": "^8.2.2",
41
+ "@babel/cli": "^7.24.1",
42
+ "@babel/core": "^7.24.3",
43
+ "@babel/plugin-proposal-class-properties": "^7.18.6",
44
+ "@babel/preset-env": "^7.24.3",
45
+ "@babel/preset-react": "^7.24.1",
46
+ "@babel/preset-typescript": "^7.24.1",
47
+ "@testing-library/jest-dom": "^6.4.2",
48
+ "@testing-library/react": "^14.2.2",
49
+ "@testing-library/react-hooks": "^8.0.1",
50
+ "@testing-library/user-event": "^14.5.2",
51
+ "@types/jest": "^29.5.12",
52
+ "@types/node": "^20.11.30",
53
+ "@types/react": "^18.3.3",
54
+ "@types/react-dom": "^18.3.0",
55
+ "@typescript-eslint/eslint-plugin": "^7.4.0",
56
+ "@typescript-eslint/parser": "^7.4.0",
57
+ "babel-loader": "^9.1.3",
57
58
  "babel-plugin-add-module-exports": "^1.0.4",
58
- "eslint": "^7.32.0",
59
- "eslint-config-standard": "^16.0.3",
60
- "eslint-plugin-import": "^2.24.2",
59
+ "core-js": "^3.36.1",
60
+ "eslint": "^8.57.0",
61
+ "eslint-config-standard": "^17.1.0",
62
+ "eslint-plugin-import": "^2.29.1",
63
+ "eslint-plugin-n": "^16.6.2",
61
64
  "eslint-plugin-node": "^11.1.0",
62
- "eslint-plugin-promise": "^5.1.0",
63
- "eslint-plugin-react": "^7.26.0",
64
- "genversion": "^3.1.1",
65
- "jest": "^29.5.0",
66
- "jest-environment-jsdom": "^29.5.0",
67
- "react": "^17.0.2",
68
- "react-dom": "^17.0.2",
69
- "react-test-renderer": "^17.0.2",
70
- "regenerator-runtime": "^0.13.9",
71
- "terser-webpack-plugin": "^5.2.4",
72
- "ts-jest": "^29.1.0",
73
- "ts-loader": "^9.2.3",
74
- "typescript": "^5.0.4",
75
- "webpack": "^5.82.0",
76
- "webpack-cli": "^5.1.0",
77
- "webpack-merge": "^5.8.0",
65
+ "eslint-plugin-promise": "^6.1.1",
66
+ "eslint-plugin-react": "^7.34.1",
67
+ "genversion": "^3.2.0",
68
+ "jest": "^29.7.0",
69
+ "jest-environment-jsdom": "^29.7.0",
70
+ "react": "^18.3.1",
71
+ "react-dom": "^18.3.1",
72
+ "react-test-renderer": "^18.2.0",
73
+ "regenerator-runtime": "^0.14.1",
74
+ "terser-webpack-plugin": "^5.3.10",
75
+ "ts-jest": "^29.1.2",
76
+ "ts-loader": "^9.5.1",
77
+ "typescript": "^5.4.3",
78
+ "webpack": "^5.91.0",
79
+ "webpack-cli": "^5.1.4",
80
+ "webpack-merge": "^5.10.0",
78
81
  "webpack-node-externals": "^3.0.0"
79
82
  },
80
83
  "scripts": {
81
84
  "dev": "tsc --watch",
82
85
  "test": "jest",
83
- "lint": "eslint . --ext .tsx",
86
+ "lint": "eslint src --ext .tsx",
84
87
  "clean": "rm -rf dist && mkdir dist",
85
88
  "generate:version": "genversion --es6 src/sdkVersion.ts",
86
89
  "build:esm": "BABEL_ENV=esm babel src --extensions '.ts,.tsx' --out-dir dist/esm --copy-files",
@@ -1,13 +0,0 @@
1
- import { FlagDTO, IFlag, IFlagMetadata } from '@flagship.io/js-sdk';
2
- export declare class Flag<T> implements IFlag<T> {
3
- private defaultValue;
4
- private key;
5
- private flag?;
6
- constructor(defaultValue: T, key: string, flagsData: Map<string, FlagDTO> | undefined);
7
- private NotSameType;
8
- getValue(): T;
9
- exists(): boolean;
10
- userExposed(): Promise<void>;
11
- visitorExposed(): Promise<void>;
12
- get metadata(): IFlagMetadata;
13
- }