@contentstorage/i18next-plugin 2.0.15 → 2.0.17
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.
- package/dist/index.esm.js +12 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +12 -1
- package/dist/index.js.map +1 -1
- package/dist/plugin.d.ts +2 -0
- package/dist/plugin.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -601,6 +601,9 @@ class ContentstorageBackend {
|
|
|
601
601
|
* Called by i18next during initialization
|
|
602
602
|
*/
|
|
603
603
|
init(services, backendOptions = {}, i18nextOptions = {}) {
|
|
604
|
+
// Store for use in initializeScreenshotMode
|
|
605
|
+
this.services = services;
|
|
606
|
+
this.i18nextOptions = i18nextOptions;
|
|
604
607
|
this.options = {
|
|
605
608
|
debug: false,
|
|
606
609
|
maxMemoryMapSize: 10000,
|
|
@@ -649,12 +652,20 @@ class ContentstorageBackend {
|
|
|
649
652
|
if (this.options.debug) {
|
|
650
653
|
console.log('[ContentStorage] Screenshot mode detected');
|
|
651
654
|
}
|
|
655
|
+
// Initialize memory map for translation tracking
|
|
656
|
+
initializeMemoryMap();
|
|
652
657
|
// Expose API key for live-editor.js to use
|
|
653
658
|
exposeApiKey(screenshotConfig.contentstorageKey);
|
|
654
659
|
// Clean URL params for security
|
|
655
660
|
cleanScreenshotUrlParams();
|
|
661
|
+
// Register post-processor for translation tracking
|
|
662
|
+
if (this.services && this.i18nextOptions) {
|
|
663
|
+
this.registerPostProcessor(this.services, this.i18nextOptions);
|
|
664
|
+
}
|
|
665
|
+
// Load live-editor.js script (handles screenshot UI)
|
|
666
|
+
loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);
|
|
656
667
|
if (this.options.debug) {
|
|
657
|
-
console.log('[ContentStorage]
|
|
668
|
+
console.log('[ContentStorage] Screenshot mode initialized: memory map, post-processor, API key exposed');
|
|
658
669
|
}
|
|
659
670
|
}
|
|
660
671
|
/**
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/utils.ts","../src/screenshot.ts","../src/post-processor.ts","../src/plugin.ts"],"sourcesContent":["import type { ContentstorageWindow, MemoryMap, MemoryMapEntry } from './types';\n\n/**\n * Checks if the code is running in a browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Gets the Contentstorage window object with type safety\n */\nexport function getContentstorageWindow(): ContentstorageWindow | null {\n if (!isBrowser()) return null;\n return window as ContentstorageWindow;\n}\n\n/**\n * Detects if the application is running in ContentStorage live editor mode\n *\n * @param liveEditorParam - Query parameter name to check\n * @param forceLiveMode - Force live mode regardless of environment\n * @returns true if in live editor mode\n */\nexport function detectLiveEditorMode(\n liveEditorParam: string = 'contentstorage_live_editor',\n forceLiveMode: boolean = false\n): boolean {\n if (forceLiveMode) return true;\n if (!isBrowser()) return false;\n\n try {\n const win = getContentstorageWindow();\n if (!win) return false;\n\n // Check 1: Running in an iframe\n const inIframe = win.self !== win.top;\n\n // Check 2: URL has the live editor marker\n const urlParams = new URLSearchParams(win.location.search);\n const hasMarker = urlParams.has(liveEditorParam);\n\n return !!(inIframe && hasMarker);\n } catch (e) {\n // Cross-origin restrictions might block window.top access\n // This is expected when not in live editor mode\n return false;\n }\n}\n\n/**\n * Initializes the global memory map if it doesn't exist\n */\nexport function initializeMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n if (!win) return null;\n\n if (!win.memoryMap) {\n win.memoryMap = new Map<string, MemoryMapEntry>();\n }\n\n return win.memoryMap;\n}\n\n/**\n * Load the ContentStorage live editor script\n * This script enables the click-to-edit functionality in the live editor\n */\nlet liveEditorReadyPromise: Promise<boolean> | null = null;\n\nexport function loadLiveEditorScript(\n retries: number = 2,\n delay: number = 3000,\n debug: boolean = false,\n customScriptUrl?: string\n): Promise<boolean> {\n // Return existing promise if already loading\n if (liveEditorReadyPromise) {\n return liveEditorReadyPromise;\n }\n\n liveEditorReadyPromise = new Promise<boolean>((resolve) => {\n const win = getContentstorageWindow();\n if (!win) {\n resolve(false);\n return;\n }\n\n const cdnScriptUrl = customScriptUrl || 'https://cdn.contentstorage.app/live-editor.js?contentstorage-live-editor=true';\n\n const loadScript = (attempt: number = 1) => {\n if (debug) {\n console.log(`[ContentStorage] Attempting to load live editor script (attempt ${attempt}/${retries})`);\n }\n\n const scriptElement = win.document.createElement('script');\n scriptElement.type = 'text/javascript';\n scriptElement.src = cdnScriptUrl;\n\n scriptElement.onload = () => {\n if (debug) {\n console.log(`[ContentStorage] Live editor script loaded successfully`);\n }\n resolve(true);\n };\n\n scriptElement.onerror = (error) => {\n // Clean up the failed script element\n scriptElement.remove();\n\n if (debug) {\n console.error(`[ContentStorage] Failed to load live editor script (attempt ${attempt}/${retries})`, error);\n }\n\n if (attempt < retries) {\n setTimeout(() => loadScript(attempt + 1), delay);\n } else {\n console.error(`[ContentStorage] All ${retries} attempts to load live editor script failed`);\n resolve(false);\n }\n };\n\n win.document.head.appendChild(scriptElement);\n };\n\n loadScript();\n });\n\n return liveEditorReadyPromise;\n}\n\n/**\n * Gets the global memory map\n */\nexport function getMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n return win?.memoryMap || null;\n}\n\n/**\n * Sets the current language code on the window object\n * This is used by the live editor to know which language is currently active\n *\n * @param languageCode - The language code to set (e.g., 'en', 'es', 'fr')\n */\nexport function setCurrentLanguageCode(languageCode: string): void {\n const win = getContentstorageWindow();\n if (win) {\n win.currentLanguageCode = languageCode;\n }\n}\n\n/**\n * Gets the current language code from the window object\n *\n * @returns The current language code, or null if not set\n */\nexport function getCurrentLanguageCode(): string | null {\n const win = getContentstorageWindow();\n return win?.currentLanguageCode || null;\n}\n\n/**\n * Normalizes i18next key format to consistent dot notation\n * Converts namespace:key format to namespace.key\n * Only adds namespace prefix if explicitly present in the key (colon notation)\n *\n * @param key - The translation key\n * @param namespace - Optional namespace (only used if not already in key)\n * @returns Normalized key in dot notation\n */\nexport function normalizeKey(key: string, namespace?: string): string {\n // namespace parameter kept for backward compatibility but not used\n void namespace;\n\n let normalizedKey = key;\n\n // Convert colon notation to dot notation (e.g., \"common:welcome\" -> \"common.welcome\")\n if (normalizedKey.includes(':')) {\n normalizedKey = normalizedKey.replace(':', '.');\n }\n\n // Don't automatically prepend namespace - only if key already had it via colon notation\n // This ensures keys match ContentStorage content IDs by default\n\n return normalizedKey;\n}\n\n/**\n * Extracts the base translation key without interpolation context\n * Handles plural forms, contexts, and other i18next features\n *\n * Examples:\n * - 'welcome' -> 'welcome'\n * - 'items_plural' -> 'items'\n * - 'friend_male' -> 'friend'\n *\n * @param key - The translation key\n * @returns Base key without suffixes\n */\nexport function extractBaseKey(key: string): string {\n // Remove plural suffixes (_zero, _one, _two, _few, _many, _other, _plural)\n let baseKey = key.replace(/_(zero|one|two|few|many|other|plural)$/, '');\n\n // Remove context suffixes (anything after last underscore that's not a nested key)\n // Be careful not to remove underscores that are part of the actual key\n // This is a heuristic - contexts usually come at the end\n const lastUnderscore = baseKey.lastIndexOf('_');\n if (lastUnderscore > 0) {\n // Only remove if it looks like a context (short suffix, typically lowercase)\n const suffix = baseKey.substring(lastUnderscore + 1);\n if (suffix.length < 10 && suffix.toLowerCase() === suffix) {\n // This might be a context, but we'll keep it for now to avoid false positives\n // Real context handling should be done at a higher level\n }\n }\n\n return baseKey;\n}\n\n/**\n * Removes interpolation variables from a translated string\n *\n * Examples:\n * - 'Hello {{name}}!' -> 'Hello !'\n * - 'You have {{count}} items' -> 'You have items'\n *\n * @param value - The translated string\n * @returns String with interpolations removed\n */\nexport function removeInterpolation(value: string): string {\n // Remove i18next interpolation syntax: {{variable}}\n return value.replace(/\\{\\{[^}]+\\}\\}/g, '').trim();\n}\n\n/**\n * i18next internal option keys that should not be treated as user variables\n * Note: 'count' and 'context' are included as they are often used in interpolation\n */\nconst I18NEXT_INTERNAL_KEYS = new Set([\n 'defaultValue',\n 'replace',\n 'lng',\n 'lngs',\n 'fallbackLng',\n 'ns',\n 'keySeparator',\n 'nsSeparator',\n 'returnObjects',\n 'returnDetails',\n 'returnedObjectHandler',\n 'joinArrays',\n 'postProcess',\n 'interpolation',\n 'skipInterpolation',\n 'appendNamespaceToMissingKey',\n 'missingKeyHandler',\n 'parseMissingKeyHandler',\n 'overloadTranslationOptionHandler',\n 'saveMissing',\n 'saveMissingTo',\n 'missingKeyNoValueFallbackToKey',\n 'missingInterpolationHandler',\n 'formatSeparator',\n 'ignoreJSONStructure',\n]);\n\n/**\n * Extracts user-provided variables from i18next options\n * Filters out i18next internal options to return only interpolation variables\n *\n * @param options - i18next options object\n * @returns Object containing only user variables, or undefined if none\n */\nexport function extractUserVariables(options?: any): Record<string, any> | undefined {\n if (!options || typeof options !== 'object') {\n return undefined;\n }\n\n const variables: Record<string, any> = {};\n let hasVariables = false;\n\n for (const key in options) {\n if (!Object.prototype.hasOwnProperty.call(options, key)) continue;\n\n // Skip i18next internal keys\n if (I18NEXT_INTERNAL_KEYS.has(key)) continue;\n\n // Skip keys starting with underscore (private i18next properties)\n if (key.startsWith('_')) continue;\n\n // Skip undefined values\n if (options[key] === undefined) continue;\n\n // This is a user variable\n variables[key] = options[key];\n hasVariables = true;\n }\n\n return hasVariables ? variables : undefined;\n}\n\n/**\n * Tracks a translation in the memory map\n *\n * @param translationValue - The actual translated text\n * @param translationKey - The content ID (i18next key)\n * @param namespace - Optional namespace\n * @param language - Optional language code\n * @param debug - Enable debug logging\n * @param variables - Optional interpolation variables used in the translation\n */\nexport function trackTranslation(\n translationValue: string,\n translationKey: string,\n namespace?: string,\n language?: string,\n debug: boolean = false,\n variables?: Record<string, any>\n): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) return;\n\n // Normalize the key\n const normalizedKey = normalizeKey(translationKey, namespace);\n\n // Get or create entry\n const existingEntry = memoryMap.get(translationValue);\n const idSet = existingEntry ? existingEntry.ids : new Set<string>();\n idSet.add(normalizedKey);\n\n // Merge variables: prefer new variables if provided, otherwise keep existing\n // This ensures variables are preserved when backend tracks without them\n const mergedVariables = variables && Object.keys(variables).length > 0\n ? variables\n : existingEntry?.variables;\n\n const entry: MemoryMapEntry = {\n ids: idSet,\n type: 'text',\n ...(mergedVariables && Object.keys(mergedVariables).length > 0 && { variables: mergedVariables }),\n metadata: {\n namespace,\n language,\n trackedAt: Date.now(),\n },\n };\n\n memoryMap.set(translationValue, entry);\n\n if (debug) {\n console.log('[ContentStorage] Tracked translation:', {\n value: translationValue,\n key: normalizedKey,\n namespace,\n language,\n variables,\n });\n }\n}\n\n/**\n * Cleans up old entries from memory map when size exceeds limit\n * Removes oldest entries first (based on trackedAt timestamp)\n *\n * @param maxSize - Maximum number of entries to keep\n */\nexport function cleanupMemoryMap(maxSize: number): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap || memoryMap.size <= maxSize) return;\n\n // Convert to array with timestamps\n const entries = Array.from(memoryMap.entries()).map(([key, value]) => ({\n key,\n value,\n timestamp: value.metadata?.trackedAt || 0,\n }));\n\n // Sort by timestamp (oldest first)\n entries.sort((a, b) => a.timestamp - b.timestamp);\n\n // Calculate how many to remove\n const toRemove = memoryMap.size - maxSize;\n\n // Remove oldest entries\n for (let i = 0; i < toRemove; i++) {\n memoryMap.delete(entries[i].key);\n }\n}\n\n/**\n * Deeply traverses a translation object and extracts all string values with their keys\n *\n * @param obj - Translation object to traverse\n * @param prefix - Current key prefix (for nested objects)\n * @returns Array of [key, value] pairs\n */\nexport function flattenTranslations(\n obj: any,\n prefix: string = ''\n): Array<[string, string]> {\n const results: Array<[string, string]> = [];\n\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n\n const value = obj[key];\n const fullKey = prefix ? `${prefix}.${key}` : key;\n\n if (typeof value === 'string') {\n results.push([fullKey, value]);\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Recurse into nested objects\n results.push(...flattenTranslations(value, fullKey));\n }\n }\n\n return results;\n}\n\n/**\n * Debug helper to log memory map contents\n */\nexport function debugMemoryMap(): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) {\n console.log('[ContentStorage] Memory map not initialized');\n return;\n }\n\n console.log('[ContentStorage] Memory map contents:');\n console.log(`Total entries: ${memoryMap.size}`);\n\n const entries = Array.from(memoryMap.entries()).slice(0, 10);\n console.table(\n entries.map(([value, entry]) => ({\n value: value.substring(0, 50),\n keys: Array.from(entry.ids).join(', '),\n namespace: entry.metadata?.namespace || 'N/A',\n }))\n );\n\n if (memoryMap.size > 10) {\n console.log(`... and ${memoryMap.size - 10} more entries`);\n }\n}\n","import { isBrowser, getContentstorageWindow } from './utils';\n\n/**\n * Decodes and validates the contentstorage key\n * Just decodes URL encoding and checks non-empty (backend validates format)\n *\n * @param key - The raw key from URL params\n * @returns Decoded key if valid, null if empty/invalid\n */\nexport function decodeContentstorageKey(key: string | null): string | null {\n if (!key) return null;\n\n try {\n const decoded = decodeURIComponent(key);\n return decoded.trim() || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Detects if screenshot mode should be activated\n * Requires: contentstorage_live_editor=true AND screenshot_mode=true AND valid contentstorage_key\n *\n * NOTE: Unlike live editor mode, screenshot mode does NOT require iframe\n *\n * @returns Object with contentstorageKey if active, null otherwise\n */\nexport function detectScreenshotMode(): { contentstorageKey: string } | null {\n if (!isBrowser()) return null;\n\n const win = getContentstorageWindow();\n if (!win) return null;\n\n try {\n const urlParams = new URLSearchParams(win.location.search);\n\n // Check required params\n const liveEditorParam = urlParams.get('contentstorage_live_editor');\n const screenshotModeParam = urlParams.get('screenshot_mode');\n const contentstorageKey = urlParams.get('contentstorage_key');\n\n // All three must be present and valid\n if (liveEditorParam !== 'true') return null;\n if (screenshotModeParam !== 'true') return null;\n\n const decodedKey = decodeContentstorageKey(contentstorageKey);\n if (!decodedKey) return null;\n\n return {\n contentstorageKey: decodedKey,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Removes screenshot-related params from URL without page reload\n * Uses History API to update URL bar\n */\nexport function cleanScreenshotUrlParams(): void {\n if (!isBrowser()) return;\n\n const win = getContentstorageWindow();\n if (!win) return;\n\n try {\n const url = new URL(win.location.href);\n const paramsToRemove = [\n 'contentstorage_live_editor',\n 'screenshot_mode',\n 'contentstorage_key',\n ];\n\n paramsToRemove.forEach((param) => {\n url.searchParams.delete(param);\n });\n\n // Use replaceState to update URL without reload\n win.history.replaceState({}, '', url.toString());\n } catch (e) {\n console.warn('[ContentStorage] Failed to clean URL params:', e);\n }\n}\n\n/**\n * Exposes the API key on window for live-editor.js to use\n * Uses a non-enumerable property for security\n *\n * @param key - The validated contentstorage API key\n */\nexport function exposeApiKey(key: string): void {\n const win = getContentstorageWindow();\n if (!win) return;\n\n // Store as non-enumerable property for security\n Object.defineProperty(win, '__contentstorageApiKey', {\n value: key,\n writable: false,\n enumerable: false,\n configurable: true, // Allow cleanup later\n });\n}\n\n/**\n * Gets the exposed API key (if any)\n */\nexport function getApiKey(): string | null {\n const win = getContentstorageWindow();\n return win?.__contentstorageApiKey || null;\n}\n","import type { PostProcessorModule } from 'i18next';\nimport type { ContentstoragePluginOptions } from './types';\nimport { trackTranslation, detectLiveEditorMode, initializeMemoryMap, loadLiveEditorScript, extractUserVariables, setCurrentLanguageCode } from './utils';\n\n/**\n * Contentstorage Live Editor Post-Processor\n *\n * This post-processor enables live editor functionality by tracking translations\n * at the point of resolution, capturing the actual values returned by i18next\n * including interpolations and plural forms.\n *\n * Use this to enable click-to-edit functionality in the Contentstorage live editor.\n * It works in addition to or instead of the backend plugin for more comprehensive\n * tracking, especially for dynamic translations.\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import { ContentstorageLiveEditorPostProcessor } from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(new ContentstorageLiveEditorPostProcessor({ debug: true }))\n * .init({\n * postProcess: ['contentstorage']\n * });\n * ```\n */\nexport class ContentstorageLiveEditorPostProcessor implements PostProcessorModule {\n static type: 'postProcessor' = 'postProcessor';\n type: 'postProcessor' = 'postProcessor';\n name: string = 'contentstorage';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n\n constructor(options: ContentstoragePluginOptions = {}) {\n this.options = {\n debug: false,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...options,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n initializeMemoryMap();\n\n // Initialize current language code with browser language or fallback\n // This ensures window.currentLanguageCode is never undefined\n const browserLanguage = typeof navigator !== 'undefined' && navigator.language\n ? navigator.language.split('-')[0]\n : 'en';\n setCurrentLanguageCode(browserLanguage);\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Post-processor initialized in live mode');\n console.log(`[ContentStorage] Initial language code set to: ${browserLanguage}`);\n }\n }\n }\n\n /**\n * Process the translated value\n * Called by i18next after translation resolution\n */\n process(\n value: string,\n key: string | string[],\n options: any,\n translator: any\n ): string {\n // Only track in live mode\n if (!this.isLiveMode) {\n return value;\n }\n\n // Handle array of keys (fallback keys)\n const translationKey = Array.isArray(key) ? key[0] : key;\n\n // Only extract namespace if key explicitly uses colon notation\n // Don't pass namespace from options - let keys be clean by default\n let namespace: string | undefined;\n if (translationKey.includes(':')) {\n [namespace] = translationKey.split(':');\n }\n console.log('[Contentstorage plugin] ', {\n options,\n translator\n })\n // Extract language\n const language = options?.lng || translator?.language;\n\n // Set current language code for live editor\n if (language) {\n setCurrentLanguageCode(language);\n }\n\n // Extract user variables from options\n const variables = extractUserVariables(options);\n\n // Try to get the template (non-interpolated value) from the translator\n // This allows us to track the template with {{placeholders}} instead of resolved values\n let template = value;\n try {\n if (translator?.resourceStore) {\n const ns = namespace || options?.ns || translator.options?.defaultNS || 'translation';\n const lng = language || translator.language;\n\n // Try to get the raw translation template from the resource store\n const rawTranslation = translator.resourceStore.getResource(lng, ns, translationKey);\n if (rawTranslation && typeof rawTranslation === 'string') {\n template = rawTranslation;\n }\n }\n } catch (e) {\n // If we can't get the template, fall back to using the resolved value\n if (this.options.debug) {\n console.warn('[Contentstorage plugin] Could not retrieve template for:', translationKey, e);\n }\n }\n\n // Track the translation with the template\n trackTranslation(\n template,\n translationKey,\n namespace,\n language,\n this.options.debug,\n variables\n );\n\n return value;\n }\n}\n\n/**\n * Create a new instance of the Contentstorage Live Editor post-processor\n */\nexport function createContentstorageLiveEditorPostProcessor(\n options?: ContentstoragePluginOptions\n): ContentstorageLiveEditorPostProcessor {\n return new ContentstorageLiveEditorPostProcessor(options);\n}\n","import type {\n BackendModule,\n ReadCallback,\n Services,\n InitOptions,\n} from 'i18next';\nimport type {\n ContentstoragePluginOptions,\n TranslationData,\n} from './types';\nimport {\n detectLiveEditorMode,\n initializeMemoryMap,\n trackTranslation,\n cleanupMemoryMap,\n flattenTranslations,\n isBrowser,\n loadLiveEditorScript,\n} from './utils';\nimport {\n detectScreenshotMode,\n cleanScreenshotUrlParams,\n exposeApiKey,\n} from './screenshot';\nimport { ContentstorageLiveEditorPostProcessor } from './post-processor';\n\n/**\n * Contentstorage i18next Backend Plugin\n *\n * This plugin enables translation tracking for the Contentstorage live editor\n * by maintaining a memory map of translations and their keys.\n *\n * Features:\n * - Automatic live editor mode detection\n * - Translation tracking with memory map\n * - Support for nested translations\n * - Memory management with size limits\n * - Custom CDN or load path support\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import ContentstorageBackend from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(ContentstorageBackend)\n * .init({\n * backend: {\n * contentKey: 'your-content-key',\n * debug: true\n * }\n * });\n * ```\n */\nexport class ContentstorageBackend implements BackendModule<ContentstoragePluginOptions> {\n static type: 'backend' = 'backend';\n type: 'backend' = 'backend';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n private postProcessor?: ContentstorageLiveEditorPostProcessor;\n\n constructor(_services?: Services, options?: ContentstoragePluginOptions, _i18nextOptions?: InitOptions) {\n this.options = options || {};\n\n // Initialize if services and i18nextOptions are provided\n // This allows i18next to initialize the plugin automatically\n if (_services && _i18nextOptions) {\n this.init(_services, options, _i18nextOptions);\n }\n }\n\n /**\n * Initialize the plugin\n * Called by i18next during initialization\n */\n init(\n services: Services,\n backendOptions: ContentstoragePluginOptions = {},\n i18nextOptions: InitOptions = {}\n ): void {\n\n this.options = {\n debug: false,\n maxMemoryMapSize: 10000,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...backendOptions,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n // Initialize memory map\n initializeMemoryMap();\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl).then((loaded) => {\n if (loaded) {\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor ready');\n }\n } else {\n console.warn('[ContentStorage] Failed to load live editor script');\n }\n });\n\n // Auto-register the post-processor for live editor tracking\n this.registerPostProcessor(services, i18nextOptions);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor mode enabled');\n console.log('[ContentStorage] Post-processor auto-registered');\n console.log('[ContentStorage] Plugin initialized with options:', this.options);\n }\n } else if (this.options.debug) {\n console.log('[ContentStorage] Running in normal mode (not live editor)');\n }\n\n // Check for screenshot mode (works in local dev without iframe)\n this.initializeScreenshotMode();\n }\n\n /**\n * Initialize screenshot mode if URL params indicate it\n * Exposes the API key for live-editor.js to use\n */\n private initializeScreenshotMode(): void {\n const screenshotConfig = detectScreenshotMode();\n\n if (!screenshotConfig) return;\n\n if (this.options.debug) {\n console.log('[ContentStorage] Screenshot mode detected');\n }\n\n // Expose API key for live-editor.js to use\n exposeApiKey(screenshotConfig.contentstorageKey);\n\n // Clean URL params for security\n cleanScreenshotUrlParams();\n\n if (this.options.debug) {\n console.log('[ContentStorage] API key exposed, URL params cleaned');\n }\n }\n\n /**\n * Auto-register the live editor post-processor\n * This allows dynamic translation tracking without requiring explicit postProcess config\n */\n private registerPostProcessor(services: Services, i18nextOptions: InitOptions): void {\n // Create post-processor instance\n this.postProcessor = new ContentstorageLiveEditorPostProcessor(this.options);\n\n // Register with i18next\n services.languageUtils?.addPostProcessor(this.postProcessor);\n\n // Add to postProcess array if it exists, otherwise create it\n const initOptions = i18nextOptions as any;\n if (!initOptions.postProcess) {\n initOptions.postProcess = [];\n }\n\n // Ensure postProcess is an array\n if (!Array.isArray(initOptions.postProcess)) {\n initOptions.postProcess = [initOptions.postProcess];\n }\n\n // Add our post-processor if not already present\n if (!initOptions.postProcess.includes('contentstorage')) {\n initOptions.postProcess.push('contentstorage');\n }\n }\n\n /**\n * Read translations for a given language and namespace\n * This is the main method called by i18next to load translations\n */\n read(\n language: string,\n namespace: string,\n callback: ReadCallback\n ): void {\n if (this.options.debug) {\n console.log(`[ContentStorage] Loading translations: ${language}/${namespace}`);\n }\n\n this.loadTranslations(language, namespace)\n .then((translations) => {\n // Track translations if in live mode\n if (this.isLiveMode && this.shouldTrackNamespace(namespace)) {\n this.trackTranslations(translations, namespace, language);\n\n // Cleanup if needed\n if (this.options.maxMemoryMapSize) {\n cleanupMemoryMap(this.options.maxMemoryMapSize);\n }\n }\n\n callback(null, translations);\n })\n .catch((error) => {\n if (this.options.debug) {\n console.error('[ContentStorage] Failed to load translations:', error);\n }\n callback(error, false);\n });\n }\n\n /**\n * Load translations from CDN or custom source\n */\n private async loadTranslations(\n language: string,\n namespace: string\n ): Promise<TranslationData> {\n const url = this.getLoadPath(language, namespace);\n\n if (this.options.debug) {\n console.log(`[ContentStorage] Fetching from: ${url}`);\n }\n\n try {\n const fetchFn = this.options.request || this.defaultFetch.bind(this);\n return await fetchFn(url, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n });\n } catch (error) {\n if (this.options.debug) {\n console.error('[ContentStorage] Fetch error:', error);\n }\n throw error;\n }\n }\n\n /**\n * Default fetch implementation\n */\n private async defaultFetch(url: string, options: RequestInit): Promise<any> {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translations: ${response.status} ${response.statusText}`\n );\n }\n\n return response.json();\n }\n\n /**\n * Get the URL to load translations from\n */\n private getLoadPath(language: string, namespace: string): string {\n const { loadPath, contentKey } = this.options;\n\n // Custom load path function\n if (typeof loadPath === 'function') {\n return loadPath(language, namespace);\n }\n\n // Custom load path string with interpolation\n if (typeof loadPath === 'string') {\n return loadPath\n .replace('{{lng}}', language)\n .replace('{{ns}}', namespace);\n }\n\n // Default CDN path\n if (!contentKey) {\n throw new Error(\n '[ContentStorage] contentKey is required when using default CDN path'\n );\n }\n\n // Default: Always use uppercase language code\n const lng = language.toUpperCase();\n\n // Default: https://cdn.contentstorage.app/{contentKey}/content/{LNG}.json\n return `https://cdn.contentstorage.app/${contentKey}/content/${lng}.json`;\n }\n\n /**\n * Check if a namespace should be tracked\n */\n private shouldTrackNamespace(namespace: string): boolean {\n const { trackNamespaces } = this.options;\n\n // If no filter specified, track all namespaces\n if (!trackNamespaces || trackNamespaces.length === 0) {\n return true;\n }\n\n return trackNamespaces.includes(namespace);\n }\n\n /**\n * Track all translations in the loaded data\n */\n private trackTranslations(\n translations: TranslationData,\n namespace: string,\n language: string\n ): void {\n if (!isBrowser()) return;\n\n const flatTranslations = flattenTranslations(translations);\n\n for (const [key, value] of flatTranslations) {\n // Skip empty values\n if (!value) continue;\n\n // Don't pass namespace - let keys be tracked without prefix by default\n // Only keys with explicit colon notation (e.g., \"common:welcome\") will have namespace\n trackTranslation(\n value,\n key,\n undefined, // namespace not passed by default\n language,\n this.options.debug\n );\n }\n\n if (this.options.debug) {\n console.log(\n `[ContentStorage] Tracked ${flatTranslations.length} translations for ${namespace}`\n );\n }\n }\n}\n\n/**\n * Create a new instance of the Contentstorage backend\n */\nexport function createContentstorageBackend(\n options?: ContentstoragePluginOptions\n): ContentstorageBackend {\n return new ContentstorageBackend(undefined, options);\n}\n\n// Default export\nexport default ContentstorageBackend;\n"],"names":[],"mappings":"AAEA;;AAEG;SACa,SAAS,GAAA;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW;AACzE;AAEA;;AAEG;SACa,uBAAuB,GAAA;IACrC,IAAI,CAAC,SAAS,EAAE;AAAE,QAAA,OAAO,IAAI;AAC7B,IAAA,OAAO,MAA8B;AACvC;AAEA;;;;;;AAMG;SACa,oBAAoB,CAClC,kBAA0B,4BAA4B,EACtD,gBAAyB,KAAK,EAAA;AAE9B,IAAA,IAAI,aAAa;AAAE,QAAA,OAAO,IAAI;IAC9B,IAAI,CAAC,SAAS,EAAE;AAAE,QAAA,OAAO,KAAK;AAE9B,IAAA,IAAI;AACF,QAAA,MAAM,GAAG,GAAG,uBAAuB,EAAE;AACrC,QAAA,IAAI,CAAC,GAAG;AAAE,YAAA,OAAO,KAAK;;QAGtB,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG;;QAGrC,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC1D,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;AAEhD,QAAA,OAAO,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC;IAClC;IAAE,OAAO,CAAC,EAAE;;;AAGV,QAAA,OAAO,KAAK;IACd;AACF;AAEA;;AAEG;SACa,mBAAmB,GAAA;AACjC,IAAA,MAAM,GAAG,GAAG,uBAAuB,EAAE;AACrC,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,IAAI;AAErB,IAAA,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;AAClB,QAAA,GAAG,CAAC,SAAS,GAAG,IAAI,GAAG,EAA0B;IACnD;IAEA,OAAO,GAAG,CAAC,SAAS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AC,SAAiB,EAAA;AAC5C,QAAA,MAAM,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,OAAO;;QAGxC,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;AACpD,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,OAAO,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC5C;AAEA;;AAEG;AACK,IAAA,iBAAiB,CACvB,YAA6B,EAC7B,SAAiB,EACjB,QAAgB,EAAA;QAEhB,IAAI,CAAC,SAAS,EAAE;YAAE;AAElB,QAAA,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,YAAY,CAAC;QAE1D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,gBAAgB,EAAE;;AAE3C,YAAA,IAAI,CAAC,KAAK;gBAAE;;;AAIZ,YAAA,gBAAgB,CACd,KAAK,EACL,GAAG,EACH,SAAS;AACT,YAAA,QAAQ,EACR,IAAI,CAAC,OAAO,CAAC,KAAK,CACnB;QACH;AAEA,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACtB,OAAO,CAAC,GAAG,CACT,CAAA,yBAAA,EAA4B,gBAAgB,CAAC,MAAM,CAAA,kBAAA,EAAqB,SAAS,CAAA,CAAE,CACpF;QACH;IACF;;AAzRO,qBAAA,CAAA,IAAI,GAAc,SAAd;AA4Rb;;AAEG;AACG,SAAU,2BAA2B,CACzC,OAAqC,EAAA;AAErC,IAAA,OAAO,IAAI,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC;AACtD;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/utils.ts","../src/screenshot.ts","../src/post-processor.ts","../src/plugin.ts"],"sourcesContent":["import type { ContentstorageWindow, MemoryMap, MemoryMapEntry } from './types';\n\n/**\n * Checks if the code is running in a browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Gets the Contentstorage window object with type safety\n */\nexport function getContentstorageWindow(): ContentstorageWindow | null {\n if (!isBrowser()) return null;\n return window as ContentstorageWindow;\n}\n\n/**\n * Detects if the application is running in ContentStorage live editor mode\n *\n * @param liveEditorParam - Query parameter name to check\n * @param forceLiveMode - Force live mode regardless of environment\n * @returns true if in live editor mode\n */\nexport function detectLiveEditorMode(\n liveEditorParam: string = 'contentstorage_live_editor',\n forceLiveMode: boolean = false\n): boolean {\n if (forceLiveMode) return true;\n if (!isBrowser()) return false;\n\n try {\n const win = getContentstorageWindow();\n if (!win) return false;\n\n // Check 1: Running in an iframe\n const inIframe = win.self !== win.top;\n\n // Check 2: URL has the live editor marker\n const urlParams = new URLSearchParams(win.location.search);\n const hasMarker = urlParams.has(liveEditorParam);\n\n return !!(inIframe && hasMarker);\n } catch (e) {\n // Cross-origin restrictions might block window.top access\n // This is expected when not in live editor mode\n return false;\n }\n}\n\n/**\n * Initializes the global memory map if it doesn't exist\n */\nexport function initializeMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n if (!win) return null;\n\n if (!win.memoryMap) {\n win.memoryMap = new Map<string, MemoryMapEntry>();\n }\n\n return win.memoryMap;\n}\n\n/**\n * Load the ContentStorage live editor script\n * This script enables the click-to-edit functionality in the live editor\n */\nlet liveEditorReadyPromise: Promise<boolean> | null = null;\n\nexport function loadLiveEditorScript(\n retries: number = 2,\n delay: number = 3000,\n debug: boolean = false,\n customScriptUrl?: string\n): Promise<boolean> {\n // Return existing promise if already loading\n if (liveEditorReadyPromise) {\n return liveEditorReadyPromise;\n }\n\n liveEditorReadyPromise = new Promise<boolean>((resolve) => {\n const win = getContentstorageWindow();\n if (!win) {\n resolve(false);\n return;\n }\n\n const cdnScriptUrl = customScriptUrl || 'https://cdn.contentstorage.app/live-editor.js?contentstorage-live-editor=true';\n\n const loadScript = (attempt: number = 1) => {\n if (debug) {\n console.log(`[ContentStorage] Attempting to load live editor script (attempt ${attempt}/${retries})`);\n }\n\n const scriptElement = win.document.createElement('script');\n scriptElement.type = 'text/javascript';\n scriptElement.src = cdnScriptUrl;\n\n scriptElement.onload = () => {\n if (debug) {\n console.log(`[ContentStorage] Live editor script loaded successfully`);\n }\n resolve(true);\n };\n\n scriptElement.onerror = (error) => {\n // Clean up the failed script element\n scriptElement.remove();\n\n if (debug) {\n console.error(`[ContentStorage] Failed to load live editor script (attempt ${attempt}/${retries})`, error);\n }\n\n if (attempt < retries) {\n setTimeout(() => loadScript(attempt + 1), delay);\n } else {\n console.error(`[ContentStorage] All ${retries} attempts to load live editor script failed`);\n resolve(false);\n }\n };\n\n win.document.head.appendChild(scriptElement);\n };\n\n loadScript();\n });\n\n return liveEditorReadyPromise;\n}\n\n/**\n * Gets the global memory map\n */\nexport function getMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n return win?.memoryMap || null;\n}\n\n/**\n * Sets the current language code on the window object\n * This is used by the live editor to know which language is currently active\n *\n * @param languageCode - The language code to set (e.g., 'en', 'es', 'fr')\n */\nexport function setCurrentLanguageCode(languageCode: string): void {\n const win = getContentstorageWindow();\n if (win) {\n win.currentLanguageCode = languageCode;\n }\n}\n\n/**\n * Gets the current language code from the window object\n *\n * @returns The current language code, or null if not set\n */\nexport function getCurrentLanguageCode(): string | null {\n const win = getContentstorageWindow();\n return win?.currentLanguageCode || null;\n}\n\n/**\n * Normalizes i18next key format to consistent dot notation\n * Converts namespace:key format to namespace.key\n * Only adds namespace prefix if explicitly present in the key (colon notation)\n *\n * @param key - The translation key\n * @param namespace - Optional namespace (only used if not already in key)\n * @returns Normalized key in dot notation\n */\nexport function normalizeKey(key: string, namespace?: string): string {\n // namespace parameter kept for backward compatibility but not used\n void namespace;\n\n let normalizedKey = key;\n\n // Convert colon notation to dot notation (e.g., \"common:welcome\" -> \"common.welcome\")\n if (normalizedKey.includes(':')) {\n normalizedKey = normalizedKey.replace(':', '.');\n }\n\n // Don't automatically prepend namespace - only if key already had it via colon notation\n // This ensures keys match ContentStorage content IDs by default\n\n return normalizedKey;\n}\n\n/**\n * Extracts the base translation key without interpolation context\n * Handles plural forms, contexts, and other i18next features\n *\n * Examples:\n * - 'welcome' -> 'welcome'\n * - 'items_plural' -> 'items'\n * - 'friend_male' -> 'friend'\n *\n * @param key - The translation key\n * @returns Base key without suffixes\n */\nexport function extractBaseKey(key: string): string {\n // Remove plural suffixes (_zero, _one, _two, _few, _many, _other, _plural)\n let baseKey = key.replace(/_(zero|one|two|few|many|other|plural)$/, '');\n\n // Remove context suffixes (anything after last underscore that's not a nested key)\n // Be careful not to remove underscores that are part of the actual key\n // This is a heuristic - contexts usually come at the end\n const lastUnderscore = baseKey.lastIndexOf('_');\n if (lastUnderscore > 0) {\n // Only remove if it looks like a context (short suffix, typically lowercase)\n const suffix = baseKey.substring(lastUnderscore + 1);\n if (suffix.length < 10 && suffix.toLowerCase() === suffix) {\n // This might be a context, but we'll keep it for now to avoid false positives\n // Real context handling should be done at a higher level\n }\n }\n\n return baseKey;\n}\n\n/**\n * Removes interpolation variables from a translated string\n *\n * Examples:\n * - 'Hello {{name}}!' -> 'Hello !'\n * - 'You have {{count}} items' -> 'You have items'\n *\n * @param value - The translated string\n * @returns String with interpolations removed\n */\nexport function removeInterpolation(value: string): string {\n // Remove i18next interpolation syntax: {{variable}}\n return value.replace(/\\{\\{[^}]+\\}\\}/g, '').trim();\n}\n\n/**\n * i18next internal option keys that should not be treated as user variables\n * Note: 'count' and 'context' are included as they are often used in interpolation\n */\nconst I18NEXT_INTERNAL_KEYS = new Set([\n 'defaultValue',\n 'replace',\n 'lng',\n 'lngs',\n 'fallbackLng',\n 'ns',\n 'keySeparator',\n 'nsSeparator',\n 'returnObjects',\n 'returnDetails',\n 'returnedObjectHandler',\n 'joinArrays',\n 'postProcess',\n 'interpolation',\n 'skipInterpolation',\n 'appendNamespaceToMissingKey',\n 'missingKeyHandler',\n 'parseMissingKeyHandler',\n 'overloadTranslationOptionHandler',\n 'saveMissing',\n 'saveMissingTo',\n 'missingKeyNoValueFallbackToKey',\n 'missingInterpolationHandler',\n 'formatSeparator',\n 'ignoreJSONStructure',\n]);\n\n/**\n * Extracts user-provided variables from i18next options\n * Filters out i18next internal options to return only interpolation variables\n *\n * @param options - i18next options object\n * @returns Object containing only user variables, or undefined if none\n */\nexport function extractUserVariables(options?: any): Record<string, any> | undefined {\n if (!options || typeof options !== 'object') {\n return undefined;\n }\n\n const variables: Record<string, any> = {};\n let hasVariables = false;\n\n for (const key in options) {\n if (!Object.prototype.hasOwnProperty.call(options, key)) continue;\n\n // Skip i18next internal keys\n if (I18NEXT_INTERNAL_KEYS.has(key)) continue;\n\n // Skip keys starting with underscore (private i18next properties)\n if (key.startsWith('_')) continue;\n\n // Skip undefined values\n if (options[key] === undefined) continue;\n\n // This is a user variable\n variables[key] = options[key];\n hasVariables = true;\n }\n\n return hasVariables ? variables : undefined;\n}\n\n/**\n * Tracks a translation in the memory map\n *\n * @param translationValue - The actual translated text\n * @param translationKey - The content ID (i18next key)\n * @param namespace - Optional namespace\n * @param language - Optional language code\n * @param debug - Enable debug logging\n * @param variables - Optional interpolation variables used in the translation\n */\nexport function trackTranslation(\n translationValue: string,\n translationKey: string,\n namespace?: string,\n language?: string,\n debug: boolean = false,\n variables?: Record<string, any>\n): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) return;\n\n // Normalize the key\n const normalizedKey = normalizeKey(translationKey, namespace);\n\n // Get or create entry\n const existingEntry = memoryMap.get(translationValue);\n const idSet = existingEntry ? existingEntry.ids : new Set<string>();\n idSet.add(normalizedKey);\n\n // Merge variables: prefer new variables if provided, otherwise keep existing\n // This ensures variables are preserved when backend tracks without them\n const mergedVariables = variables && Object.keys(variables).length > 0\n ? variables\n : existingEntry?.variables;\n\n const entry: MemoryMapEntry = {\n ids: idSet,\n type: 'text',\n ...(mergedVariables && Object.keys(mergedVariables).length > 0 && { variables: mergedVariables }),\n metadata: {\n namespace,\n language,\n trackedAt: Date.now(),\n },\n };\n\n memoryMap.set(translationValue, entry);\n\n if (debug) {\n console.log('[ContentStorage] Tracked translation:', {\n value: translationValue,\n key: normalizedKey,\n namespace,\n language,\n variables,\n });\n }\n}\n\n/**\n * Cleans up old entries from memory map when size exceeds limit\n * Removes oldest entries first (based on trackedAt timestamp)\n *\n * @param maxSize - Maximum number of entries to keep\n */\nexport function cleanupMemoryMap(maxSize: number): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap || memoryMap.size <= maxSize) return;\n\n // Convert to array with timestamps\n const entries = Array.from(memoryMap.entries()).map(([key, value]) => ({\n key,\n value,\n timestamp: value.metadata?.trackedAt || 0,\n }));\n\n // Sort by timestamp (oldest first)\n entries.sort((a, b) => a.timestamp - b.timestamp);\n\n // Calculate how many to remove\n const toRemove = memoryMap.size - maxSize;\n\n // Remove oldest entries\n for (let i = 0; i < toRemove; i++) {\n memoryMap.delete(entries[i].key);\n }\n}\n\n/**\n * Deeply traverses a translation object and extracts all string values with their keys\n *\n * @param obj - Translation object to traverse\n * @param prefix - Current key prefix (for nested objects)\n * @returns Array of [key, value] pairs\n */\nexport function flattenTranslations(\n obj: any,\n prefix: string = ''\n): Array<[string, string]> {\n const results: Array<[string, string]> = [];\n\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n\n const value = obj[key];\n const fullKey = prefix ? `${prefix}.${key}` : key;\n\n if (typeof value === 'string') {\n results.push([fullKey, value]);\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Recurse into nested objects\n results.push(...flattenTranslations(value, fullKey));\n }\n }\n\n return results;\n}\n\n/**\n * Debug helper to log memory map contents\n */\nexport function debugMemoryMap(): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) {\n console.log('[ContentStorage] Memory map not initialized');\n return;\n }\n\n console.log('[ContentStorage] Memory map contents:');\n console.log(`Total entries: ${memoryMap.size}`);\n\n const entries = Array.from(memoryMap.entries()).slice(0, 10);\n console.table(\n entries.map(([value, entry]) => ({\n value: value.substring(0, 50),\n keys: Array.from(entry.ids).join(', '),\n namespace: entry.metadata?.namespace || 'N/A',\n }))\n );\n\n if (memoryMap.size > 10) {\n console.log(`... and ${memoryMap.size - 10} more entries`);\n }\n}\n","import { isBrowser, getContentstorageWindow } from './utils';\n\n/**\n * Decodes and validates the contentstorage key\n * Just decodes URL encoding and checks non-empty (backend validates format)\n *\n * @param key - The raw key from URL params\n * @returns Decoded key if valid, null if empty/invalid\n */\nexport function decodeContentstorageKey(key: string | null): string | null {\n if (!key) return null;\n\n try {\n const decoded = decodeURIComponent(key);\n return decoded.trim() || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Detects if screenshot mode should be activated\n * Requires: contentstorage_live_editor=true AND screenshot_mode=true AND valid contentstorage_key\n *\n * NOTE: Unlike live editor mode, screenshot mode does NOT require iframe\n *\n * @returns Object with contentstorageKey if active, null otherwise\n */\nexport function detectScreenshotMode(): { contentstorageKey: string } | null {\n if (!isBrowser()) return null;\n\n const win = getContentstorageWindow();\n if (!win) return null;\n\n try {\n const urlParams = new URLSearchParams(win.location.search);\n\n // Check required params\n const liveEditorParam = urlParams.get('contentstorage_live_editor');\n const screenshotModeParam = urlParams.get('screenshot_mode');\n const contentstorageKey = urlParams.get('contentstorage_key');\n\n // All three must be present and valid\n if (liveEditorParam !== 'true') return null;\n if (screenshotModeParam !== 'true') return null;\n\n const decodedKey = decodeContentstorageKey(contentstorageKey);\n if (!decodedKey) return null;\n\n return {\n contentstorageKey: decodedKey,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Removes screenshot-related params from URL without page reload\n * Uses History API to update URL bar\n */\nexport function cleanScreenshotUrlParams(): void {\n if (!isBrowser()) return;\n\n const win = getContentstorageWindow();\n if (!win) return;\n\n try {\n const url = new URL(win.location.href);\n const paramsToRemove = [\n 'contentstorage_live_editor',\n 'screenshot_mode',\n 'contentstorage_key',\n ];\n\n paramsToRemove.forEach((param) => {\n url.searchParams.delete(param);\n });\n\n // Use replaceState to update URL without reload\n win.history.replaceState({}, '', url.toString());\n } catch (e) {\n console.warn('[ContentStorage] Failed to clean URL params:', e);\n }\n}\n\n/**\n * Exposes the API key on window for live-editor.js to use\n * Uses a non-enumerable property for security\n *\n * @param key - The validated contentstorage API key\n */\nexport function exposeApiKey(key: string): void {\n const win = getContentstorageWindow();\n if (!win) return;\n\n // Store as non-enumerable property for security\n Object.defineProperty(win, '__contentstorageApiKey', {\n value: key,\n writable: false,\n enumerable: false,\n configurable: true, // Allow cleanup later\n });\n}\n\n/**\n * Gets the exposed API key (if any)\n */\nexport function getApiKey(): string | null {\n const win = getContentstorageWindow();\n return win?.__contentstorageApiKey || null;\n}\n","import type { PostProcessorModule } from 'i18next';\nimport type { ContentstoragePluginOptions } from './types';\nimport { trackTranslation, detectLiveEditorMode, initializeMemoryMap, loadLiveEditorScript, extractUserVariables, setCurrentLanguageCode } from './utils';\n\n/**\n * Contentstorage Live Editor Post-Processor\n *\n * This post-processor enables live editor functionality by tracking translations\n * at the point of resolution, capturing the actual values returned by i18next\n * including interpolations and plural forms.\n *\n * Use this to enable click-to-edit functionality in the Contentstorage live editor.\n * It works in addition to or instead of the backend plugin for more comprehensive\n * tracking, especially for dynamic translations.\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import { ContentstorageLiveEditorPostProcessor } from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(new ContentstorageLiveEditorPostProcessor({ debug: true }))\n * .init({\n * postProcess: ['contentstorage']\n * });\n * ```\n */\nexport class ContentstorageLiveEditorPostProcessor implements PostProcessorModule {\n static type: 'postProcessor' = 'postProcessor';\n type: 'postProcessor' = 'postProcessor';\n name: string = 'contentstorage';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n\n constructor(options: ContentstoragePluginOptions = {}) {\n this.options = {\n debug: false,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...options,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n initializeMemoryMap();\n\n // Initialize current language code with browser language or fallback\n // This ensures window.currentLanguageCode is never undefined\n const browserLanguage = typeof navigator !== 'undefined' && navigator.language\n ? navigator.language.split('-')[0]\n : 'en';\n setCurrentLanguageCode(browserLanguage);\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Post-processor initialized in live mode');\n console.log(`[ContentStorage] Initial language code set to: ${browserLanguage}`);\n }\n }\n }\n\n /**\n * Process the translated value\n * Called by i18next after translation resolution\n */\n process(\n value: string,\n key: string | string[],\n options: any,\n translator: any\n ): string {\n // Only track in live mode\n if (!this.isLiveMode) {\n return value;\n }\n\n // Handle array of keys (fallback keys)\n const translationKey = Array.isArray(key) ? key[0] : key;\n\n // Only extract namespace if key explicitly uses colon notation\n // Don't pass namespace from options - let keys be clean by default\n let namespace: string | undefined;\n if (translationKey.includes(':')) {\n [namespace] = translationKey.split(':');\n }\n console.log('[Contentstorage plugin] ', {\n options,\n translator\n })\n // Extract language\n const language = options?.lng || translator?.language;\n\n // Set current language code for live editor\n if (language) {\n setCurrentLanguageCode(language);\n }\n\n // Extract user variables from options\n const variables = extractUserVariables(options);\n\n // Try to get the template (non-interpolated value) from the translator\n // This allows us to track the template with {{placeholders}} instead of resolved values\n let template = value;\n try {\n if (translator?.resourceStore) {\n const ns = namespace || options?.ns || translator.options?.defaultNS || 'translation';\n const lng = language || translator.language;\n\n // Try to get the raw translation template from the resource store\n const rawTranslation = translator.resourceStore.getResource(lng, ns, translationKey);\n if (rawTranslation && typeof rawTranslation === 'string') {\n template = rawTranslation;\n }\n }\n } catch (e) {\n // If we can't get the template, fall back to using the resolved value\n if (this.options.debug) {\n console.warn('[Contentstorage plugin] Could not retrieve template for:', translationKey, e);\n }\n }\n\n // Track the translation with the template\n trackTranslation(\n template,\n translationKey,\n namespace,\n language,\n this.options.debug,\n variables\n );\n\n return value;\n }\n}\n\n/**\n * Create a new instance of the Contentstorage Live Editor post-processor\n */\nexport function createContentstorageLiveEditorPostProcessor(\n options?: ContentstoragePluginOptions\n): ContentstorageLiveEditorPostProcessor {\n return new ContentstorageLiveEditorPostProcessor(options);\n}\n","import type {\n BackendModule,\n ReadCallback,\n Services,\n InitOptions,\n} from 'i18next';\nimport type {\n ContentstoragePluginOptions,\n TranslationData,\n} from './types';\nimport {\n detectLiveEditorMode,\n initializeMemoryMap,\n trackTranslation,\n cleanupMemoryMap,\n flattenTranslations,\n isBrowser,\n loadLiveEditorScript,\n} from './utils';\nimport {\n detectScreenshotMode,\n cleanScreenshotUrlParams,\n exposeApiKey,\n} from './screenshot';\nimport { ContentstorageLiveEditorPostProcessor } from './post-processor';\n\n/**\n * Contentstorage i18next Backend Plugin\n *\n * This plugin enables translation tracking for the Contentstorage live editor\n * by maintaining a memory map of translations and their keys.\n *\n * Features:\n * - Automatic live editor mode detection\n * - Translation tracking with memory map\n * - Support for nested translations\n * - Memory management with size limits\n * - Custom CDN or load path support\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import ContentstorageBackend from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(ContentstorageBackend)\n * .init({\n * backend: {\n * contentKey: 'your-content-key',\n * debug: true\n * }\n * });\n * ```\n */\nexport class ContentstorageBackend implements BackendModule<ContentstoragePluginOptions> {\n static type: 'backend' = 'backend';\n type: 'backend' = 'backend';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n private postProcessor?: ContentstorageLiveEditorPostProcessor;\n private services?: Services;\n private i18nextOptions?: InitOptions;\n\n constructor(_services?: Services, options?: ContentstoragePluginOptions, _i18nextOptions?: InitOptions) {\n this.options = options || {};\n\n // Initialize if services and i18nextOptions are provided\n // This allows i18next to initialize the plugin automatically\n if (_services && _i18nextOptions) {\n this.init(_services, options, _i18nextOptions);\n }\n }\n\n /**\n * Initialize the plugin\n * Called by i18next during initialization\n */\n init(\n services: Services,\n backendOptions: ContentstoragePluginOptions = {},\n i18nextOptions: InitOptions = {}\n ): void {\n // Store for use in initializeScreenshotMode\n this.services = services;\n this.i18nextOptions = i18nextOptions;\n\n this.options = {\n debug: false,\n maxMemoryMapSize: 10000,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...backendOptions,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n // Initialize memory map\n initializeMemoryMap();\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl).then((loaded) => {\n if (loaded) {\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor ready');\n }\n } else {\n console.warn('[ContentStorage] Failed to load live editor script');\n }\n });\n\n // Auto-register the post-processor for live editor tracking\n this.registerPostProcessor(services, i18nextOptions);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor mode enabled');\n console.log('[ContentStorage] Post-processor auto-registered');\n console.log('[ContentStorage] Plugin initialized with options:', this.options);\n }\n } else if (this.options.debug) {\n console.log('[ContentStorage] Running in normal mode (not live editor)');\n }\n\n // Check for screenshot mode (works in local dev without iframe)\n this.initializeScreenshotMode();\n }\n\n /**\n * Initialize screenshot mode if URL params indicate it\n * Exposes the API key for live-editor.js to use\n */\n private initializeScreenshotMode(): void {\n const screenshotConfig = detectScreenshotMode();\n\n if (!screenshotConfig) return;\n\n if (this.options.debug) {\n console.log('[ContentStorage] Screenshot mode detected');\n }\n\n // Initialize memory map for translation tracking\n initializeMemoryMap();\n\n // Expose API key for live-editor.js to use\n exposeApiKey(screenshotConfig.contentstorageKey);\n\n // Clean URL params for security\n cleanScreenshotUrlParams();\n\n // Register post-processor for translation tracking\n if (this.services && this.i18nextOptions) {\n this.registerPostProcessor(this.services, this.i18nextOptions);\n }\n\n // Load live-editor.js script (handles screenshot UI)\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Screenshot mode initialized: memory map, post-processor, API key exposed');\n }\n }\n\n /**\n * Auto-register the live editor post-processor\n * This allows dynamic translation tracking without requiring explicit postProcess config\n */\n private registerPostProcessor(services: Services, i18nextOptions: InitOptions): void {\n // Create post-processor instance\n this.postProcessor = new ContentstorageLiveEditorPostProcessor(this.options);\n\n // Register with i18next\n services.languageUtils?.addPostProcessor(this.postProcessor);\n\n // Add to postProcess array if it exists, otherwise create it\n const initOptions = i18nextOptions as any;\n if (!initOptions.postProcess) {\n initOptions.postProcess = [];\n }\n\n // Ensure postProcess is an array\n if (!Array.isArray(initOptions.postProcess)) {\n initOptions.postProcess = [initOptions.postProcess];\n }\n\n // Add our post-processor if not already present\n if (!initOptions.postProcess.includes('contentstorage')) {\n initOptions.postProcess.push('contentstorage');\n }\n }\n\n /**\n * Read translations for a given language and namespace\n * This is the main method called by i18next to load translations\n */\n read(\n language: string,\n namespace: string,\n callback: ReadCallback\n ): void {\n if (this.options.debug) {\n console.log(`[ContentStorage] Loading translations: ${language}/${namespace}`);\n }\n\n this.loadTranslations(language, namespace)\n .then((translations) => {\n // Track translations if in live mode\n if (this.isLiveMode && this.shouldTrackNamespace(namespace)) {\n this.trackTranslations(translations, namespace, language);\n\n // Cleanup if needed\n if (this.options.maxMemoryMapSize) {\n cleanupMemoryMap(this.options.maxMemoryMapSize);\n }\n }\n\n callback(null, translations);\n })\n .catch((error) => {\n if (this.options.debug) {\n console.error('[ContentStorage] Failed to load translations:', error);\n }\n callback(error, false);\n });\n }\n\n /**\n * Load translations from CDN or custom source\n */\n private async loadTranslations(\n language: string,\n namespace: string\n ): Promise<TranslationData> {\n const url = this.getLoadPath(language, namespace);\n\n if (this.options.debug) {\n console.log(`[ContentStorage] Fetching from: ${url}`);\n }\n\n try {\n const fetchFn = this.options.request || this.defaultFetch.bind(this);\n return await fetchFn(url, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n });\n } catch (error) {\n if (this.options.debug) {\n console.error('[ContentStorage] Fetch error:', error);\n }\n throw error;\n }\n }\n\n /**\n * Default fetch implementation\n */\n private async defaultFetch(url: string, options: RequestInit): Promise<any> {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translations: ${response.status} ${response.statusText}`\n );\n }\n\n return response.json();\n }\n\n /**\n * Get the URL to load translations from\n */\n private getLoadPath(language: string, namespace: string): string {\n const { loadPath, contentKey } = this.options;\n\n // Custom load path function\n if (typeof loadPath === 'function') {\n return loadPath(language, namespace);\n }\n\n // Custom load path string with interpolation\n if (typeof loadPath === 'string') {\n return loadPath\n .replace('{{lng}}', language)\n .replace('{{ns}}', namespace);\n }\n\n // Default CDN path\n if (!contentKey) {\n throw new Error(\n '[ContentStorage] contentKey is required when using default CDN path'\n );\n }\n\n // Default: Always use uppercase language code\n const lng = language.toUpperCase();\n\n // Default: https://cdn.contentstorage.app/{contentKey}/content/{LNG}.json\n return `https://cdn.contentstorage.app/${contentKey}/content/${lng}.json`;\n }\n\n /**\n * Check if a namespace should be tracked\n */\n private shouldTrackNamespace(namespace: string): boolean {\n const { trackNamespaces } = this.options;\n\n // If no filter specified, track all namespaces\n if (!trackNamespaces || trackNamespaces.length === 0) {\n return true;\n }\n\n return trackNamespaces.includes(namespace);\n }\n\n /**\n * Track all translations in the loaded data\n */\n private trackTranslations(\n translations: TranslationData,\n namespace: string,\n language: string\n ): void {\n if (!isBrowser()) return;\n\n const flatTranslations = flattenTranslations(translations);\n\n for (const [key, value] of flatTranslations) {\n // Skip empty values\n if (!value) continue;\n\n // Don't pass namespace - let keys be tracked without prefix by default\n // Only keys with explicit colon notation (e.g., \"common:welcome\") will have namespace\n trackTranslation(\n value,\n key,\n undefined, // namespace not passed by default\n language,\n this.options.debug\n );\n }\n\n if (this.options.debug) {\n console.log(\n `[ContentStorage] Tracked ${flatTranslations.length} translations for ${namespace}`\n );\n }\n }\n}\n\n/**\n * Create a new instance of the Contentstorage backend\n */\nexport function createContentstorageBackend(\n options?: ContentstoragePluginOptions\n): ContentstorageBackend {\n return new ContentstorageBackend(undefined, options);\n}\n\n// Default export\nexport default ContentstorageBackend;\n"],"names":[],"mappings":"AAEA;;AAEG;SACa,SAAS,GAAA;IACvB,OAAO,OAAO,MAAM,KAAK,WAAW,IAAI,OAAO,QAAQ,KAAK,WAAW;AACzE;AAEA;;AAEG;SACa,uBAAuB,GAAA;IACrC,IAAI,CAAC,SAAS,EAAE;AAAE,QAAA,OAAO,IAAI;AAC7B,IAAA,OAAO,MAA8B;AACvC;AAEA;;;;;;AAMG;SACa,oBAAoB,CAClC,kBAA0B,4BAA4B,EACtD,gBAAyB,KAAK,EAAA;AAE9B,IAAA,IAAI,aAAa;AAAE,QAAA,OAAO,IAAI;IAC9B,IAAI,CAAC,SAAS,EAAE;AAAE,QAAA,OAAO,KAAK;AAE9B,IAAA,IAAI;AACF,QAAA,MAAM,GAAG,GAAG,uBAAuB,EAAE;AACrC,QAAA,IAAI,CAAC,GAAG;AAAE,YAAA,OAAO,KAAK;;QAGtB,MAAM,QAAQ,GAAG,GAAG,CAAC,IAAI,KAAK,GAAG,CAAC,GAAG;;QAGrC,MAAM,SAAS,GAAG,IAAI,eAAe,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC;QAC1D,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC;AAEhD,QAAA,OAAO,CAAC,EAAE,QAAQ,IAAI,SAAS,CAAC;IAClC;IAAE,OAAO,CAAC,EAAE;;;AAGV,QAAA,OAAO,KAAK;IACd;AACF;AAEA;;AAEG;SACa,mBAAmB,GAAA;AACjC,IAAA,MAAM,GAAG,GAAG,uBAAuB,EAAE;AACrC,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,OAAO,IAAI;AAErB,IAAA,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE;AAClB,QAAA,GAAG,CAAC,SAAS,GAAG,IAAI,GAAG,EAA0B;IACnD;IAEA,OAAO,GAAG,CAAC,SAAS;AACtB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A,IAAI,GAAc,SAAd;AA4Sb;;AAEG;AACG,SAAU,2BAA2B,CACzC,OAAqC,EAAA;AAErC,IAAA,OAAO,IAAI,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC;AACtD;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -605,6 +605,9 @@ class ContentstorageBackend {
|
|
|
605
605
|
* Called by i18next during initialization
|
|
606
606
|
*/
|
|
607
607
|
init(services, backendOptions = {}, i18nextOptions = {}) {
|
|
608
|
+
// Store for use in initializeScreenshotMode
|
|
609
|
+
this.services = services;
|
|
610
|
+
this.i18nextOptions = i18nextOptions;
|
|
608
611
|
this.options = {
|
|
609
612
|
debug: false,
|
|
610
613
|
maxMemoryMapSize: 10000,
|
|
@@ -653,12 +656,20 @@ class ContentstorageBackend {
|
|
|
653
656
|
if (this.options.debug) {
|
|
654
657
|
console.log('[ContentStorage] Screenshot mode detected');
|
|
655
658
|
}
|
|
659
|
+
// Initialize memory map for translation tracking
|
|
660
|
+
initializeMemoryMap();
|
|
656
661
|
// Expose API key for live-editor.js to use
|
|
657
662
|
exposeApiKey(screenshotConfig.contentstorageKey);
|
|
658
663
|
// Clean URL params for security
|
|
659
664
|
cleanScreenshotUrlParams();
|
|
665
|
+
// Register post-processor for translation tracking
|
|
666
|
+
if (this.services && this.i18nextOptions) {
|
|
667
|
+
this.registerPostProcessor(this.services, this.i18nextOptions);
|
|
668
|
+
}
|
|
669
|
+
// Load live-editor.js script (handles screenshot UI)
|
|
670
|
+
loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);
|
|
660
671
|
if (this.options.debug) {
|
|
661
|
-
console.log('[ContentStorage]
|
|
672
|
+
console.log('[ContentStorage] Screenshot mode initialized: memory map, post-processor, API key exposed');
|
|
662
673
|
}
|
|
663
674
|
}
|
|
664
675
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/screenshot.ts","../src/post-processor.ts","../src/plugin.ts"],"sourcesContent":["import type { ContentstorageWindow, MemoryMap, MemoryMapEntry } from './types';\n\n/**\n * Checks if the code is running in a browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Gets the Contentstorage window object with type safety\n */\nexport function getContentstorageWindow(): ContentstorageWindow | null {\n if (!isBrowser()) return null;\n return window as ContentstorageWindow;\n}\n\n/**\n * Detects if the application is running in ContentStorage live editor mode\n *\n * @param liveEditorParam - Query parameter name to check\n * @param forceLiveMode - Force live mode regardless of environment\n * @returns true if in live editor mode\n */\nexport function detectLiveEditorMode(\n liveEditorParam: string = 'contentstorage_live_editor',\n forceLiveMode: boolean = false\n): boolean {\n if (forceLiveMode) return true;\n if (!isBrowser()) return false;\n\n try {\n const win = getContentstorageWindow();\n if (!win) return false;\n\n // Check 1: Running in an iframe\n const inIframe = win.self !== win.top;\n\n // Check 2: URL has the live editor marker\n const urlParams = new URLSearchParams(win.location.search);\n const hasMarker = urlParams.has(liveEditorParam);\n\n return !!(inIframe && hasMarker);\n } catch (e) {\n // Cross-origin restrictions might block window.top access\n // This is expected when not in live editor mode\n return false;\n }\n}\n\n/**\n * Initializes the global memory map if it doesn't exist\n */\nexport function initializeMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n if (!win) return null;\n\n if (!win.memoryMap) {\n win.memoryMap = new Map<string, MemoryMapEntry>();\n }\n\n return win.memoryMap;\n}\n\n/**\n * Load the ContentStorage live editor script\n * This script enables the click-to-edit functionality in the live editor\n */\nlet liveEditorReadyPromise: Promise<boolean> | null = null;\n\nexport function loadLiveEditorScript(\n retries: number = 2,\n delay: number = 3000,\n debug: boolean = false,\n customScriptUrl?: string\n): Promise<boolean> {\n // Return existing promise if already loading\n if (liveEditorReadyPromise) {\n return liveEditorReadyPromise;\n }\n\n liveEditorReadyPromise = new Promise<boolean>((resolve) => {\n const win = getContentstorageWindow();\n if (!win) {\n resolve(false);\n return;\n }\n\n const cdnScriptUrl = customScriptUrl || 'https://cdn.contentstorage.app/live-editor.js?contentstorage-live-editor=true';\n\n const loadScript = (attempt: number = 1) => {\n if (debug) {\n console.log(`[ContentStorage] Attempting to load live editor script (attempt ${attempt}/${retries})`);\n }\n\n const scriptElement = win.document.createElement('script');\n scriptElement.type = 'text/javascript';\n scriptElement.src = cdnScriptUrl;\n\n scriptElement.onload = () => {\n if (debug) {\n console.log(`[ContentStorage] Live editor script loaded successfully`);\n }\n resolve(true);\n };\n\n scriptElement.onerror = (error) => {\n // Clean up the failed script element\n scriptElement.remove();\n\n if (debug) {\n console.error(`[ContentStorage] Failed to load live editor script (attempt ${attempt}/${retries})`, error);\n }\n\n if (attempt < retries) {\n setTimeout(() => loadScript(attempt + 1), delay);\n } else {\n console.error(`[ContentStorage] All ${retries} attempts to load live editor script failed`);\n resolve(false);\n }\n };\n\n win.document.head.appendChild(scriptElement);\n };\n\n loadScript();\n });\n\n return liveEditorReadyPromise;\n}\n\n/**\n * Gets the global memory map\n */\nexport function getMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n return win?.memoryMap || null;\n}\n\n/**\n * Sets the current language code on the window object\n * This is used by the live editor to know which language is currently active\n *\n * @param languageCode - The language code to set (e.g., 'en', 'es', 'fr')\n */\nexport function setCurrentLanguageCode(languageCode: string): void {\n const win = getContentstorageWindow();\n if (win) {\n win.currentLanguageCode = languageCode;\n }\n}\n\n/**\n * Gets the current language code from the window object\n *\n * @returns The current language code, or null if not set\n */\nexport function getCurrentLanguageCode(): string | null {\n const win = getContentstorageWindow();\n return win?.currentLanguageCode || null;\n}\n\n/**\n * Normalizes i18next key format to consistent dot notation\n * Converts namespace:key format to namespace.key\n * Only adds namespace prefix if explicitly present in the key (colon notation)\n *\n * @param key - The translation key\n * @param namespace - Optional namespace (only used if not already in key)\n * @returns Normalized key in dot notation\n */\nexport function normalizeKey(key: string, namespace?: string): string {\n // namespace parameter kept for backward compatibility but not used\n void namespace;\n\n let normalizedKey = key;\n\n // Convert colon notation to dot notation (e.g., \"common:welcome\" -> \"common.welcome\")\n if (normalizedKey.includes(':')) {\n normalizedKey = normalizedKey.replace(':', '.');\n }\n\n // Don't automatically prepend namespace - only if key already had it via colon notation\n // This ensures keys match ContentStorage content IDs by default\n\n return normalizedKey;\n}\n\n/**\n * Extracts the base translation key without interpolation context\n * Handles plural forms, contexts, and other i18next features\n *\n * Examples:\n * - 'welcome' -> 'welcome'\n * - 'items_plural' -> 'items'\n * - 'friend_male' -> 'friend'\n *\n * @param key - The translation key\n * @returns Base key without suffixes\n */\nexport function extractBaseKey(key: string): string {\n // Remove plural suffixes (_zero, _one, _two, _few, _many, _other, _plural)\n let baseKey = key.replace(/_(zero|one|two|few|many|other|plural)$/, '');\n\n // Remove context suffixes (anything after last underscore that's not a nested key)\n // Be careful not to remove underscores that are part of the actual key\n // This is a heuristic - contexts usually come at the end\n const lastUnderscore = baseKey.lastIndexOf('_');\n if (lastUnderscore > 0) {\n // Only remove if it looks like a context (short suffix, typically lowercase)\n const suffix = baseKey.substring(lastUnderscore + 1);\n if (suffix.length < 10 && suffix.toLowerCase() === suffix) {\n // This might be a context, but we'll keep it for now to avoid false positives\n // Real context handling should be done at a higher level\n }\n }\n\n return baseKey;\n}\n\n/**\n * Removes interpolation variables from a translated string\n *\n * Examples:\n * - 'Hello {{name}}!' -> 'Hello !'\n * - 'You have {{count}} items' -> 'You have items'\n *\n * @param value - The translated string\n * @returns String with interpolations removed\n */\nexport function removeInterpolation(value: string): string {\n // Remove i18next interpolation syntax: {{variable}}\n return value.replace(/\\{\\{[^}]+\\}\\}/g, '').trim();\n}\n\n/**\n * i18next internal option keys that should not be treated as user variables\n * Note: 'count' and 'context' are included as they are often used in interpolation\n */\nconst I18NEXT_INTERNAL_KEYS = new Set([\n 'defaultValue',\n 'replace',\n 'lng',\n 'lngs',\n 'fallbackLng',\n 'ns',\n 'keySeparator',\n 'nsSeparator',\n 'returnObjects',\n 'returnDetails',\n 'returnedObjectHandler',\n 'joinArrays',\n 'postProcess',\n 'interpolation',\n 'skipInterpolation',\n 'appendNamespaceToMissingKey',\n 'missingKeyHandler',\n 'parseMissingKeyHandler',\n 'overloadTranslationOptionHandler',\n 'saveMissing',\n 'saveMissingTo',\n 'missingKeyNoValueFallbackToKey',\n 'missingInterpolationHandler',\n 'formatSeparator',\n 'ignoreJSONStructure',\n]);\n\n/**\n * Extracts user-provided variables from i18next options\n * Filters out i18next internal options to return only interpolation variables\n *\n * @param options - i18next options object\n * @returns Object containing only user variables, or undefined if none\n */\nexport function extractUserVariables(options?: any): Record<string, any> | undefined {\n if (!options || typeof options !== 'object') {\n return undefined;\n }\n\n const variables: Record<string, any> = {};\n let hasVariables = false;\n\n for (const key in options) {\n if (!Object.prototype.hasOwnProperty.call(options, key)) continue;\n\n // Skip i18next internal keys\n if (I18NEXT_INTERNAL_KEYS.has(key)) continue;\n\n // Skip keys starting with underscore (private i18next properties)\n if (key.startsWith('_')) continue;\n\n // Skip undefined values\n if (options[key] === undefined) continue;\n\n // This is a user variable\n variables[key] = options[key];\n hasVariables = true;\n }\n\n return hasVariables ? variables : undefined;\n}\n\n/**\n * Tracks a translation in the memory map\n *\n * @param translationValue - The actual translated text\n * @param translationKey - The content ID (i18next key)\n * @param namespace - Optional namespace\n * @param language - Optional language code\n * @param debug - Enable debug logging\n * @param variables - Optional interpolation variables used in the translation\n */\nexport function trackTranslation(\n translationValue: string,\n translationKey: string,\n namespace?: string,\n language?: string,\n debug: boolean = false,\n variables?: Record<string, any>\n): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) return;\n\n // Normalize the key\n const normalizedKey = normalizeKey(translationKey, namespace);\n\n // Get or create entry\n const existingEntry = memoryMap.get(translationValue);\n const idSet = existingEntry ? existingEntry.ids : new Set<string>();\n idSet.add(normalizedKey);\n\n // Merge variables: prefer new variables if provided, otherwise keep existing\n // This ensures variables are preserved when backend tracks without them\n const mergedVariables = variables && Object.keys(variables).length > 0\n ? variables\n : existingEntry?.variables;\n\n const entry: MemoryMapEntry = {\n ids: idSet,\n type: 'text',\n ...(mergedVariables && Object.keys(mergedVariables).length > 0 && { variables: mergedVariables }),\n metadata: {\n namespace,\n language,\n trackedAt: Date.now(),\n },\n };\n\n memoryMap.set(translationValue, entry);\n\n if (debug) {\n console.log('[ContentStorage] Tracked translation:', {\n value: translationValue,\n key: normalizedKey,\n namespace,\n language,\n variables,\n });\n }\n}\n\n/**\n * Cleans up old entries from memory map when size exceeds limit\n * Removes oldest entries first (based on trackedAt timestamp)\n *\n * @param maxSize - Maximum number of entries to keep\n */\nexport function cleanupMemoryMap(maxSize: number): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap || memoryMap.size <= maxSize) return;\n\n // Convert to array with timestamps\n const entries = Array.from(memoryMap.entries()).map(([key, value]) => ({\n key,\n value,\n timestamp: value.metadata?.trackedAt || 0,\n }));\n\n // Sort by timestamp (oldest first)\n entries.sort((a, b) => a.timestamp - b.timestamp);\n\n // Calculate how many to remove\n const toRemove = memoryMap.size - maxSize;\n\n // Remove oldest entries\n for (let i = 0; i < toRemove; i++) {\n memoryMap.delete(entries[i].key);\n }\n}\n\n/**\n * Deeply traverses a translation object and extracts all string values with their keys\n *\n * @param obj - Translation object to traverse\n * @param prefix - Current key prefix (for nested objects)\n * @returns Array of [key, value] pairs\n */\nexport function flattenTranslations(\n obj: any,\n prefix: string = ''\n): Array<[string, string]> {\n const results: Array<[string, string]> = [];\n\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n\n const value = obj[key];\n const fullKey = prefix ? `${prefix}.${key}` : key;\n\n if (typeof value === 'string') {\n results.push([fullKey, value]);\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Recurse into nested objects\n results.push(...flattenTranslations(value, fullKey));\n }\n }\n\n return results;\n}\n\n/**\n * Debug helper to log memory map contents\n */\nexport function debugMemoryMap(): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) {\n console.log('[ContentStorage] Memory map not initialized');\n return;\n }\n\n console.log('[ContentStorage] Memory map contents:');\n console.log(`Total entries: ${memoryMap.size}`);\n\n const entries = Array.from(memoryMap.entries()).slice(0, 10);\n console.table(\n entries.map(([value, entry]) => ({\n value: value.substring(0, 50),\n keys: Array.from(entry.ids).join(', '),\n namespace: entry.metadata?.namespace || 'N/A',\n }))\n );\n\n if (memoryMap.size > 10) {\n console.log(`... and ${memoryMap.size - 10} more entries`);\n }\n}\n","import { isBrowser, getContentstorageWindow } from './utils';\n\n/**\n * Decodes and validates the contentstorage key\n * Just decodes URL encoding and checks non-empty (backend validates format)\n *\n * @param key - The raw key from URL params\n * @returns Decoded key if valid, null if empty/invalid\n */\nexport function decodeContentstorageKey(key: string | null): string | null {\n if (!key) return null;\n\n try {\n const decoded = decodeURIComponent(key);\n return decoded.trim() || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Detects if screenshot mode should be activated\n * Requires: contentstorage_live_editor=true AND screenshot_mode=true AND valid contentstorage_key\n *\n * NOTE: Unlike live editor mode, screenshot mode does NOT require iframe\n *\n * @returns Object with contentstorageKey if active, null otherwise\n */\nexport function detectScreenshotMode(): { contentstorageKey: string } | null {\n if (!isBrowser()) return null;\n\n const win = getContentstorageWindow();\n if (!win) return null;\n\n try {\n const urlParams = new URLSearchParams(win.location.search);\n\n // Check required params\n const liveEditorParam = urlParams.get('contentstorage_live_editor');\n const screenshotModeParam = urlParams.get('screenshot_mode');\n const contentstorageKey = urlParams.get('contentstorage_key');\n\n // All three must be present and valid\n if (liveEditorParam !== 'true') return null;\n if (screenshotModeParam !== 'true') return null;\n\n const decodedKey = decodeContentstorageKey(contentstorageKey);\n if (!decodedKey) return null;\n\n return {\n contentstorageKey: decodedKey,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Removes screenshot-related params from URL without page reload\n * Uses History API to update URL bar\n */\nexport function cleanScreenshotUrlParams(): void {\n if (!isBrowser()) return;\n\n const win = getContentstorageWindow();\n if (!win) return;\n\n try {\n const url = new URL(win.location.href);\n const paramsToRemove = [\n 'contentstorage_live_editor',\n 'screenshot_mode',\n 'contentstorage_key',\n ];\n\n paramsToRemove.forEach((param) => {\n url.searchParams.delete(param);\n });\n\n // Use replaceState to update URL without reload\n win.history.replaceState({}, '', url.toString());\n } catch (e) {\n console.warn('[ContentStorage] Failed to clean URL params:', e);\n }\n}\n\n/**\n * Exposes the API key on window for live-editor.js to use\n * Uses a non-enumerable property for security\n *\n * @param key - The validated contentstorage API key\n */\nexport function exposeApiKey(key: string): void {\n const win = getContentstorageWindow();\n if (!win) return;\n\n // Store as non-enumerable property for security\n Object.defineProperty(win, '__contentstorageApiKey', {\n value: key,\n writable: false,\n enumerable: false,\n configurable: true, // Allow cleanup later\n });\n}\n\n/**\n * Gets the exposed API key (if any)\n */\nexport function getApiKey(): string | null {\n const win = getContentstorageWindow();\n return win?.__contentstorageApiKey || null;\n}\n","import type { PostProcessorModule } from 'i18next';\nimport type { ContentstoragePluginOptions } from './types';\nimport { trackTranslation, detectLiveEditorMode, initializeMemoryMap, loadLiveEditorScript, extractUserVariables, setCurrentLanguageCode } from './utils';\n\n/**\n * Contentstorage Live Editor Post-Processor\n *\n * This post-processor enables live editor functionality by tracking translations\n * at the point of resolution, capturing the actual values returned by i18next\n * including interpolations and plural forms.\n *\n * Use this to enable click-to-edit functionality in the Contentstorage live editor.\n * It works in addition to or instead of the backend plugin for more comprehensive\n * tracking, especially for dynamic translations.\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import { ContentstorageLiveEditorPostProcessor } from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(new ContentstorageLiveEditorPostProcessor({ debug: true }))\n * .init({\n * postProcess: ['contentstorage']\n * });\n * ```\n */\nexport class ContentstorageLiveEditorPostProcessor implements PostProcessorModule {\n static type: 'postProcessor' = 'postProcessor';\n type: 'postProcessor' = 'postProcessor';\n name: string = 'contentstorage';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n\n constructor(options: ContentstoragePluginOptions = {}) {\n this.options = {\n debug: false,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...options,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n initializeMemoryMap();\n\n // Initialize current language code with browser language or fallback\n // This ensures window.currentLanguageCode is never undefined\n const browserLanguage = typeof navigator !== 'undefined' && navigator.language\n ? navigator.language.split('-')[0]\n : 'en';\n setCurrentLanguageCode(browserLanguage);\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Post-processor initialized in live mode');\n console.log(`[ContentStorage] Initial language code set to: ${browserLanguage}`);\n }\n }\n }\n\n /**\n * Process the translated value\n * Called by i18next after translation resolution\n */\n process(\n value: string,\n key: string | string[],\n options: any,\n translator: any\n ): string {\n // Only track in live mode\n if (!this.isLiveMode) {\n return value;\n }\n\n // Handle array of keys (fallback keys)\n const translationKey = Array.isArray(key) ? key[0] : key;\n\n // Only extract namespace if key explicitly uses colon notation\n // Don't pass namespace from options - let keys be clean by default\n let namespace: string | undefined;\n if (translationKey.includes(':')) {\n [namespace] = translationKey.split(':');\n }\n console.log('[Contentstorage plugin] ', {\n options,\n translator\n })\n // Extract language\n const language = options?.lng || translator?.language;\n\n // Set current language code for live editor\n if (language) {\n setCurrentLanguageCode(language);\n }\n\n // Extract user variables from options\n const variables = extractUserVariables(options);\n\n // Try to get the template (non-interpolated value) from the translator\n // This allows us to track the template with {{placeholders}} instead of resolved values\n let template = value;\n try {\n if (translator?.resourceStore) {\n const ns = namespace || options?.ns || translator.options?.defaultNS || 'translation';\n const lng = language || translator.language;\n\n // Try to get the raw translation template from the resource store\n const rawTranslation = translator.resourceStore.getResource(lng, ns, translationKey);\n if (rawTranslation && typeof rawTranslation === 'string') {\n template = rawTranslation;\n }\n }\n } catch (e) {\n // If we can't get the template, fall back to using the resolved value\n if (this.options.debug) {\n console.warn('[Contentstorage plugin] Could not retrieve template for:', translationKey, e);\n }\n }\n\n // Track the translation with the template\n trackTranslation(\n template,\n translationKey,\n namespace,\n language,\n this.options.debug,\n variables\n );\n\n return value;\n }\n}\n\n/**\n * Create a new instance of the Contentstorage Live Editor post-processor\n */\nexport function createContentstorageLiveEditorPostProcessor(\n options?: ContentstoragePluginOptions\n): ContentstorageLiveEditorPostProcessor {\n return new ContentstorageLiveEditorPostProcessor(options);\n}\n","import type {\n BackendModule,\n ReadCallback,\n Services,\n InitOptions,\n} from 'i18next';\nimport type {\n ContentstoragePluginOptions,\n TranslationData,\n} from './types';\nimport {\n detectLiveEditorMode,\n initializeMemoryMap,\n trackTranslation,\n cleanupMemoryMap,\n flattenTranslations,\n isBrowser,\n loadLiveEditorScript,\n} from './utils';\nimport {\n detectScreenshotMode,\n cleanScreenshotUrlParams,\n exposeApiKey,\n} from './screenshot';\nimport { ContentstorageLiveEditorPostProcessor } from './post-processor';\n\n/**\n * Contentstorage i18next Backend Plugin\n *\n * This plugin enables translation tracking for the Contentstorage live editor\n * by maintaining a memory map of translations and their keys.\n *\n * Features:\n * - Automatic live editor mode detection\n * - Translation tracking with memory map\n * - Support for nested translations\n * - Memory management with size limits\n * - Custom CDN or load path support\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import ContentstorageBackend from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(ContentstorageBackend)\n * .init({\n * backend: {\n * contentKey: 'your-content-key',\n * debug: true\n * }\n * });\n * ```\n */\nexport class ContentstorageBackend implements BackendModule<ContentstoragePluginOptions> {\n static type: 'backend' = 'backend';\n type: 'backend' = 'backend';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n private postProcessor?: ContentstorageLiveEditorPostProcessor;\n\n constructor(_services?: Services, options?: ContentstoragePluginOptions, _i18nextOptions?: InitOptions) {\n this.options = options || {};\n\n // Initialize if services and i18nextOptions are provided\n // This allows i18next to initialize the plugin automatically\n if (_services && _i18nextOptions) {\n this.init(_services, options, _i18nextOptions);\n }\n }\n\n /**\n * Initialize the plugin\n * Called by i18next during initialization\n */\n init(\n services: Services,\n backendOptions: ContentstoragePluginOptions = {},\n i18nextOptions: InitOptions = {}\n ): void {\n\n this.options = {\n debug: false,\n maxMemoryMapSize: 10000,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...backendOptions,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n // Initialize memory map\n initializeMemoryMap();\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl).then((loaded) => {\n if (loaded) {\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor ready');\n }\n } else {\n console.warn('[ContentStorage] Failed to load live editor script');\n }\n });\n\n // Auto-register the post-processor for live editor tracking\n this.registerPostProcessor(services, i18nextOptions);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor mode enabled');\n console.log('[ContentStorage] Post-processor auto-registered');\n console.log('[ContentStorage] Plugin initialized with options:', this.options);\n }\n } else if (this.options.debug) {\n console.log('[ContentStorage] Running in normal mode (not live editor)');\n }\n\n // Check for screenshot mode (works in local dev without iframe)\n this.initializeScreenshotMode();\n }\n\n /**\n * Initialize screenshot mode if URL params indicate it\n * Exposes the API key for live-editor.js to use\n */\n private initializeScreenshotMode(): void {\n const screenshotConfig = detectScreenshotMode();\n\n if (!screenshotConfig) return;\n\n if (this.options.debug) {\n console.log('[ContentStorage] Screenshot mode detected');\n }\n\n // Expose API key for live-editor.js to use\n exposeApiKey(screenshotConfig.contentstorageKey);\n\n // Clean URL params for security\n cleanScreenshotUrlParams();\n\n if (this.options.debug) {\n console.log('[ContentStorage] API key exposed, URL params cleaned');\n }\n }\n\n /**\n * Auto-register the live editor post-processor\n * This allows dynamic translation tracking without requiring explicit postProcess config\n */\n private registerPostProcessor(services: Services, i18nextOptions: InitOptions): void {\n // Create post-processor instance\n this.postProcessor = new ContentstorageLiveEditorPostProcessor(this.options);\n\n // Register with i18next\n services.languageUtils?.addPostProcessor(this.postProcessor);\n\n // Add to postProcess array if it exists, otherwise create it\n const initOptions = i18nextOptions as any;\n if (!initOptions.postProcess) {\n initOptions.postProcess = [];\n }\n\n // Ensure postProcess is an array\n if (!Array.isArray(initOptions.postProcess)) {\n initOptions.postProcess = [initOptions.postProcess];\n }\n\n // Add our post-processor if not already present\n if (!initOptions.postProcess.includes('contentstorage')) {\n initOptions.postProcess.push('contentstorage');\n }\n }\n\n /**\n * Read translations for a given language and namespace\n * This is the main method called by i18next to load translations\n */\n read(\n language: string,\n namespace: string,\n callback: ReadCallback\n ): void {\n if (this.options.debug) {\n console.log(`[ContentStorage] Loading translations: ${language}/${namespace}`);\n }\n\n this.loadTranslations(language, namespace)\n .then((translations) => {\n // Track translations if in live mode\n if (this.isLiveMode && this.shouldTrackNamespace(namespace)) {\n this.trackTranslations(translations, namespace, language);\n\n // Cleanup if needed\n if (this.options.maxMemoryMapSize) {\n cleanupMemoryMap(this.options.maxMemoryMapSize);\n }\n }\n\n callback(null, translations);\n })\n .catch((error) => {\n if (this.options.debug) {\n console.error('[ContentStorage] Failed to load translations:', error);\n }\n callback(error, false);\n });\n }\n\n /**\n * Load translations from CDN or custom source\n */\n private async loadTranslations(\n language: string,\n namespace: string\n ): Promise<TranslationData> {\n const url = this.getLoadPath(language, namespace);\n\n if (this.options.debug) {\n console.log(`[ContentStorage] Fetching from: ${url}`);\n }\n\n try {\n const fetchFn = this.options.request || this.defaultFetch.bind(this);\n return await fetchFn(url, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n });\n } catch (error) {\n if (this.options.debug) {\n console.error('[ContentStorage] Fetch error:', error);\n }\n throw error;\n }\n }\n\n /**\n * Default fetch implementation\n */\n private async defaultFetch(url: string, options: RequestInit): Promise<any> {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translations: ${response.status} ${response.statusText}`\n );\n }\n\n return response.json();\n }\n\n /**\n * Get the URL to load translations from\n */\n private getLoadPath(language: string, namespace: string): string {\n const { loadPath, contentKey } = this.options;\n\n // Custom load path function\n if (typeof loadPath === 'function') {\n return loadPath(language, namespace);\n }\n\n // Custom load path string with interpolation\n if (typeof loadPath === 'string') {\n return loadPath\n .replace('{{lng}}', language)\n .replace('{{ns}}', namespace);\n }\n\n // Default CDN path\n if (!contentKey) {\n throw new Error(\n '[ContentStorage] contentKey is required when using default CDN path'\n );\n }\n\n // Default: Always use uppercase language code\n const lng = language.toUpperCase();\n\n // Default: https://cdn.contentstorage.app/{contentKey}/content/{LNG}.json\n return `https://cdn.contentstorage.app/${contentKey}/content/${lng}.json`;\n }\n\n /**\n * Check if a namespace should be tracked\n */\n private shouldTrackNamespace(namespace: string): boolean {\n const { trackNamespaces } = this.options;\n\n // If no filter specified, track all namespaces\n if (!trackNamespaces || trackNamespaces.length === 0) {\n return true;\n }\n\n return trackNamespaces.includes(namespace);\n }\n\n /**\n * Track all translations in the loaded data\n */\n private trackTranslations(\n translations: TranslationData,\n namespace: string,\n language: string\n ): void {\n if (!isBrowser()) return;\n\n const flatTranslations = flattenTranslations(translations);\n\n for (const [key, value] of flatTranslations) {\n // Skip empty values\n if (!value) continue;\n\n // Don't pass namespace - let keys be tracked without prefix by default\n // Only keys with explicit colon notation (e.g., \"common:welcome\") will have namespace\n trackTranslation(\n value,\n key,\n undefined, // namespace not passed by default\n language,\n this.options.debug\n );\n }\n\n if (this.options.debug) {\n console.log(\n `[ContentStorage] Tracked ${flatTranslations.length} translations for ${namespace}`\n );\n }\n }\n}\n\n/**\n * Create a new instance of the Contentstorage backend\n */\nexport function createContentstorageBackend(\n options?: ContentstoragePluginOptions\n): ContentstorageBackend {\n return new ContentstorageBackend(undefined, options);\n}\n\n// Default export\nexport default ContentstorageBackend;\n"],"names":[],"mappings":";;;;AAEA;;AAEG;SACa,S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,MAAM,KAAK,CAAC,EAAE;AACpD,YAAA,OAAO,IAAI;QACb;AAEA,QAAA,OAAO,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC;IAC5C;AAEA;;AAEG;AACK,IAAA,iBAAiB,CACvB,YAA6B,EAC7B,SAAiB,EACjB,QAAgB,EAAA;QAEhB,IAAI,CAAC,SAAS,EAAE;YAAE;AAElB,QAAA,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,YAAY,CAAC;QAE1D,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,gBAAgB,EAAE;;AAE3C,YAAA,IAAI,CAAC,KAAK;gBAAE;;;AAIZ,YAAA,gBAAgB,CACd,KAAK,EACL,GAAG,EACH,SAAS;AACT,YAAA,QAAQ,EACR,IAAI,CAAC,OAAO,CAAC,KAAK,CACnB;QACH;AAEA,QAAA,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE;YACtB,OAAO,CAAC,GAAG,CACT,CAAA,yBAAA,EAA4B,gBAAgB,CAAC,MAAM,CAAA,kBAAA,EAAqB,SAAS,CAAA,CAAE,CACpF;QACH;IACF;;AAzRO,qBAAA,CAAA,IAAI,GAAc,SAAd;AA4Rb;;AAEG;AACG,SAAU,2BAA2B,CACzC,OAAqC,EAAA;AAErC,IAAA,OAAO,IAAI,qBAAqB,CAAC,SAAS,EAAE,OAAO,CAAC;AACtD;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/utils.ts","../src/screenshot.ts","../src/post-processor.ts","../src/plugin.ts"],"sourcesContent":["import type { ContentstorageWindow, MemoryMap, MemoryMapEntry } from './types';\n\n/**\n * Checks if the code is running in a browser environment\n */\nexport function isBrowser(): boolean {\n return typeof window !== 'undefined' && typeof document !== 'undefined';\n}\n\n/**\n * Gets the Contentstorage window object with type safety\n */\nexport function getContentstorageWindow(): ContentstorageWindow | null {\n if (!isBrowser()) return null;\n return window as ContentstorageWindow;\n}\n\n/**\n * Detects if the application is running in ContentStorage live editor mode\n *\n * @param liveEditorParam - Query parameter name to check\n * @param forceLiveMode - Force live mode regardless of environment\n * @returns true if in live editor mode\n */\nexport function detectLiveEditorMode(\n liveEditorParam: string = 'contentstorage_live_editor',\n forceLiveMode: boolean = false\n): boolean {\n if (forceLiveMode) return true;\n if (!isBrowser()) return false;\n\n try {\n const win = getContentstorageWindow();\n if (!win) return false;\n\n // Check 1: Running in an iframe\n const inIframe = win.self !== win.top;\n\n // Check 2: URL has the live editor marker\n const urlParams = new URLSearchParams(win.location.search);\n const hasMarker = urlParams.has(liveEditorParam);\n\n return !!(inIframe && hasMarker);\n } catch (e) {\n // Cross-origin restrictions might block window.top access\n // This is expected when not in live editor mode\n return false;\n }\n}\n\n/**\n * Initializes the global memory map if it doesn't exist\n */\nexport function initializeMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n if (!win) return null;\n\n if (!win.memoryMap) {\n win.memoryMap = new Map<string, MemoryMapEntry>();\n }\n\n return win.memoryMap;\n}\n\n/**\n * Load the ContentStorage live editor script\n * This script enables the click-to-edit functionality in the live editor\n */\nlet liveEditorReadyPromise: Promise<boolean> | null = null;\n\nexport function loadLiveEditorScript(\n retries: number = 2,\n delay: number = 3000,\n debug: boolean = false,\n customScriptUrl?: string\n): Promise<boolean> {\n // Return existing promise if already loading\n if (liveEditorReadyPromise) {\n return liveEditorReadyPromise;\n }\n\n liveEditorReadyPromise = new Promise<boolean>((resolve) => {\n const win = getContentstorageWindow();\n if (!win) {\n resolve(false);\n return;\n }\n\n const cdnScriptUrl = customScriptUrl || 'https://cdn.contentstorage.app/live-editor.js?contentstorage-live-editor=true';\n\n const loadScript = (attempt: number = 1) => {\n if (debug) {\n console.log(`[ContentStorage] Attempting to load live editor script (attempt ${attempt}/${retries})`);\n }\n\n const scriptElement = win.document.createElement('script');\n scriptElement.type = 'text/javascript';\n scriptElement.src = cdnScriptUrl;\n\n scriptElement.onload = () => {\n if (debug) {\n console.log(`[ContentStorage] Live editor script loaded successfully`);\n }\n resolve(true);\n };\n\n scriptElement.onerror = (error) => {\n // Clean up the failed script element\n scriptElement.remove();\n\n if (debug) {\n console.error(`[ContentStorage] Failed to load live editor script (attempt ${attempt}/${retries})`, error);\n }\n\n if (attempt < retries) {\n setTimeout(() => loadScript(attempt + 1), delay);\n } else {\n console.error(`[ContentStorage] All ${retries} attempts to load live editor script failed`);\n resolve(false);\n }\n };\n\n win.document.head.appendChild(scriptElement);\n };\n\n loadScript();\n });\n\n return liveEditorReadyPromise;\n}\n\n/**\n * Gets the global memory map\n */\nexport function getMemoryMap(): MemoryMap | null {\n const win = getContentstorageWindow();\n return win?.memoryMap || null;\n}\n\n/**\n * Sets the current language code on the window object\n * This is used by the live editor to know which language is currently active\n *\n * @param languageCode - The language code to set (e.g., 'en', 'es', 'fr')\n */\nexport function setCurrentLanguageCode(languageCode: string): void {\n const win = getContentstorageWindow();\n if (win) {\n win.currentLanguageCode = languageCode;\n }\n}\n\n/**\n * Gets the current language code from the window object\n *\n * @returns The current language code, or null if not set\n */\nexport function getCurrentLanguageCode(): string | null {\n const win = getContentstorageWindow();\n return win?.currentLanguageCode || null;\n}\n\n/**\n * Normalizes i18next key format to consistent dot notation\n * Converts namespace:key format to namespace.key\n * Only adds namespace prefix if explicitly present in the key (colon notation)\n *\n * @param key - The translation key\n * @param namespace - Optional namespace (only used if not already in key)\n * @returns Normalized key in dot notation\n */\nexport function normalizeKey(key: string, namespace?: string): string {\n // namespace parameter kept for backward compatibility but not used\n void namespace;\n\n let normalizedKey = key;\n\n // Convert colon notation to dot notation (e.g., \"common:welcome\" -> \"common.welcome\")\n if (normalizedKey.includes(':')) {\n normalizedKey = normalizedKey.replace(':', '.');\n }\n\n // Don't automatically prepend namespace - only if key already had it via colon notation\n // This ensures keys match ContentStorage content IDs by default\n\n return normalizedKey;\n}\n\n/**\n * Extracts the base translation key without interpolation context\n * Handles plural forms, contexts, and other i18next features\n *\n * Examples:\n * - 'welcome' -> 'welcome'\n * - 'items_plural' -> 'items'\n * - 'friend_male' -> 'friend'\n *\n * @param key - The translation key\n * @returns Base key without suffixes\n */\nexport function extractBaseKey(key: string): string {\n // Remove plural suffixes (_zero, _one, _two, _few, _many, _other, _plural)\n let baseKey = key.replace(/_(zero|one|two|few|many|other|plural)$/, '');\n\n // Remove context suffixes (anything after last underscore that's not a nested key)\n // Be careful not to remove underscores that are part of the actual key\n // This is a heuristic - contexts usually come at the end\n const lastUnderscore = baseKey.lastIndexOf('_');\n if (lastUnderscore > 0) {\n // Only remove if it looks like a context (short suffix, typically lowercase)\n const suffix = baseKey.substring(lastUnderscore + 1);\n if (suffix.length < 10 && suffix.toLowerCase() === suffix) {\n // This might be a context, but we'll keep it for now to avoid false positives\n // Real context handling should be done at a higher level\n }\n }\n\n return baseKey;\n}\n\n/**\n * Removes interpolation variables from a translated string\n *\n * Examples:\n * - 'Hello {{name}}!' -> 'Hello !'\n * - 'You have {{count}} items' -> 'You have items'\n *\n * @param value - The translated string\n * @returns String with interpolations removed\n */\nexport function removeInterpolation(value: string): string {\n // Remove i18next interpolation syntax: {{variable}}\n return value.replace(/\\{\\{[^}]+\\}\\}/g, '').trim();\n}\n\n/**\n * i18next internal option keys that should not be treated as user variables\n * Note: 'count' and 'context' are included as they are often used in interpolation\n */\nconst I18NEXT_INTERNAL_KEYS = new Set([\n 'defaultValue',\n 'replace',\n 'lng',\n 'lngs',\n 'fallbackLng',\n 'ns',\n 'keySeparator',\n 'nsSeparator',\n 'returnObjects',\n 'returnDetails',\n 'returnedObjectHandler',\n 'joinArrays',\n 'postProcess',\n 'interpolation',\n 'skipInterpolation',\n 'appendNamespaceToMissingKey',\n 'missingKeyHandler',\n 'parseMissingKeyHandler',\n 'overloadTranslationOptionHandler',\n 'saveMissing',\n 'saveMissingTo',\n 'missingKeyNoValueFallbackToKey',\n 'missingInterpolationHandler',\n 'formatSeparator',\n 'ignoreJSONStructure',\n]);\n\n/**\n * Extracts user-provided variables from i18next options\n * Filters out i18next internal options to return only interpolation variables\n *\n * @param options - i18next options object\n * @returns Object containing only user variables, or undefined if none\n */\nexport function extractUserVariables(options?: any): Record<string, any> | undefined {\n if (!options || typeof options !== 'object') {\n return undefined;\n }\n\n const variables: Record<string, any> = {};\n let hasVariables = false;\n\n for (const key in options) {\n if (!Object.prototype.hasOwnProperty.call(options, key)) continue;\n\n // Skip i18next internal keys\n if (I18NEXT_INTERNAL_KEYS.has(key)) continue;\n\n // Skip keys starting with underscore (private i18next properties)\n if (key.startsWith('_')) continue;\n\n // Skip undefined values\n if (options[key] === undefined) continue;\n\n // This is a user variable\n variables[key] = options[key];\n hasVariables = true;\n }\n\n return hasVariables ? variables : undefined;\n}\n\n/**\n * Tracks a translation in the memory map\n *\n * @param translationValue - The actual translated text\n * @param translationKey - The content ID (i18next key)\n * @param namespace - Optional namespace\n * @param language - Optional language code\n * @param debug - Enable debug logging\n * @param variables - Optional interpolation variables used in the translation\n */\nexport function trackTranslation(\n translationValue: string,\n translationKey: string,\n namespace?: string,\n language?: string,\n debug: boolean = false,\n variables?: Record<string, any>\n): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) return;\n\n // Normalize the key\n const normalizedKey = normalizeKey(translationKey, namespace);\n\n // Get or create entry\n const existingEntry = memoryMap.get(translationValue);\n const idSet = existingEntry ? existingEntry.ids : new Set<string>();\n idSet.add(normalizedKey);\n\n // Merge variables: prefer new variables if provided, otherwise keep existing\n // This ensures variables are preserved when backend tracks without them\n const mergedVariables = variables && Object.keys(variables).length > 0\n ? variables\n : existingEntry?.variables;\n\n const entry: MemoryMapEntry = {\n ids: idSet,\n type: 'text',\n ...(mergedVariables && Object.keys(mergedVariables).length > 0 && { variables: mergedVariables }),\n metadata: {\n namespace,\n language,\n trackedAt: Date.now(),\n },\n };\n\n memoryMap.set(translationValue, entry);\n\n if (debug) {\n console.log('[ContentStorage] Tracked translation:', {\n value: translationValue,\n key: normalizedKey,\n namespace,\n language,\n variables,\n });\n }\n}\n\n/**\n * Cleans up old entries from memory map when size exceeds limit\n * Removes oldest entries first (based on trackedAt timestamp)\n *\n * @param maxSize - Maximum number of entries to keep\n */\nexport function cleanupMemoryMap(maxSize: number): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap || memoryMap.size <= maxSize) return;\n\n // Convert to array with timestamps\n const entries = Array.from(memoryMap.entries()).map(([key, value]) => ({\n key,\n value,\n timestamp: value.metadata?.trackedAt || 0,\n }));\n\n // Sort by timestamp (oldest first)\n entries.sort((a, b) => a.timestamp - b.timestamp);\n\n // Calculate how many to remove\n const toRemove = memoryMap.size - maxSize;\n\n // Remove oldest entries\n for (let i = 0; i < toRemove; i++) {\n memoryMap.delete(entries[i].key);\n }\n}\n\n/**\n * Deeply traverses a translation object and extracts all string values with their keys\n *\n * @param obj - Translation object to traverse\n * @param prefix - Current key prefix (for nested objects)\n * @returns Array of [key, value] pairs\n */\nexport function flattenTranslations(\n obj: any,\n prefix: string = ''\n): Array<[string, string]> {\n const results: Array<[string, string]> = [];\n\n for (const key in obj) {\n if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;\n\n const value = obj[key];\n const fullKey = prefix ? `${prefix}.${key}` : key;\n\n if (typeof value === 'string') {\n results.push([fullKey, value]);\n } else if (typeof value === 'object' && value !== null && !Array.isArray(value)) {\n // Recurse into nested objects\n results.push(...flattenTranslations(value, fullKey));\n }\n }\n\n return results;\n}\n\n/**\n * Debug helper to log memory map contents\n */\nexport function debugMemoryMap(): void {\n const memoryMap = getMemoryMap();\n if (!memoryMap) {\n console.log('[ContentStorage] Memory map not initialized');\n return;\n }\n\n console.log('[ContentStorage] Memory map contents:');\n console.log(`Total entries: ${memoryMap.size}`);\n\n const entries = Array.from(memoryMap.entries()).slice(0, 10);\n console.table(\n entries.map(([value, entry]) => ({\n value: value.substring(0, 50),\n keys: Array.from(entry.ids).join(', '),\n namespace: entry.metadata?.namespace || 'N/A',\n }))\n );\n\n if (memoryMap.size > 10) {\n console.log(`... and ${memoryMap.size - 10} more entries`);\n }\n}\n","import { isBrowser, getContentstorageWindow } from './utils';\n\n/**\n * Decodes and validates the contentstorage key\n * Just decodes URL encoding and checks non-empty (backend validates format)\n *\n * @param key - The raw key from URL params\n * @returns Decoded key if valid, null if empty/invalid\n */\nexport function decodeContentstorageKey(key: string | null): string | null {\n if (!key) return null;\n\n try {\n const decoded = decodeURIComponent(key);\n return decoded.trim() || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Detects if screenshot mode should be activated\n * Requires: contentstorage_live_editor=true AND screenshot_mode=true AND valid contentstorage_key\n *\n * NOTE: Unlike live editor mode, screenshot mode does NOT require iframe\n *\n * @returns Object with contentstorageKey if active, null otherwise\n */\nexport function detectScreenshotMode(): { contentstorageKey: string } | null {\n if (!isBrowser()) return null;\n\n const win = getContentstorageWindow();\n if (!win) return null;\n\n try {\n const urlParams = new URLSearchParams(win.location.search);\n\n // Check required params\n const liveEditorParam = urlParams.get('contentstorage_live_editor');\n const screenshotModeParam = urlParams.get('screenshot_mode');\n const contentstorageKey = urlParams.get('contentstorage_key');\n\n // All three must be present and valid\n if (liveEditorParam !== 'true') return null;\n if (screenshotModeParam !== 'true') return null;\n\n const decodedKey = decodeContentstorageKey(contentstorageKey);\n if (!decodedKey) return null;\n\n return {\n contentstorageKey: decodedKey,\n };\n } catch {\n return null;\n }\n}\n\n/**\n * Removes screenshot-related params from URL without page reload\n * Uses History API to update URL bar\n */\nexport function cleanScreenshotUrlParams(): void {\n if (!isBrowser()) return;\n\n const win = getContentstorageWindow();\n if (!win) return;\n\n try {\n const url = new URL(win.location.href);\n const paramsToRemove = [\n 'contentstorage_live_editor',\n 'screenshot_mode',\n 'contentstorage_key',\n ];\n\n paramsToRemove.forEach((param) => {\n url.searchParams.delete(param);\n });\n\n // Use replaceState to update URL without reload\n win.history.replaceState({}, '', url.toString());\n } catch (e) {\n console.warn('[ContentStorage] Failed to clean URL params:', e);\n }\n}\n\n/**\n * Exposes the API key on window for live-editor.js to use\n * Uses a non-enumerable property for security\n *\n * @param key - The validated contentstorage API key\n */\nexport function exposeApiKey(key: string): void {\n const win = getContentstorageWindow();\n if (!win) return;\n\n // Store as non-enumerable property for security\n Object.defineProperty(win, '__contentstorageApiKey', {\n value: key,\n writable: false,\n enumerable: false,\n configurable: true, // Allow cleanup later\n });\n}\n\n/**\n * Gets the exposed API key (if any)\n */\nexport function getApiKey(): string | null {\n const win = getContentstorageWindow();\n return win?.__contentstorageApiKey || null;\n}\n","import type { PostProcessorModule } from 'i18next';\nimport type { ContentstoragePluginOptions } from './types';\nimport { trackTranslation, detectLiveEditorMode, initializeMemoryMap, loadLiveEditorScript, extractUserVariables, setCurrentLanguageCode } from './utils';\n\n/**\n * Contentstorage Live Editor Post-Processor\n *\n * This post-processor enables live editor functionality by tracking translations\n * at the point of resolution, capturing the actual values returned by i18next\n * including interpolations and plural forms.\n *\n * Use this to enable click-to-edit functionality in the Contentstorage live editor.\n * It works in addition to or instead of the backend plugin for more comprehensive\n * tracking, especially for dynamic translations.\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import { ContentstorageLiveEditorPostProcessor } from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(new ContentstorageLiveEditorPostProcessor({ debug: true }))\n * .init({\n * postProcess: ['contentstorage']\n * });\n * ```\n */\nexport class ContentstorageLiveEditorPostProcessor implements PostProcessorModule {\n static type: 'postProcessor' = 'postProcessor';\n type: 'postProcessor' = 'postProcessor';\n name: string = 'contentstorage';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n\n constructor(options: ContentstoragePluginOptions = {}) {\n this.options = {\n debug: false,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...options,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n initializeMemoryMap();\n\n // Initialize current language code with browser language or fallback\n // This ensures window.currentLanguageCode is never undefined\n const browserLanguage = typeof navigator !== 'undefined' && navigator.language\n ? navigator.language.split('-')[0]\n : 'en';\n setCurrentLanguageCode(browserLanguage);\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Post-processor initialized in live mode');\n console.log(`[ContentStorage] Initial language code set to: ${browserLanguage}`);\n }\n }\n }\n\n /**\n * Process the translated value\n * Called by i18next after translation resolution\n */\n process(\n value: string,\n key: string | string[],\n options: any,\n translator: any\n ): string {\n // Only track in live mode\n if (!this.isLiveMode) {\n return value;\n }\n\n // Handle array of keys (fallback keys)\n const translationKey = Array.isArray(key) ? key[0] : key;\n\n // Only extract namespace if key explicitly uses colon notation\n // Don't pass namespace from options - let keys be clean by default\n let namespace: string | undefined;\n if (translationKey.includes(':')) {\n [namespace] = translationKey.split(':');\n }\n console.log('[Contentstorage plugin] ', {\n options,\n translator\n })\n // Extract language\n const language = options?.lng || translator?.language;\n\n // Set current language code for live editor\n if (language) {\n setCurrentLanguageCode(language);\n }\n\n // Extract user variables from options\n const variables = extractUserVariables(options);\n\n // Try to get the template (non-interpolated value) from the translator\n // This allows us to track the template with {{placeholders}} instead of resolved values\n let template = value;\n try {\n if (translator?.resourceStore) {\n const ns = namespace || options?.ns || translator.options?.defaultNS || 'translation';\n const lng = language || translator.language;\n\n // Try to get the raw translation template from the resource store\n const rawTranslation = translator.resourceStore.getResource(lng, ns, translationKey);\n if (rawTranslation && typeof rawTranslation === 'string') {\n template = rawTranslation;\n }\n }\n } catch (e) {\n // If we can't get the template, fall back to using the resolved value\n if (this.options.debug) {\n console.warn('[Contentstorage plugin] Could not retrieve template for:', translationKey, e);\n }\n }\n\n // Track the translation with the template\n trackTranslation(\n template,\n translationKey,\n namespace,\n language,\n this.options.debug,\n variables\n );\n\n return value;\n }\n}\n\n/**\n * Create a new instance of the Contentstorage Live Editor post-processor\n */\nexport function createContentstorageLiveEditorPostProcessor(\n options?: ContentstoragePluginOptions\n): ContentstorageLiveEditorPostProcessor {\n return new ContentstorageLiveEditorPostProcessor(options);\n}\n","import type {\n BackendModule,\n ReadCallback,\n Services,\n InitOptions,\n} from 'i18next';\nimport type {\n ContentstoragePluginOptions,\n TranslationData,\n} from './types';\nimport {\n detectLiveEditorMode,\n initializeMemoryMap,\n trackTranslation,\n cleanupMemoryMap,\n flattenTranslations,\n isBrowser,\n loadLiveEditorScript,\n} from './utils';\nimport {\n detectScreenshotMode,\n cleanScreenshotUrlParams,\n exposeApiKey,\n} from './screenshot';\nimport { ContentstorageLiveEditorPostProcessor } from './post-processor';\n\n/**\n * Contentstorage i18next Backend Plugin\n *\n * This plugin enables translation tracking for the Contentstorage live editor\n * by maintaining a memory map of translations and their keys.\n *\n * Features:\n * - Automatic live editor mode detection\n * - Translation tracking with memory map\n * - Support for nested translations\n * - Memory management with size limits\n * - Custom CDN or load path support\n *\n * @example\n * ```typescript\n * import i18next from 'i18next';\n * import ContentstorageBackend from '@contentstorage/i18next-plugin';\n *\n * i18next\n * .use(ContentstorageBackend)\n * .init({\n * backend: {\n * contentKey: 'your-content-key',\n * debug: true\n * }\n * });\n * ```\n */\nexport class ContentstorageBackend implements BackendModule<ContentstoragePluginOptions> {\n static type: 'backend' = 'backend';\n type: 'backend' = 'backend';\n\n private options: ContentstoragePluginOptions;\n private isLiveMode: boolean = false;\n private postProcessor?: ContentstorageLiveEditorPostProcessor;\n private services?: Services;\n private i18nextOptions?: InitOptions;\n\n constructor(_services?: Services, options?: ContentstoragePluginOptions, _i18nextOptions?: InitOptions) {\n this.options = options || {};\n\n // Initialize if services and i18nextOptions are provided\n // This allows i18next to initialize the plugin automatically\n if (_services && _i18nextOptions) {\n this.init(_services, options, _i18nextOptions);\n }\n }\n\n /**\n * Initialize the plugin\n * Called by i18next during initialization\n */\n init(\n services: Services,\n backendOptions: ContentstoragePluginOptions = {},\n i18nextOptions: InitOptions = {}\n ): void {\n // Store for use in initializeScreenshotMode\n this.services = services;\n this.i18nextOptions = i18nextOptions;\n\n this.options = {\n debug: false,\n maxMemoryMapSize: 10000,\n liveEditorParam: 'contentstorage_live_editor',\n forceLiveMode: false,\n ...backendOptions,\n };\n\n // Detect live editor mode\n this.isLiveMode = detectLiveEditorMode(\n this.options.liveEditorParam,\n this.options.forceLiveMode\n );\n\n if (this.isLiveMode) {\n // Initialize memory map\n initializeMemoryMap();\n\n // Load the live editor script\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl).then((loaded) => {\n if (loaded) {\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor ready');\n }\n } else {\n console.warn('[ContentStorage] Failed to load live editor script');\n }\n });\n\n // Auto-register the post-processor for live editor tracking\n this.registerPostProcessor(services, i18nextOptions);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Live editor mode enabled');\n console.log('[ContentStorage] Post-processor auto-registered');\n console.log('[ContentStorage] Plugin initialized with options:', this.options);\n }\n } else if (this.options.debug) {\n console.log('[ContentStorage] Running in normal mode (not live editor)');\n }\n\n // Check for screenshot mode (works in local dev without iframe)\n this.initializeScreenshotMode();\n }\n\n /**\n * Initialize screenshot mode if URL params indicate it\n * Exposes the API key for live-editor.js to use\n */\n private initializeScreenshotMode(): void {\n const screenshotConfig = detectScreenshotMode();\n\n if (!screenshotConfig) return;\n\n if (this.options.debug) {\n console.log('[ContentStorage] Screenshot mode detected');\n }\n\n // Initialize memory map for translation tracking\n initializeMemoryMap();\n\n // Expose API key for live-editor.js to use\n exposeApiKey(screenshotConfig.contentstorageKey);\n\n // Clean URL params for security\n cleanScreenshotUrlParams();\n\n // Register post-processor for translation tracking\n if (this.services && this.i18nextOptions) {\n this.registerPostProcessor(this.services, this.i18nextOptions);\n }\n\n // Load live-editor.js script (handles screenshot UI)\n loadLiveEditorScript(2, 3000, this.options.debug, this.options.customLiveEditorScriptUrl);\n\n if (this.options.debug) {\n console.log('[ContentStorage] Screenshot mode initialized: memory map, post-processor, API key exposed');\n }\n }\n\n /**\n * Auto-register the live editor post-processor\n * This allows dynamic translation tracking without requiring explicit postProcess config\n */\n private registerPostProcessor(services: Services, i18nextOptions: InitOptions): void {\n // Create post-processor instance\n this.postProcessor = new ContentstorageLiveEditorPostProcessor(this.options);\n\n // Register with i18next\n services.languageUtils?.addPostProcessor(this.postProcessor);\n\n // Add to postProcess array if it exists, otherwise create it\n const initOptions = i18nextOptions as any;\n if (!initOptions.postProcess) {\n initOptions.postProcess = [];\n }\n\n // Ensure postProcess is an array\n if (!Array.isArray(initOptions.postProcess)) {\n initOptions.postProcess = [initOptions.postProcess];\n }\n\n // Add our post-processor if not already present\n if (!initOptions.postProcess.includes('contentstorage')) {\n initOptions.postProcess.push('contentstorage');\n }\n }\n\n /**\n * Read translations for a given language and namespace\n * This is the main method called by i18next to load translations\n */\n read(\n language: string,\n namespace: string,\n callback: ReadCallback\n ): void {\n if (this.options.debug) {\n console.log(`[ContentStorage] Loading translations: ${language}/${namespace}`);\n }\n\n this.loadTranslations(language, namespace)\n .then((translations) => {\n // Track translations if in live mode\n if (this.isLiveMode && this.shouldTrackNamespace(namespace)) {\n this.trackTranslations(translations, namespace, language);\n\n // Cleanup if needed\n if (this.options.maxMemoryMapSize) {\n cleanupMemoryMap(this.options.maxMemoryMapSize);\n }\n }\n\n callback(null, translations);\n })\n .catch((error) => {\n if (this.options.debug) {\n console.error('[ContentStorage] Failed to load translations:', error);\n }\n callback(error, false);\n });\n }\n\n /**\n * Load translations from CDN or custom source\n */\n private async loadTranslations(\n language: string,\n namespace: string\n ): Promise<TranslationData> {\n const url = this.getLoadPath(language, namespace);\n\n if (this.options.debug) {\n console.log(`[ContentStorage] Fetching from: ${url}`);\n }\n\n try {\n const fetchFn = this.options.request || this.defaultFetch.bind(this);\n return await fetchFn(url, {\n method: 'GET',\n headers: {\n 'Accept': 'application/json',\n },\n });\n } catch (error) {\n if (this.options.debug) {\n console.error('[ContentStorage] Fetch error:', error);\n }\n throw error;\n }\n }\n\n /**\n * Default fetch implementation\n */\n private async defaultFetch(url: string, options: RequestInit): Promise<any> {\n const response = await fetch(url, options);\n\n if (!response.ok) {\n throw new Error(\n `Failed to load translations: ${response.status} ${response.statusText}`\n );\n }\n\n return response.json();\n }\n\n /**\n * Get the URL to load translations from\n */\n private getLoadPath(language: string, namespace: string): string {\n const { loadPath, contentKey } = this.options;\n\n // Custom load path function\n if (typeof loadPath === 'function') {\n return loadPath(language, namespace);\n }\n\n // Custom load path string with interpolation\n if (typeof loadPath === 'string') {\n return loadPath\n .replace('{{lng}}', language)\n .replace('{{ns}}', namespace);\n }\n\n // Default CDN path\n if (!contentKey) {\n throw new Error(\n '[ContentStorage] contentKey is required when using default CDN path'\n );\n }\n\n // Default: Always use uppercase language code\n const lng = language.toUpperCase();\n\n // Default: https://cdn.contentstorage.app/{contentKey}/content/{LNG}.json\n return `https://cdn.contentstorage.app/${contentKey}/content/${lng}.json`;\n }\n\n /**\n * Check if a namespace should be tracked\n */\n private shouldTrackNamespace(namespace: string): boolean {\n const { trackNamespaces } = this.options;\n\n // If no filter specified, track all namespaces\n if (!trackNamespaces || trackNamespaces.length === 0) {\n return true;\n }\n\n return trackNamespaces.includes(namespace);\n }\n\n /**\n * Track all translations in the loaded data\n */\n private trackTranslations(\n translations: TranslationData,\n namespace: string,\n language: string\n ): void {\n if (!isBrowser()) return;\n\n const flatTranslations = flattenTranslations(translations);\n\n for (const [key, value] of flatTranslations) {\n // Skip empty values\n if (!value) continue;\n\n // Don't pass namespace - let keys be tracked without prefix by default\n // Only keys with explicit colon notation (e.g., \"common:welcome\") will have namespace\n trackTranslation(\n value,\n key,\n undefined, // namespace not passed by default\n language,\n this.options.debug\n );\n }\n\n if (this.options.debug) {\n console.log(\n `[ContentStorage] Tracked ${flatTranslations.length} translations for ${namespace}`\n );\n }\n }\n}\n\n/**\n * Create a new instance of the Contentstorage backend\n */\nexport function createContentstorageBackend(\n options?: ContentstoragePluginOptions\n): ContentstorageBackend {\n return new ContentstorageBackend(undefined, options);\n}\n\n// Default export\nexport default ContentstorageBackend;\n"],"names":[],"mappings":";;;;AAEA;;AA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,CAAC,SAAS,EAAE,OAAO,CAAC;AACtD;;;;;;;;;;;;;;;;;"}
|
package/dist/plugin.d.ts
CHANGED
|
@@ -34,6 +34,8 @@ export declare class ContentstorageBackend implements BackendModule<Contentstora
|
|
|
34
34
|
private options;
|
|
35
35
|
private isLiveMode;
|
|
36
36
|
private postProcessor?;
|
|
37
|
+
private services?;
|
|
38
|
+
private i18nextOptions?;
|
|
37
39
|
constructor(_services?: Services, options?: ContentstoragePluginOptions, _i18nextOptions?: InitOptions);
|
|
38
40
|
/**
|
|
39
41
|
* Initialize the plugin
|
package/dist/plugin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,SAAS,CAAC;AAiBjB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,qBAAsB,YAAW,aAAa,CAAC,2BAA2B,CAAC;IACtF,MAAM,CAAC,IAAI,EAAE,SAAS,CAAa;IACnC,IAAI,EAAE,SAAS,CAAa;IAE5B,OAAO,CAAC,OAAO,CAA8B;IAC7C,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,aAAa,CAAC,CAAwC;
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,QAAQ,EACR,WAAW,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EACV,2BAA2B,EAE5B,MAAM,SAAS,CAAC;AAiBjB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,qBAAa,qBAAsB,YAAW,aAAa,CAAC,2BAA2B,CAAC;IACtF,MAAM,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