# extendify/3.2.0/src/Agent/workflows/theme/tools/update-variation.js

Extendify, version 3.2.0. 54 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.2.0/code/src/Agent/workflows/theme/tools/update-variation.js
- Raw: https://pluginprobe.com/plugins/extendify/3.2.0/raw/src/Agent/workflows/theme/tools/update-variation.js
- Modified: 2026-09-09T18:23:40+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.2.0/code/src/Agent/workflows/theme/tools/update-variation.js#L10-L20`.

```javascript
import { appliedVibeOwnership } from '@shared/lib/applied-vibes';
import { deepMerge } from '@shared/lib/utils';
import {
	preserveVibeSettings,
	preserveVibeStyles,
} from '@shared/lib/vibe-globals';
import apiFetch from '@wordpress/api-fetch';

const { globalStylesPostID } = window.extSharedData;

// The vibe layer keeps its owned leaves even when the variation declares them.
export default async ({ variation, purge = (document) => document }) => {
	const [current, vibes] = await Promise.all([
		apiFetch({
			path: `/wp/v2/global-styles/${globalStylesPostID}?context=edit`,
		}),
		getCurrentVibes(),
	]);

	const merged = deepMerge(
		purge({ settings: current.settings, styles: current.styles }),
		variation,
	);

	return apiFetch({
		method: 'POST',
		path: `/wp/v2/global-styles/${globalStylesPostID}`,
		data: {
			id: globalStylesPostID,
			settings: preserveVibeSettings({
				mergedSettings: merged.settings,
				currentSettings: current.settings,
				vibes,
			}),
			styles: preserveVibeStyles({
				mergedStyles: merged.styles,
				currentStyles: current.styles,
				vibes,
			}),
		},
	});
};

const getCurrentVibes = async () => {
	try {
		const { data } = await apiFetch({
			path: '/extendify/v1/launch/options?option=extendify_siteStyle',
		});
		return await appliedVibeOwnership(data?.vibe);
	} catch {
		return {};
	}
};

```
