preact-intlayer 8.9.6 → 8.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (126) hide show
  1. package/dist/cjs/IntlayerNode.cjs.map +1 -1
  2. package/dist/cjs/UI/ContentSelector.cjs.map +1 -1
  3. package/dist/cjs/client/IntlayerProvider.cjs.map +1 -1
  4. package/dist/cjs/client/index.cjs +1 -1
  5. package/dist/cjs/client/t.cjs.map +1 -1
  6. package/dist/cjs/client/useContent.cjs.map +1 -1
  7. package/dist/cjs/client/useDictionary.cjs.map +1 -1
  8. package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
  9. package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
  10. package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
  11. package/dist/cjs/client/useIntlayer.cjs.map +1 -1
  12. package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
  13. package/dist/cjs/client/useLocale.cjs.map +1 -1
  14. package/dist/cjs/client/useLocaleBase.cjs.map +1 -1
  15. package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
  16. package/dist/cjs/client/useTraduction.cjs.map +1 -1
  17. package/dist/cjs/editor/ContentSelector.cjs.map +1 -1
  18. package/dist/cjs/editor/EditorProvider.cjs.map +1 -1
  19. package/dist/cjs/editor/useEditor.cjs.map +1 -1
  20. package/dist/cjs/format/useCompact.cjs.map +1 -1
  21. package/dist/cjs/format/useCurrency.cjs.map +1 -1
  22. package/dist/cjs/format/useDate.cjs.map +1 -1
  23. package/dist/cjs/format/useIntl.cjs.map +1 -1
  24. package/dist/cjs/format/useList.cjs.map +1 -1
  25. package/dist/cjs/format/useNumber.cjs.map +1 -1
  26. package/dist/cjs/format/usePercentage.cjs.map +1 -1
  27. package/dist/cjs/format/useRelativeTime.cjs.map +1 -1
  28. package/dist/cjs/format/useUnit.cjs.map +1 -1
  29. package/dist/cjs/getDictionary.cjs.map +1 -1
  30. package/dist/cjs/getIntlayer.cjs.map +1 -1
  31. package/dist/cjs/html/HTMLProvider.cjs.map +1 -1
  32. package/dist/cjs/html/HTMLRenderer.cjs.map +1 -1
  33. package/dist/cjs/index.cjs +1 -1
  34. package/dist/cjs/markdown/MarkdownProvider.cjs.map +1 -1
  35. package/dist/cjs/markdown/MarkdownRenderer.cjs.map +1 -1
  36. package/dist/cjs/markdown/MarkdownRendererPlugin.cjs.map +1 -1
  37. package/dist/cjs/markdown/compiler.cjs.map +1 -1
  38. package/dist/cjs/markdown/runtime.cjs.map +1 -1
  39. package/dist/cjs/plugins.cjs +36 -29
  40. package/dist/cjs/plugins.cjs.map +1 -1
  41. package/dist/cjs/preactElement/renderPreactElement.cjs.map +1 -1
  42. package/dist/esm/IntlayerNode.mjs.map +1 -1
  43. package/dist/esm/UI/ContentSelector.mjs.map +1 -1
  44. package/dist/esm/client/IntlayerProvider.mjs.map +1 -1
  45. package/dist/esm/client/index.mjs +1 -1
  46. package/dist/esm/client/t.mjs.map +1 -1
  47. package/dist/esm/client/useContent.mjs.map +1 -1
  48. package/dist/esm/client/useDictionary.mjs.map +1 -1
  49. package/dist/esm/client/useDictionaryAsync.mjs.map +1 -1
  50. package/dist/esm/client/useDictionaryDynamic.mjs +1 -1
  51. package/dist/esm/client/useDictionaryDynamic.mjs.map +1 -1
  52. package/dist/esm/client/useIntlayer.mjs.map +1 -1
  53. package/dist/esm/client/useLoadDynamic.mjs.map +1 -1
  54. package/dist/esm/client/useLocale.mjs.map +1 -1
  55. package/dist/esm/client/useLocaleBase.mjs.map +1 -1
  56. package/dist/esm/client/useLocaleStorage.mjs.map +1 -1
  57. package/dist/esm/client/useTraduction.mjs.map +1 -1
  58. package/dist/esm/editor/ContentSelector.mjs.map +1 -1
  59. package/dist/esm/editor/EditorProvider.mjs.map +1 -1
  60. package/dist/esm/editor/useEditor.mjs.map +1 -1
  61. package/dist/esm/format/useCompact.mjs.map +1 -1
  62. package/dist/esm/format/useCurrency.mjs.map +1 -1
  63. package/dist/esm/format/useDate.mjs.map +1 -1
  64. package/dist/esm/format/useIntl.mjs.map +1 -1
  65. package/dist/esm/format/useList.mjs.map +1 -1
  66. package/dist/esm/format/useNumber.mjs.map +1 -1
  67. package/dist/esm/format/usePercentage.mjs.map +1 -1
  68. package/dist/esm/format/useRelativeTime.mjs.map +1 -1
  69. package/dist/esm/format/useUnit.mjs.map +1 -1
  70. package/dist/esm/getDictionary.mjs.map +1 -1
  71. package/dist/esm/getIntlayer.mjs.map +1 -1
  72. package/dist/esm/html/HTMLProvider.mjs.map +1 -1
  73. package/dist/esm/html/HTMLRenderer.mjs.map +1 -1
  74. package/dist/esm/index.mjs +1 -1
  75. package/dist/esm/markdown/MarkdownProvider.mjs.map +1 -1
  76. package/dist/esm/markdown/MarkdownRenderer.mjs.map +1 -1
  77. package/dist/esm/markdown/MarkdownRendererPlugin.mjs.map +1 -1
  78. package/dist/esm/markdown/compiler.mjs.map +1 -1
  79. package/dist/esm/markdown/runtime.mjs.map +1 -1
  80. package/dist/esm/plugins.mjs +36 -29
  81. package/dist/esm/plugins.mjs.map +1 -1
  82. package/dist/esm/preactElement/renderPreactElement.mjs.map +1 -1
  83. package/dist/types/IntlayerNode.d.ts.map +1 -1
  84. package/dist/types/UI/ContentSelector.d.ts.map +1 -1
  85. package/dist/types/client/IntlayerProvider.d.ts +1 -2
  86. package/dist/types/client/IntlayerProvider.d.ts.map +1 -1
  87. package/dist/types/client/useContent.d.ts +1 -2
  88. package/dist/types/client/useContent.d.ts.map +1 -1
  89. package/dist/types/client/useDictionary.d.ts +2 -4
  90. package/dist/types/client/useDictionary.d.ts.map +1 -1
  91. package/dist/types/client/useDictionaryDynamic.d.ts +2 -4
  92. package/dist/types/client/useDictionaryDynamic.d.ts.map +1 -1
  93. package/dist/types/client/useLocale.d.ts.map +1 -1
  94. package/dist/types/client/useLocaleBase.d.ts +4 -6
  95. package/dist/types/client/useLocaleBase.d.ts.map +1 -1
  96. package/dist/types/client/useLocaleStorage.d.ts +4 -5
  97. package/dist/types/client/useLocaleStorage.d.ts.map +1 -1
  98. package/dist/types/client/useTraduction.d.ts.map +1 -1
  99. package/dist/types/editor/ContentSelector.d.ts.map +1 -1
  100. package/dist/types/editor/EditorProvider.d.ts.map +1 -1
  101. package/dist/types/format/useCompact.d.ts +1 -3
  102. package/dist/types/format/useCompact.d.ts.map +1 -1
  103. package/dist/types/format/useCurrency.d.ts +1 -3
  104. package/dist/types/format/useCurrency.d.ts.map +1 -1
  105. package/dist/types/format/useDate.d.ts.map +1 -1
  106. package/dist/types/format/useIntl.d.ts.map +1 -1
  107. package/dist/types/format/useList.d.ts +1 -3
  108. package/dist/types/format/useList.d.ts.map +1 -1
  109. package/dist/types/format/useNumber.d.ts +1 -3
  110. package/dist/types/format/useNumber.d.ts.map +1 -1
  111. package/dist/types/format/usePercentage.d.ts +1 -3
  112. package/dist/types/format/usePercentage.d.ts.map +1 -1
  113. package/dist/types/format/useRelativeTime.d.ts +1 -3
  114. package/dist/types/format/useRelativeTime.d.ts.map +1 -1
  115. package/dist/types/format/useUnit.d.ts +1 -3
  116. package/dist/types/format/useUnit.d.ts.map +1 -1
  117. package/dist/types/html/HTMLProvider.d.ts.map +1 -1
  118. package/dist/types/html/HTMLRenderer.d.ts.map +1 -1
  119. package/dist/types/markdown/MarkdownProvider.d.ts.map +1 -1
  120. package/dist/types/markdown/MarkdownRenderer.d.ts.map +1 -1
  121. package/dist/types/markdown/MarkdownRendererPlugin.d.ts.map +1 -1
  122. package/dist/types/markdown/compiler.d.ts.map +1 -1
  123. package/dist/types/markdown/runtime.d.ts.map +1 -1
  124. package/dist/types/plugins.d.ts.map +1 -1
  125. package/dist/types/preactElement/renderPreactElement.d.ts.map +1 -1
  126. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerNode.cjs","names":["Fragment"],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChildren,\n Fragment,\n h,\n isValidElement,\n type VNode,\n} from 'preact';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = ResolvedEditor<T, VNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: ComponentChildren;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid VNode, wrap it in a fragment\n const element: VNode<any> = isValidElement(children)\n ? children\n : h(Fragment, {}, children);\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as VNode, {\n get(target, prop, receiver) {\n if (prop === 'value') return value;\n if (prop === Symbol.toPrimitive) return () => value ?? '';\n if (prop === 'toString') return () => String(value ?? '');\n if (prop === 'valueOf') return () => value;\n\n // Additional Props take precedence\n if (additionalProps && prop in additionalProps) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n // Delegate native methods/properties to the underlying value\n if (\n value !== null &&\n value !== undefined &&\n typeof prop === 'string' &&\n prop !== 'constructor' &&\n !(prop in target) // Prevents overwriting VNode internals (type, props, key)\n ) {\n const valObj = Object(value); // Safely boxes primitives (e.g., 50 -> Number object)\n if (prop in valObj) {\n const valProp = valObj[prop];\n return typeof valProp === 'function' ? valProp.bind(value) : valProp;\n }\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;;;AAwBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CAEjD,MAAM,qCAAqC,SAAS,GAChD,yBACEA,iBAAU,EAAE,EAAE,SAAS;CAI7B,OAAO,IAAI,MAAM,SAAkB,EACjC,IAAI,QAAQ,MAAM,UAAU;EAC1B,IAAI,SAAS,SAAS,OAAO;EAC7B,IAAI,SAAS,OAAO,aAAa,aAAa,SAAS;EACvD,IAAI,SAAS,YAAY,aAAa,OAAO,SAAS,GAAG;EACzD,IAAI,SAAS,WAAW,aAAa;EAGrC,IAAI,mBAAmB,QAAQ,iBAC7B,OAAO,gBAAgB;EAIzB,IACE,UAAU,QACV,UAAU,UACV,OAAO,SAAS,YAChB,SAAS,iBACT,EAAE,QAAQ,SACV;GACA,MAAM,SAAS,OAAO,MAAM;GAC5B,IAAI,QAAQ,QAAQ;IAClB,MAAM,UAAU,OAAO;IACvB,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,MAAM,GAAG;;;EAIjE,OAAO,QAAQ,IAAI,QAAQ,MAAM,SAAS;IAE7C,CAAC"}
1
+ {"version":3,"file":"IntlayerNode.cjs","names":["Fragment"],"sources":["../../src/IntlayerNode.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport type { ResolvedEditor } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChildren,\n Fragment,\n h,\n isValidElement,\n type VNode,\n} from 'preact';\n\nexport type IntlayerNode<\n T = NodeProps['children'],\n AdditionalProps = {},\n> = ResolvedEditor<T, VNode> & {\n value: T;\n} & AdditionalProps &\n T;\n\ntype RenderIntlayerNodeProps<T> = {\n value: T;\n children: ComponentChildren;\n additionalProps?: { [key: string]: any };\n};\n\nexport const renderIntlayerNode = <\n T, // Broadened to support arrays, numbers, objects, etc.\n>({\n children,\n value,\n additionalProps,\n}: RenderIntlayerNodeProps<T>): IntlayerNode<T> => {\n // If children is not a valid VNode, wrap it in a fragment\n const element: VNode<any> = isValidElement(children)\n ? children\n : h(Fragment, {}, children);\n\n // Return a Proxy that pretends to be the original element\n // but also has a .value getter.\n return new Proxy(element as VNode, {\n get(target, prop, receiver) {\n if (prop === 'value') return value;\n if (prop === Symbol.toPrimitive) return () => value ?? '';\n if (prop === 'toString') return () => String(value ?? '');\n if (prop === 'valueOf') return () => value;\n\n // Additional Props take precedence\n if (additionalProps && prop in additionalProps) {\n return additionalProps[prop as keyof typeof additionalProps];\n }\n\n // Delegate native methods/properties to the underlying value\n if (\n value !== null &&\n value !== undefined &&\n typeof prop === 'string' &&\n prop !== 'constructor' &&\n !(prop in target) // Prevents overwriting VNode internals (type, props, key)\n ) {\n const valObj = Object(value); // Safely boxes primitives (e.g., 50 -> Number object)\n if (prop in valObj) {\n const valProp = valObj[prop];\n return typeof valProp === 'function' ? valProp.bind(value) : valProp;\n }\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as IntlayerNode<T>;\n};\n"],"mappings":";;;;;AAwBA,MAAa,sBAEX,EACA,UACA,OACA,sBACiD;CAEjD,MAAM,qCAAqC,QAAQ,IAC/C,yBACEA,iBAAU,CAAC,GAAG,QAAQ;CAI5B,OAAO,IAAI,MAAM,SAAkB,EACjC,IAAI,QAAQ,MAAM,UAAU;EAC1B,IAAI,SAAS,SAAS,OAAO;EAC7B,IAAI,SAAS,OAAO,aAAa,aAAa,SAAS;EACvD,IAAI,SAAS,YAAY,aAAa,OAAO,SAAS,EAAE;EACxD,IAAI,SAAS,WAAW,aAAa;EAGrC,IAAI,mBAAmB,QAAQ,iBAC7B,OAAO,gBAAgB;EAIzB,IACE,UAAU,QACV,UAAU,UACV,OAAO,SAAS,YAChB,SAAS,iBACT,EAAE,QAAQ,SACV;GACA,MAAM,SAAS,OAAO,KAAK;GAC3B,IAAI,QAAQ,QAAQ;IAClB,MAAM,UAAU,OAAO;IACvB,OAAO,OAAO,YAAY,aAAa,QAAQ,KAAK,KAAK,IAAI;GAC/D;EACF;EAEA,OAAO,QAAQ,IAAI,QAAQ,MAAM,QAAQ;CAC3C,EACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type { FunctionalComponent, JSX } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: JSX.MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;AAGA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,kCAAgC,KAAK;CAC3C,MAAM,CAAC,WAAW,2CAAyB,MAAM;CACjD,MAAM,CAAC,kBAAkB,kDAAgC,gBAAgB;CACzE,MAAM,yCAA6D,KAAK;CACxE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,KAAK;EACzB,UAAU;;CAGZ,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,mBAAmB;KAClB,cAAc;;CAGnB,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,QAAQ;GACnC,cAAc,UAAU;;;CAI5B,MAAM,wBAAwB;EAC5B,iBAAiB;EACjB,iBAAiB;;CAGnB,MAAM,yBAAyB;EAC7B,aAAa,KAAK;EAClB,WAAW;;CAGb,MAAM,sBAAsB;EAC1B,IAAI,WAAW;GACb,aAAa,MAAM;GACnB,aAAa;;EAEf,iBAAiB;;CAInB,MAAM,oDACH,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,OAAe,EAAE;GACpE,oBAAoB,MAAM;GAC1B,cAAc;;IAGlB,CAAC,WAAW,CACb;CAED,kCAAgB;EAEd,SAAS,iBAAiB,aAAa,mBAAmB;EAE1D,aAAa;GAEX,SAAS,oBAAoB,aAAa,mBAAmB;;IAG9D,CAAC,mBAAmB,CAAC;CAExB,MAAM,iBAAwD,MAAM;EAClE,IAAI,kBAAkB;GACpB,EAAE,gBAAgB;GAClB,EAAE,iBAAiB;;;CAIvB,MAAM,qBAAqB;EAEzB,oBAAoB,MAAM;;CAG5B,OACE,4CAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;GACb;EACD,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;EACI"}
1
+ {"version":3,"file":"ContentSelector.cjs","names":[],"sources":["../../../src/UI/ContentSelector.tsx"],"sourcesContent":["import type { FunctionalComponent, JSX } from 'preact';\nimport { useCallback, useEffect, useRef, useState } from 'preact/hooks';\n\nconst DEFAULT_PRESS_DETECT_DURATION = 250;\n\ntype ContentSelectorProps = {\n onPress: () => void;\n onHover?: () => void;\n onUnhover?: () => void;\n onClickOutside?: () => void;\n pressDuration?: number;\n isSelecting?: boolean;\n} & Omit<JSX.HTMLAttributes<HTMLDivElement>, 'content'>;\n\nexport const ContentSelector: FunctionalComponent<ContentSelectorProps> = ({\n children,\n onPress: onSelect,\n onHover,\n onUnhover,\n onClickOutside: onUnselect,\n pressDuration = DEFAULT_PRESS_DETECT_DURATION,\n isSelecting: isSelectingProp,\n ...props\n}) => {\n const divRef = useRef<HTMLDivElement>(null);\n const [isHovered, setIsHovered] = useState(false);\n const [isSelectingState, setIsSelectingState] = useState(isSelectingProp);\n const pressTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);\n const isChildrenString = typeof children === 'string';\n\n const handleOnLongPress = () => {\n setIsSelectingState(true);\n onSelect();\n };\n\n const startPressTimer = () => {\n pressTimerRef.current = setTimeout(() => {\n handleOnLongPress();\n }, pressDuration);\n };\n\n const clearPressTimer = () => {\n if (pressTimerRef.current) {\n clearTimeout(pressTimerRef.current);\n pressTimerRef.current = null;\n }\n };\n\n const handleMouseDown = () => {\n clearPressTimer(); // Ensure any previous timer is cleared\n startPressTimer();\n };\n\n const handleMouseEnter = () => {\n setIsHovered(true);\n onHover?.();\n };\n\n const handleMouseUp = () => {\n if (isHovered) {\n setIsHovered(false);\n onUnhover?.();\n }\n clearPressTimer();\n };\n\n // Use useCallback to ensure the function identity remains stable\n const handleClickOutside = useCallback(\n (event: MouseEvent) => {\n if (divRef.current && !divRef.current.contains(event.target as Node)) {\n setIsSelectingState(false);\n onUnselect?.();\n }\n },\n [onUnselect]\n );\n\n useEffect(() => {\n // Attach click outside listener\n document.addEventListener('mousedown', handleClickOutside);\n\n return () => {\n // Cleanup\n document.removeEventListener('mousedown', handleClickOutside);\n // clearPressTimer(); // Ensure to clear the timer when component unmounts\n };\n }, [handleClickOutside]);\n\n const handleOnClick: JSX.MouseEventHandler<HTMLDivElement> = (e) => {\n if (isSelectingState) {\n e.preventDefault();\n e.stopPropagation();\n }\n };\n\n const handleOnBlur = () => {\n // Stop editing when the element loses focus\n setIsSelectingState(false);\n };\n\n return (\n <span\n style={{\n display: isChildrenString ? 'inline' : 'inline-block',\n cursor: 'pointer',\n userSelect: 'none',\n borderRadius: '0.375rem',\n outlineWidth: '2px',\n outlineOffset: '4px',\n outlineStyle: 'solid',\n outlineColor:\n isSelectingProp || isSelectingState || isHovered\n ? 'inherit'\n : 'transparent',\n transition: 'all 100ms 50ms ease-in-out',\n }}\n role=\"button\"\n tabIndex={0}\n onKeyUp={() => null}\n onClick={handleOnClick}\n onMouseDown={handleMouseDown}\n onMouseUp={handleMouseUp}\n onMouseLeave={handleMouseUp}\n onTouchStart={handleMouseDown}\n onTouchEnd={handleMouseUp}\n onTouchCancel={handleMouseUp}\n onBlur={handleOnBlur}\n onMouseEnter={handleMouseEnter}\n ref={divRef}\n {...props}\n >\n {children}\n </span>\n );\n};\n"],"mappings":";;;;;;AAGA,MAAM,gCAAgC;AAWtC,MAAa,mBAA8D,EACzE,UACA,SAAS,UACT,SACA,WACA,gBAAgB,YAChB,gBAAgB,+BAChB,aAAa,iBACb,GAAG,YACC;CACJ,MAAM,kCAAgC,IAAI;CAC1C,MAAM,CAAC,WAAW,2CAAyB,KAAK;CAChD,MAAM,CAAC,kBAAkB,kDAAgC,eAAe;CACxE,MAAM,yCAA6D,IAAI;CACvE,MAAM,mBAAmB,OAAO,aAAa;CAE7C,MAAM,0BAA0B;EAC9B,oBAAoB,IAAI;EACxB,SAAS;CACX;CAEA,MAAM,wBAAwB;EAC5B,cAAc,UAAU,iBAAiB;GACvC,kBAAkB;EACpB,GAAG,aAAa;CAClB;CAEA,MAAM,wBAAwB;EAC5B,IAAI,cAAc,SAAS;GACzB,aAAa,cAAc,OAAO;GAClC,cAAc,UAAU;EAC1B;CACF;CAEA,MAAM,wBAAwB;EAC5B,gBAAgB;EAChB,gBAAgB;CAClB;CAEA,MAAM,yBAAyB;EAC7B,aAAa,IAAI;EACjB,UAAU;CACZ;CAEA,MAAM,sBAAsB;EAC1B,IAAI,WAAW;GACb,aAAa,KAAK;GAClB,YAAY;EACd;EACA,gBAAgB;CAClB;CAGA,MAAM,oDACH,UAAsB;EACrB,IAAI,OAAO,WAAW,CAAC,OAAO,QAAQ,SAAS,MAAM,MAAc,GAAG;GACpE,oBAAoB,KAAK;GACzB,aAAa;EACf;CACF,GACA,CAAC,UAAU,CACb;CAEA,kCAAgB;EAEd,SAAS,iBAAiB,aAAa,kBAAkB;EAEzD,aAAa;GAEX,SAAS,oBAAoB,aAAa,kBAAkB;EAE9D;CACF,GAAG,CAAC,kBAAkB,CAAC;CAEvB,MAAM,iBAAwD,MAAM;EAClE,IAAI,kBAAkB;GACpB,EAAE,eAAe;GACjB,EAAE,gBAAgB;EACpB;CACF;CAEA,MAAM,qBAAqB;EAEzB,oBAAoB,KAAK;CAC3B;CAEA,OACE,4CAAC,QAAD;EACE,OAAO;GACL,SAAS,mBAAmB,WAAW;GACvC,QAAQ;GACR,YAAY;GACZ,cAAc;GACd,cAAc;GACd,eAAe;GACf,cAAc;GACd,cACE,mBAAmB,oBAAoB,YACnC,YACA;GACN,YAAY;EACd;EACA,MAAK;EACL,UAAU;EACV,eAAe;EACf,SAAS;EACT,aAAa;EACb,WAAW;EACX,cAAc;EACd,cAAc;EACd,YAAY;EACZ,eAAe;EACf,QAAQ;EACR,cAAc;EACd,KAAK;EACL,GAAI;EAEH;CACG;AAEV"}
@@ -1 +1 @@
1
- {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","internationalization","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,kDAAqD;CAChE,QAAQA,mDAAmBC,6CAAsB;CACjD,iBAAiB;CAClB,CAAC;;;;AAKF,MAAa,wDAAsC,sBAAsB,IAAI,EAAE;;;;AAa/E,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,sBACI;CACJ,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnDA,+CAAwB,EAAE;CAK5B,MAAM,CAAC,eAAe,+CAFpB,cAAcD,mDAAmB,qBAAqB,oBAIvD;CAED,kCAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,WAAW;IAE7B;EAAC;EAAY;EAAe;EAAiB,CAAC;CAEjD,kCAAgB;EACd,oDAAuB;IACtB,EAAE,CAAC;CAEN,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,UAAU,KAAK,UAAU,UAAU,EAAE;EAEvD,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE;GACtD,QAAQ,MAAM,UAAU,UAAU,mBAAmB;GACrD;;EAGF,iBAAiB,UAAU;EAC3B,mDAAmB,WAAW,mBAAmB,KAAK;;CAGxD,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iEAAgC,cAAc,cAAc;CAElE,OACE,4CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;GACD;EAEA;EAC8B;;;;;;;;;;;;;;;;;;;;;;AAwBrC,MAAa,oBAA8D,EACzE,UACA,GAAG,YAEH,6CAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,4CAACE,8CAAD,EAAkB,GACjB,SACuB"}
1
+ {"version":3,"file":"IntlayerProvider.cjs","names":["localeInStorage","internationalization","EditorProvider"],"sources":["../../../src/client/IntlayerProvider.tsx"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { setIntlayerIdentifier } from '@intlayer/config/client';\nimport { localeResolver } from '@intlayer/core/localization';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport {\n type ComponentChild,\n createContext,\n type FunctionComponent,\n} from 'preact';\nimport { useContext, useEffect, useState } from 'preact/hooks';\nimport { EditorProvider } from '../editor/EditorProvider';\nimport { localeInStorage, setLocaleInStorage } from './useLocaleStorage';\n\ntype IntlayerValue = {\n locale: LocalesValues;\n setLocale: (newLocale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Context that store the current locale on the client side\n */\nexport const IntlayerClientContext = createContext<IntlayerValue>({\n locale: localeInStorage ?? internationalization?.defaultLocale,\n setLocale: () => null,\n});\n\n/**\n * Hook that provides the current locale\n */\nexport const useIntlayerContext = () => useContext(IntlayerClientContext) ?? {};\n\nexport type IntlayerProviderProps = {\n children?: ComponentChild;\n locale?: LocalesValues;\n defaultLocale?: LocalesValues;\n setLocale?: (locale: LocalesValues) => void;\n isCookieEnabled?: boolean;\n};\n\n/**\n * Provider that store the current locale on the client side\n */\nexport const IntlayerProviderContent: FunctionComponent<\n IntlayerProviderProps\n> = ({\n locale: localeProp,\n defaultLocale: defaultLocaleProp,\n children,\n setLocale: setLocaleProp,\n isCookieEnabled,\n}) => {\n const { defaultLocale: defaultLocaleConfig, locales: availableLocales } =\n internationalization ?? {};\n\n const defaultLocale =\n localeProp ?? localeInStorage ?? defaultLocaleProp ?? defaultLocaleConfig;\n\n const [currentLocale, setCurrentLocale] = useState<LocalesValues>(\n defaultLocale as LocalesValues\n );\n\n useEffect(() => {\n if (localeProp && localeProp !== currentLocale) {\n setCurrentLocale(localeProp);\n }\n }, [localeProp, currentLocale, setCurrentLocale]);\n\n useEffect(() => {\n setIntlayerIdentifier();\n }, []);\n\n const setLocaleBase = (newLocale: LocalesValues) => {\n if (currentLocale.toString() === newLocale.toString()) return;\n\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n setCurrentLocale(newLocale); // Update state\n setLocaleInStorage(newLocale, isCookieEnabled ?? true); // Optionally set cookie for persistence\n };\n\n const setLocale = setLocaleProp ?? setLocaleBase;\n\n const resolvedLocale = localeResolver(localeProp ?? currentLocale);\n\n return (\n <IntlayerClientContext.Provider\n value={{\n locale: resolvedLocale,\n setLocale,\n isCookieEnabled,\n }}\n >\n {children}\n </IntlayerClientContext.Provider>\n );\n};\n\n/**\n * Main provider for Intlayer in Preact applications.\n *\n * It provides the Intlayer context to your application, allowing the use\n * of hooks like `useIntlayer` and `useLocale`.\n *\n * @param props - The provider props.\n * @returns The provider component.\n *\n * @example\n * ```tsx\n * import { IntlayerProvider } from 'preact-intlayer';\n *\n * const App = () => (\n * <IntlayerProvider>\n * <MyComponent />\n * </IntlayerProvider>\n * );\n * ```\n */\nexport const IntlayerProvider: FunctionComponent<IntlayerProviderProps> = ({\n children,\n ...props\n}) => (\n <IntlayerProviderContent {...props}>\n <EditorProvider />\n {children}\n </IntlayerProviderContent>\n);\n"],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAa,kDAAqD;CAChE,QAAQA,mDAAmBC,6CAAsB;CACjD,iBAAiB;AACnB,CAAC;;;;AAKD,MAAa,wDAAsC,qBAAqB,KAAK,CAAC;;;;AAa9E,MAAa,2BAER,EACH,QAAQ,YACR,eAAe,mBACf,UACA,WAAW,eACX,sBACI;CACJ,MAAM,EAAE,eAAe,qBAAqB,SAAS,qBACnDA,+CAAwB,CAAC;CAK3B,MAAM,CAAC,eAAe,+CAFpB,cAAcD,mDAAmB,qBAAqB,mBAIxD;CAEA,kCAAgB;EACd,IAAI,cAAc,eAAe,eAC/B,iBAAiB,UAAU;CAE/B,GAAG;EAAC;EAAY;EAAe;CAAgB,CAAC;CAEhD,kCAAgB;EACd,mDAAsB;CACxB,GAAG,CAAC,CAAC;CAEL,MAAM,iBAAiB,cAA6B;EAClD,IAAI,cAAc,SAAS,MAAM,UAAU,SAAS,GAAG;EAEvD,IAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,SAAS,GAAG;GACtD,QAAQ,MAAM,UAAU,UAAU,kBAAkB;GACpD;EACF;EAEA,iBAAiB,SAAS;EAC1B,mDAAmB,WAAW,mBAAmB,IAAI;CACvD;CAEA,MAAM,YAAY,iBAAiB;CAEnC,MAAM,iEAAgC,cAAc,aAAa;CAEjE,OACE,4CAAC,sBAAsB,UAAvB;EACE,OAAO;GACL,QAAQ;GACR;GACA;EACF;EAEC;CAC6B;AAEpC;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,oBAA8D,EACzE,UACA,GAAG,YAEH,6CAAC,yBAAD;CAAyB,GAAI;WAA7B,CACE,4CAACE,8CAAD,CAAiB,IAChB,QACsB"}
@@ -1,10 +1,10 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
2
3
  const require_client_useLocaleStorage = require('./useLocaleStorage.cjs');
3
4
  const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
4
5
  const require_client_t = require('./t.cjs');
5
6
  const require_client_useDictionary = require('./useDictionary.cjs');
6
7
  const require_client_useDictionaryAsync = require('./useDictionaryAsync.cjs');
7
- const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
8
8
  const require_client_useDictionaryDynamic = require('./useDictionaryDynamic.cjs');
9
9
  const require_client_useIntlayer = require('./useIntlayer.cjs');
10
10
  const require_client_useLocale = require('./useLocale.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAGzE,sDAA+B,kBAFV,UAAU,cAE+B"}
1
+ {"version":3,"file":"t.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/t.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, this function returns the translation of the provided multilang content.\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const t = <Content = string>(\n multilangContent: StrictModeLocaleMap<Content>,\n locale?: Locale\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = locale ?? currentLocale;\n\n return getTranslation<Content>(multilangContent, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,KACX,kBACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,qDAAqB,KAAK,CAAC;CAGxE,sDAA+B,kBAFV,UAAU,aAE8B;AAC/D"}
@@ -1 +1 @@
1
- {"version":3,"file":"useContent.cjs","names":["useLocaleBase","useTranslation"],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAWA,4CAAe;CAIlC,OAAO;EACL;EACA,SAJcC,4CAAe,gBAItB;EACP,GAAGA;EACJ"}
1
+ {"version":3,"file":"useContent.cjs","names":["useLocaleBase","useTranslation"],"sources":["../../../src/client/useContent.ts"],"sourcesContent":["import type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useLocaleBase } from './useLocaleBase';\nimport { useTranslation } from './useTraduction';\n\n/**\n * On the client side, hook to get the translation content based on the locale\n */\nexport const useContent = <Content>(\n languageContent: StrictModeLocaleMap<Content>\n) => {\n const { locale } = useLocaleBase();\n\n const content = useTranslation(languageContent);\n\n return {\n locale,\n content,\n t: useTranslation,\n };\n};\n"],"mappings":";;;;;;;;AAOA,MAAa,cACX,oBACG;CACH,MAAM,EAAE,WAAWA,2CAAc;CAIjC,OAAO;EACL;EACA,SAJcC,4CAAe,eAIvB;EACN,GAAGA;CACL;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAEzE,uCAAqB;EAGnB,OAAOC,oCAAoB,YAFN,UAAU,cAE0B;IACxD;EAAC,WAAW;EAAK;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useDictionary.cjs","names":["IntlayerClientContext","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getDictionary } from '../getDictionary';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n return getDictionary<T, L>(dictionary, localeTarget as L);\n }, [dictionary.key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAcA,MAAa,iBAIX,YACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,qDAAqB,KAAK,CAAC;CAExE,uCAAqB;EAGnB,OAAOC,oCAAoB,YAFN,UAAU,aAEyB;CAC1D,GAAG;EAAC,WAAW;EAAK;EAAe;CAAM,CAAC;AAC5C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAEzE,MAAM,+CACE,UAAU,iBAAiBC,4CAAqB,eACtD,CAAC,eAAe,OAAO,CACxB;CAUD,OAAOC,2CAAc,gCAPnB,YACG,MAAM,kBACL,iBACG,EACP,CAAC,mBAAmB,aAAa,CAClC,EAEgC,aAAa"}
1
+ {"version":3,"file":"useDictionaryAsync.cjs","names":["IntlayerClientContext","internationalization","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryAsync = async <T extends Dictionary>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n locale?: LocalesValues\n): Promise<T> => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n const localeTarget = useMemo(\n () => locale ?? currentLocale ?? internationalization.defaultLocale,\n [currentLocale, locale]\n );\n\n const dictionary = await useMemo(\n async () =>\n (await dictionaryPromise[\n localeTarget as keyof typeof dictionaryPromise\n ]?.()) as T,\n [dictionaryPromise, localeTarget]\n );\n\n return useDictionary(dictionary, localeTarget) as any;\n};\n"],"mappings":";;;;;;;;;;;;;AAeA,MAAa,qBAAqB,OAChC,mBACA,WACe;CACf,MAAM,EAAE,QAAQ,+CAA6BA,qDAAqB,KAAK,CAAC;CAExE,MAAM,+CACE,UAAU,iBAAiBC,4CAAqB,eACtD,CAAC,eAAe,MAAM,CACxB;CAUA,OAAOC,2CAAc,gCAPnB,YACG,MAAM,kBACL,gBACE,GACN,CAAC,mBAAmB,YAAY,CAClC,GAEiC,YAAY;AAC/C"}
@@ -1,8 +1,8 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_runtime = require('../_virtual/_rolldown/runtime.cjs');
3
+ const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
3
4
  const require_client_IntlayerProvider = require('./IntlayerProvider.cjs');
4
5
  const require_client_useDictionary = require('./useDictionary.cjs');
5
- const require_client_useLoadDynamic = require('./useLoadDynamic.cjs');
6
6
  let preact_hooks = require("preact/hooks");
7
7
 
8
8
  //#region src/client/useDictionaryDynamic.ts
@@ -1 +1 @@
1
- {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,+CACE,UAAU,eAChB,CAAC,eAAe,OAAO,CACxB;CAOD,OAAOC,2CALYC,6CACjB,GAAG,OAAO,IAAI,CAAC,GAAG,gBACjB,kBAA0B,iBAAiB,CAGf,EAAE,aAAa"}
1
+ {"version":3,"file":"useDictionaryDynamic.cjs","names":["IntlayerClientContext","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["import type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DictionaryKeys,\n LocalesValues,\n StrictModeLocaleMap,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { useDictionary } from './useDictionary';\nimport { useLoadDynamic } from './useLoadDynamic';\n\n/**\n * On the server side, Hook that transform a dictionary and return the content\n *\n * If the locale is not provided, it will use the locale from the client context\n */\nexport const useDictionaryDynamic = <\n T extends Dictionary,\n K extends DictionaryKeys,\n>(\n dictionaryPromise: StrictModeLocaleMap<() => Promise<T>>,\n key: K,\n locale?: LocalesValues\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n const localeTarget = useMemo(\n () => locale ?? currentLocale,\n [currentLocale, locale]\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget}`,\n (dictionaryPromise as any)[localeTarget]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget);\n};\n"],"mappings":";;;;;;;;;;;;;AAgBA,MAAa,wBAIX,mBACA,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,qDAAqB,KAAK,CAAC;CACxE,MAAM,+CACE,UAAU,eAChB,CAAC,eAAe,MAAM,CACxB;CAOA,OAAOC,2CALYC,6CACjB,GAAG,OAAO,GAAG,EAAE,GAAG,gBACjB,kBAA0B,gBAAgB,CAGf,GAAG,YAAY;AAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Preact hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'preact-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getIntlayer<T, L>(key, localeTarget as L) as DeepTransformContent<\n DictionaryRegistryContent<T>\n >;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,eACX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CAEzE,uCAAqB;EAInB,OAAOC,gCAAkB,KAHJ,UAAU,cAGiB;IAG/C;EAAC;EAAK;EAAe;EAAO,CAAC"}
1
+ {"version":3,"file":"useIntlayer.cjs","names":["IntlayerClientContext","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import type {\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * Preact hook that picks one dictionary by its key and returns its content.\n *\n * If the locale is not provided, it will use the locale from the client context.\n *\n * @param key - The unique key of the dictionary to retrieve.\n * @param locale - Optional locale to override the current context locale.\n * @returns The transformed dictionary content.\n *\n * @example\n * ```tsx\n * import { useIntlayer } from 'preact-intlayer';\n *\n * const MyComponent = () => {\n * const content = useIntlayer('my-dictionary-key');\n *\n * return <div>{content.myField.value}</div>;\n * };\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: L\n) => {\n const { locale: currentLocale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(() => {\n const localeTarget = locale ?? currentLocale;\n\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n return getIntlayer<T, L>(key, localeTarget as L) as DeepTransformContent<\n DictionaryRegistryContent<T>\n >;\n }, [key, currentLocale, locale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,eACX,KACA,WACG;CACH,MAAM,EAAE,QAAQ,+CAA6BA,qDAAqB,KAAK,CAAC;CAExE,uCAAqB;EAInB,OAAOC,gCAAkB,KAHJ,UAAU,aAGgB;CAGjD,GAAG;EAAC;EAAK;EAAe;CAAM,CAAC;AACjC"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";;;AAEA,MAAM,mBAAsB,YAAwB;CAClD,IAAI,SAAiB;CACrB,IAAI;CACJ,MAAM,YAAY,QAAQ,MACvB,MAAM;EACL,SAAS;EACT,SAAS;KAEV,MAAM;EACL,SAAS;EACT,SAAS;GAEZ;CAED,OAAO,EACL,OAAO;EACL,IAAI,WAAW,WAAW,MAAM;EAChC,IAAI,WAAW,SAAS,MAAM;EAC9B,OAAO;IAEV;;AAGH,MAAM,wBAAQ,IAAI,KAAiD;AAEnE,MAAa,kBAAqB,KAAa,YAA2B;CACxE,IAAI,CAAC,MAAM,IAAI,IAAI,EACjB,MAAM,IAAI,KAAK,gBAAgB,QAAQ,CAAC;CAG1C,OAAQ,MAAM,IAAI,IAAI,CAAyC,MAAM"}
1
+ {"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["type Status = 'pending' | 'success' | 'error';\n\nconst createSuspender = <T>(promise: Promise<T>) => {\n let status: Status = 'pending';\n let result: T;\n const suspender = promise.then(\n (r) => {\n status = 'success';\n result = r;\n },\n (e) => {\n status = 'error';\n result = e as any;\n }\n );\n\n return {\n read() {\n if (status === 'pending') throw suspender;\n if (status === 'error') throw result;\n return result!;\n },\n };\n};\n\nconst cache = new Map<string, ReturnType<typeof createSuspender>>();\n\nexport const useLoadDynamic = <T>(key: string, promise: Promise<T>): T => {\n if (!cache.has(key)) {\n cache.set(key, createSuspender(promise));\n }\n\n return (cache.get(key)! as ReturnType<typeof createSuspender>).read() as T;\n};\n"],"mappings":";;;AAEA,MAAM,mBAAsB,YAAwB;CAClD,IAAI,SAAiB;CACrB,IAAI;CACJ,MAAM,YAAY,QAAQ,MACvB,MAAM;EACL,SAAS;EACT,SAAS;CACX,IACC,MAAM;EACL,SAAS;EACT,SAAS;CACX,CACF;CAEA,OAAO,EACL,OAAO;EACL,IAAI,WAAW,WAAW,MAAM;EAChC,IAAI,WAAW,SAAS,MAAM;EAC9B,OAAO;CACT,EACF;AACF;AAEA,MAAM,wBAAQ,IAAI,IAAgD;AAElE,MAAa,kBAAqB,KAAa,YAA2B;CACxE,IAAI,CAAC,MAAM,IAAI,GAAG,GAChB,MAAM,IAAI,KAAK,gBAAgB,OAAO,CAAC;CAGzC,OAAQ,MAAM,IAAI,GAAG,EAA0C,KAAK;AACtE"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocale.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,aAAa,EACxB,iBACA,mBACkB,EAAE,KAAsB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,EAAE;CAE5B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,wDACJC,sDAAsB,IAAI,EAAE;CAE3C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,OAAO,CAAC,SAAS,OAAO,EAAE;GACnD,QAAQ,MAAM,UAAU,OAAO,mBAAmB;GAClD;;EAGF,eAAe,OAAO;EAEtB,mDACE,QACA,mBAAmB,0BAA0B,KAC9C;EAED,iBAAiB,OAA0B;;CAG7C,OAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocale.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype UseLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: DeclaredLocales) => void;\n};\n\ntype UseLocaleResult = {\n locale: DeclaredLocales;\n defaultLocale: DeclaredLocales;\n availableLocales: DeclaredLocales[];\n setLocale: (locale: LocalesValues) => void;\n};\n\n/**\n * Preact hook to get the current locale and related locale management functions.\n *\n * @param props - Optional properties for the hook.\n * @returns An object containing the current locale, default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```tsx\n * import { useLocale } from 'preact-intlayer';\n *\n * const LocaleSwitcher = () => {\n * const { locale, setLocale, availableLocales } = useLocale();\n *\n * return (\n * <select value={locale} onChange={(e) => setLocale(e.target.value)}>\n * {availableLocales.map((loc) => (\n * <option key={loc} value={loc}>{loc}</option>\n * ))}\n * </select>\n * );\n * };\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: UseLocaleProps = {}): UseLocaleResult => {\n const { defaultLocale, locales: availableLocales } =\n internationalization ?? {};\n\n const {\n locale,\n setLocale: setLocaleState,\n isCookieEnabled: isCookieEnabledContext,\n } = useContext(IntlayerClientContext) ?? {};\n\n const setLocale = (locale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(locale)) {\n console.error(`Locale ${locale} is not available`);\n return;\n }\n\n setLocaleState(locale);\n\n setLocaleInStorage(\n locale,\n isCookieEnabled ?? isCookieEnabledContext ?? true\n );\n\n onLocaleChange?.(locale as DeclaredLocales);\n };\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n } as UseLocaleResult;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,aAAa,EACxB,iBACA,mBACkB,CAAC,MAAuB;CAC1C,MAAM,EAAE,eAAe,SAAS,qBAC9BA,+CAAwB,CAAC;CAE3B,MAAM,EACJ,QACA,WAAW,gBACX,iBAAiB,wDACJC,qDAAqB,KAAK,CAAC;CAE1C,MAAM,aAAa,WAA0B;EAC3C,IAAI,CAAC,kBAAkB,IAAI,MAAM,EAAE,SAAS,MAAM,GAAG;GACnD,QAAQ,MAAM,UAAU,OAAO,kBAAkB;GACjD;EACF;EAEA,eAAe,MAAM;EAErB,mDACE,QACA,mBAAmB,0BAA0B,IAC/C;EAEA,iBAAiB,MAAyB;CAC5C;CAEA,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleBase.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,EAAE,eAAe,SAAS,qBAAqBA;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,2CAAyBC,sDAAsB,IAAI,EAAE;CAErE,OAAO;EACL;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"useLocaleBase.cjs","names":["internationalization","IntlayerClientContext"],"sources":["../../../src/client/useLocaleBase.ts"],"sourcesContent":["import { internationalization } from '@intlayer/config/built';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\nconst { defaultLocale, locales: availableLocales } = internationalization;\n\n/**\n * On the client side, hook to get the current locale and all related fields\n */\nexport const useLocaleBase = () => {\n const { locale, setLocale } = useContext(IntlayerClientContext) ?? {};\n\n return {\n locale, // Current locale\n defaultLocale, // Principal locale defined in config\n availableLocales, // List of the available locales defined in config\n setLocale, // Function to set the locale\n };\n};\n"],"mappings":";;;;;;;AAIA,MAAM,EAAE,eAAe,SAAS,qBAAqBA;;;;AAKrD,MAAa,sBAAsB;CACjC,MAAM,EAAE,QAAQ,2CAAyBC,qDAAqB,KAAK,CAAC;CAEpE,OAAO;EACL;EACA;EACA;EACA;CACF;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'preact/hooks';\n\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":";;;;;;;;;;AAYA,MAAa,uEAA6CA,iDAAqB;;;;;;AAM/E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,uEAEuB,QAAQ;CAC7B,GAAGA;CACH;CACD,CAAC;;;;;;AAOJ,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,kGAGP;CAClB,GAAGA;CACH;CACD,CAAC,EACJ,CAAC,gBAAgB,CAClB;;;;;;;;AASH,MAAa,kBAAkB"}
1
+ {"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorageClient,\n LocaleStorageClient,\n setLocaleInStorageClient as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useMemo } from 'preact/hooks';\n\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorageClient(localeStorageOptions);\n/**\n * @deprecated Use localeInStorage instead\n *\n * Get the locale cookie\n */\nexport const localeCookie = localeInStorage;\n\n/**\n * Set the locale cookie\n */\nexport const setLocaleInStorage = (\n locale: LocalesValues,\n isCookieEnabled: boolean\n) =>\n setLocaleInStorageCore(locale, {\n ...localeStorageOptions,\n isCookieEnabled,\n });\n\n/**\n * @deprecated Use setLocaleInStorage instead\n *\n * Set the locale cookie\n */\nexport const setLocaleCookie = setLocaleInStorage;\n\n/**\n * Hook that provides the locale storage and a function to set it\n */\nexport const useLocaleStorage = (isCookieEnabled?: boolean) =>\n useMemo(\n () =>\n LocaleStorageClient({\n ...localeStorageOptions,\n isCookieEnabled,\n }),\n [isCookieEnabled]\n );\n\n/**\n * @deprecated Use useLocaleStorage instead\n *\n * For GDPR compliance, use useLocaleStorage instead\n *\n * Hook that provides the locale cookie and a function to set it\n */\nexport const useLocaleCookie = useLocaleStorage;\n"],"mappings":";;;;;;;;;;AAYA,MAAa,uEAA6CA,gDAAoB;;;;;;AAM9E,MAAa,eAAe;;;;AAK5B,MAAa,sBACX,QACA,uEAEuB,QAAQ;CAC7B,GAAGA;CACH;AACF,CAAC;;;;;;AAOH,MAAa,kBAAkB;;;;AAK/B,MAAa,oBAAoB,kGAGP;CAClB,GAAGA;CACH;AACF,CAAC,GACH,CAAC,eAAe,CAClB;;;;;;;;AASF,MAAa,kBAAkB"}
@@ -1 +1 @@
1
- {"version":3,"file":"useTraduction.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sFACuB,iBAAiB,OAAO,EAC7C,CAAC,iBAAiB,OAAO,CAC1B"}
1
+ {"version":3,"file":"useTraduction.cjs","names":["IntlayerClientContext"],"sources":["../../../src/client/useTraduction.ts"],"sourcesContent":["import { getTranslation } from '@intlayer/core/interpreter';\nimport type { StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from './IntlayerProvider';\n\n/**\n * On the client side, Hook that picking one dictionary by its id and return the content.\n *\n * If not locale found, it will return the content related to the default locale.\n *\n * Return either the content editor, or the content itself depending on the configuration.\n *\n * Usage:\n *\n * ```tsx\n * const content = useTranslation<string>({\n * en: 'Hello',\n * fr: 'Bonjour',\n * }, 'fr');\n * // 'Bonjour'\n * ```\n *\n * Using TypeScript:\n * - this function will require each locale to be defined if defined in the project configuration.\n * - If a locale is missing, it will make each existing locale optional and raise an error if the locale is not found.\n */\nexport const useTranslation = <Content = string>(\n languageContent: StrictModeLocaleMap<Content>\n): Content => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useMemo(\n () => getTranslation(languageContent, locale),\n [languageContent, locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBACX,oBACY;CACZ,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sFACuB,iBAAiB,MAAM,GAC5C,CAAC,iBAAiB,MAAM,CAC1B;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"ContentSelector.cjs","names":["isEnabled"],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !isEnabled ||\n typeof window === 'undefined'\n )\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":";;;;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;CAC5C,kCAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAACA,wCACD,OAAO,WAAW,aAElB;EACF,OAAO,oBAAoB,MAAM,EAAE,6BAA6B;GAC9D,wBAAwB;IACxB;IACD,CAACA,qCAAU,CAAC;CAEf,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,sCACzD,OAAO;CAGT,OACE,4CAAC,qCAAD;EACE,YAAU,KAAK,UAAU,QAAQ;EACjC,kBAAgB;EAEf;EACiC"}
1
+ {"version":3,"file":"ContentSelector.cjs","names":["isEnabled"],"sources":["../../../src/editor/ContentSelector.tsx"],"sourcesContent":["import type { NodeProps } from '@intlayer/core/interpreter';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { FunctionalComponent, HTMLAttributes } from 'preact';\nimport { useEffect } from 'preact/hooks';\n\n// JSX declaration for the Lit web component in Preact\ndeclare module 'preact' {\n namespace JSX {\n interface IntrinsicElements {\n 'intlayer-content-selector-wrapper': HTMLAttributes<HTMLElement> & {\n 'key-path'?: string;\n 'dictionary-key'?: string;\n };\n }\n }\n}\n\nexport type ContentSelectorWrapperProps = NodeProps &\n Omit<HTMLAttributes<HTMLDivElement>, 'children'>;\n\nexport const ContentSelector: FunctionalComponent<\n ContentSelectorWrapperProps\n> = ({ children, dictionaryKey, keyPath }) => {\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !isEnabled ||\n typeof window === 'undefined'\n )\n return;\n import('@intlayer/editor').then(({ defineIntlayerElements }) => {\n defineIntlayerElements();\n });\n }, [isEnabled]);\n\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled) {\n return children;\n }\n\n return (\n <intlayer-content-selector-wrapper\n key-path={JSON.stringify(keyPath)}\n dictionary-key={dictionaryKey}\n >\n {children}\n </intlayer-content-selector-wrapper>\n );\n};\n"],"mappings":";;;;;;;AAoBA,MAAa,mBAER,EAAE,UAAU,eAAe,cAAc;CAC5C,kCAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAACA,wCACD,OAAO,WAAW,aAElB;EACF,OAAO,oBAAoB,MAAM,EAAE,6BAA6B;GAC9D,uBAAuB;EACzB,CAAC;CACH,GAAG,CAACA,oCAAS,CAAC;CAEd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACA,sCACzD,OAAO;CAGT,OACE,4CAAC,qCAAD;EACE,YAAU,KAAK,UAAU,OAAO;EAChC,kBAAgB;EAEf;CACgC;AAEvC"}
@@ -1 +1 @@
1
- {"version":3,"file":"EditorProvider.cjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["import type { ComponentChild, FunctionComponent } from 'preact';\nimport { useEditor } from './useEditor';\n\nexport const EditorProvider: FunctionComponent<{\n children?: ComponentChild;\n}> = ({ children }) => {\n useEditor();\n\n return children;\n};\n"],"mappings":";;;;AAGA,MAAa,kBAEP,EAAE,eAAe;CACrB,oCAAW;CAEX,OAAO"}
1
+ {"version":3,"file":"EditorProvider.cjs","names":[],"sources":["../../../src/editor/EditorProvider.tsx"],"sourcesContent":["import type { ComponentChild, FunctionComponent } from 'preact';\nimport { useEditor } from './useEditor';\n\nexport const EditorProvider: FunctionComponent<{\n children?: ComponentChild;\n}> = ({ children }) => {\n useEditor();\n\n return children;\n};\n"],"mappings":";;;;AAGA,MAAa,kBAEP,EAAE,eAAe;CACrB,mCAAU;CAEV,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !locale ||\n !managerRef.current\n )\n return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAC1D,MAAM,sCAA+C,KAAK;CAE1D,kCAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACC,sCACzD;EAEF,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,kBAAkB;GAClC,WAAW,UAAU;GAErB,IAAI,QAAQ,QAAQ,cAAc,IAAI,OAAiB;IACvD;EAEF,aAAa;GACX,WAAW,UAAU;GACrB,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;IACxD,kBAAkB;KAClB;;IAEH,EAAE,CAAC;CAEN,kCAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,UACD,CAAC,WAAW,SAEZ;EAEF,WAAW,QAAQ,cAAc,IAAI,OAAiB;IACrD,CAAC,OAAO,CAAC"}
1
+ {"version":3,"file":"useEditor.cjs","names":["IntlayerClientContext","isEnabled"],"sources":["../../../src/editor/useEditor.tsx"],"sourcesContent":["import type { EditorStateManager } from '@intlayer/editor';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { useContext, useEffect, useRef } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Initialises the Intlayer editor client singleton when the editor is enabled.\n * Syncs the current locale from the Intlayer context into the editor manager so\n * the editor always knows which locale the app is displaying.\n */\nexport const useEditor = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n const managerRef = useRef<EditorStateManager | null>(null);\n\n useEffect(() => {\n if (process.env['INTLAYER_EDITOR_ENABLED'] === 'false' || !isEnabled)\n return;\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n managerRef.current = manager;\n\n if (locale) manager.currentLocale.set(locale as Locale);\n });\n\n return () => {\n managerRef.current = null;\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n };\n }, []);\n\n useEffect(() => {\n if (\n process.env['INTLAYER_EDITOR_ENABLED'] === 'false' ||\n !locale ||\n !managerRef.current\n )\n return;\n\n managerRef.current.currentLocale.set(locale as Locale);\n }, [locale]);\n};\n"],"mappings":";;;;;;;;;;;;AAWA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CACzD,MAAM,sCAA+C,IAAI;CAEzD,kCAAgB;EACd,IAAI,QAAQ,IAAI,+BAA+B,WAAW,CAACC,sCACzD;EAEF,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;GACxD,MAAM,UAAU,iBAAiB;GACjC,WAAW,UAAU;GAErB,IAAI,QAAQ,QAAQ,cAAc,IAAI,MAAgB;EACxD,CAAC;EAED,aAAa;GACX,WAAW,UAAU;GACrB,OAAO,oBAAoB,MAAM,EAAE,uBAAuB;IACxD,iBAAiB;GACnB,CAAC;EACH;CACF,GAAG,CAAC,CAAC;CAEL,kCAAgB;EACd,IACE,QAAQ,IAAI,+BAA+B,WAC3C,CAAC,UACD,CAAC,WAAW,SAEZ;EAEF,WAAW,QAAQ,cAAc,IAAI,MAAgB;CACvD,GAAG,CAAC,MAAM,CAAC;AACb"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCompact.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,gDACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCompact.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useCompact.ts"],"sourcesContent":["import { compact } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a compact number formatter\n * bound to the current application locale.\n *\n * @example\n * ```tsx\n * const formatCompact = useCompact();\n * formatCompact(1500); // \"1.5K\"\n * ```\n */\nexport const useCompact = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof compact>) =>\n compact(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAa,mBAAmB;CAC9B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,gDACM,KAAK,IAAI;EACf,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useCurrency.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,iDACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useCurrency.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useCurrency.ts"],"sourcesContent":["import { currency } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a currency formatter\n * bound to the current application locale.\n *\n * @returns {(value: string | number, options?: CurrencyProps) => string}\n * A function to format numbers into localized currency strings.\n *\n * @example\n * ```tsx\n * const formatCurrency = useCurrency();\n *\n * formatCurrency(1500, { currency: \"USD\" });\n * // \"$1,500.00\"\n *\n * formatCurrency(1500, { currency: \"EUR\", locale: \"de-DE\" });\n * // \"1.500,00 €\"\n *\n * formatCurrency(9876543.21, {\n * currency: \"JPY\",\n * fractionDigits: 0,\n * });\n * // \"¥9,876,543\"\n * ```\n */\nexport const useCurrency = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof currency>) =>\n currency(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAa,oBAAoB;CAC/B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,iDACO,KAAK,IAAI;EAChB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDate.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,QAAQ,GAAG,6CACJ,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC"}
1
+ {"version":3,"file":"useDate.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useDate.ts"],"sourcesContent":["import { date } from '@intlayer/core/formatters';\nimport { useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized date/time formatter\n * bound to the current application locale.\n *\n * @returns {(date: Date | string | number, options?: DateProps) => string}\n * A function to format dates or timestamps into localized date/time strings.\n *\n * @example\n * ```tsx\n * const formatDate = useDate();\n *\n * formatDate(new Date(\"2025-01-01\"));\n * // \"Jan 1, 2025\"\n *\n * formatDate(\"2025-01-01T15:30:00Z\", {\n * dateStyle: \"full\",\n * timeStyle: \"short\",\n * });\n * // \"Wednesday, January 1, 2025 at 3:30 PM\"\n *\n * formatDate(1735689600000, { locale: \"fr-FR\", dateStyle: \"long\" });\n * // \"1 janvier 2025\"\n * ```\n *\n * @see createDate\n */\nexport const useDate = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return (...args: Parameters<typeof date>) =>\n date(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,QAAQ,GAAG,6CACJ,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC;AACL"}
@@ -1 +1 @@
1
- {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Preact client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,+CAA6BA,sDAAsB,IAAI,EAAE;CACzE,MAAM,gBAAgB,UAAU;CAEhC,+EAA2C,cAAc,EAAE,CAAC,cAAc,CAAC"}
1
+ {"version":3,"file":"useIntl.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useIntl.ts"],"sourcesContent":["import { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { useContext, useMemo } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Preact client hook that provides a locale-bound `Intl` object.\n *\n * It acts exactly like the native `Intl` object, but acts as a proxy to:\n * 1. Inject the current locale automatically if none is provided.\n * 2. Use the performance-optimized `CachedIntl` under the hood.\n *\n * @example\n * ```tsx\n * const intl = useIntl(); // uses context locale\n *\n * // Standard API, but no need to pass locale as the first argument\n * const formatted = new intl.NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45);\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const { locale: contextLocale } = useContext(IntlayerClientContext) ?? {};\n const currentLocale = locale ?? contextLocale;\n\n return useMemo<WrappedIntl>(() => bindIntl(currentLocale), [currentLocale]);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,WAAW,WAA2B;CACjD,MAAM,EAAE,QAAQ,+CAA6BA,qDAAqB,KAAK,CAAC;CACxE,MAAM,gBAAgB,UAAU;CAEhC,+EAA2C,aAAa,GAAG,CAAC,aAAa,CAAC;AAC5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"useList.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,6CACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useList.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useList.ts"],"sourcesContent":["import { list } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a list formatter\n * bound to the current application locale.\n *\n * @returns {(values: (string | number)[], options?: ListProps) => string}\n * A function to format arrays into localized list strings.\n *\n * @example\n * ```tsx\n * const formatList = useList();\n *\n * formatList(['apple', 'banana', 'orange']);\n * // \"apple, banana, and orange\"\n *\n * formatList(['red', 'green', 'blue'], { type: 'disjunction' });\n * // \"red, green, or blue\"\n *\n * formatList([1, 2, 3], { type: 'unit', locale: 'de-DE' });\n * // \"1, 2 und 3\"\n * ```\n */\nexport const useList = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof list>) =>\n list(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,6CACG,KAAK,IAAI;EACZ,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useNumber.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,+CACK,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useNumber.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useNumber.ts"],"sourcesContent":["import { number } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React client hook that provides a localized number formatter.\n *\n * Uses the current locale from {@link useLocaleBase} and returns\n * a function that can be used to format numbers consistently\n * according to the user's locale.\n *\n * @example\n * ```tsx\n * const formatNumber = useNumber();\n *\n * formatNumber(12345);\n * // e.g. \"12,345\" (en-US)\n * // e.g. \"12 345\" (fr-FR)\n *\n * formatNumber(0.75, { style: \"percent\" });\n * // e.g. \"75%\"\n * ```\n *\n * @returns {(value: string | number, options?: import(\"../createNumber\").NumberProps) => string}\n * A number formatting function bound to the active locale.\n */\nexport const useNumber = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof number>) =>\n number(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,MAAa,kBAAkB;CAC7B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,+CACK,KAAK,IAAI;EACd,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"usePercentage.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,mDACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"usePercentage.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/usePercentage.ts"],"sourcesContent":["import { percentage } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook to provide a percentage formatter function\n * based on the current application locale.\n *\n * This hook retrieves the active locale using {@link useLocaleBase}\n * and memoizes a `createPercentage` instance for that locale.\n *\n * @example\n * ```tsx\n * const formatPercentage = usePercentage();\n *\n * const result = formatPercentage(0.875, { maximumFractionDigits: 1 });\n * // \"87.5%\" (depending on locale)\n * ```\n *\n * @returns {(value: string | number, options?: Omit<PercentageOptions, \"value\">) => string}\n * A function that formats numbers or numeric strings into localized percentages.\n */\nexport const usePercentage = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof percentage>) =>\n percentage(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,sBAAsB;CACjC,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,mDACS,KAAK,IAAI;EAClB,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useRelativeTime.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,qDACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useRelativeTime.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useRelativeTime.ts"],"sourcesContent":["import { relativeTime } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * Client-side React hook for accessing a localized relative time formatter.\n *\n * This hook:\n * - Reads the current locale from {@link useLocaleBase}.\n * - Creates a new relative time formatter with {@link createRelativeTime}.\n * - Returns a function that can format time differences into localized strings.\n *\n * Example:\n * ```tsx\n * const relativeTime = useRelativeTime();\n * const formatted = relativeTime(new Date(\"2024-08-01\"), new Date());\n * // e.g., \"2 weeks ago\"\n * ```\n *\n * @returns {ReturnType<typeof createRelativeTime>} A relative time formatting function\n * bound to the current client locale.\n */\nexport const useRelativeTime = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof relativeTime>) =>\n relativeTime(args[0], args[1], {\n ...args[2],\n locale: args[2]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,MAAa,wBAAwB;CACnC,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,qDACW,KAAK,IAAI,KAAK,IAAI;EAC7B,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useUnit.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,sDAAsB,IAAI,EAAE;CAE1D,sCACG,GAAG,8CACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;EAC5B,CAAC,EACJ,CAAC,OAAO,CACT"}
1
+ {"version":3,"file":"useUnit.cjs","names":["IntlayerClientContext"],"sources":["../../../src/format/useUnit.ts"],"sourcesContent":["import { units } from '@intlayer/core/formatters';\nimport { useCallback, useContext } from 'preact/hooks';\nimport { IntlayerClientContext } from '../client/IntlayerProvider';\n\n/**\n * React hook that provides a unit formatting function\n * based on the current locale from {@link useLocaleBase}.\n *\n * This hook wraps {@link createUnit} to return a formatter\n * that can convert values into human-readable localized units\n * (e.g., \"10 km\", \"5 lbs\").\n *\n * @example\n * ```tsx\n * const formatUnit = useUnit();\n * const distance = formatUnit(10, { unit: \"kilometer\" });\n * // \"10 km\" (depending on locale)\n * ```\n *\n * @returns {Function} A unit formatting function that accepts a value and optional formatting options.\n */\nexport const useUnit = () => {\n const { locale } = useContext(IntlayerClientContext) ?? {};\n\n return useCallback(\n (...args: Parameters<typeof units>) =>\n units(args[0], {\n ...args[1],\n locale: args[1]?.locale ?? locale,\n }),\n [locale]\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAqBA,MAAa,gBAAgB;CAC3B,MAAM,EAAE,wCAAsBA,qDAAqB,KAAK,CAAC;CAEzD,sCACG,GAAG,8CACI,KAAK,IAAI;EACb,GAAG,KAAK;EACR,QAAQ,KAAK,IAAI,UAAU;CAC7B,CAAC,GACH,CAAC,MAAM,CACT;AACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content']> =>\n getDictionaryCore<T, L>(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;;;AAQA,MAAa,iBAIX,YACA,yDAEwB,YAAY,QAAQA,2BAAW,OAAO,CAAC"}
1
+ {"version":3,"file":"getDictionary.cjs","names":["getPlugins"],"sources":["../../src/getDictionary.ts"],"sourcesContent":["import { getDictionary as getDictionaryCore } from '@intlayer/core/interpreter';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n): DeepTransformContent<T['content']> =>\n getDictionaryCore<T, L>(dictionary, locale, getPlugins(locale)) as any;\n"],"mappings":";;;;;;AAQA,MAAa,iBAIX,YACA,yDAEwB,YAAY,QAAQA,2BAAW,MAAM,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) =>\n getIntlayerCore<T, L>(\n key,\n locale,\n getPlugins(locale)\n ) as DeepTransformContent<DictionaryRegistryContent<T>>;\n"],"mappings":";;;;;;AASA,MAAa,eAIX,KACA,uDAGE,KACA,QACAA,2BAAW,OAAO,CACnB"}
1
+ {"version":3,"file":"getIntlayer.cjs","names":["getPlugins"],"sources":["../../src/getIntlayer.ts"],"sourcesContent":["import { getIntlayer as getIntlayerCore } from '@intlayer/core/interpreter';\nimport type {\n DeclaredLocales,\n DictionaryKeys,\n DictionaryRegistryContent,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { type DeepTransformContent, getPlugins } from './plugins';\n\nexport const getIntlayer = <\n T extends DictionaryKeys,\n L extends LocalesValues = DeclaredLocales,\n>(\n key: T,\n locale?: L\n) =>\n getIntlayerCore<T, L>(\n key,\n locale,\n getPlugins(locale)\n ) as DeepTransformContent<DictionaryRegistryContent<T>>;\n"],"mappings":";;;;;;AASA,MAAa,eAIX,KACA,uDAGE,KACA,QACAA,2BAAW,MAAM,CACnB"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLProvider.cjs","names":[],"sources":["../../../src/html/HTMLProvider.tsx"],"sourcesContent":["import {\n createContext,\n type FunctionalComponent,\n type RenderableProps,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from './types';\n\ntype HTMLContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n};\n\ntype HTMLProviderProps = RenderableProps<{\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n}>;\n\nconst HTMLContext = createContext<HTMLContextValue | undefined>(undefined);\n\nexport const useHTMLContext = () => useContext(HTMLContext);\n\nexport const HTMLProvider: FunctionalComponent<HTMLProviderProps> = ({\n children,\n components,\n}) => (\n <HTMLContext.Provider value={{ components }}>{children}</HTMLContext.Provider>\n);\n"],"mappings":";;;;;;;AAmBA,MAAM,wCAA0D,OAAU;AAE1E,MAAa,oDAAkC,YAAY;AAE3D,MAAa,gBAAwD,EACnE,UACA,iBAEA,4CAAC,YAAY,UAAb;CAAsB,OAAO,EAAE,YAAY;CAAG;CAAgC"}
1
+ {"version":3,"file":"HTMLProvider.cjs","names":[],"sources":["../../../src/html/HTMLProvider.tsx"],"sourcesContent":["import {\n createContext,\n type FunctionalComponent,\n type RenderableProps,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from './types';\n\ntype HTMLContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n};\n\ntype HTMLProviderProps = RenderableProps<{\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n}>;\n\nconst HTMLContext = createContext<HTMLContextValue | undefined>(undefined);\n\nexport const useHTMLContext = () => useContext(HTMLContext);\n\nexport const HTMLProvider: FunctionalComponent<HTMLProviderProps> = ({\n children,\n components,\n}) => (\n <HTMLContext.Provider value={{ components }}>{children}</HTMLContext.Provider>\n);\n"],"mappings":";;;;;;;AAmBA,MAAM,wCAA0D,MAAS;AAEzE,MAAa,oDAAkC,WAAW;AAE1D,MAAa,gBAAwD,EACnE,UACA,iBAEA,4CAAC,YAAY,UAAb;CAAsB,OAAO,EAAE,WAAW;CAAI;AAA+B"}
@@ -1 +1 @@
1
- {"version":3,"file":"HTMLRenderer.cjs","names":["Fragment","useHTMLContext"],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,EAAE,KAAsB,EAAE,KACzB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,WAAW,CACvB,QAAQ,GAAG,eAAe,UAAU,CACpC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,wBAAiB,WAAkB,MAAM,CAC3C,CAAC,CACL;CAiBD,qBAASA,iBAAU,8CAAc,SAAS,IAdZ,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;EAChB,IAAI,OAAO,SAAS,YAAY,QAAQ,QACtC,OAAO,OAAO;EAGhB,IAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,KAAK,EAC3D,QAAQ,wBAAiB,MAAM,MAAM;IAI1C,CAG0D,CAAQ,CAAC;;;;;;;;AAStE,MAAa,mBAAmB,EAAE,eAAgC,EAAE,KAAK;CACvE,MAAM,UAAUC,0CAAgB;CAEhC,QAAQ,YAAoB;EAC1B,OAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;GACJ,EACF,CAAC;;;;;;AAwBN,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;CAIJ,OAHe,gBAAgB,EAAE,YAAY,CAGhC,CAFG,YAAY,QAAQ,GAEd"}
1
+ {"version":3,"file":"HTMLRenderer.cjs","names":["Fragment","useHTMLContext"],"sources":["../../../src/html/HTMLRenderer.tsx"],"sourcesContent":["import { getHTML } from '@intlayer/core/interpreter';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport { Fragment, type FunctionComponent, h, type JSX } from 'preact';\nimport { useHTMLContext } from './HTMLProvider';\nimport type { HTMLComponents } from './types';\n\nexport type RenderHTMLProps = {\n /**\n * Component overrides for HTML tags.\n * Allows you to customize how specific HTML elements are rendered.\n */\n components?: HTMLComponents<'permissive', {}>;\n};\n\n/**\n * Renders HTML-like content to JSX with the provided components.\n *\n * This function does not use context from HTMLProvider. Use `useHTMLRenderer`\n * hook if you want to leverage provider context.\n */\nexport const renderHTML = (\n content: string,\n { components = {} }: RenderHTMLProps = {}\n): JSX.Element => {\n // Wrap explicit user components to ensure they are rendered via Preact's h\n const userComponents = Object.fromEntries(\n Object.entries(components)\n .filter(([, Component]) => Component)\n .map(([key, Component]) => [\n key,\n (props: any) => h(Component as any, props),\n ])\n );\n\n // Proxy handles standard HTML tags lazily without a hardcoded list\n const wrappedComponents = new Proxy(userComponents, {\n get(target, prop) {\n if (typeof prop === 'string' && prop in target) {\n return target[prop];\n }\n // Fallback: Lazily generate a wrapper for standard lowercase HTML tags\n if (typeof prop === 'string' && /^[a-z][a-z0-9]*$/.test(prop)) {\n return (props: any) => h(prop, props);\n }\n return undefined;\n },\n });\n\n // Cast wrappedComponents to any to satisfy getHTML's dictionary typing\n return h(Fragment, null, getHTML(content, wrappedComponents as any));\n};\n\n/**\n * Hook that returns a function to render HTML content.\n *\n * This hook considers the configuration from the `HTMLProvider` context if available,\n * falling back to the provided components.\n */\nexport const useHTMLRenderer = ({ components }: RenderHTMLProps = {}) => {\n const context = useHTMLContext();\n\n return (content: string) => {\n return renderHTML(content, {\n components: {\n ...context?.components,\n ...components,\n },\n });\n };\n};\n\nexport type HTMLRendererProps = RenderHTMLProps & {\n /**\n * The HTML content to render as a string.\n */\n children?: string;\n /**\n * Alias for children, used by the plugin.\n */\n html?: string;\n /**\n * Alias for components, used by the plugin.\n */\n components?: HTMLComponents<'permissive', {}>;\n dictionaryKey?: string;\n keyPath?: KeyPath[];\n};\n\n/**\n * Preact component that renders HTML-like content to JSX.\n */\nexport const HTMLRenderer: FunctionComponent<HTMLRendererProps> = ({\n children = '',\n html,\n components,\n}) => {\n const render = useHTMLRenderer({ components });\n const content = children || html || '';\n\n return render(content);\n};\n"],"mappings":";;;;;;;;;;;;;AAoBA,MAAa,cACX,SACA,EAAE,aAAa,CAAC,MAAuB,CAAC,MACxB;CAEhB,MAAM,iBAAiB,OAAO,YAC5B,OAAO,QAAQ,UAAU,EACtB,QAAQ,GAAG,eAAe,SAAS,EACnC,KAAK,CAAC,KAAK,eAAe,CACzB,MACC,wBAAiB,WAAkB,KAAK,CAC3C,CAAC,CACL;CAiBA,qBAASA,iBAAU,8CAAc,SAAS,IAdZ,MAAM,gBAAgB,EAClD,IAAI,QAAQ,MAAM;EAChB,IAAI,OAAO,SAAS,YAAY,QAAQ,QACtC,OAAO,OAAO;EAGhB,IAAI,OAAO,SAAS,YAAY,mBAAmB,KAAK,IAAI,GAC1D,QAAQ,wBAAiB,MAAM,KAAK;CAGxC,EACF,CAG0D,CAAQ,CAAC;AACrE;;;;;;;AAQA,MAAa,mBAAmB,EAAE,eAAgC,CAAC,MAAM;CACvE,MAAM,UAAUC,yCAAe;CAE/B,QAAQ,YAAoB;EAC1B,OAAO,WAAW,SAAS,EACzB,YAAY;GACV,GAAG,SAAS;GACZ,GAAG;EACL,EACF,CAAC;CACH;AACF;;;;AAsBA,MAAa,gBAAsD,EACjE,WAAW,IACX,MACA,iBACI;CAIJ,OAHe,gBAAgB,EAAE,WAAW,CAGhC,EAFI,YAAY,QAAQ,EAEf;AACvB"}
@@ -1,4 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
2
3
  const require_getIntlayer = require('./getIntlayer.cjs');
3
4
  const require_getDictionary = require('./getDictionary.cjs');
4
5
  const require_client_useLocaleStorage = require('./client/useLocaleStorage.cjs');
@@ -6,7 +7,6 @@ const require_client_IntlayerProvider = require('./client/IntlayerProvider.cjs')
6
7
  const require_client_t = require('./client/t.cjs');
7
8
  const require_client_useDictionary = require('./client/useDictionary.cjs');
8
9
  const require_client_useDictionaryAsync = require('./client/useDictionaryAsync.cjs');
9
- const require_client_useLoadDynamic = require('./client/useLoadDynamic.cjs');
10
10
  const require_client_useDictionaryDynamic = require('./client/useDictionaryDynamic.cjs');
11
11
  const require_client_useIntlayer = require('./client/useIntlayer.cjs');
12
12
  const require_client_useLocale = require('./client/useLocale.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownProvider.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AA0EA,MAAM,4CACJ,OACD;AAED,MAAa,wDAAsC,gBAAgB;AAEnE,MAAM,gBACJ,gBACA,aACA,UAAmC,EAAE,EACrC,aAA+C,EAAE,EACjD,YAC0B;CAC1B,OAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;GAAY;EACjD;;AAGH,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;EACD;CAGD,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;EAQtB,OAAOA,0CAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,EAAE,EACxB,gBAE4C,CAAC;;CAKjD,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,4CAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,gBAAgB;EAChD;CAG7B,OACE,4CAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;GACL;EAEA;EACwB"}
1
+ {"version":3,"file":"MarkdownProvider.cjs","names":["compileMarkdown"],"sources":["../../../src/markdown/MarkdownProvider.tsx"],"sourcesContent":["import {\n type ComponentChildren,\n type ComponentType,\n createContext,\n type FunctionComponent,\n type JSX,\n} from 'preact';\nimport { useContext } from 'preact/hooks';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown } from './compiler';\n\ntype PropsWithChildren<P = {}> = P & { children?: ComponentChildren };\n\n/**\n * Refined options for the MarkdownProvider.\n */\nexport type MarkdownProviderOptions = {\n /**\n * Forces the compiler to always output content with a block-level wrapper.\n */\n forceBlock?: boolean;\n /**\n * Forces the compiler to always output content with an inline wrapper.\n */\n forceInline?: boolean;\n /**\n * Whether to preserve frontmatter in the markdown content.\n */\n preserveFrontmatter?: boolean;\n /**\n * Whether to use the GitHub Tag Filter.\n */\n tagfilter?: boolean;\n};\n\ntype RenderMarkdownOptions = MarkdownProviderOptions & {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceWrapper?: boolean;\n};\n\ntype MarkdownContextValue = {\n components?: HTMLComponents<'permissive', {}>;\n renderMarkdown: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\ntype MarkdownProviderProps = PropsWithChildren<\n MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite all rules and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: MarkdownProviderOptions,\n components?: HTMLComponents<'permissive', {}>,\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n ) => ComponentChildren | Promise<ComponentChildren>;\n }\n>;\n\nconst MarkdownContext = createContext<MarkdownContextValue | undefined>(\n undefined\n);\n\nexport const useMarkdownContext = () => useContext(MarkdownContext);\n\nconst mergeOptions = (\n baseComponents: HTMLComponents<'permissive', {}> | undefined,\n baseOptions: Omit<RenderMarkdownOptions, 'components'>,\n options: MarkdownProviderOptions = {},\n components: HTMLComponents<'permissive', {}> = {},\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements\n): RenderMarkdownOptions => {\n return {\n ...baseOptions,\n ...options,\n forceBlock: options.forceBlock ?? baseOptions.forceBlock,\n forceInline: options.forceInline ?? baseOptions.forceInline,\n preserveFrontmatter:\n options.preserveFrontmatter ?? baseOptions.preserveFrontmatter,\n tagfilter: options.tagfilter ?? baseOptions.tagfilter,\n wrapper: wrapper || baseOptions.wrapper,\n forceWrapper: !!(wrapper || baseOptions.wrapper),\n components: { ...baseComponents, ...components },\n };\n};\n\nexport const MarkdownProvider: FunctionComponent<MarkdownProviderProps> = ({\n children,\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderFn,\n}) => {\n const baseOptions: Omit<RenderMarkdownOptions, 'components'> = {\n forceBlock,\n forceInline,\n wrapper,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n // Standard internal renderer\n const defaultRenderMarkdown = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => {\n const mergedOptions = mergeOptions(\n components,\n baseOptions,\n options,\n componentsOverride ?? {},\n wrapperOverride\n );\n return compileMarkdown(markdown, mergedOptions) as ComponentChildren;\n };\n\n // Wrapper for user-provided custom renderer\n // Note: We wrap in a clean Provider to prevent infinite recursion\n const customRenderMarkdownWrapper = (\n markdown: string,\n options?: MarkdownProviderOptions,\n componentsOverride?: HTMLComponents<'permissive', {}>,\n wrapperOverride?: ComponentType<any> | keyof JSX.IntrinsicElements\n ): ComponentChildren => (\n <MarkdownContext.Provider value={undefined}>\n {customRenderFn?.(markdown, options, componentsOverride, wrapperOverride)}\n </MarkdownContext.Provider>\n );\n\n return (\n <MarkdownContext.Provider\n value={{\n components,\n renderMarkdown: customRenderFn\n ? customRenderMarkdownWrapper\n : defaultRenderMarkdown,\n }}\n >\n {children}\n </MarkdownContext.Provider>\n );\n};\n"],"mappings":";;;;;;;;AA0EA,MAAM,4CACJ,MACF;AAEA,MAAa,wDAAsC,eAAe;AAElE,MAAM,gBACJ,gBACA,aACA,UAAmC,CAAC,GACpC,aAA+C,CAAC,GAChD,YAC0B;CAC1B,OAAO;EACL,GAAG;EACH,GAAG;EACH,YAAY,QAAQ,cAAc,YAAY;EAC9C,aAAa,QAAQ,eAAe,YAAY;EAChD,qBACE,QAAQ,uBAAuB,YAAY;EAC7C,WAAW,QAAQ,aAAa,YAAY;EAC5C,SAAS,WAAW,YAAY;EAChC,cAAc,CAAC,EAAE,WAAW,YAAY;EACxC,YAAY;GAAE,GAAG;GAAgB,GAAG;EAAW;CACjD;AACF;AAEA,MAAa,oBAA8D,EACzE,UACA,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,qBACZ;CACJ,MAAM,cAAyD;EAC7D;EACA;EACA;EACA,cAAc,CAAC,CAAC;EAChB;EACA;CACF;CAGA,MAAM,yBACJ,UACA,SACA,oBACA,oBACsB;EAQtB,OAAOA,0CAAgB,UAPD,aACpB,YACA,aACA,SACA,sBAAsB,CAAC,GACvB,eAE2C,CAAC;CAChD;CAIA,MAAM,+BACJ,UACA,SACA,oBACA,oBAEA,4CAAC,gBAAgB,UAAjB;EAA0B,OAAO;YAC9B,iBAAiB,UAAU,SAAS,oBAAoB,eAAe;CAChD;CAG5B,OACE,4CAAC,gBAAgB,UAAjB;EACE,OAAO;GACL;GACA,gBAAgB,iBACZ,8BACA;EACN;EAEC;CACuB;AAE9B"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KACX;CAYhB,OAAOA,0CAAgB,SAAS;EAT9B;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;EAG6C,CAAC;;AAGlD,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,EAAE,KAAK;CAC9B,MAAM,UAAUC,sDAAoB;CAEpC,QAAQ,YAAoB;EAC1B,IAAI,SACF,OAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;GACD,EACD,YACA,QACD;EAGH,OAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;;;;;;;;;AAgCN,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAUA,sDAAoB;CAEpC,IAAI,sBACF,OACE,qFACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC,EACD;CAIP,IAAI,SACF,OACE,qFACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;EACD,EACD,YACA,QACD,EACA;CAIP,OAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;EACD,CAAC"}
1
+ {"version":3,"file":"MarkdownRenderer.cjs","names":["compileMarkdown","useMarkdownContext"],"sources":["../../../src/markdown/MarkdownRenderer.tsx"],"sourcesContent":["import type {\n ComponentChildren,\n ComponentType,\n FunctionComponent,\n JSX,\n} from 'preact';\nimport type { HTMLComponents } from '../html/types';\nimport { compileMarkdown, type MarkdownCompilerOptions } from './compiler';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\nexport type RenderMarkdownProps = MarkdownProviderOptions & {\n /**\n * Component overrides for HTML tags.\n * Only used if not wrapped in a MarkdownProvider.\n */\n components?: HTMLComponents<'permissive', {}>;\n /**\n * Wrapper element or component to be used when there are multiple children.\n * Only used if not wrapped in a MarkdownProvider.\n */\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n};\n\nexport const renderMarkdown = (\n content: string,\n {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n }: RenderMarkdownProps = {}\n): JSX.Element => {\n // Map public options to internal processor options\n const internalOptions: MarkdownCompilerOptions = {\n components,\n forceBlock,\n forceInline,\n wrapper: wrapper as any,\n forceWrapper: !!wrapper,\n preserveFrontmatter,\n tagfilter,\n };\n\n return compileMarkdown(content, internalOptions) as JSX.Element;\n};\n\nexport const useMarkdownRenderer = ({\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n}: RenderMarkdownProps = {}) => {\n const context = useMarkdownContext();\n\n return (content: string) => {\n if (context) {\n return context.renderMarkdown(\n content,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n );\n }\n\n return renderMarkdown(content, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n };\n};\n\nexport type MarkdownRendererProps = RenderMarkdownProps & {\n /**\n * The markdown content to render.\n */\n children: string;\n /**\n * Custom render function for markdown.\n * If provided, it will overwrite context and default rendering.\n */\n renderMarkdown?: (\n markdown: string,\n options?: {\n components?: HTMLComponents<'permissive', {}>;\n wrapper?: ComponentType<any> | keyof JSX.IntrinsicElements;\n forceBlock?: boolean;\n forceInline?: boolean;\n preserveFrontmatter?: boolean;\n tagfilter?: boolean;\n }\n ) => ComponentChildren | Promise<ComponentChildren>;\n};\n\n/**\n * Preact component that renders markdown to JSX.\n *\n * It uses the renderMarkdown function from the MarkdownProvider context if available.\n * Otherwise, it falls back to the default compiler with provided components and options.\n */\nexport const MarkdownRenderer: FunctionComponent<MarkdownRendererProps> = ({\n children = '',\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n renderMarkdown: customRenderMarkdown,\n}) => {\n const context = useMarkdownContext();\n\n if (customRenderMarkdown) {\n return (\n <>\n {customRenderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n })}\n </>\n );\n }\n\n if (context) {\n return (\n <>\n {context.renderMarkdown(\n children,\n {\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n },\n components,\n wrapper\n )}\n </>\n );\n }\n\n return renderMarkdown(children, {\n components,\n wrapper,\n forceBlock,\n forceInline,\n preserveFrontmatter,\n tagfilter,\n });\n};\n"],"mappings":";;;;;;;AA0BA,MAAa,kBACX,SACA,EACE,YACA,SACA,YACA,aACA,qBACA,cACuB,CAAC,MACV;CAYhB,OAAOA,0CAAgB,SAAS;EAT9B;EACA;EACA;EACS;EACT,cAAc,CAAC,CAAC;EAChB;EACA;CAG4C,CAAC;AACjD;AAEA,MAAa,uBAAuB,EAClC,YACA,SACA,YACA,aACA,qBACA,cACuB,CAAC,MAAM;CAC9B,MAAM,UAAUC,qDAAmB;CAEnC,QAAQ,YAAoB;EAC1B,IAAI,SACF,OAAO,QAAQ,eACb,SACA;GACE;GACA;GACA;GACA;EACF,GACA,YACA,OACF;EAGF,OAAO,eAAe,SAAS;GAC7B;GACA;GACA;GACA;GACA;GACA;EACF,CAAC;CACH;AACF;;;;;;;AA8BA,MAAa,oBAA8D,EACzE,WAAW,IACX,YACA,SACA,YACA,aACA,qBACA,WACA,gBAAgB,2BACZ;CACJ,MAAM,UAAUA,qDAAmB;CAEnC,IAAI,sBACF,OACE,qFACG,qBAAqB,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC,EACD;CAIN,IAAI,SACF,OACE,qFACG,QAAQ,eACP,UACA;EACE;EACA;EACA;EACA;CACF,GACA,YACA,OACF,EACA;CAIN,OAAO,eAAe,UAAU;EAC9B;EACA;EACA;EACA;EACA;EACA;CACF,CAAC;AACH"}
@@ -1 +1 @@
1
- {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAUA,sDAAoB;CAGpC,QAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,EAAE;EAC7B,GAAI,cAAc,EAAE;EACrB,CAAC;;AAOJ,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkBC,oCAAW;CAU7C,0HARqC,SAG3B,EACR,iBACA,cAGe"}
1
+ {"version":3,"file":"MarkdownRendererPlugin.cjs","names":["useMarkdownContext","useLocale"],"sources":["../../../src/markdown/MarkdownRendererPlugin.tsx"],"sourcesContent":["'use client';\n\nimport { getContentNodeByKeyPath } from '@intlayer/core/dictionaryManipulator';\nimport { getMarkdownMetadata } from '@intlayer/core/markdown';\nimport type { ContentNode } from '@intlayer/types/dictionary';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport type { ComponentChildren, FunctionComponent } from 'preact';\nimport { useLocale } from '../client/useLocale';\nimport type { HTMLComponents } from '../html/types';\nimport {\n type MarkdownProviderOptions,\n useMarkdownContext,\n} from './MarkdownProvider';\n\ntype MarkdownRendererPluginProps = {\n dictionaryKey: string;\n keyPath: KeyPath[];\n locale?: LocalesValues;\n children: string;\n options?: MarkdownProviderOptions;\n components?: HTMLComponents<'permissive', {}>;\n};\n\nexport const MarkdownRendererPlugin: FunctionComponent<\n MarkdownRendererPluginProps\n> = (props): ComponentChildren => {\n const { children, options, components } = props;\n const context = useMarkdownContext();\n const renderMarkdown = context?.renderMarkdown ?? ((md) => md);\n\n return renderMarkdown(children, options, {\n ...(context?.components ?? {}),\n ...(components ?? {}),\n }) as ComponentChildren;\n};\n\ntype MarkdownMetadataRendererProps = MarkdownRendererPluginProps & {\n metadataKeyPath: KeyPath[];\n};\n\nexport const MarkdownMetadataRenderer: FunctionComponent<\n MarkdownMetadataRendererProps\n> = ({ children, metadataKeyPath }): ComponentChildren => {\n const { locale: currentLocale } = useLocale();\n\n const metadata = getMarkdownMetadata(children);\n\n const metadataEl = getContentNodeByKeyPath(\n metadata as ContentNode,\n metadataKeyPath,\n currentLocale as any\n );\n\n return metadataEl as ComponentChildren;\n};\n"],"mappings":";;;;;;;;;;AAwBA,MAAa,0BAER,UAA6B;CAChC,MAAM,EAAE,UAAU,SAAS,eAAe;CAC1C,MAAM,UAAUA,qDAAmB;CAGnC,QAFuB,SAAS,oBAAoB,OAAO,KAErC,UAAU,SAAS;EACvC,GAAI,SAAS,cAAc,CAAC;EAC5B,GAAI,cAAc,CAAC;CACrB,CAAC;AACH;AAMA,MAAa,4BAER,EAAE,UAAU,sBAAyC;CACxD,MAAM,EAAE,QAAQ,kBAAkBC,mCAAU;CAU5C,0HARqC,QAG5B,GACP,iBACA,aAGc;AAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"compiler.cjs","names":["preactRuntime"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport { RuleType };\nexport { defaultSlugify as slugify, defaultSanitizer as sanitizer };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to Preact VNodes.\n * This is the primary export - use this for new code.\n */\nexport const compileMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n) => compileWithOptions(markdown, preactRuntime, options);\n\n// Aliases for consistency with React adapter\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAa,mBACX,WAAmB,IACnB,UAAmC,EAAE,qDACf,UAAUA,kCAAe,QAAQ;AAGzD,MAAa,WAAW;AACxB,MAAa,UAAU"}
1
+ {"version":3,"file":"compiler.cjs","names":["preactRuntime"],"sources":["../../../src/markdown/compiler.ts"],"sourcesContent":["/**\n * Preact adapter for the framework-agnostic markdown processor.\n */\n\nimport {\n type CompileOptions,\n compileWithOptions,\n sanitizer as defaultSanitizer,\n slugify as defaultSlugify,\n RuleType,\n} from '@intlayer/core/markdown';\nimport { preactRuntime } from './runtime';\n\n// Re-export RuleType and utilities for compatibility\nexport { defaultSanitizer as sanitizer, defaultSlugify as slugify, RuleType };\n\nexport type MarkdownCompilerOptions = CompileOptions;\n\n/**\n * Compile markdown to Preact VNodes.\n * This is the primary export - use this for new code.\n */\nexport const compileMarkdown = (\n markdown: string = '',\n options: MarkdownCompilerOptions = {}\n) => compileWithOptions(markdown, preactRuntime, options);\n\n// Aliases for consistency with React adapter\nexport const compiler = compileMarkdown;\nexport const compile = compileMarkdown;\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAa,mBACX,WAAmB,IACnB,UAAmC,CAAC,sDACd,UAAUA,kCAAe,OAAO;AAGxD,MAAa,WAAW;AACxB,MAAa,UAAU"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":";;;;;;;;AAgBA,MAAa,gBAAiC;CAC5C,gBACE,MACA,OACA,GAAG,uCACmB,MAAa,OAAO,GAAG,SAAS;CAExD,eACE,SACA,OACA,GAAG,sCACkB,SAAkB,OAAO,GAAG,SAAS;CAE5D;CAEA,iBACE,MACA,UACwB;CAC3B"}
1
+ {"version":3,"file":"runtime.cjs","names":[],"sources":["../../../src/markdown/runtime.ts"],"sourcesContent":["/**\n * Preact-specific MarkdownRuntime implementation.\n */\n\nimport type { HTMLTag, MarkdownRuntime } from '@intlayer/core/markdown';\nimport {\n type Component,\n cloneElement,\n createElement,\n Fragment,\n type VNode,\n} from 'preact';\n\n/**\n * Preact-specific runtime for the markdown processor.\n */\nexport const preactRuntime: MarkdownRuntime = {\n createElement: (\n type: string | Component,\n props: Record<string, any> | null,\n ...children: any[]\n ): any => createElement(type as any, props, ...children),\n\n cloneElement: (\n element: unknown,\n props: Record<string, any>,\n ...children: any[]\n ): any => cloneElement(element as VNode, props, ...children),\n\n Fragment,\n\n normalizeProps: (\n _tag: HTMLTag,\n props: Record<string, any>\n ): Record<string, any> => props,\n};\n\nexport default preactRuntime;\n"],"mappings":";;;;;;;;AAgBA,MAAa,gBAAiC;CAC5C,gBACE,MACA,OACA,GAAG,uCACmB,MAAa,OAAO,GAAG,QAAQ;CAEvD,eACE,SACA,OACA,GAAG,sCACkB,SAAkB,OAAO,GAAG,QAAQ;CAE3D;CAEA,iBACE,MACA,UACwB;AAC5B"}