Skip to content

The open alternative to Salesforce, designed for AI.

565 B
Raw Blame
import { getNamespacedStorageKeys } from '@/host/storage/utils/getNamespacedStorageKeys';
import { type FrontComponentStorageScope } from '@/types/FrontComponentStorageScope';

export const snapshotFrontComponentStorage = ({
  namespace,
  storageType,
}: FrontComponentStorageScope): Record<string, string> => {
  const storage = window[storageType];

  return Object.fromEntries(
    getNamespacedStorageKeys({ storage, namespace }).map((namespacedKey) => [
      namespacedKey.slice(namespace.length),
      storage.getItem(namespacedKey) ?? '',
    ]),
  );
};