SILENT KILLERPanel

Current Path: > home > codekrsu > > ameliagraphics.com > wp-content > plugins > extendify > > src > Shared > state


Operation   : Linux premium131.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
Software     : Apache
Server IP    : 162.0.232.56 | Your IP: 216.73.216.111
Domains      : 1034 Domain(s)
Permission   : [ 0755 ]

Files and Folders in: /home/codekrsu//ameliagraphics.com/wp-content/plugins/extendify//src/Shared/state

NameTypeSizeLast ModifiedActions
activity.js File 1253 bytes October 08 2024 14:19:28.
ai-consent.js File 1515 bytes May 19 2025 16:47:28.
site-profile.js File 1551 bytes March 13 2025 21:10:44.
unsplash-cache.js File 661 bytes March 13 2025 21:10:44.

Reading File: /home/codekrsu//ameliagraphics.com/wp-content/plugins/extendify//src/Shared/state/activity.js

import apiFetch from '@wordpress/api-fetch';
import { safeParseJson } from '@shared/lib/parsing';
import { create } from 'zustand';
import { devtools, persist, createJSONStorage } from 'zustand/middleware';

const path = '/extendify/v1/shared/activity';

/**
 * Implementation of a custom storage engine for Zustand's persist middleware.
 * It replicates the Storage interface defined at https://developer.mozilla.org/en-US/docs/Web/API/Storage
 *
 * This storage uses a WordPress custom endpoint to persist the state in `wp_options`.
 */
const storage = {
	getItem: () => apiFetch({ path }),
	setItem: (_name, state) =>
		apiFetch({ path, method: 'POST', data: { state } }),
};

const incomingState = safeParseJson(window.extSharedData.activity);

const initialState = {
	actions: {},
};

const state = (set, get) => ({
	...initialState,
	...(incomingState?.state ?? {}),
	incrementActivity: (id) => {
		set((state) => ({
			...state,
			actions: {
				...state.actions,
				[id]: Number(get().actions[id] || 0) + 1,
			},
		}));
	},
});

export const useActivityStore = create(
	persist(devtools(state, { name: 'Extendify Activity' }), {
		name: 'extendify_shared_activity',
		storage: createJSONStorage(() => storage),
		skipHydration: true,
	}),
);

SILENT KILLER Tool