Skip to content

Commit

Permalink
Switch to @configcat/sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Nov 8, 2024
1 parent 8f8cc52 commit 2fd1b37
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 585 deletions.
28 changes: 19 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"homepage": "https://configcat.com",
"license": "MIT",
"dependencies": {
"configcat-common": "9.3.1",
"@configcat/sdk": "0.0.1",
"tslib": "^2.4.1"
},
"peerDependencies": {
Expand Down
3 changes: 1 addition & 2 deletions sandbox/src/stories/Hoc.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { useState } from 'react';
import { ConfigCatProvider, LogLevel, withConfigCatClient, WithConfigCatClientProps } from 'configcat-react';
import { User } from 'configcat-common';
import { ConfigCatProvider, LogLevel, withConfigCatClient, WithConfigCatClientProps, User } from 'configcat-react';


export class HocComponent extends React.Component<
Expand Down
36 changes: 0 additions & 36 deletions src/Cache.test.ts

This file was deleted.

59 changes: 0 additions & 59 deletions src/Cache.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/ConfigCatContext.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IConfigCatClient } from "configcat-common";
import type { IConfigCatClient } from "@configcat/sdk";
import React from "react";

export interface ConfigCatContextData {
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigCatHOC.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "configcat-common";
import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "@configcat/sdk";
import React from "react";
import { type ConfigCatContextData, getConfigCatContext } from "./ConfigCatContext";
import { createConfigCatProviderError } from "./ConfigCatProvider";
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigCatHooks.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { PollingMode } from "@configcat/sdk";
import { cleanup, render, screen } from "@testing-library/react";
import { PollingMode } from "configcat-common";
import React, { useEffect, useState } from "react";
import { useConfigCatClient, useFeatureFlag } from "./ConfigCatHooks";
import ConfigCatProvider from "./ConfigCatProvider";
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigCatHooks.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "configcat-common";
import type { IConfigCatClient, SettingTypeOf, SettingValue, User } from "@configcat/sdk";
import { useContext, useEffect, useState } from "react";
import { getConfigCatContext } from "./ConfigCatContext";
import { createConfigCatProviderError } from "./ConfigCatProvider";
Expand Down
2 changes: 1 addition & 1 deletion src/ConfigCatProvider.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { DataGovernance, PollingMode } from "@configcat/sdk";
import { cleanup, render, screen } from "@testing-library/react";
import { DataGovernance, PollingMode } from "configcat-common";
import React, { useState } from "react";
import { useFeatureFlag } from "./ConfigCatHooks";
import ConfigCatProvider from "./ConfigCatProvider";
Expand Down
13 changes: 6 additions & 7 deletions src/ConfigCatProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"use client";

import type { ClientCacheState, HookEvents, IConfig, IConfigCatClient, IConfigCatClientSnapshot, IConfigCatKernel, IEvaluationDetails, RefreshResult, SettingKeyValue, SettingTypeOf, SettingValue, User } from "configcat-common";
import { PollingMode, getClient } from "configcat-common";
import type { ClientCacheState, HookEvents, IConfig, IConfigCatClient, IConfigCatClientSnapshot, IEvaluationDetails, RefreshResult, SettingKeyValue, SettingTypeOf, SettingValue, User } from "@configcat/sdk";
import { Internals, PollingMode } from "@configcat/sdk";
import React, { Component, type PropsWithChildren } from "react";
import { LocalStorageCache } from "./Cache";
import { type ConfigCatContextData, ensureConfigCatContext } from "./ConfigCatContext";
import { HttpConfigFetcher } from "./ConfigFetcher";
import CONFIGCAT_SDK_VERSION from "./Version";
import type { IReactAutoPollOptions, IReactLazyLoadingOptions, IReactManualPollOptions } from ".";

Expand Down Expand Up @@ -69,13 +67,14 @@ class ConfigCatProvider extends Component<PropsWithChildren<ConfigCatProviderPro

private initializeConfigCatClient() {
const { pollingMode, options, sdkKey } = this.props;
const configCatKernel: IConfigCatKernel = LocalStorageCache.setup({
configFetcher: new HttpConfigFetcher(),
const configCatKernel: Internals.IConfigCatKernel = Internals.LocalStorageCache.setup({
configFetcher: new Internals.XmlHttpRequestConfigFetcher(),
sdkType: "ConfigCat-React",
sdkVersion: CONFIGCAT_SDK_VERSION,
eventEmitterFactory: () => new Internals.DefaultEventEmitter()
});

return getClient(sdkKey, pollingMode ?? PollingMode.AutoPoll, options, configCatKernel);
return Internals.getClient(sdkKey, pollingMode ?? PollingMode.AutoPoll, options, configCatKernel);
}

reactConfigChanged(_newConfig: IConfig): void {
Expand Down
55 changes: 0 additions & 55 deletions src/ConfigFetcher.ts

This file was deleted.

Loading

0 comments on commit 2fd1b37

Please sign in to comment.