PHP 8.2.30
Preview: logOnly.ts Size: 2.55 KB
//proc/thread-self/root/home/byroehnu/.trash/node_modules11/@redux-devtools/extension/src/logOnly.ts

import assign from './utils/assign';
import { compose } from 'redux';
import type {
  Action,
  Dispatch,
  PreloadedState,
  Reducer,
  StoreEnhancer,
} from 'redux';
import type { Config, EnhancerOptions, InferComposedStoreExt } from './index';

function enhancer(options?: EnhancerOptions): StoreEnhancer {
  const config: Config = options || {};
  config.features = { pause: true, export: true, test: true };
  config.type = 'redux';
  if (config.autoPause === undefined) config.autoPause = true;
  if (config.latency === undefined) config.latency = 500;

  return function (createStore) {
    return function <S, A extends Action<string>>(
      reducer: Reducer<S, A>,
      preloadedState: PreloadedState<S> | undefined,
    ) {
      const store = createStore(reducer, preloadedState);
      const origDispatch = store.dispatch;

      const devTools = window.__REDUX_DEVTOOLS_EXTENSION__!.connect(config);
      devTools.init(store.getState());

      const dispatch: Dispatch<A> = function (action) {
        const r = origDispatch(action);
        devTools.send(action, store.getState());
        return r;
      };

      if (Object.assign) return Object.assign(store, { dispatch: dispatch });
      return assign(store, 'dispatch', dispatch);
    };
  };
}

function composeWithEnhancer(config?: EnhancerOptions) {
  return function (...funcs: StoreEnhancer<unknown>[]) {
    return compose(compose(...funcs), enhancer(config));
  };
}

export function composeWithDevTools(
  config: Config,
): <StoreEnhancers extends readonly StoreEnhancer<unknown>[]>(
  ...funcs: StoreEnhancers
) => StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
export function composeWithDevTools<
  StoreEnhancers extends readonly StoreEnhancer<unknown>[],
>(
  ...funcs: StoreEnhancers
): StoreEnhancer<InferComposedStoreExt<StoreEnhancers>>;
export function composeWithDevTools(
  ...funcs: [Config] | StoreEnhancer<unknown>[]
) {
  if (typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__) {
    if (funcs.length === 0) return enhancer();
    if (typeof funcs[0] === 'object') return composeWithEnhancer(funcs[0]);
    return composeWithEnhancer()(...(funcs as StoreEnhancer<unknown>[]));
  }

  if (funcs.length === 0) return undefined;
  if (typeof funcs[0] === 'object') return compose;
  return compose(...(funcs as StoreEnhancer[]));
}

export const devToolsEnhancer: (options?: EnhancerOptions) => StoreEnhancer =
  typeof window !== 'undefined' && window.__REDUX_DEVTOOLS_EXTENSION__
    ? enhancer
    : function () {
        return function (noop) {
          return noop;
        };
      };

Directory Contents

Dirs: 1 × Files: 4

Name Size Perms Modified Actions
utils DIR
- drwxr-xr-x 2026-02-28 00:28:26
Edit Download
1.44 KB lrw-r--r-- 2026-02-28 00:28:30
Edit Download
11.80 KB lrw-r--r-- 2026-02-28 00:28:34
Edit Download
2.55 KB lrw-r--r-- 2026-02-28 00:28:38
Edit Download
1.56 KB lrw-r--r-- 2026-02-28 00:28:40
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).