0.0.1
Composable that returns the application's public API base URL from the Nuxt runtime configuration.
string
— The value of runtimeConfig.public.API_BASE_URL
.string
:
The public API base URL.
Composable that provides a reactive reference to the browser's history state.
It initializes with the current history.state
and updates automatically
whenever the user navigates through the browser history (back/forward navigation).
Event listener is cleaned up automatically when the component is unmounted.
Ref<object>
— A reactive reference containing the current history state.Ref<object>
:
Reactive history state object.
Composable that tracks changes in a reactive object.
It compares the initial state of the object with the latest state
using snapshots from useRefHistory
.
If any property differs, isNotEqual
becomes true
.
Ref<boolean>
— Becomes true
if the object has changed.Function
— Reset the tracked history to the current state.Function
— Clear the entire tracked history.(Ref<object>)
A reactive object to track.
{isNotEqual: Ref<boolean>, reset: Function, clear: Function}
:
Composable that provides a reactive "time ago" string in Persian (Farsi).
It uses date-fns-jalali
to calculate the distance between the given date
and the current time, formatted with Persian locale (faIR
).
The value updates automatically every 60 seconds.
Ref<string>
— A reactive string like "۲ دقیقه پیش"
.(Date)
The date to compare against the current time.
Ref<string>
:
A reactive string containing the relative Persian time.
Composable that provides a countdown timer with start and reset functionality.
The timer counts down from the given duration (in milliseconds) and optionally calls a callback function when finished.
Ref<boolean>
— true
if the timer is currently running.Ref<number>
— The remaining time in seconds.Function
— Resets the timer to the initial duration and stops it.Function
— Starts the countdown timer.{isPending: Ref<boolean>, timer: Ref<number>, reset: Function, start: Function}
:
Timer state and controls.
Nuxt plugin that provides a lightweight event bus using mitt
.
The event bus allows different parts of the application to communicate through events without requiring direct references.
It exposes three main methods:
on
→ Listen for an eventoff
→ Stop listening for an eventemit
→ Trigger an event// Injected as `bus` in your app
const { $bus } = useNuxtApp();
// Listen for an event
$bus.on("my-event", (payload) => {
console.log("Received:", payload);
});
// Emit an event
$bus.emit("my-event", { foo: "bar" });
// Stop listening
$bus.off("my-event", handler);
Nuxt plugin that integrates GSAP (GreenSock Animation Platform) and registers common GSAP plugins for use in the application.
Registered plugins:
ScrollTrigger
→ Enables scroll-based animations.ScrollToPlugin
→ Allows smooth scrolling to elements or positions.TextPlugin
→ Animates text content changes.Provides global access to:
gsap
→ Core GSAP animation library.ScrollTrigger
→ ScrollTrigger plugin instance.Converts a number of bytes into a human-readable string with appropriate units.
Examples:
number
— The number of bytes to format.number
— Optional number of decimal places (default: 2).string
— Formatted string with the size and unit (e.g., "1.23 Mb"
).string
:
Human-readable byte size.
Ensures that a file exists at the given path.
If the file does not exist, it creates the necessary directories and writes the file with the specified initial content.
string
— The path of the file to ensure.string
— Optional initial content to write if the file does not exist (default: ""
).Promise<void>
— Resolves when the file exists or has been created.(string)
Path to the file to ensure.
(string
= ""
)
Content to write if the file does not exist.
Promise<void>
:
Resolves when the file exists or is created.
Parses a user agent string and returns an object describing the operating system, browser, browser version, and device type.
any
— The user agent string to parse.{ os: string, browser: string, browserVersion: string, deviceType: string } | undefined
—
An object containing the detected OS, browser, browser version, and device type,
or undefined
if no user agent is provided.(any)
The user agent string to analyze.
{os: string, browser: string, browserVersion: string, deviceType: string}
:
Object with OS, browser, browser version, and device type, or undefined.
Formats a number as a Persian currency string.
Uses Intl.NumberFormat
with the "fa-IR" locale and IRR currency.
Replaces the default "ریال" text with a custom currency symbol.
number
— The numeric value to format.string
— Optional currency symbol to replace "ریال" (default: "تومان"
).string
— Formatted price string, e.g., "۱,۰۰۰ تومان"
.string
:
Formatted Persian currency string.
Checks if a file name has an image extension.
Supported image types: .jpg
, .jpeg
, .png
, .svg
, .webp
.
string | undefined
— The file name to check.boolean
— true
if the file name ends with a supported image extension, otherwise false
.(string)
File name to check (optional).
boolean
:
Whether the file is an image.
Converts Persian (Farsi) digits in a string to English digits.
For example, "۱۲۳۴"
becomes "1234"
.
string
— The string containing Persian digits to convert.string
— A new string with all Persian digits replaced by English digits.(string)
String containing Persian digits.
string
:
Converted string with English digits.
Converts a JavaScript Date
object into a readable Persian calendar date string.
The function uses @internationalized/date
to convert the Gregorian date
to the Persian calendar and formats it as YYYY-MM-DD - HH:MM:SS
by default.
You can optionally hide the date or time by providing the format
object.
Date
— The JavaScript Date
object to convert.object
— Optional formatting options:
date
: "full"
or "none"
— Whether to include the date (default "full"
).time
: "full"
or "none"
— Whether to include the time (default "full"
).string
— Formatted Persian calendar date string.string
:
Persian calendar date and time string.