katex4arabic 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +303 -0
  3. package/dist/cdn/katex-arabic.min.cjs +258 -0
  4. package/dist/cdn/katex-arabic.min.css +9 -0
  5. package/dist/cdn/katex-arabic.min.js +258 -0
  6. package/dist/cdn/katex-arabic.min.mjs +11878 -0
  7. package/dist/lib/arabicFunctions.d.ts +87 -0
  8. package/dist/lib/arabicFunctions.d.ts.map +1 -0
  9. package/dist/lib/arabicNumerals.d.ts +50 -0
  10. package/dist/lib/arabicNumerals.d.ts.map +1 -0
  11. package/dist/lib/arabicSymbols.d.ts +52 -0
  12. package/dist/lib/arabicSymbols.d.ts.map +1 -0
  13. package/dist/lib/cdn.d.ts +18 -0
  14. package/dist/lib/cdn.d.ts.map +1 -0
  15. package/dist/lib/hooks.cjs +41 -0
  16. package/dist/lib/hooks.cjs.map +1 -0
  17. package/dist/lib/hooks.d.cts +61 -0
  18. package/dist/lib/hooks.d.ts +61 -0
  19. package/dist/lib/hooks.d.ts.map +1 -0
  20. package/dist/lib/hooks.mjs +41 -0
  21. package/dist/lib/hooks.mjs.map +1 -0
  22. package/dist/lib/index.cjs +71 -0
  23. package/dist/lib/index.cjs.map +1 -0
  24. package/dist/lib/index.d.cts +53 -0
  25. package/dist/lib/index.d.ts +53 -0
  26. package/dist/lib/index.d.ts.map +1 -0
  27. package/dist/lib/index.mjs +72 -0
  28. package/dist/lib/index.mjs.map +1 -0
  29. package/dist/lib/katex-arabic.css +458 -0
  30. package/dist/lib/protectedRegions.d.ts +26 -0
  31. package/dist/lib/protectedRegions.d.ts.map +1 -0
  32. package/dist/lib/render.cjs +811 -0
  33. package/dist/lib/render.cjs.map +1 -0
  34. package/dist/lib/render.d.ts +65 -0
  35. package/dist/lib/render.d.ts.map +1 -0
  36. package/dist/lib/render.mjs +812 -0
  37. package/dist/lib/render.mjs.map +1 -0
  38. package/dist/lib/rtlRenderer.d.ts +100 -0
  39. package/dist/lib/rtlRenderer.d.ts.map +1 -0
  40. package/dist/lib/types.d.ts +98 -0
  41. package/dist/lib/types.d.ts.map +1 -0
  42. package/docs/INSTALL.md +314 -0
  43. package/package.json +119 -0
@@ -0,0 +1,87 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════
3
+ * arabicFunctions.ts
4
+ * Comprehensive translation dictionaries and transforms that
5
+ * convert LaTeX function names, variables, and Greek letters
6
+ * into their Arabic equivalents.
7
+ *
8
+ * Design notes:
9
+ * - All keys are LaTeX command names beginning with a backslash,
10
+ * except for the VARIABLE_MAP which uses single letters.
11
+ * - Translations never mutate the input. Each function returns
12
+ * a new string.
13
+ * - Regex safety: the `escapeRegex` helper protects against
14
+ * special characters in keys when building dynamic patterns.
15
+ * ════════════════════════════════════════════════════════════════
16
+ */
17
+ /**
18
+ * Map of LaTeX command → Arabic operator name.
19
+ * \operatorname* is used for operators with limits (e.g. lim, max, min).
20
+ * \operatorname is used for plain operator names.
21
+ */
22
+ export declare const FUNCTION_MAP: Record<string, string>;
23
+ /**
24
+ * Standard mapping of Latin letters to their conventional Arabic
25
+ * equivalents in mathematical literature. The uppercase forms follow
26
+ * the same scheme, with a few exceptions (e.g. E → هـ for Euler's
27
+ * constant, I → ت for the imaginary unit).
28
+ */
29
+ export declare const VARIABLE_MAP: Record<string, string>;
30
+ /**
31
+ * KaTeX renders Greek letters as native Unicode, so no translation
32
+ * is required. This table is provided for documentation and
33
+ * for users who want to inspect the supported set.
34
+ */
35
+ export declare const GREEK_MAP: Record<string, string>;
36
+ /**
37
+ * Convert a `dX` differential to Arabic form: `دX` where X is the
38
+ * Arabic variable. e.g. dx → د س, dθ → د θ.
39
+ */
40
+ export declare const DIFFERENTIAL_PATTERNS: Record<string, string>;
41
+ /**
42
+ * Translate LaTeX function commands (sin, cos, lim, …) to Arabic.
43
+ *
44
+ * Uses a single left-to-right scan of the source so that:
45
+ * • the longest command wins at every position (\\arcsin before \\sin),
46
+ * • verbatim regions (\\text{…}, \\operatorname{…}) are never modified,
47
+ * • offsets stay stable — there is no cascade of in-place edits that
48
+ * could re-shift later matches.
49
+ *
50
+ * @param latex LaTeX source.
51
+ * @param customMap User-supplied overrides merged on top of FUNCTION_MAP.
52
+ */
53
+ export declare function translateFunctions(latex: string, customMap?: Record<string, string>): string;
54
+ /**
55
+ * Translate differential patterns like `dx`, `dy`, `d\theta` to their
56
+ * Arabic equivalents.
57
+ */
58
+ export declare function translateDifferentials(latex: string): string;
59
+ /**
60
+ * Translate standalone Latin variables to their Arabic equivalents.
61
+ *
62
+ * Critical: avoid translating inside LaTeX commands, math text blocks,
63
+ * and \\operatorname names. We pre-compute the "protected" regions once
64
+ * and run a single combined pass so that no offset ever shifts.
65
+ *
66
+ * Implementation note: the pattern has exactly one capture group, so the
67
+ * `replace` callback is `(match, p1, offset, string)` — `offset` is the
68
+ * **third** argument.
69
+ */
70
+ export declare function translateVariables(latex: string, customMap?: Record<string, string>): string;
71
+ /**
72
+ * Translate `d\theta` and other named Greek differentials to Arabic.
73
+ * Used by the differential pipeline; exposed for completeness.
74
+ */
75
+ export declare function translateSpecialPatterns(latex: string): string;
76
+ /**
77
+ * Translate everything: differentials, functions, and variables.
78
+ * Each step is independent and may be toggled by the caller.
79
+ */
80
+ export declare function translateAll(latex: string, options?: {
81
+ functions?: boolean;
82
+ variables?: boolean;
83
+ differentials?: boolean;
84
+ customFunctionMap?: Record<string, string>;
85
+ customVariableMap?: Record<string, string>;
86
+ }): string;
87
+ //# sourceMappingURL=arabicFunctions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arabicFunctions.d.ts","sourceRoot":"","sources":["../../src/lib/katex-arabic/arabicFunctions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAQH;;;;GAIG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwF/C,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAwD/C,CAAC;AAMF;;;;GAIG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAW5C,CAAC;AAMF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAYxD,CAAC;AAkBF;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACrC,MAAM,CAgCR;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CA6B5D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,GACrC,MAAM,CAqBR;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE9D;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE;IACP,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC3C,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC,GACL,MAAM,CA6BR"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════
3
+ * arabicNumerals.ts
4
+ * Convert Latin digits to Arabic-Indic / Persian digits, and
5
+ * format numbers with proper Arabic separators.
6
+ *
7
+ * Digit ranges:
8
+ * - Arabic-Indic (٠-٩) U+0660 – U+0669 (Standard Arabic)
9
+ * - Eastern Arabic (۰-۹) U+06F0 – U+06F9 (Persian / Urdu)
10
+ * ════════════════════════════════════════════════════════════════
11
+ */
12
+ import type { NumeralStyle } from './types';
13
+ /**
14
+ * Converts a string of Latin digits to the requested numeral style.
15
+ * Returns the input unchanged when style is 'latin'.
16
+ *
17
+ * @param input The text to convert.
18
+ * @param style Target numeral style. Defaults to 'arabic'.
19
+ */
20
+ export declare function toArabicNumerals(input: string | number, style?: NumeralStyle): string;
21
+ /**
22
+ * Converts Arabic-Indic and Eastern-Arabic digits back to Latin.
23
+ * Useful for round-tripping or input normalization.
24
+ */
25
+ export declare function fromArabicNumerals(input: string): string;
26
+ /**
27
+ * Formats a numeric string with Arabic-Indic digits and Arabic separators:
28
+ * - Thousands separator: ٬ (U+066C)
29
+ * - Decimal separator: ٫ (U+066B)
30
+ *
31
+ * Example: `1,000.50` → `١٬٠٠٠٫٥٠`
32
+ *
33
+ * Always uses the Arabic-Indic digit set, regardless of the requested style,
34
+ * because the Arabic separators are paired with that set in standard usage.
35
+ */
36
+ export declare function formatArabicNumber(numStr: string): string;
37
+ /**
38
+ * Convert all numeric substrings inside a text to the requested style.
39
+ * Optionally applies Arabic separators.
40
+ */
41
+ export declare function convertNumbersInText(text: string, style?: NumeralStyle, formatSeparators?: boolean): string;
42
+ /**
43
+ * Internal: returns true if the given character is any Arabic digit
44
+ * (Arabic-Indic or Eastern-Arabic).
45
+ *
46
+ * We rebuild a fresh regex per call to avoid the global-regex
47
+ * `lastIndex` state that would otherwise cause flaky results.
48
+ */
49
+ export declare function isArabicDigit(ch: string): boolean;
50
+ //# sourceMappingURL=arabicNumerals.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arabicNumerals.d.ts","sourceRoot":"","sources":["../../src/lib/katex-arabic/arabicNumerals.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAY5C;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,KAAK,GAAE,YAAuB,GAAG,MAAM,CAO/F;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAIxD;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKzD;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,YAAuB,EAC9B,gBAAgB,UAAO,GACtB,MAAM,CASR;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEjD"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════
3
+ * arabicSymbols.ts
4
+ * Symbol mirroring and Unicode math-symbol definitions.
5
+ *
6
+ * When an equation is rendered in an RTL context, certain symbols
7
+ * (≤, ≥, ∫, Σ, …) should appear visually mirrored so that the
8
+ * smaller / open end faces the start of the reading direction.
9
+ *
10
+ * This module is the *LaTeX-level* mirror. The CSS layer may
11
+ * additionally apply `transform: scaleX(-1)` to the rendered
12
+ * DOM nodes for finer-grained control over glyphs that KaTeX
13
+ * renders directly (√, ∫, Σ, ∏).
14
+ * ════════════════════════════════════════════════════════════════
15
+ */
16
+ /**
17
+ * Combined mirror map. Each group can be toggled independently.
18
+ */
19
+ export declare const MIRRORED_SYMBOLS: Record<string, string>;
20
+ /**
21
+ * Sub-maps exposed for fine-grained control by callers.
22
+ */
23
+ export declare const COMPARISON_SYMBOLS: Record<string, string>;
24
+ export declare const ARROW_SYMBOLS: Record<string, string>;
25
+ export declare const BRACKET_SYMBOLS: Record<string, string>;
26
+ /**
27
+ * The Unicode "Arabic Mathematical Alphabet" provides isolated-form
28
+ * Arabic letters optimized for math typesetting. These are *not*
29
+ * connecting forms; they are intended to behave like individual
30
+ * Latin letters inside an equation.
31
+ */
32
+ export declare const ARABIC_MATH_UNICODE: Record<string, string>;
33
+ /**
34
+ * Curated special symbols used in Arabic math typography.
35
+ */
36
+ export declare const SPECIAL_ARABIC_SYMBOLS: {
37
+ readonly arabicFractionSlash: "/";
38
+ readonly integralMaghribi: "\\int";
39
+ };
40
+ /**
41
+ * Apply symbol mirroring to a LaTeX string.
42
+ *
43
+ * A single left-to-right pass over the *original* string is used. Each
44
+ * symbol is mapped at most once (so `<` never re-mirrors back to `<`),
45
+ * longer commands win over shorter prefixes, and verbatim regions are
46
+ * skipped — all without the offset-shift problems of chained passes.
47
+ *
48
+ * @param latex LaTeX source.
49
+ * @param enabled Whether mirroring is active.
50
+ */
51
+ export declare function applyMirroredSymbols(latex: string, enabled?: boolean): string;
52
+ //# sourceMappingURL=arabicSymbols.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arabicSymbols.d.ts","sourceRoot":"","sources":["../../src/lib/katex-arabic/arabicSymbols.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AA+FH;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAKnD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,wBAAqB,CAAC;AACrD,eAAO,MAAM,aAAa,wBAAgB,CAAC;AAC3C,eAAO,MAAM,eAAe,wBAAkB,CAAC;AAM/C;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2BtD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;CAGzB,CAAC;AA2BX;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,UAAO,GAAG,MAAM,CAkC1E"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * cdn.ts
3
+ * Dedicated CDN entry point.
4
+ *
5
+ * The full `index.ts` barrel exports many named symbols; the CDN IIFE
6
+ * needs a *single* default export so that `window.KaTeXArabic` IS the
7
+ * namespace object (exactly like the `katex` global). This wrapper
8
+ * re-exports just that object.
9
+ *
10
+ * Everything the namespace needs is reachable through it:
11
+ *
12
+ * KaTeXArabic.renderToString('...')
13
+ * KaTeXArabic.render(el, '...')
14
+ * KaTeXArabic.toArabicNumerals('123') → '١٢٣'
15
+ * KaTeXArabic.DEFAULT_OPTIONS
16
+ */
17
+ export { default } from './index';
18
+ //# sourceMappingURL=cdn.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cdn.d.ts","sourceRoot":"","sources":["../../src/lib/katex-arabic/cdn.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const react = require("react");
4
+ const render = require("./render.cjs");
5
+ const EMPTY_OPTIONS = Object.freeze({});
6
+ function useArabicKatex(latex, options = EMPTY_OPTIONS) {
7
+ const deferredLatex = react.useDeferredValue(latex);
8
+ return react.useMemo(() => {
9
+ try {
10
+ return render.renderArabicWithMeta(deferredLatex, options).html;
11
+ } catch {
12
+ return "";
13
+ }
14
+ }, [deferredLatex, options]);
15
+ }
16
+ function useArabicKatexResult(latex, options = EMPTY_OPTIONS) {
17
+ const deferredLatex = react.useDeferredValue(latex);
18
+ return react.useMemo(() => {
19
+ const processedLatex = render.processArabicLatex(deferredLatex, options);
20
+ const { html, error } = render.renderArabicWithMeta(deferredLatex, options);
21
+ if (error !== null) {
22
+ return { html: "", processedLatex, ok: false, error };
23
+ }
24
+ return { html, processedLatex, ok: true };
25
+ }, [deferredLatex, options]);
26
+ }
27
+ function useArabicKatexBatch(items, options = EMPTY_OPTIONS) {
28
+ const itemsKey = react.useMemo(
29
+ () => items.map((it) => typeof it === "string" ? it : `${it.latex}|${JSON.stringify(it.options ?? {})}`).join("\0"),
30
+ [items]
31
+ );
32
+ return react.useMemo(
33
+ () => render.renderArabicBatch(items, options),
34
+ // eslint-disable-next-line react-hooks/exhaustive-deps
35
+ [itemsKey, options]
36
+ );
37
+ }
38
+ exports.useArabicKatex = useArabicKatex;
39
+ exports.useArabicKatexBatch = useArabicKatexBatch;
40
+ exports.useArabicKatexResult = useArabicKatexResult;
41
+ //# sourceMappingURL=hooks.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.cjs","sources":["../../src/lib/katex-arabic/hooks.ts"],"sourcesContent":["/**\n * ════════════════════════════════════════════════════════════════\n * hooks.ts\n * React hooks for the KaTeX Arabic library.\n *\n * These hooks memoize the rendered output and re-render only when\n * inputs change. They are designed to integrate seamlessly with\n * React 18+ concurrent rendering.\n *\n * Performance notes:\n * - A stable EMPTY_OPTIONS sentinel is used as the default so\n * callers who omit `options` don't break memoization with a\n * fresh object identity on every render.\n * - `useArabicKatexResult` renders once and derives the error\n * from the result instead of calling KaTeX twice.\n * ════════════════════════════════════════════════════════════════\n */\n\nimport { useMemo, useDeferredValue } from 'react';\nimport { renderArabicWithMeta, renderArabicBatch } from './render';\nimport { processArabicLatex } from './rtlRenderer';\nimport type { PartialArabicOptions, RenderResult } from './types';\n\n/**\n * Stable empty-options sentinel. Using a module-level constant as the\n * default parameter keeps the `options` identity stable across renders,\n * which is essential for the useMemo dependency check to work.\n */\nconst EMPTY_OPTIONS: PartialArabicOptions = Object.freeze({});\n\n/**\n * React hook: render a LaTeX string to HTML.\n *\n * The result is memoized on the (latex, options) identity. Heavy\n * renders use `useDeferredValue` so typing in an editor stays\n * responsive even for very long LaTeX strings.\n *\n * @param latex The LaTeX source.\n * @param options Arabic rendering options.\n */\nexport function useArabicKatex(\n latex: string,\n options: PartialArabicOptions = EMPTY_OPTIONS,\n): string {\n // Defer the value to keep the UI responsive when the user is\n // rapidly editing a long equation. The first render uses the\n // current value, then subsequent renders may use the deferred\n // one if React chooses to deprioritize the work.\n const deferredLatex = useDeferredValue(latex);\n\n return useMemo(() => {\n try {\n return renderArabicWithMeta(deferredLatex, options).html;\n } catch {\n // The renderer never throws (it returns a styled error string),\n // but be defensive for unforeseen runtime errors.\n return '';\n }\n }, [deferredLatex, options]);\n}\n\n/**\n * React hook: render LaTeX and return structured metadata.\n *\n * Returns both the rendered HTML and a flag indicating success,\n * along with any validation error message. Useful for editor UIs\n * that want to surface errors inline.\n *\n * Implementation: a single `renderArabicWithMeta` call yields both\n * the HTML and the error message, avoiding the double-render cost\n * of validate + render.\n */\nexport function useArabicKatexResult(\n latex: string,\n options: PartialArabicOptions = EMPTY_OPTIONS,\n): RenderResult {\n const deferredLatex = useDeferredValue(latex);\n\n return useMemo<RenderResult>(() => {\n const processedLatex = processArabicLatex(deferredLatex, options);\n const { html, error } = renderArabicWithMeta(deferredLatex, options);\n\n if (error !== null) {\n return { html: '', processedLatex, ok: false, error };\n }\n\n return { html, processedLatex, ok: true };\n }, [deferredLatex, options]);\n}\n\n/**\n * React hook: render a batch of LaTeX strings in one memoized pass.\n *\n * Returns an array of `{ html, error }` results in the same order as\n * the input. This is the most efficient way to render a list of\n * equations (e.g. a gallery) because the options object is resolved\n * once and the shared LRU cache is reused across the whole batch.\n *\n * @param items Array of LaTeX strings (or `{ latex, options }` objects\n * for per-item overrides).\n * @param options Shared options applied to every item unless overridden.\n */\nexport function useArabicKatexBatch(\n items: ReadonlyArray<string | { latex: string; options?: PartialArabicOptions }>,\n options: PartialArabicOptions = EMPTY_OPTIONS,\n): Array<{ html: string; error: string | null }> {\n // Serialize the items into a stable dependency so the memo only\n // recomputes when the actual content changes, not on every render.\n const itemsKey = useMemo(\n () =>\n items\n .map((it) => (typeof it === 'string' ? it : `${it.latex}|${JSON.stringify(it.options ?? {})}`))\n .join('\\u0000'),\n [items],\n );\n\n return useMemo(\n () => renderArabicBatch(items, options),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [itemsKey, options],\n );\n}\n\n"],"names":["useDeferredValue","useMemo","renderArabicWithMeta","processArabicLatex","renderArabicBatch"],"mappings":";;;;AA4BA,MAAM,gBAAsC,OAAO,OAAO,EAAE;AAYrD,SAAS,eACd,OACA,UAAgC,eACxB;AAKR,QAAM,gBAAgBA,MAAAA,iBAAiB,KAAK;AAE5C,SAAOC,MAAAA,QAAQ,MAAM;AACnB,QAAI;AACF,aAAOC,4BAAqB,eAAe,OAAO,EAAE;AAAA,IACtD,QAAQ;AAGN,aAAO;AAAA,IACT;AAAA,EACF,GAAG,CAAC,eAAe,OAAO,CAAC;AAC7B;AAaO,SAAS,qBACd,OACA,UAAgC,eAClB;AACd,QAAM,gBAAgBF,MAAAA,iBAAiB,KAAK;AAE5C,SAAOC,MAAAA,QAAsB,MAAM;AACjC,UAAM,iBAAiBE,OAAAA,mBAAmB,eAAe,OAAO;AAChE,UAAM,EAAE,MAAM,MAAA,IAAUD,OAAAA,qBAAqB,eAAe,OAAO;AAEnE,QAAI,UAAU,MAAM;AAClB,aAAO,EAAE,MAAM,IAAI,gBAAgB,IAAI,OAAO,MAAA;AAAA,IAChD;AAEA,WAAO,EAAE,MAAM,gBAAgB,IAAI,KAAA;AAAA,EACrC,GAAG,CAAC,eAAe,OAAO,CAAC;AAC7B;AAcO,SAAS,oBACd,OACA,UAAgC,eACe;AAG/C,QAAM,WAAWD,MAAAA;AAAAA,IACf,MACE,MACG,IAAI,CAAC,OAAQ,OAAO,OAAO,WAAW,KAAK,GAAG,GAAG,KAAK,IAAI,KAAK,UAAU,GAAG,WAAW,CAAA,CAAE,CAAC,EAAG,EAC7F,KAAK,IAAQ;AAAA,IAClB,CAAC,KAAK;AAAA,EAAA;AAGR,SAAOA,MAAAA;AAAAA,IACL,MAAMG,OAAAA,kBAAkB,OAAO,OAAO;AAAA;AAAA,IAEtC,CAAC,UAAU,OAAO;AAAA,EAAA;AAEtB;;;;"}
@@ -0,0 +1,61 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════
3
+ * hooks.ts
4
+ * React hooks for the KaTeX Arabic library.
5
+ *
6
+ * These hooks memoize the rendered output and re-render only when
7
+ * inputs change. They are designed to integrate seamlessly with
8
+ * React 18+ concurrent rendering.
9
+ *
10
+ * Performance notes:
11
+ * - A stable EMPTY_OPTIONS sentinel is used as the default so
12
+ * callers who omit `options` don't break memoization with a
13
+ * fresh object identity on every render.
14
+ * - `useArabicKatexResult` renders once and derives the error
15
+ * from the result instead of calling KaTeX twice.
16
+ * ════════════════════════════════════════════════════════════════
17
+ */
18
+ import type { PartialArabicOptions, RenderResult } from './types';
19
+ /**
20
+ * React hook: render a LaTeX string to HTML.
21
+ *
22
+ * The result is memoized on the (latex, options) identity. Heavy
23
+ * renders use `useDeferredValue` so typing in an editor stays
24
+ * responsive even for very long LaTeX strings.
25
+ *
26
+ * @param latex The LaTeX source.
27
+ * @param options Arabic rendering options.
28
+ */
29
+ export declare function useArabicKatex(latex: string, options?: PartialArabicOptions): string;
30
+ /**
31
+ * React hook: render LaTeX and return structured metadata.
32
+ *
33
+ * Returns both the rendered HTML and a flag indicating success,
34
+ * along with any validation error message. Useful for editor UIs
35
+ * that want to surface errors inline.
36
+ *
37
+ * Implementation: a single `renderArabicWithMeta` call yields both
38
+ * the HTML and the error message, avoiding the double-render cost
39
+ * of validate + render.
40
+ */
41
+ export declare function useArabicKatexResult(latex: string, options?: PartialArabicOptions): RenderResult;
42
+ /**
43
+ * React hook: render a batch of LaTeX strings in one memoized pass.
44
+ *
45
+ * Returns an array of `{ html, error }` results in the same order as
46
+ * the input. This is the most efficient way to render a list of
47
+ * equations (e.g. a gallery) because the options object is resolved
48
+ * once and the shared LRU cache is reused across the whole batch.
49
+ *
50
+ * @param items Array of LaTeX strings (or `{ latex, options }` objects
51
+ * for per-item overrides).
52
+ * @param options Shared options applied to every item unless overridden.
53
+ */
54
+ export declare function useArabicKatexBatch(items: ReadonlyArray<string | {
55
+ latex: string;
56
+ options?: PartialArabicOptions;
57
+ }>, options?: PartialArabicOptions): Array<{
58
+ html: string;
59
+ error: string | null;
60
+ }>;
61
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1,61 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════
3
+ * hooks.ts
4
+ * React hooks for the KaTeX Arabic library.
5
+ *
6
+ * These hooks memoize the rendered output and re-render only when
7
+ * inputs change. They are designed to integrate seamlessly with
8
+ * React 18+ concurrent rendering.
9
+ *
10
+ * Performance notes:
11
+ * - A stable EMPTY_OPTIONS sentinel is used as the default so
12
+ * callers who omit `options` don't break memoization with a
13
+ * fresh object identity on every render.
14
+ * - `useArabicKatexResult` renders once and derives the error
15
+ * from the result instead of calling KaTeX twice.
16
+ * ════════════════════════════════════════════════════════════════
17
+ */
18
+ import type { PartialArabicOptions, RenderResult } from './types';
19
+ /**
20
+ * React hook: render a LaTeX string to HTML.
21
+ *
22
+ * The result is memoized on the (latex, options) identity. Heavy
23
+ * renders use `useDeferredValue` so typing in an editor stays
24
+ * responsive even for very long LaTeX strings.
25
+ *
26
+ * @param latex The LaTeX source.
27
+ * @param options Arabic rendering options.
28
+ */
29
+ export declare function useArabicKatex(latex: string, options?: PartialArabicOptions): string;
30
+ /**
31
+ * React hook: render LaTeX and return structured metadata.
32
+ *
33
+ * Returns both the rendered HTML and a flag indicating success,
34
+ * along with any validation error message. Useful for editor UIs
35
+ * that want to surface errors inline.
36
+ *
37
+ * Implementation: a single `renderArabicWithMeta` call yields both
38
+ * the HTML and the error message, avoiding the double-render cost
39
+ * of validate + render.
40
+ */
41
+ export declare function useArabicKatexResult(latex: string, options?: PartialArabicOptions): RenderResult;
42
+ /**
43
+ * React hook: render a batch of LaTeX strings in one memoized pass.
44
+ *
45
+ * Returns an array of `{ html, error }` results in the same order as
46
+ * the input. This is the most efficient way to render a list of
47
+ * equations (e.g. a gallery) because the options object is resolved
48
+ * once and the shared LRU cache is reused across the whole batch.
49
+ *
50
+ * @param items Array of LaTeX strings (or `{ latex, options }` objects
51
+ * for per-item overrides).
52
+ * @param options Shared options applied to every item unless overridden.
53
+ */
54
+ export declare function useArabicKatexBatch(items: ReadonlyArray<string | {
55
+ latex: string;
56
+ options?: PartialArabicOptions;
57
+ }>, options?: PartialArabicOptions): Array<{
58
+ html: string;
59
+ error: string | null;
60
+ }>;
61
+ //# sourceMappingURL=hooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/lib/katex-arabic/hooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AASlE;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAoC,GAC5C,MAAM,CAgBR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAClC,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,oBAAoC,GAC5C,YAAY,CAad;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,aAAa,CAAC,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,oBAAoB,CAAA;CAAE,CAAC,EAChF,OAAO,GAAE,oBAAoC,GAC5C,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,CAgB/C"}
@@ -0,0 +1,41 @@
1
+ import { useDeferredValue, useMemo } from "react";
2
+ import { r as renderArabicWithMeta, a as renderArabicBatch, p as processArabicLatex } from "./render.mjs";
3
+ const EMPTY_OPTIONS = Object.freeze({});
4
+ function useArabicKatex(latex, options = EMPTY_OPTIONS) {
5
+ const deferredLatex = useDeferredValue(latex);
6
+ return useMemo(() => {
7
+ try {
8
+ return renderArabicWithMeta(deferredLatex, options).html;
9
+ } catch {
10
+ return "";
11
+ }
12
+ }, [deferredLatex, options]);
13
+ }
14
+ function useArabicKatexResult(latex, options = EMPTY_OPTIONS) {
15
+ const deferredLatex = useDeferredValue(latex);
16
+ return useMemo(() => {
17
+ const processedLatex = processArabicLatex(deferredLatex, options);
18
+ const { html, error } = renderArabicWithMeta(deferredLatex, options);
19
+ if (error !== null) {
20
+ return { html: "", processedLatex, ok: false, error };
21
+ }
22
+ return { html, processedLatex, ok: true };
23
+ }, [deferredLatex, options]);
24
+ }
25
+ function useArabicKatexBatch(items, options = EMPTY_OPTIONS) {
26
+ const itemsKey = useMemo(
27
+ () => items.map((it) => typeof it === "string" ? it : `${it.latex}|${JSON.stringify(it.options ?? {})}`).join("\0"),
28
+ [items]
29
+ );
30
+ return useMemo(
31
+ () => renderArabicBatch(items, options),
32
+ // eslint-disable-next-line react-hooks/exhaustive-deps
33
+ [itemsKey, options]
34
+ );
35
+ }
36
+ export {
37
+ useArabicKatex,
38
+ useArabicKatexBatch,
39
+ useArabicKatexResult
40
+ };
41
+ //# sourceMappingURL=hooks.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.mjs","sources":["../../src/lib/katex-arabic/hooks.ts"],"sourcesContent":["/**\n * ════════════════════════════════════════════════════════════════\n * hooks.ts\n * React hooks for the KaTeX Arabic library.\n *\n * These hooks memoize the rendered output and re-render only when\n * inputs change. They are designed to integrate seamlessly with\n * React 18+ concurrent rendering.\n *\n * Performance notes:\n * - A stable EMPTY_OPTIONS sentinel is used as the default so\n * callers who omit `options` don't break memoization with a\n * fresh object identity on every render.\n * - `useArabicKatexResult` renders once and derives the error\n * from the result instead of calling KaTeX twice.\n * ════════════════════════════════════════════════════════════════\n */\n\nimport { useMemo, useDeferredValue } from 'react';\nimport { renderArabicWithMeta, renderArabicBatch } from './render';\nimport { processArabicLatex } from './rtlRenderer';\nimport type { PartialArabicOptions, RenderResult } from './types';\n\n/**\n * Stable empty-options sentinel. Using a module-level constant as the\n * default parameter keeps the `options` identity stable across renders,\n * which is essential for the useMemo dependency check to work.\n */\nconst EMPTY_OPTIONS: PartialArabicOptions = Object.freeze({});\n\n/**\n * React hook: render a LaTeX string to HTML.\n *\n * The result is memoized on the (latex, options) identity. Heavy\n * renders use `useDeferredValue` so typing in an editor stays\n * responsive even for very long LaTeX strings.\n *\n * @param latex The LaTeX source.\n * @param options Arabic rendering options.\n */\nexport function useArabicKatex(\n latex: string,\n options: PartialArabicOptions = EMPTY_OPTIONS,\n): string {\n // Defer the value to keep the UI responsive when the user is\n // rapidly editing a long equation. The first render uses the\n // current value, then subsequent renders may use the deferred\n // one if React chooses to deprioritize the work.\n const deferredLatex = useDeferredValue(latex);\n\n return useMemo(() => {\n try {\n return renderArabicWithMeta(deferredLatex, options).html;\n } catch {\n // The renderer never throws (it returns a styled error string),\n // but be defensive for unforeseen runtime errors.\n return '';\n }\n }, [deferredLatex, options]);\n}\n\n/**\n * React hook: render LaTeX and return structured metadata.\n *\n * Returns both the rendered HTML and a flag indicating success,\n * along with any validation error message. Useful for editor UIs\n * that want to surface errors inline.\n *\n * Implementation: a single `renderArabicWithMeta` call yields both\n * the HTML and the error message, avoiding the double-render cost\n * of validate + render.\n */\nexport function useArabicKatexResult(\n latex: string,\n options: PartialArabicOptions = EMPTY_OPTIONS,\n): RenderResult {\n const deferredLatex = useDeferredValue(latex);\n\n return useMemo<RenderResult>(() => {\n const processedLatex = processArabicLatex(deferredLatex, options);\n const { html, error } = renderArabicWithMeta(deferredLatex, options);\n\n if (error !== null) {\n return { html: '', processedLatex, ok: false, error };\n }\n\n return { html, processedLatex, ok: true };\n }, [deferredLatex, options]);\n}\n\n/**\n * React hook: render a batch of LaTeX strings in one memoized pass.\n *\n * Returns an array of `{ html, error }` results in the same order as\n * the input. This is the most efficient way to render a list of\n * equations (e.g. a gallery) because the options object is resolved\n * once and the shared LRU cache is reused across the whole batch.\n *\n * @param items Array of LaTeX strings (or `{ latex, options }` objects\n * for per-item overrides).\n * @param options Shared options applied to every item unless overridden.\n */\nexport function useArabicKatexBatch(\n items: ReadonlyArray<string | { latex: string; options?: PartialArabicOptions }>,\n options: PartialArabicOptions = EMPTY_OPTIONS,\n): Array<{ html: string; error: string | null }> {\n // Serialize the items into a stable dependency so the memo only\n // recomputes when the actual content changes, not on every render.\n const itemsKey = useMemo(\n () =>\n items\n .map((it) => (typeof it === 'string' ? it : `${it.latex}|${JSON.stringify(it.options ?? {})}`))\n .join('\\u0000'),\n [items],\n );\n\n return useMemo(\n () => renderArabicBatch(items, options),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [itemsKey, options],\n );\n}\n\n"],"names":[],"mappings":";;AA4BA,MAAM,gBAAsC,OAAO,OAAO,EAAE;AAYrD,SAAS,eACd,OACA,UAAgC,eACxB;AAKR,QAAM,gBAAgB,iBAAiB,KAAK;AAE5C,SAAO,QAAQ,MAAM;AACnB,QAAI;AACF,aAAO,qBAAqB,eAAe,OAAO,EAAE;AAAA,IACtD,QAAQ;AAGN,aAAO;AAAA,IACT;AAAA,EACF,GAAG,CAAC,eAAe,OAAO,CAAC;AAC7B;AAaO,SAAS,qBACd,OACA,UAAgC,eAClB;AACd,QAAM,gBAAgB,iBAAiB,KAAK;AAE5C,SAAO,QAAsB,MAAM;AACjC,UAAM,iBAAiB,mBAAmB,eAAe,OAAO;AAChE,UAAM,EAAE,MAAM,MAAA,IAAU,qBAAqB,eAAe,OAAO;AAEnE,QAAI,UAAU,MAAM;AAClB,aAAO,EAAE,MAAM,IAAI,gBAAgB,IAAI,OAAO,MAAA;AAAA,IAChD;AAEA,WAAO,EAAE,MAAM,gBAAgB,IAAI,KAAA;AAAA,EACrC,GAAG,CAAC,eAAe,OAAO,CAAC;AAC7B;AAcO,SAAS,oBACd,OACA,UAAgC,eACe;AAG/C,QAAM,WAAW;AAAA,IACf,MACE,MACG,IAAI,CAAC,OAAQ,OAAO,OAAO,WAAW,KAAK,GAAG,GAAG,KAAK,IAAI,KAAK,UAAU,GAAG,WAAW,CAAA,CAAE,CAAC,EAAG,EAC7F,KAAK,IAAQ;AAAA,IAClB,CAAC,KAAK;AAAA,EAAA;AAGR,SAAO;AAAA,IACL,MAAM,kBAAkB,OAAO,OAAO;AAAA;AAAA,IAEtC,CAAC,UAAU,OAAO;AAAA,EAAA;AAEtB;"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
3
+ const render = require("./render.cjs");
4
+ const VERSION = "1.1.1";
5
+ const KaTeXArabic = {
6
+ // ─── Rendering ───────────────────────────────────────────
7
+ render: render.renderArabic,
8
+ renderToString: render.renderArabicToString,
9
+ renderWithMeta: render.renderArabicWithMeta,
10
+ renderBatch: render.renderArabicBatch,
11
+ // ─── Text processing ─────────────────────────────────────
12
+ process: render.processLatex,
13
+ validate: render.validateLatex,
14
+ // ─── Numerals ────────────────────────────────────────────
15
+ toArabicNumerals: render.toArabicNumerals,
16
+ fromArabicNumerals: render.fromArabicNumerals,
17
+ formatArabicNumber: render.formatArabicNumber,
18
+ convertNumbersInText: render.convertNumbersInText,
19
+ isArabicDigit: render.isArabicDigit,
20
+ // ─── Translation ─────────────────────────────────────────
21
+ translateFunctions: render.translateFunctions,
22
+ translateVariables: render.translateVariables,
23
+ translateDifferentials: render.translateDifferentials,
24
+ translateSpecialPatterns: render.translateSpecialPatterns,
25
+ translateAll: render.translateAll,
26
+ // ─── Mirroring ───────────────────────────────────────────
27
+ applyMirroredSymbols: render.applyMirroredSymbols,
28
+ // ─── Options / cache ─────────────────────────────────────
29
+ resolveOptions: render.resolveOptions,
30
+ buildCssClasses: render.buildCssClasses,
31
+ getArabicMacros: render.getArabicMacros,
32
+ clearCache: render.clearRenderCache,
33
+ DEFAULT_OPTIONS: render.DEFAULT_OPTIONS,
34
+ VERSION
35
+ };
36
+ exports.ARABIC_MATH_UNICODE = render.ARABIC_MATH_UNICODE;
37
+ exports.ARROW_SYMBOLS = render.ARROW_SYMBOLS;
38
+ exports.BRACKET_SYMBOLS = render.BRACKET_SYMBOLS;
39
+ exports.COMPARISON_SYMBOLS = render.COMPARISON_SYMBOLS;
40
+ exports.DEFAULT_OPTIONS = render.DEFAULT_OPTIONS;
41
+ exports.DIFFERENTIAL_PATTERNS = render.DIFFERENTIAL_PATTERNS;
42
+ exports.FUNCTION_MAP = render.FUNCTION_MAP;
43
+ exports.GREEK_MAP = render.GREEK_MAP;
44
+ exports.MAX_INPUT_LENGTH = render.MAX_INPUT_LENGTH;
45
+ exports.MIRRORED_SYMBOLS = render.MIRRORED_SYMBOLS;
46
+ exports.SPECIAL_ARABIC_SYMBOLS = render.SPECIAL_ARABIC_SYMBOLS;
47
+ exports.VARIABLE_MAP = render.VARIABLE_MAP;
48
+ exports.applyMirroredSymbols = render.applyMirroredSymbols;
49
+ exports.buildCssClasses = render.buildCssClasses;
50
+ exports.clearRenderCache = render.clearRenderCache;
51
+ exports.convertNumbersInText = render.convertNumbersInText;
52
+ exports.formatArabicNumber = render.formatArabicNumber;
53
+ exports.fromArabicNumerals = render.fromArabicNumerals;
54
+ exports.getArabicMacros = render.getArabicMacros;
55
+ exports.isArabicDigit = render.isArabicDigit;
56
+ exports.processLatex = render.processLatex;
57
+ exports.renderArabic = render.renderArabic;
58
+ exports.renderArabicBatch = render.renderArabicBatch;
59
+ exports.renderArabicToString = render.renderArabicToString;
60
+ exports.renderArabicWithMeta = render.renderArabicWithMeta;
61
+ exports.resolveOptions = render.resolveOptions;
62
+ exports.toArabicNumerals = render.toArabicNumerals;
63
+ exports.translateAll = render.translateAll;
64
+ exports.translateDifferentials = render.translateDifferentials;
65
+ exports.translateFunctions = render.translateFunctions;
66
+ exports.translateSpecialPatterns = render.translateSpecialPatterns;
67
+ exports.translateVariables = render.translateVariables;
68
+ exports.validateLatex = render.validateLatex;
69
+ exports.VERSION = VERSION;
70
+ exports.default = KaTeXArabic;
71
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../src/lib/katex-arabic/index.ts"],"sourcesContent":["/**\n * ════════════════════════════════════════════════════════════════\n * index.ts\n * Public entry point for the KaTeX Arabic library.\n *\n * This module is the *only* file the application should import\n * from when consuming the library. All internal modules are\n * re-exported below for advanced use cases.\n *\n * The render functions themselves live in `render.ts` so that\n * `hooks.ts` can import them without a circular dependency\n * through this barrel.\n * ════════════════════════════════════════════════════════════════\n */\n\nimport {\n renderArabic,\n renderArabicToString,\n renderArabicWithMeta,\n renderArabicBatch,\n processLatex,\n validateLatex,\n} from './render';\nimport {\n DEFAULT_OPTIONS,\n clearRenderCache,\n resolveOptions,\n buildCssClasses,\n getArabicMacros,\n} from './rtlRenderer';\nimport {\n toArabicNumerals,\n fromArabicNumerals,\n formatArabicNumber,\n convertNumbersInText,\n isArabicDigit,\n} from './arabicNumerals';\nimport {\n translateFunctions,\n translateVariables,\n translateDifferentials,\n translateSpecialPatterns,\n translateAll,\n} from './arabicFunctions';\nimport { applyMirroredSymbols } from './arabicSymbols';\n\n// ─── Re-exports: configuration ─────────────────────────────\nexport {\n DEFAULT_OPTIONS,\n resolveOptions,\n buildCssClasses,\n getArabicMacros,\n clearRenderCache,\n MAX_INPUT_LENGTH,\n} from './rtlRenderer';\nexport type { ArabicKatexOptions, PartialArabicOptions, RenderResult } from './types';\n\n// ─── Re-exports: render functions ────────────────────────────\nexport {\n renderArabicToString,\n renderArabicWithMeta,\n renderArabic,\n renderArabicBatch,\n processLatex,\n validateLatex,\n} from './render';\n\n// ─── Re-exports: numerals ──────────────────────────────────\nexport {\n toArabicNumerals,\n fromArabicNumerals,\n formatArabicNumber,\n convertNumbersInText,\n isArabicDigit,\n} from './arabicNumerals';\n\n// ─── Re-exports: function translation ──────────────────────\nexport {\n translateFunctions,\n translateVariables,\n translateDifferentials,\n translateSpecialPatterns,\n translateAll,\n FUNCTION_MAP,\n VARIABLE_MAP,\n GREEK_MAP,\n DIFFERENTIAL_PATTERNS,\n} from './arabicFunctions';\n\n// ─── Re-exports: symbol mirroring ──────────────────────────\nexport {\n applyMirroredSymbols,\n MIRRORED_SYMBOLS,\n COMPARISON_SYMBOLS,\n ARROW_SYMBOLS,\n BRACKET_SYMBOLS,\n ARABIC_MATH_UNICODE,\n SPECIAL_ARABIC_SYMBOLS,\n} from './arabicSymbols';\n\n// ─── Version constant ──────────────────────────────────────\n// Kept in sync with package.json by scripts/build-cdn.mjs\n// (the CDN build fails if these ever drift apart).\nexport const VERSION = '1.1.1';\n\n// ═══════════════════════════════════════════════════════════════\n// Default export — the \"KaTeXArabic\" namespace\n//\n// This object is what a CDN <script> tag exposes as `window.KaTeXArabic`,\n// and what `import KaTeXArabic from 'katex-arabic'` returns. It mirrors\n// `katex`'s own API shape (render / renderToString / …) plus every\n// Arabic helper, so it works as a full drop-in namespace.\n// ═══════════════════════════════════════════════════════════════\n\nconst KaTeXArabic = {\n // ─── Rendering ───────────────────────────────────────────\n render: renderArabic,\n renderToString: renderArabicToString,\n renderWithMeta: renderArabicWithMeta,\n renderBatch: renderArabicBatch,\n\n // ─── Text processing ─────────────────────────────────────\n process: processLatex,\n validate: validateLatex,\n\n // ─── Numerals ────────────────────────────────────────────\n toArabicNumerals,\n fromArabicNumerals,\n formatArabicNumber,\n convertNumbersInText,\n isArabicDigit,\n\n // ─── Translation ─────────────────────────────────────────\n translateFunctions,\n translateVariables,\n translateDifferentials,\n translateSpecialPatterns,\n translateAll,\n\n // ─── Mirroring ───────────────────────────────────────────\n applyMirroredSymbols,\n\n // ─── Options / cache ─────────────────────────────────────\n resolveOptions,\n buildCssClasses,\n getArabicMacros,\n clearCache: clearRenderCache,\n DEFAULT_OPTIONS,\n VERSION,\n};\n\nexport default KaTeXArabic;"],"names":["renderArabic","renderArabicToString","renderArabicWithMeta","renderArabicBatch","processLatex","validateLatex","toArabicNumerals","fromArabicNumerals","formatArabicNumber","convertNumbersInText","isArabicDigit","translateFunctions","translateVariables","translateDifferentials","translateSpecialPatterns","translateAll","applyMirroredSymbols","resolveOptions","buildCssClasses","getArabicMacros","clearRenderCache","DEFAULT_OPTIONS"],"mappings":";;;AAuGO,MAAM,UAAU;AAWvB,MAAM,cAAc;AAAA;AAAA,EAElB,QAAQA,OAAAA;AAAAA,EACR,gBAAgBC,OAAAA;AAAAA,EAChB,gBAAgBC,OAAAA;AAAAA,EAChB,aAAaC,OAAAA;AAAAA;AAAAA,EAGb,SAASC,OAAAA;AAAAA,EACT,UAAUC,OAAAA;AAAAA;AAAAA,EAAA,kBAGVC,OAAAA;AAAAA,EAAA,oBACAC,OAAAA;AAAAA,EAAA,oBACAC,OAAAA;AAAAA,EAAA,sBACAC,OAAAA;AAAAA,EAAA,eACAC,OAAAA;AAAAA;AAAAA,EAAA,oBAGAC,OAAAA;AAAAA,EAAA,oBACAC,OAAAA;AAAAA,EAAA,wBACAC,OAAAA;AAAAA,EAAA,0BACAC,OAAAA;AAAAA,EAAA,cACAC,OAAAA;AAAAA;AAAAA,EAAA,sBAGAC,OAAAA;AAAAA;AAAAA,EAAA,gBAGAC,OAAAA;AAAAA,EAAA,iBACAC,OAAAA;AAAAA,EAAA,iBACAC,OAAAA;AAAAA,EACA,YAAYC,OAAAA;AAAAA,EAAA,iBACZC,OAAAA;AAAAA,EACA;AACF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * ════════════════════════════════════════════════════════════════
3
+ * index.ts
4
+ * Public entry point for the KaTeX Arabic library.
5
+ *
6
+ * This module is the *only* file the application should import
7
+ * from when consuming the library. All internal modules are
8
+ * re-exported below for advanced use cases.
9
+ *
10
+ * The render functions themselves live in `render.ts` so that
11
+ * `hooks.ts` can import them without a circular dependency
12
+ * through this barrel.
13
+ * ════════════════════════════════════════════════════════════════
14
+ */
15
+ import { renderArabic, renderArabicToString, renderArabicWithMeta, renderArabicBatch, processLatex, validateLatex } from './render';
16
+ import { clearRenderCache, resolveOptions, buildCssClasses, getArabicMacros } from './rtlRenderer';
17
+ import { toArabicNumerals, fromArabicNumerals, formatArabicNumber, convertNumbersInText, isArabicDigit } from './arabicNumerals';
18
+ import { translateFunctions, translateVariables, translateDifferentials, translateSpecialPatterns, translateAll } from './arabicFunctions';
19
+ import { applyMirroredSymbols } from './arabicSymbols';
20
+ export { DEFAULT_OPTIONS, resolveOptions, buildCssClasses, getArabicMacros, clearRenderCache, MAX_INPUT_LENGTH, } from './rtlRenderer';
21
+ export type { ArabicKatexOptions, PartialArabicOptions, RenderResult } from './types';
22
+ export { renderArabicToString, renderArabicWithMeta, renderArabic, renderArabicBatch, processLatex, validateLatex, } from './render';
23
+ export { toArabicNumerals, fromArabicNumerals, formatArabicNumber, convertNumbersInText, isArabicDigit, } from './arabicNumerals';
24
+ export { translateFunctions, translateVariables, translateDifferentials, translateSpecialPatterns, translateAll, FUNCTION_MAP, VARIABLE_MAP, GREEK_MAP, DIFFERENTIAL_PATTERNS, } from './arabicFunctions';
25
+ export { applyMirroredSymbols, MIRRORED_SYMBOLS, COMPARISON_SYMBOLS, ARROW_SYMBOLS, BRACKET_SYMBOLS, ARABIC_MATH_UNICODE, SPECIAL_ARABIC_SYMBOLS, } from './arabicSymbols';
26
+ export declare const VERSION = "1.1.1";
27
+ declare const KaTeXArabic: {
28
+ render: typeof renderArabic;
29
+ renderToString: typeof renderArabicToString;
30
+ renderWithMeta: typeof renderArabicWithMeta;
31
+ renderBatch: typeof renderArabicBatch;
32
+ process: typeof processLatex;
33
+ validate: typeof validateLatex;
34
+ toArabicNumerals: typeof toArabicNumerals;
35
+ fromArabicNumerals: typeof fromArabicNumerals;
36
+ formatArabicNumber: typeof formatArabicNumber;
37
+ convertNumbersInText: typeof convertNumbersInText;
38
+ isArabicDigit: typeof isArabicDigit;
39
+ translateFunctions: typeof translateFunctions;
40
+ translateVariables: typeof translateVariables;
41
+ translateDifferentials: typeof translateDifferentials;
42
+ translateSpecialPatterns: typeof translateSpecialPatterns;
43
+ translateAll: typeof translateAll;
44
+ applyMirroredSymbols: typeof applyMirroredSymbols;
45
+ resolveOptions: typeof resolveOptions;
46
+ buildCssClasses: typeof buildCssClasses;
47
+ getArabicMacros: typeof getArabicMacros;
48
+ clearCache: typeof clearRenderCache;
49
+ DEFAULT_OPTIONS: import("./types").ArabicKatexOptions;
50
+ VERSION: string;
51
+ };
52
+ export default KaTeXArabic;
53
+ //# sourceMappingURL=index.d.ts.map