angular-intlayer 8.4.0 → 8.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs +9 -0
- package/dist/cjs/ContentSelector.component-Dfy-4WRH.cjs.map +1 -0
- package/dist/cjs/{_virtual/_rolldown/runtime.cjs → chunk-Bmb41Sf3.cjs} +1 -1
- package/dist/cjs/client/installIntlayer.cjs +1 -1
- package/dist/cjs/client/installIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useDictionary.cjs +1 -1
- package/dist/cjs/client/useDictionary.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs +1 -1
- package/dist/cjs/client/useDictionaryAsync.cjs.map +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs +1 -1
- package/dist/cjs/client/useDictionaryDynamic.cjs.map +1 -1
- package/dist/cjs/client/useIntl.cjs +1 -1
- package/dist/cjs/client/useIntl.cjs.map +1 -1
- package/dist/cjs/client/useIntlayer.cjs +1 -1
- package/dist/cjs/client/useIntlayer.cjs.map +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs +1 -1
- package/dist/cjs/client/useLoadDynamic.cjs.map +1 -1
- package/dist/cjs/client/useLocale.cjs +1 -1
- package/dist/cjs/client/useLocale.cjs.map +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs +1 -1
- package/dist/cjs/client/useLocaleStorage.cjs.map +1 -1
- package/dist/{esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.mjs → cjs/decorate-B_4qGGx3.cjs} +1 -1
- package/dist/cjs/editor/ContentSelector.component.cjs +1 -9
- package/dist/cjs/editor/useEditor.cjs +1 -1
- package/dist/cjs/editor/useEditor.cjs.map +1 -1
- package/dist/cjs/getDictionary.cjs +1 -1
- package/dist/cjs/getDictionary.cjs.map +1 -1
- package/dist/cjs/getIntlayer.cjs +1 -1
- package/dist/cjs/getIntlayer.cjs.map +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs +1 -1
- package/dist/cjs/markdown/installIntlayerMarkdown.cjs.map +1 -1
- package/dist/cjs/plugins.cjs +1 -1
- package/dist/cjs/plugins.cjs.map +1 -1
- package/dist/cjs/webpack/mergeConfig.cjs +1 -1
- package/dist/cjs/webpack/mergeConfig.cjs.map +1 -1
- package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs +9 -0
- package/dist/esm/ContentSelector.component-B9Uvy9gY.mjs.map +1 -0
- package/dist/esm/client/installIntlayer.mjs +1 -1
- package/dist/esm/client/installIntlayer.mjs.map +1 -1
- package/dist/esm/client/useIntl.mjs.map +1 -1
- package/dist/{cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorate.cjs → esm/decorate-EVKP5RjP.mjs} +1 -1
- package/dist/esm/editor/ContentSelector.component.mjs +1 -9
- package/dist/esm/editor/useEditor.mjs +1 -1
- package/dist/esm/editor/useEditor.mjs.map +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs +1 -1
- package/dist/esm/markdown/installIntlayerMarkdown.mjs.map +1 -1
- package/dist/esm/plugins.mjs +1 -1
- package/dist/esm/plugins.mjs.map +1 -1
- package/dist/types/client/index.d.ts +8 -8
- package/dist/types/client/installIntlayer.d.ts +2 -50
- package/dist/types/client/useDictionary.d.ts +2 -10
- package/dist/types/client/useDictionaryAsync.d.ts +2 -14
- package/dist/types/client/useDictionaryDynamic.d.ts +2 -17
- package/dist/types/client/useIntl.d.ts +2 -89
- package/dist/types/client/useIntlayer.d.ts +2 -38
- package/dist/types/client/useLoadDynamic.d.ts +2 -11
- package/dist/types/client/useLocale.d.ts +2 -48
- package/dist/types/getDictionary-DDjZzxAC.d.ts +9 -0
- package/dist/types/getDictionary-DDjZzxAC.d.ts.map +1 -0
- package/dist/types/getDictionary.d.ts +2 -9
- package/dist/types/getIntlayer-CWM6qsJJ.d.ts +8 -0
- package/dist/types/getIntlayer-CWM6qsJJ.d.ts.map +1 -0
- package/dist/types/getIntlayer.d.ts +2 -8
- package/dist/types/index-Cf8zm5QQ.d.ts +1 -0
- package/dist/types/index-D5QAgZ5v.d.ts +22 -0
- package/dist/types/index-D5QAgZ5v.d.ts.map +1 -0
- package/dist/types/index.d.ts +13 -21
- package/dist/types/installIntlayer-Ce7kST5N.d.ts +50 -0
- package/dist/types/installIntlayer-Ce7kST5N.d.ts.map +1 -0
- package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts +36 -0
- package/dist/types/installIntlayerMarkdown-BIU3FTDH.d.ts.map +1 -0
- package/dist/types/markdown/index.d.ts +1 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts +2 -36
- package/dist/types/plugins-C_v3w-vC.d.ts +89 -0
- package/dist/types/plugins-C_v3w-vC.d.ts.map +1 -0
- package/dist/types/plugins.d.ts +2 -89
- package/dist/types/useDictionary-Dq9yu0X_.d.ts +10 -0
- package/dist/types/useDictionary-Dq9yu0X_.d.ts.map +1 -0
- package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts +14 -0
- package/dist/types/useDictionaryAsync-BYUsr8w4.d.ts.map +1 -0
- package/dist/types/useIntl-CHizZCR2.d.ts +33 -0
- package/dist/types/useIntl-CHizZCR2.d.ts.map +1 -0
- package/dist/types/useIntlayer-m3n_upwm.d.ts +38 -0
- package/dist/types/useIntlayer-m3n_upwm.d.ts.map +1 -0
- package/dist/types/useLoadDynamic-C4pltPcC.d.ts +11 -0
- package/dist/types/useLoadDynamic-C4pltPcC.d.ts.map +1 -0
- package/dist/types/useLocale-BzfAmXlx.d.ts +48 -0
- package/dist/types/useLocale-BzfAmXlx.d.ts.map +1 -0
- package/dist/types/webpack/index.d.ts +5 -2
- package/dist/types/webpack/index.d.ts.map +1 -0
- package/dist/types/webpack/mergeConfig.d.ts +2 -5
- package/package.json +8 -8
- package/dist/cjs/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.cjs +0 -1
- package/dist/cjs/editor/ContentSelector.component.cjs.map +0 -1
- package/dist/esm/_virtual/_@oxc-project_runtime@0.115.0/helpers/decorateMetadata.mjs +0 -1
- package/dist/esm/editor/ContentSelector.component.mjs.map +0 -1
- package/dist/types/client/installIntlayer.d.ts.map +0 -1
- package/dist/types/client/useDictionary.d.ts.map +0 -1
- package/dist/types/client/useDictionaryAsync.d.ts.map +0 -1
- package/dist/types/client/useDictionaryDynamic.d.ts.map +0 -1
- package/dist/types/client/useIntl.d.ts.map +0 -1
- package/dist/types/client/useIntlayer.d.ts.map +0 -1
- package/dist/types/client/useLoadDynamic.d.ts.map +0 -1
- package/dist/types/client/useLocale.d.ts.map +0 -1
- package/dist/types/getDictionary.d.ts.map +0 -1
- package/dist/types/getIntlayer.d.ts.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/markdown/installIntlayerMarkdown.d.ts.map +0 -1
- package/dist/types/plugins.d.ts.map +0 -1
- package/dist/types/webpack/mergeConfig.d.ts.map +0 -1
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./decorate-B_4qGGx3.cjs`);let t=require(`@angular/core`);function n(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}let r=class{dictionaryKey;keyPath;get keyPathJson(){return JSON.stringify(this.keyPath)}};e.t([(0,t.Input)(),n(`design:type`,String)],r.prototype,`dictionaryKey`,void 0),e.t([(0,t.Input)(),n(`design:type`,Array)],r.prototype,`keyPath`,void 0),r=e.t([(0,t.Component)({selector:`app-content-selector-wrapper`,standalone:!0,schemas:[t.CUSTOM_ELEMENTS_SCHEMA],template:`
|
|
2
|
+
<intlayer-content-selector-wrapper
|
|
3
|
+
[attr.key-path]="keyPathJson"
|
|
4
|
+
[attr.dictionary-key]="dictionaryKey"
|
|
5
|
+
>
|
|
6
|
+
<ng-content></ng-content>
|
|
7
|
+
</intlayer-content-selector-wrapper>
|
|
8
|
+
`})],r),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return r}});
|
|
9
|
+
//# sourceMappingURL=ContentSelector.component-Dfy-4WRH.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.component-Dfy-4WRH.cjs","names":["CUSTOM_ELEMENTS_SCHEMA"],"sources":["../../src/editor/ContentSelector.component.ts"],"sourcesContent":["import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core';\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n template: `\n <intlayer-content-selector-wrapper\n [attr.key-path]=\"keyPathJson\"\n [attr.dictionary-key]=\"dictionaryKey\"\n >\n <ng-content></ng-content>\n </intlayer-content-selector-wrapper>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n get keyPathJson() {\n return JSON.stringify(this.keyPath);\n }\n}\n"],"mappings":"wNAeO,IAAA,EAAA,KAAsC,CAC3C,cACA,QAEA,IAAI,aAAc,CAChB,OAAO,KAAK,UAAU,KAAK,QAAQ,qBAJ7B,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,mBACA,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,wBAfC,CACT,SAAU,+BACV,WAAY,GACZ,QAAS,CAACA,EAAAA,uBAAuB,CACjC,SAAU;;;;;;;IAQX,CAAC,CAAA,CAAA,EAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));exports
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return s}});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`../decorate-B_4qGGx3.cjs`);let n=require(`@intlayer/config/built`);n=e.t(n);let r=require(`@angular/core`);const i=new r.InjectionToken(`intlayer`);let a=null,o=class{isCookieEnabled=(0,r.signal)(!0);_locale=(0,r.signal)(n.default.internationalization?.defaultLocale);locale=this._locale.asReadonly();setLocale=e=>{this._locale.set(e)}};o=t.t([(0,r.Injectable)({providedIn:`root`})],o);const s=(e,t=!0)=>a||(a=new o,e&&a.setLocale(e),a.isCookieEnabled.set(t),a),c=(e,t=!0)=>({provide:i,useValue:l(e,t)}),l=(e,t=!0)=>s(e,t);exports.INTLAYER_TOKEN=i,Object.defineProperty(exports,`IntlayerProvider`,{enumerable:!0,get:function(){return o}}),exports.createIntlayerClient=s,exports.installIntlayer=l,exports.provideIntlayer=c;
|
|
2
2
|
//# sourceMappingURL=installIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.cjs","names":["InjectionToken","configuration"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayer.cjs","names":["InjectionToken","configuration"],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"kOAIA,MAAa,EAAiB,IAAIA,EAAAA,eAAiC,WAAW,CAK9E,IAAI,EAAoC,KAKjC,EAAA,KAAuB,CAC5B,iBAAA,EAAA,EAAA,QAAyB,GAAK,CAC9B,SAAQ,EAAA,EAAA,QACNC,EAAAA,QAAc,sBAAsB,cACrC,CAED,OAAyC,KAAK,QAAQ,YAAY,CAElE,UAAa,GAA0B,CACrC,KAAK,QAAQ,IAAI,EAAO,2BAZhB,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,GACX,EACA,EAAkB,KAEd,IAEJ,EAAW,IAAI,EAEX,GACF,EAAS,UAAU,EAAO,CAE5B,EAAS,gBAAgB,IAAI,EAAgB,CAEtC,GA0BI,GACX,EACA,EAAkB,MACd,CACJ,QAAS,EACT,SAAU,EAAgB,EAAQ,EAAgB,CACnD,EAKY,GACX,EACA,EAAkB,KAEH,EAAqB,EAAQ,EAAgB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../getDictionary.cjs`),t=require(`./installIntlayer.cjs`);let n=require(`@angular/core`);const r=(r,i)=>{let a=(0,n.inject)(t.INTLAYER_TOKEN),o=(0,n.computed)(()=>i??a?.locale());return(0,n.computed)(()=>e.getDictionary(r,o()))};exports.useDictionary=r;
|
|
2
2
|
//# sourceMappingURL=useDictionary.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionary.cjs","names":["INTLAYER_TOKEN","getDictionary"],"sources":["../../../src/client/useDictionary.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getDictionary } from '../getDictionary';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\nexport const useDictionary = <T extends Dictionary>(\n dictionary: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<T['content']>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(() => locale ?? intlayer?.locale());\n\n /** a *stable* reactive dictionary object */\n const content = computed(() =>\n getDictionary<T, LocalesValues>(dictionary, localeTarget())\n );\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"8MAOA,MAAa,GACX,EACA,IAC+C,CAC/C,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAEnD,GAAA,EAAA,EAAA,cAA8B,GAAU,GAAU,QAAQ,CAAC,CAOjE,OAAA,EAAA,EAAA,cAHEC,EAAAA,cAAgC,EAAY,GAAc,CAAC,CAC5D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useDictionary.cjs`);let r=require(`@intlayer/config/built`);r=e.t(r);let i=require(`@angular/core`);const a=async(e,a)=>{let o=(0,i.inject)(t.INTLAYER_TOKEN),s=(0,i.computed)(()=>a??o?.locale()??r.default?.internationalization.defaultLocale);return n.useDictionary(await e[s()]?.(),s())};exports.useDictionaryAsync=a;
|
|
2
2
|
//# sourceMappingURL=useDictionaryAsync.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryAsync.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\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) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryAsync.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary"],"sources":["../../../src/client/useDictionaryAsync.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\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) => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = await dictionaryPromise[localeTarget()]?.();\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"6QAcA,MAAa,EAAqB,MAChC,EACA,IACG,CACH,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAEnD,GAAA,EAAA,EAAA,cAEF,GACA,GAAU,QAAQ,EAClBC,EAAAA,SAAe,qBAAqB,cACvC,CAID,OAAOC,EAAAA,cAFY,MAAM,EAAkB,GAAc,KAAK,CAE7B,GAAc,CAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
"use client";Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useDictionary.cjs`),r=require(`./useLoadDynamic.cjs`);let i=require(`@intlayer/config/built`);i=e.t(i);let a=require(`@angular/core`);const o=(e,o,s)=>{let c=(0,a.inject)(t.INTLAYER_TOKEN),l=(0,a.computed)(()=>s??c?.locale()??i.default?.internationalization.defaultLocale);return n.useDictionary(r.useLoadDynamic(`${String(o)}.${l()}`,e[l()]?.()),l())};exports.useDictionaryDynamic=o;
|
|
2
2
|
//# sourceMappingURL=useDictionaryDynamic.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\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 intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDictionaryDynamic.cjs","names":["INTLAYER_TOKEN","configuration","useDictionary","useLoadDynamic"],"sources":["../../../src/client/useDictionaryDynamic.ts"],"sourcesContent":["'use client';\n\nimport { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport type { DictionaryKeys, LocalesValues, StrictModeLocaleMap } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\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 intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n const localeTarget = computed(\n () =>\n locale ??\n intlayer?.locale() ??\n configuration?.internationalization.defaultLocale\n );\n\n const dictionary = useLoadDynamic<T>(\n `${String(key)}.${localeTarget()}`,\n dictionaryPromise[localeTarget()]?.()\n ) as T;\n\n return useDictionary(dictionary, localeTarget() as any);\n};\n"],"mappings":"+SAeA,MAAa,GAIX,EACA,EACA,IACG,CACH,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAEnD,GAAA,EAAA,EAAA,cAEF,GACA,GAAU,QAAQ,EAClBC,EAAAA,SAAe,qBAAqB,cACvC,CAOD,OAAOC,EAAAA,cALYC,EAAAA,eACjB,GAAG,OAAO,EAAI,CAAC,GAAG,GAAc,GAChC,EAAkB,GAAc,KAAK,CACtC,CAEgC,GAAc,CAAQ"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`./installIntlayer.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/core/formatters`);const r=r=>{let i=(0,t.inject)(e.IntlayerProvider);return(0,t.computed)(()=>(0,n.bindIntl)(r??i.locale()))};exports.useIntl=r;
|
|
2
2
|
//# sourceMappingURL=useIntl.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable 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 * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntl.cjs","names":["IntlayerProvider"],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable 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 * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"mNA6BA,MAAa,EAAW,GAA2B,CACjD,IAAM,GAAA,EAAA,EAAA,QAAkBA,EAAAA,iBAAiB,CAEzC,OAAA,EAAA,EAAA,eAGE,EAAA,EAAA,UAFsB,GAAU,EAAS,QAAQ,CAEnB,CAC9B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../getIntlayer.cjs`),t=require(`./installIntlayer.cjs`);let n=require(`@angular/core`);const r=e=>!!e&&typeof e==`object`&&typeof e.__update==`function`,i=(r,i)=>{let a=(0,n.inject)(t.INTLAYER_TOKEN),o=(0,n.computed)(()=>i??a.locale());return(0,n.computed)(()=>e.getIntlayer(r,o()))};exports.isUpdatableNode=r,exports.useIntlayer=i;
|
|
2
2
|
//# sourceMappingURL=useIntlayer.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\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 * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useIntlayer.cjs","names":["INTLAYER_TOKEN","getIntlayer"],"sources":["../../../src/client/useIntlayer.ts"],"sourcesContent":["import { computed, inject, type Signal } from '@angular/core';\nimport type { DictionaryKeys, DictionaryRegistryContent, LocalesValues } from '@intlayer/types/module_augmentation';\nimport { getIntlayer } from '../getIntlayer';\nimport type { DeepTransformContent } from '../plugins';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\n\n/** guard utility - true only for objects generated by `renderIntlayerNode()` */\nexport const isUpdatableNode = (\n val: unknown\n): val is { __update: (n: unknown) => void } =>\n !!val &&\n typeof val === 'object' &&\n typeof (val as any).__update === 'function';\n\n/**\n * Angular hook that picks one dictionary by its key and returns its reactive content.\n *\n * It utilizes Angular signals to provide deep reactivity, ensuring your components\n * update automatically when the locale changes.\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 * ```ts\n * import { Component } from '@angular/core';\n * import { useIntlayer } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-my-component',\n * template: `<div>{{ content().myField.value }}</div>`,\n * })\n * export class MyComponent {\n * content = useIntlayer('my-dictionary-key');\n * }\n * ```\n */\nexport const useIntlayer = <T extends DictionaryKeys, L extends LocalesValues>(\n key: T,\n locale?: LocalesValues\n): Signal<DeepTransformContent<DictionaryRegistryContent<T>>> => {\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN)!;\n\n /** which locale should we use right now? */\n const localeTarget = computed(() => locale ?? intlayer.locale());\n\n /** a *stable* reactive dictionary object */\n // @ts-ignore Type instantiation is excessively deep and possibly infinite\n const content = computed(() => getIntlayer<T, L>(key, localeTarget() as L));\n\n return content; // all consumers keep full reactivity\n};\n"],"mappings":"4MAOA,MAAa,EACX,GAEA,CAAC,CAAC,GACF,OAAO,GAAQ,UACf,OAAQ,EAAY,UAAa,WA2BtB,GACX,EACA,IAC+D,CAC/D,IAAM,GAAA,EAAA,EAAA,QAAoCA,EAAAA,eAAe,CAGnD,GAAA,EAAA,EAAA,cAA8B,GAAU,EAAS,QAAQ,CAAC,CAMhE,OAAA,EAAA,EAAA,cAF+BC,EAAAA,YAAkB,EAAK,GAAc,CAAM,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`@angular/core`);const t=(n,r)=>{let i=t._cache||=new Map,a=(0,e.signal)({});if(i.has(n))i.get(n)?.then(e=>{a.set(e)});else{let e=r.then(e=>(a.set(e),e));i.set(n,e)}return a()};exports.useLoadDynamic=t;
|
|
2
2
|
//# sourceMappingURL=useLoadDynamic.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLoadDynamic.cjs","names":[],"sources":["../../../src/client/useLoadDynamic.ts"],"sourcesContent":["import { signal } from '@angular/core';\n\n/**\n * A \"synchronous\" loader for a dynamically‐imported JSON (or anything).\n *\n * - Immediately returns a reactive signal so that Angular can properly track changes.\n * - When the Promise resolves, it replaces the signal's value with the real data.\n */\nexport const useLoadDynamic = <T extends Record<string, any>>(\n key: string,\n promise: Promise<T>\n): T => {\n // A module‐level cache of Promises, so we only import once per key.\n const cache: Map<string, Promise<T>> = (useLoadDynamic as any)._cache ||\n ((useLoadDynamic as any)._cache = new Map());\n\n // Hold the \"current\" value as a reactive signal\n // This starts as an empty object but Angular can track changes to it\n const container = signal({} as T);\n\n if (!cache.has(key)) {\n // Kick off the dynamic import & cache it\n const p = promise.then((real) => {\n // As soon as the import resolves, update the signal with the real data\n container.set(real);\n return real;\n });\n cache.set(key, p);\n } else {\n // If it's already in flight (or done), hook into it so that the container still updates\n cache.get(key)?.then((real) => {\n container.set(real);\n });\n }\n\n // Return the current signal value directly - Angular can track all changes to it\n return container();\n};\n"],"mappings":"mIAQA,MAAa,GACX,EACA,IACM,CAEN,IAAM,EAAkC,AACvC,EAAwB,SAAS,IAAI,IAIhC,GAAA,EAAA,EAAA,QAAmB,EAAE,CAAM,CAEjC,GAAK,EAAM,IAAI,EAAI,CAUjB,EAAM,IAAI,EAAI,EAAE,KAAM,GAAS,CAC7B,EAAU,IAAI,EAAK,EACnB,KAZiB,CAEnB,IAAM,EAAI,EAAQ,KAAM,IAEtB,EAAU,IAAI,EAAK,CACZ,GACP,CACF,EAAM,IAAI,EAAK,EAAE,CASnB,OAAO,GAAW"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../chunk-Bmb41Sf3.cjs`),t=require(`./installIntlayer.cjs`),n=require(`./useLocaleStorage.cjs`);let r=require(`@intlayer/config/built`);r=e.t(r);let i=require(`@angular/core`);const a=({isCookieEnabled:e,onLocaleChange:a}={})=>{let{defaultLocale:o,locales:s}=r.default?.internationalization??{},c=(0,i.inject)(t.INTLAYER_TOKEN),l=(0,i.computed)(()=>c?.locale()??o),u=(0,i.computed)(()=>c?.isCookieEnabled()??!0);return{locale:l,defaultLocale:o,availableLocales:s,setLocale:t=>{if(!s?.map(String).includes(t)){console.error(`Locale ${t} is not available`);return}c&&c.setLocale(t),n.setLocaleInStorage(t,e??u()??!0),a?.(t)}}};exports.useLocale=a;
|
|
2
2
|
//# sourceMappingURL=useLocale.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\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 };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocale.cjs","names":["configuration","INTLAYER_TOKEN"],"sources":["../../../src/client/useLocale.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from './installIntlayer';\nimport { setLocaleInStorage } from './useLocaleStorage';\n\ntype useLocaleProps = {\n isCookieEnabled?: boolean;\n onLocaleChange?: (locale: LocalesValues) => void;\n};\n\n/**\n * Angular hook to manage the current locale and related functions.\n *\n * @param props - Optional configuration for locale management.\n * @returns An object containing the current locale (signal), default locale, available locales, and a function to update the locale.\n *\n * @example\n * ```ts\n * import { Component } from '@angular/core';\n * import { useLocale } from 'angular-intlayer';\n *\n * @Component({\n * standalone: true,\n * selector: 'app-locale-switcher',\n * template: `\n * <select [value]=\"locale()\" (change)=\"setLocale($any($event.target).value)\">\n * @for (loc of availableLocales; track loc) {\n * <option [value]=\"loc\">{{ loc }}</option>\n * }\n * </select>\n * `,\n * })\n * export class LocaleSwitcher {\n * const { locale, setLocale, availableLocales } = useLocale();\n * }\n * ```\n */\nexport const useLocale = ({\n isCookieEnabled,\n onLocaleChange,\n}: useLocaleProps = {}) => {\n const { defaultLocale, locales: availableLocales } =\n configuration?.internationalization ?? {};\n const intlayer = inject<IntlayerProvider>(INTLAYER_TOKEN);\n\n // Create a reactive reference for the locale\n const locale = computed(() => intlayer?.locale() ?? defaultLocale);\n const isCookieEnabledContext = computed(\n () => intlayer?.isCookieEnabled() ?? true\n );\n\n const setLocale = (newLocale: LocalesValues) => {\n if (!availableLocales?.map(String).includes(newLocale)) {\n console.error(`Locale ${newLocale} is not available`);\n return;\n }\n\n if (intlayer) {\n intlayer.setLocale(newLocale);\n }\n setLocaleInStorage(\n newLocale,\n isCookieEnabled ?? isCookieEnabledContext() ?? true\n );\n onLocaleChange?.(newLocale);\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 };\n};\n"],"mappings":"mQAsCA,MAAa,GAAa,CACxB,kBACA,kBACkB,EAAE,GAAK,CACzB,GAAM,CAAE,gBAAe,QAAS,GAC9BA,EAAAA,SAAe,sBAAwB,EAAE,CACrC,GAAA,EAAA,EAAA,QAAoCC,EAAAA,eAAe,CAGnD,GAAA,EAAA,EAAA,cAAwB,GAAU,QAAQ,EAAI,EAAc,CAC5D,GAAA,EAAA,EAAA,cACE,GAAU,iBAAiB,EAAI,GACtC,CAkBD,MAAO,CACL,SACA,gBACA,mBACA,UApBiB,GAA6B,CAC9C,GAAI,CAAC,GAAkB,IAAI,OAAO,CAAC,SAAS,EAAU,CAAE,CACtD,QAAQ,MAAM,UAAU,EAAU,mBAAmB,CACrD,OAGE,GACF,EAAS,UAAU,EAAU,CAE/B,EAAA,mBACE,EACA,GAAmB,GAAwB,EAAI,GAChD,CACD,IAAiB,EAAU,EAQ5B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`@intlayer/core/localization`),t=require(`@intlayer/core/utils`);const n=(0,t.getLocaleFromStorage)(e.localeStorageOptions),r=n,i=(n,r)=>(0,t.setLocaleInStorage)(n,{...e.localeStorageOptions,isCookieEnabled:r}),a=i,o=n=>(0,t.LocaleStorage)({...e.localeStorageOptions,isCookieEnabled:n}),s=e=>{let t=o(e);return{localeCookie:t.getLocale(),setLocaleCookie:t.setLocale}};exports.localeCookie=r,exports.localeInStorage=n,exports.setLocaleCookie=a,exports.setLocaleInStorage=i,exports.useLocaleCookie=s,exports.useLocaleStorage=o;
|
|
2
2
|
//# sourceMappingURL=useLocaleStorage.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(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 LocaleStorage({\n ...localeStorageOptions,\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 = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocaleStorage.cjs","names":["localeStorageOptions"],"sources":["../../../src/client/useLocaleStorage.ts"],"sourcesContent":["import { localeStorageOptions } from '@intlayer/core/localization';\nimport {\n getLocaleFromStorage,\n LocaleStorage,\n setLocaleInStorage as setLocaleInStorageCore,\n} from '@intlayer/core/utils';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\n/**\n * Get the locale cookie\n */\n/**\n * Get the locale cookie\n */\nexport const localeInStorage = getLocaleFromStorage(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 LocaleStorage({\n ...localeStorageOptions,\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 = (isCookieEnabled?: boolean) => {\n const storage = useLocaleStorage(isCookieEnabled);\n\n return {\n localeCookie: storage.getLocale(),\n setLocaleCookie: storage.setLocale,\n };\n};\n"],"mappings":"mLAcA,MAAa,GAAA,EAAA,EAAA,sBAAuCA,EAAAA,qBAAqB,CAM5D,EAAe,EAKf,GACX,EACA,KAAA,EAAA,EAAA,oBAEuB,EAAQ,CAC7B,GAAGA,EAAAA,qBACH,kBACD,CAAC,CAOS,EAAkB,EAKlB,EAAoB,IAAA,EAAA,EAAA,eACjB,CACZ,GAAGA,EAAAA,qBACH,kBACD,CAAC,CASS,EAAmB,GAA8B,CAC5D,IAAM,EAAU,EAAiB,EAAgB,CAEjD,MAAO,CACL,aAAc,EAAQ,WAAW,CACjC,gBAAiB,EAAQ,UAC1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}
|
|
1
|
+
function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`})
|
|
2
|
-
<intlayer-content-selector-wrapper
|
|
3
|
-
[attr.key-path]="keyPathJson"
|
|
4
|
-
[attr.dictionary-key]="dictionaryKey"
|
|
5
|
-
>
|
|
6
|
-
<ng-content></ng-content>
|
|
7
|
-
</intlayer-content-selector-wrapper>
|
|
8
|
-
`})],r),Object.defineProperty(exports,`ContentSelectorWrapperComponent`,{enumerable:!0,get:function(){return r}});
|
|
9
|
-
//# sourceMappingURL=ContentSelector.component.cjs.map
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../ContentSelector.component-Dfy-4WRH.cjs`);Object.defineProperty(exports,`ContentSelectorWrapperComponent`,{enumerable:!0,get:function(){return e.t}});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../client/installIntlayer.cjs`);require(`../client/index.cjs`);let t=require(`@angular/core`),n=require(`@intlayer/editor/isEnabled`);const r=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!n.isEnabled)return;let r=(0,t.inject)(t.DestroyRef,{optional:!0}),i=(0,t.inject)(e.INTLAYER_TOKEN,{optional:!0}),a=(0,t.inject)(t.Injector);import(`@intlayer/editor`).then(({initEditorClient:e})=>{let n=e();if(i){let e=(0,t.runInInjectionContext)(a,()=>(0,t.effect)(()=>{let e=i.locale();e&&n.currentLocale.set(e)}));r?.onDestroy(()=>e.destroy())}}),r?.onDestroy(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};exports.useEditor=r;
|
|
2
2
|
//# sourceMappingURL=useEditor.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.cjs","names":["isEnabled","DestroyRef","INTLAYER_TOKEN","Injector"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (!isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.cjs","names":["isEnabled","DestroyRef","INTLAYER_TOKEN","Injector"],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"2PAWA,MAAa,MAAkB,CAC7B,GAAI,QAAQ,IAAI,0BAA4B,SAAW,CAACA,EAAAA,UAAW,OAEnE,IAAM,GAAA,EAAA,EAAA,QAAoBC,EAAAA,WAAY,CAAE,SAAU,GAAM,CAAC,CACnD,GAAA,EAAA,EAAA,QAAkCC,EAAAA,eAAgB,CACtD,SAAU,GACX,CAAQ,CACH,GAAA,EAAA,EAAA,QAAkBC,EAAAA,SAAS,CAEjC,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAElC,GAAI,EAAQ,CACV,IAAM,GAAA,EAAA,EAAA,uBAAkC,OAAA,EAAA,EAAA,YACzB,CACX,IAAM,EAAS,EAAO,QAAQ,CAC1B,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,CACH,CACD,GAAY,cAAgB,EAAU,SAAS,CAAC,GAElD,CAEF,GAAY,cAAgB,CAC1B,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,EACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./plugins.cjs`);let t=require(`@intlayer/core/interpreter`);const n=(n,r)=>(0,t.getDictionary)(n,resolvedLocale,e.getPlugins(r));exports.getDictionary=n;
|
|
2
2
|
//# sourceMappingURL=getDictionary.cjs.map
|
|
@@ -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 { getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => getDictionaryCore<T, L>(dictionary, resolvedLocale, getPlugins(locale));\n"],"mappings":"
|
|
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 { getPlugins } from './plugins';\n\nexport const getDictionary = <\n T extends Dictionary,\n L extends LocalesValues = DeclaredLocales,\n>(\n dictionary: T,\n locale?: L\n) => getDictionaryCore<T, L>(dictionary, resolvedLocale, getPlugins(locale));\n"],"mappings":"gLAQA,MAAa,GAIX,EACA,KAAA,EAAA,EAAA,eAC2B,EAAY,eAAgBA,EAAAA,WAAW,EAAO,CAAC"}
|
package/dist/cjs/getIntlayer.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`./chunk-Bmb41Sf3.cjs`);const e=require(`./plugins.cjs`);let t=require(`@intlayer/core/interpreter`);const n=(n,r)=>(0,t.getIntlayer)(n,r,e.getPlugins(r));exports.getIntlayer=n;
|
|
2
2
|
//# sourceMappingURL=getIntlayer.cjs.map
|
|
@@ -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":"
|
|
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":"gLASA,MAAa,GAIX,EACA,KAAA,EAAA,EAAA,aAGE,EACA,EACAA,EAAAA,WAAW,EAAO,CACnB"}
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./markdown/installIntlayerMarkdown.cjs`),t=require(`./plugins.cjs`),n=require(`./getIntlayer.cjs`),r=require(`./getDictionary.cjs`),i=require(`./client/installIntlayer.cjs`),a=require(`./client/useDictionary.cjs`),o=require(`./client/useDictionaryAsync.cjs`),s=require(`./client/useLoadDynamic.cjs`),c=require(`./client/useDictionaryDynamic.cjs`),l=require(`./client/useIntl.cjs`),u=require(`./client/useIntlayer.cjs`),d=require(`./client/useLocale.cjs`);exports.INTLAYER_MARKDOWN_TOKEN=e.INTLAYER_MARKDOWN_TOKEN,exports.INTLAYER_TOKEN=i.INTLAYER_TOKEN,Object.defineProperty(exports,`IntlayerMarkdownService`,{enumerable:!0,get:function(){return e.IntlayerMarkdownService}}),Object.defineProperty(exports,`IntlayerProvider`,{enumerable:!0,get:function(){return i.IntlayerProvider}}),exports.createIntlayerClient=i.createIntlayerClient,exports.createIntlayerMarkdownProvider=e.createIntlayerMarkdownProvider,exports.getDictionary=r.getDictionary,exports.getIntlayer=n.getIntlayer,exports.getPlugins=t.getPlugins,exports.htmlPlugin=t.htmlPlugin,exports.htmlRuntime=e.htmlRuntime,exports.insertionPlugin=t.insertionPlugin,exports.installIntlayer=i.installIntlayer,exports.intlayerNodePlugins=t.intlayerNodePlugins,exports.isUpdatableNode=u.isUpdatableNode,exports.markdownPlugin=t.markdownPlugin,exports.markdownStringPlugin=t.markdownStringPlugin,exports.provideIntlayer=i.provideIntlayer,exports.useDictionary=a.useDictionary,exports.useDictionaryAsync=o.useDictionaryAsync,exports.useDictionaryDynamic=c.useDictionaryDynamic,exports.useIntl=l.useIntl,exports.useIntlayer=u.useIntlayer,exports.useLoadDynamic=s.useLoadDynamic,exports.useLocale=d.useLocale,exports.useMarkdown=e.useMarkdown;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./markdown/installIntlayerMarkdown.cjs`),t=require(`./plugins.cjs`),n=require(`./getIntlayer.cjs`),r=require(`./getDictionary.cjs`),i=require(`./client/installIntlayer.cjs`),a=require(`./client/useDictionary.cjs`),o=require(`./client/useDictionaryAsync.cjs`),s=require(`./client/useLoadDynamic.cjs`),c=require(`./client/useDictionaryDynamic.cjs`),l=require(`./client/useIntl.cjs`),u=require(`./client/useIntlayer.cjs`),d=require(`./client/useLocale.cjs`);require(`./client/index.cjs`),require(`./markdown/index.cjs`),exports.INTLAYER_MARKDOWN_TOKEN=e.INTLAYER_MARKDOWN_TOKEN,exports.INTLAYER_TOKEN=i.INTLAYER_TOKEN,Object.defineProperty(exports,`IntlayerMarkdownService`,{enumerable:!0,get:function(){return e.IntlayerMarkdownService}}),Object.defineProperty(exports,`IntlayerProvider`,{enumerable:!0,get:function(){return i.IntlayerProvider}}),exports.createIntlayerClient=i.createIntlayerClient,exports.createIntlayerMarkdownProvider=e.createIntlayerMarkdownProvider,exports.getDictionary=r.getDictionary,exports.getIntlayer=n.getIntlayer,exports.getPlugins=t.getPlugins,exports.htmlPlugin=t.htmlPlugin,exports.htmlRuntime=e.htmlRuntime,exports.insertionPlugin=t.insertionPlugin,exports.installIntlayer=i.installIntlayer,exports.intlayerNodePlugins=t.intlayerNodePlugins,exports.isUpdatableNode=u.isUpdatableNode,exports.markdownPlugin=t.markdownPlugin,exports.markdownStringPlugin=t.markdownStringPlugin,exports.provideIntlayer=i.provideIntlayer,exports.useDictionary=a.useDictionary,exports.useDictionaryAsync=o.useDictionaryAsync,exports.useDictionaryDynamic=c.useDictionaryDynamic,exports.useIntl=l.useIntl,exports.useIntlayer=u.useIntlayer,exports.useLoadDynamic=s.useLoadDynamic,exports.useLocale=d.useLocale,exports.useMarkdown=e.useMarkdown;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);const e=require(`../decorate-B_4qGGx3.cjs`);let t=require(`@intlayer/core/markdown`),n=require(`@angular/core`);const r=new n.InjectionToken(`intlayerMarkdown`),i={createElement:(e,t,...n)=>{if(typeof e!=`string`)return e===i.Fragment?n.join(``):``;let r=t?Object.entries(t).map(([e,t])=>e===`key`||t==null?``:`${e===`className`?`class`:e}="${String(t).replace(/"/g,`"`)}"`).filter(Boolean).join(` `):``,a=n.join(``);return[`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`].includes(e)?`<${e} ${r} />`:`<${e}${r?` ${r}`:``}>${a}</${e}>`},cloneElement:(e,t)=>e,Fragment:Symbol(`Fragment`)},a=e=>(0,t.compile)(e,{runtime:i}),o=(e=a)=>({provide:r,useValue:{renderMarkdown:e}});let s=class{markdownProvider=(0,n.inject)(r,{optional:!0});renderMarkdown(e,t){return this.markdownProvider?this.markdownProvider.renderMarkdown(e,t):e}};s=e.t([(0,n.Injectable)({providedIn:`root`})],s);const c=()=>(0,n.inject)(r,{optional:!0})||{renderMarkdown:a};exports.INTLAYER_MARKDOWN_TOKEN=r,Object.defineProperty(exports,`IntlayerMarkdownService`,{enumerable:!0,get:function(){return s}}),exports.createIntlayerMarkdownProvider=o,exports.htmlRuntime=i,exports.useMarkdown=c;
|
|
2
2
|
//# sourceMappingURL=installIntlayerMarkdown.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport type { MarkdownRuntime } from '@intlayer/core/markdown';\nimport { compile } from '@intlayer/core/markdown';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '"')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayerMarkdown.cjs","names":["InjectionToken"],"sources":["../../../src/markdown/installIntlayerMarkdown.ts"],"sourcesContent":["import {\n Injectable,\n InjectionToken,\n inject,\n type TemplateRef,\n} from '@angular/core';\nimport type { MarkdownRuntime } from '@intlayer/core/markdown';\nimport { compile } from '@intlayer/core/markdown';\n\nexport const INTLAYER_MARKDOWN_TOKEN =\n new InjectionToken<IntlayerMarkdownProvider>('intlayerMarkdown');\n\ntype RenderMarkdownOptions = {\n components?: any;\n wrapper?: any;\n options?: any;\n};\n\ntype RenderMarkdownFunction = (\n markdown: string,\n overrides?: any | RenderMarkdownOptions\n) => string | TemplateRef<any>;\n\nexport type IntlayerMarkdownProvider = {\n renderMarkdown: RenderMarkdownFunction;\n};\n\n// Minimal runtime to generate HTML strings\nexport const htmlRuntime: MarkdownRuntime = {\n createElement: (tag: string | any, props: any, ...children: any[]) => {\n if (typeof tag !== 'string') {\n // Handle non-string tags if necessary (e.g. components), or fallback to div\n if (tag === htmlRuntime.Fragment) {\n return children.join('');\n }\n return '';\n }\n\n const attrs = props\n ? Object.entries(props)\n .map(([k, v]) => {\n if (k === 'key' || v === undefined || v === null) return '';\n const key = k === 'className' ? 'class' : k;\n return `${key}=\"${String(v).replace(/\"/g, '"')}\"`;\n })\n .filter(Boolean)\n .join(' ')\n : '';\n\n const childrenStr = children.join('');\n const voidTags = [\n 'area',\n 'base',\n 'br',\n 'col',\n 'embed',\n 'hr',\n 'img',\n 'input',\n 'link',\n 'meta',\n 'param',\n 'source',\n 'track',\n 'wbr',\n ];\n\n if (voidTags.includes(tag)) {\n return `<${tag} ${attrs} />`;\n }\n\n return `<${tag}${attrs ? ` ${attrs}` : ''}>${childrenStr}</${tag}>`;\n },\n cloneElement: (element: any, _props: any) => element, // Not really supported for strings\n Fragment: Symbol('Fragment'),\n};\n\n/**\n * Default markdown renderer that converts markdown to HTML string\n */\nconst defaultMarkdownRenderer: RenderMarkdownFunction = (markdown: string) =>\n compile(markdown, { runtime: htmlRuntime }) as string;\n\n/**\n * Create IntlayerMarkdown provider configuration\n */\nexport const createIntlayerMarkdownProvider = (\n renderMarkdown: RenderMarkdownFunction = defaultMarkdownRenderer\n) => ({\n provide: INTLAYER_MARKDOWN_TOKEN,\n useValue: {\n renderMarkdown,\n } as IntlayerMarkdownProvider,\n});\n\n/**\n * Injectable service for markdown rendering\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerMarkdownService {\n private markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, {\n optional: true,\n });\n\n renderMarkdown(markdown: string, overrides?: any): string | TemplateRef<any> {\n if (!this.markdownProvider) {\n return markdown; // Fallback to returning markdown as is\n }\n return this.markdownProvider.renderMarkdown(markdown, overrides);\n }\n}\n\n/**\n * Function to inject markdown provider\n */\nexport const useMarkdown = (): IntlayerMarkdownProvider => {\n const markdownProvider = inject(INTLAYER_MARKDOWN_TOKEN, { optional: true });\n\n if (!markdownProvider) {\n return {\n renderMarkdown: defaultMarkdownRenderer,\n };\n }\n\n return markdownProvider;\n};\n"],"mappings":"oNASA,MAAa,EACX,IAAIA,EAAAA,eAAyC,mBAAmB,CAkBrD,EAA+B,CAC1C,eAAgB,EAAmB,EAAY,GAAG,IAAoB,CACpE,GAAI,OAAO,GAAQ,SAKjB,OAHI,IAAQ,EAAY,SACf,EAAS,KAAK,GAAG,CAEnB,GAGT,IAAM,EAAQ,EACV,OAAO,QAAQ,EAAM,CAClB,KAAK,CAAC,EAAG,KACJ,IAAM,OAAS,GAAyB,KAAa,GAElD,GADK,IAAM,YAAc,QAAU,EAC5B,IAAI,OAAO,EAAE,CAAC,QAAQ,KAAM,SAAS,CAAC,GACpD,CACD,OAAO,QAAQ,CACf,KAAK,IAAI,CACZ,GAEE,EAAc,EAAS,KAAK,GAAG,CAsBrC,MArBiB,CACf,OACA,OACA,KACA,MACA,QACA,KACA,MACA,QACA,OACA,OACA,QACA,SACA,QACA,MACD,CAEY,SAAS,EAAI,CACjB,IAAI,EAAI,GAAG,EAAM,KAGnB,IAAI,IAAM,EAAQ,IAAI,IAAU,GAAG,GAAG,EAAY,IAAI,EAAI,IAEnE,cAAe,EAAc,IAAgB,EAC7C,SAAU,OAAO,WAAW,CAC7B,CAKK,EAAmD,IAAA,EAAA,EAAA,SAC/C,EAAU,CAAE,QAAS,EAAa,CAAC,CAKhC,GACX,EAAyC,KACrC,CACJ,QAAS,EACT,SAAU,CACR,iBACD,CACF,EAQM,IAAA,EAAA,KAA8B,CACnC,kBAAQ,EAAA,EAAA,QAA0B,EAAyB,CACzD,SAAU,GACX,CAAC,CAEF,eAAe,EAAkB,EAA4C,CAI3E,OAHK,KAAK,iBAGH,KAAK,iBAAiB,eAAe,EAAU,EAAU,CAFvD,4BAVD,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,OACL,EAAA,EAAA,QAA0B,EAAyB,CAAE,SAAU,GAAM,CAAC,EAGnE,CACL,eAAgB,EACjB"}
|
package/dist/cjs/plugins.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./chunk-Bmb41Sf3.cjs`),t=require(`./renderIntlayerNode.cjs`),n=require(`./ContentSelector.component-Dfy-4WRH.cjs`),r=require(`./markdown/installIntlayerMarkdown.cjs`);let i=require(`@intlayer/core/interpreter`),a=require(`@intlayer/config/built`);a=e.t(a);let o=require(`@intlayer/core/markdown`),s=require(`@intlayer/types/nodeType`);const c=(e,t)=>({...e,createElement:(n,r,...i)=>{let a=t?.[n];if(a){let t={...r,...a},o=r?.class||r?.className,s=a.class||a.className;return o&&s&&(t.class=`${o} ${s}`,t.className=void 0),e.createElement(n,t,...i)}return e.createElement(n,r,...i)}}),l={id:`intlayer-node-plugin`,canHandle:e=>typeof e==`bigint`||typeof e==`string`||typeof e==`number`,transform:(e,{children:r,...i})=>t.renderIntlayerNode({...i,value:r,children:()=>({component:a.default?.editor.enabled?n.t:r,props:{dictionaryKey:i.dictionaryKey,keyPath:i.keyPath},children:r})})},u={id:`markdown-string-plugin`,canHandle:e=>typeof e==`string`,transform:(e,i,s)=>{let{plugins:l,...u}=i,d=s((0,o.getMarkdownMetadata)(e),{plugins:[{id:`markdown-metadata-plugin`,canHandle:e=>typeof e==`string`||typeof e==`number`||typeof e==`boolean`||!e,transform:(n,r)=>t.renderIntlayerNode({...r,value:n,children:e})}],dictionaryKey:u.dictionaryKey,keyPath:[]}),f=i=>t.renderIntlayerNode({...u,value:e,children:a.default?.editor.enabled?()=>({component:n.t,props:{dictionaryKey:u.dictionaryKey,keyPath:u.keyPath,...i},children:()=>{let{renderMarkdown:t}=r.useMarkdown();return t(e,i)}}):()=>{let{renderMarkdown:t}=r.useMarkdown();return t(e,i)},additionalProps:{metadata:d}}),p=(t,n)=>new Proxy(t,{get(t,i,a){return i===`value`?e:i===`metadata`?d:i===`toString`||i===Symbol.toPrimitive?()=>(0,o.compile)(e,{runtime:n?c(r.htmlRuntime,n):r.htmlRuntime}):i===`use`?e=>{let t={...n,...e};return p(f(t),t)}:Reflect.get(t,i,a)}});return p(f())}},d={id:`markdown-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.Markdown,transform:(e,t,n)=>{let r=[...t.keyPath,{type:s.NodeType.Markdown}],i=e[s.NodeType.Markdown];return n(i,{...t,children:i,keyPath:r,plugins:[u,...t.plugins??[]]})}},f={id:`html-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.HTML,transform:(e,i)=>{let l=e[s.NodeType.HTML],{plugins:u,...d}=i,f=e=>t.renderIntlayerNode({...d,value:l,children:a.default?.editor.enabled?()=>({component:n.t,props:{dictionaryKey:d.dictionaryKey,keyPath:d.keyPath,...e},children:l}):l}),p=(e,t)=>new Proxy(e,{get(e,n,i){return n===`value`?l:n===`toString`||n===Symbol.toPrimitive?()=>!t||typeof t==`object`&&Object.keys(t).length===0?String(l):(0,o.compile)(l,{runtime:c(r.htmlRuntime,t)}):n===`use`?e=>{let n={...t,...e};return p(f(n),n)}:Reflect.get(e,n,i)}});return p(f())}},p={id:`insertion-plugin`,canHandle:e=>typeof e==`object`&&e?.nodeType===s.NodeType.Insertion,transform:(e,n)=>{let{plugins:r,...i}=n,a=(t={})=>{let n=e.insertion;return t&&Object.entries(t).forEach(([e,t])=>{n=n.replace(RegExp(`{{\\s*${e}\\s*}}`,`g`),String(t))}),n};return t.renderIntlayerNode({...i,value:a,children:a})}},m=(e,t=!0)=>[(0,i.translationPlugin)(e??a.default.internationalization.defaultLocale,t?a.default.internationalization.defaultLocale:void 0),i.enumerationPlugin,i.conditionPlugin,(0,i.nestedPlugin)(e??a.default.internationalization.defaultLocale),i.filePlugin,i.genderPlugin,l,d,f,p];exports.getPlugins=m,exports.htmlPlugin=f,exports.insertionPlugin=p,exports.intlayerNodePlugins=l,exports.markdownPlugin=d,exports.markdownStringPlugin=u;
|
|
2
2
|
//# sourceMappingURL=plugins.cjs.map
|
package/dist/cjs/plugins.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n }),\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n }),\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"plugins.cjs","names":["renderIntlayerNode","configuration","ContentSelectorWrapperComponent","useMarkdown","htmlRuntime","NodeType","enumerationPlugin","conditionPlugin","filePlugin","genderPlugin"],"sources":["../../src/plugins.ts"],"sourcesContent":["import configuration from '@intlayer/config/built';\nimport {\n conditionPlugin,\n type DeepTransformContent as DeepTransformContentCore,\n enumerationPlugin,\n filePlugin,\n genderPlugin,\n type IInterpreterPluginState as IInterpreterPluginStateCore,\n nestedPlugin,\n type Plugins,\n translationPlugin,\n} from '@intlayer/core/interpreter';\nimport {\n compile,\n getMarkdownMetadata,\n type MarkdownContent,\n} from '@intlayer/core/markdown';\nimport type { HTMLContent, InsertionContent } from '@intlayer/core/transpiler';\nimport type { KeyPath } from '@intlayer/types/keyPath';\nimport type {\n DeclaredLocales,\n LocalesValues,\n} from '@intlayer/types/module_augmentation';\nimport { NodeType } from '@intlayer/types/nodeType';\nimport { ContentSelectorWrapperComponent } from './editor/ContentSelector.component';\nimport { htmlRuntime, useMarkdown } from './markdown/installIntlayerMarkdown';\nimport { renderIntlayerNode } from './renderIntlayerNode';\n\n/** ---------------------------------------------\n * UTILS\n * --------------------------------------------- */\n\nconst createRuntimeWithOverides = (baseRuntime: any, overrides: any) => ({\n ...baseRuntime,\n createElement: (tag: string, props: any, ...children: any[]) => {\n const override = overrides?.[tag];\n\n if (override) {\n const newProps = { ...props, ...override };\n\n // Merge class attributes intelligently\n const originalClass = props?.class || props?.className;\n const overrideClass = override.class || override.className;\n\n if (originalClass && overrideClass) {\n newProps.class = `${originalClass} ${overrideClass}`;\n newProps.className = undefined;\n }\n\n return baseRuntime.createElement(tag, newProps, ...children);\n }\n\n return baseRuntime.createElement(tag, props, ...children);\n },\n});\n\n/** ---------------------------------------------\n * INTLAYER NODE PLUGIN\n * --------------------------------------------- */\n\nexport type IntlayerNodeCond<T> = T extends number | string\n ? IntlayerNode<T>\n : never;\n\nexport interface IntlayerNode<T, P = {}> {\n value: T;\n children?: any;\n additionalProps?: P;\n}\n\n/** Translation plugin. Replaces node with a locale string if nodeType = Translation. */\nexport const intlayerNodePlugins: Plugins = {\n id: 'intlayer-node-plugin',\n canHandle: (node) =>\n typeof node === 'bigint' ||\n typeof node === 'string' ||\n typeof node === 'number',\n transform: (_node, { children, ...rest }) =>\n renderIntlayerNode({\n ...rest,\n value: children,\n children: () => ({\n component: configuration?.editor.enabled\n ? ContentSelectorWrapperComponent\n : children,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n },\n children: children,\n }),\n }),\n};\n\n/**\n * MARKDOWN PLUGIN\n */\n\nexport type MarkdownStringCond<T> = T extends string\n ? IntlayerNode<string, { metadata: DeepTransformContent<string> }>\n : never;\n\n/** Markdown string plugin. Replaces string node with a component that render the markdown. */\nexport const markdownStringPlugin: Plugins = {\n id: 'markdown-string-plugin',\n canHandle: (node) => typeof node === 'string',\n transform: (node: string, props, deepTransformNode) => {\n const {\n plugins, // Removed to avoid next error - Functions cannot be passed directly to Client Components\n ...rest\n } = props;\n\n const metadata = getMarkdownMetadata(node);\n\n const metadataPlugins: Plugins = {\n id: 'markdown-metadata-plugin',\n canHandle: (metadataNode) =>\n typeof metadataNode === 'string' ||\n typeof metadataNode === 'number' ||\n typeof metadataNode === 'boolean' ||\n !metadataNode,\n transform: (metadataNode, props) =>\n renderIntlayerNode({\n ...props,\n value: metadataNode,\n children: node,\n }),\n };\n\n // Transform metadata while keeping the same structure\n const metadataNodes = deepTransformNode(metadata, {\n plugins: [metadataPlugins],\n dictionaryKey: rest.dictionaryKey,\n keyPath: [],\n });\n\n const render = (components?: any) =>\n renderIntlayerNode({\n ...rest,\n value: node,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...components,\n },\n children: () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n })\n : () => {\n const { renderMarkdown } = useMarkdown();\n return renderMarkdown(node, components);\n },\n additionalProps: {\n metadata: metadataNodes,\n },\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return node;\n }\n if (prop === 'metadata') {\n return metadataNodes;\n }\n\n if (prop === 'toString') {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n const runtime = components\n ? createRuntimeWithOverides(htmlRuntime, components)\n : htmlRuntime;\n return compile(node, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n return (newComponents?: any) => {\n const mergedComponents = { ...components, ...newComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\nexport type MarkdownCond<T, _S, _L extends LocalesValues> = T extends {\n nodeType: NodeType | string;\n [NodeType.Markdown]: infer M;\n tags?: infer U;\n metadata?: infer V;\n}\n ? IntlayerNode<\n M,\n {\n use: (components?: Record<keyof U, any>) => any;\n metadata: DeepTransformContent<V>;\n }\n >\n : never;\n\nexport const markdownPlugin: Plugins = {\n id: 'markdown-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Markdown,\n transform: (node: MarkdownContent, props, deepTransformNode) => {\n const newKeyPath: KeyPath[] = [\n ...props.keyPath,\n {\n type: NodeType.Markdown,\n },\n ];\n\n const children = node[NodeType.Markdown];\n\n return deepTransformNode(children, {\n ...props,\n children,\n keyPath: newKeyPath,\n plugins: [markdownStringPlugin, ...(props.plugins ?? [])],\n });\n },\n};\n\n/** ---------------------------------------------\n * HTML PLUGIN\n * --------------------------------------------- */\n\n/**\n * HTML conditional type.\n *\n * This ensures type safety:\n * - `html('<div>Hello <CustomComponent /></div>').use({ CustomComponent: ... })` - optional but typed\n */\nexport type HTMLPluginCond<T, _S, _L> = T extends {\n nodeType: NodeType | string;\n [NodeType.HTML]: infer I;\n tags?: infer U;\n}\n ? IntlayerNode<\n I,\n {\n use: (components?: Record<keyof U, any>) => any;\n }\n >\n : never;\n\n/** HTML plugin. Replaces node with a function that takes components => IntlayerNode. */\nexport const htmlPlugin: Plugins = {\n id: 'html-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.HTML,\n\n transform: (node: HTMLContent<string>, props) => {\n const html = node[NodeType.HTML];\n const { plugins, ...rest } = props;\n\n // Type-safe render function that accepts properly typed components\n const render = (userComponents?: any) =>\n renderIntlayerNode({\n ...rest,\n value: html,\n children: configuration?.editor.enabled\n ? () => ({\n component: ContentSelectorWrapperComponent,\n props: {\n dictionaryKey: rest.dictionaryKey,\n keyPath: rest.keyPath,\n ...userComponents,\n },\n children: html,\n })\n : html,\n });\n\n const createProxy = (element: any, components?: any) =>\n new Proxy(element, {\n get(target, prop, receiver) {\n if (prop === 'value') {\n return html;\n }\n\n if (prop === 'toString') {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === Symbol.toPrimitive) {\n return () => {\n if (\n !components ||\n (typeof components === 'object' &&\n Object.keys(components).length === 0)\n ) {\n return String(html);\n }\n const runtime = createRuntimeWithOverides(\n htmlRuntime,\n components\n );\n return compile(html, {\n runtime,\n }) as string;\n };\n }\n\n if (prop === 'use') {\n // Return a properly typed function based on custom components\n return (userComponents?: any) => {\n const mergedComponents = { ...components, ...userComponents };\n return createProxy(render(mergedComponents), mergedComponents);\n };\n }\n\n return Reflect.get(target, prop, receiver);\n },\n }) as any;\n\n return createProxy(render() as any);\n },\n};\n\n/** ---------------------------------------------\n * INSERTION PLUGIN\n * --------------------------------------------- */\n\n/**\n * Insertion conditional type.\n */\nexport type InsertionPluginCond<T> = T extends {\n nodeType: NodeType | string;\n [NodeType.Insertion]: infer _I;\n}\n ? (args: Record<string, string | number>) => string\n : never;\n\nexport const insertionPlugin: Plugins = {\n id: 'insertion-plugin',\n canHandle: (node) =>\n typeof node === 'object' && node?.nodeType === NodeType.Insertion,\n transform: (node: InsertionContent, props) => {\n const { plugins, ...rest } = props;\n\n // Return a function that performs the interpolation\n const render = (args: Record<string, string | number> = {}) => {\n let text = node.insertion as string;\n if (args) {\n Object.entries(args).forEach(([key, value]) => {\n text = text.replace(\n new RegExp(`{{\\\\s*${key}\\\\s*}}`, 'g'),\n String(value)\n );\n });\n }\n return text;\n };\n\n return renderIntlayerNode({\n ...rest,\n value: render as any,\n children: render,\n });\n },\n};\n\nexport interface IInterpreterPluginAngular<T, S, L extends LocalesValues> {\n angularIntlayerNode: IntlayerNodeCond<T>;\n angularMarkdown: MarkdownCond<T, S, L>;\n angularHtml: HTMLPluginCond<T, S, L>;\n angularInsertion: InsertionPluginCond<T>;\n}\n\n/**\n * Insert this type as param of `DeepTransformContent` to avoid `intlayer` package pollution.\n *\n * Otherwise the the `angular-intlayer` plugins will override the types of `intlayer` functions.\n */\nexport type IInterpreterPluginState = Omit<\n IInterpreterPluginStateCore,\n 'insertion' // Remove insertion type from core package\n> & {\n angularIntlayerNode: true;\n angularMarkdown: true;\n angularHtml: true;\n angularInsertion: true;\n};\n\nexport type DeepTransformContent<\n T,\n L extends LocalesValues = DeclaredLocales,\n> = DeepTransformContentCore<T, IInterpreterPluginState, L>;\n\n/**\n * Get the plugins array for Angular content transformation.\n * This function is used by both getIntlayer and getDictionary to ensure consistent plugin configuration.\n */\nexport const getPlugins = (\n locale?: LocalesValues,\n fallback: boolean = true\n): Plugins[] => [\n translationPlugin(\n locale ?? configuration.internationalization.defaultLocale,\n fallback ? configuration.internationalization.defaultLocale : undefined\n ),\n enumerationPlugin,\n conditionPlugin,\n nestedPlugin(locale ?? configuration.internationalization.defaultLocale),\n filePlugin,\n genderPlugin,\n intlayerNodePlugins,\n markdownPlugin,\n htmlPlugin,\n insertionPlugin,\n];\n"],"mappings":"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"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`}),require(`../chunk-Bmb41Sf3.cjs`);let e=require(`node:path`),t=require(`@intlayer/config/node`),n=require(`@intlayer/config/utils`),r=require(`@intlayer/webpack`),i=require(`defu`);const a=a=>{let o=(0,t.getConfiguration)();return(0,i.defu)({resolve:{alias:(0,n.getAlias)({configuration:o,formatter:t=>(0,e.resolve)(t)})},externals:{esbuild:`esbuild`,module:`module`,fs:`fs`,chokidar:`chokidar`,fsevents:`fsevents`},module:{rules:[{test:/\.node$/,loader:`node-loader`},{test:/\.mjs$/,include:[/[\\/]\.intlayer[\\/]/],type:`javascript/auto`,enforce:`pre`,use:{loader:`babel-loader`,options:{presets:[[`@babel/preset-env`,{modules:`commonjs`}]],plugins:[[`@babel/plugin-syntax-import-attributes`,{deprecatedAssert:!0}]]}}}]},plugins:[new r.IntlayerPlugin(o)]},a)};exports.mergeConfig=a;
|
|
2
2
|
//# sourceMappingURL=mergeConfig.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mergeConfig.cjs","names":["IntlayerPlugin"],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n\n // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: 'babel-loader',\n options: {\n presets: [['@babel/preset-env', { modules: 'commonjs' }]],\n plugins: [\n [\n '@babel/plugin-syntax-import-attributes',\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as WebpackConfig;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"mergeConfig.cjs","names":["IntlayerPlugin"],"sources":["../../../src/webpack/mergeConfig.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { getConfiguration } from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\nimport { IntlayerPlugin } from '@intlayer/webpack'; // adjust path if needed\nimport { defu } from 'defu';\nimport type { Configuration as WebpackConfig } from 'webpack';\n\nexport const mergeConfig = (baseConfig: WebpackConfig): WebpackConfig => {\n const intlayerConfig = getConfiguration();\n\n const config = {\n resolve: {\n alias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n },\n externals: {\n esbuild: 'esbuild',\n module: 'module',\n fs: 'fs',\n chokidar: 'chokidar',\n fsevents: 'fsevents',\n },\n module: {\n rules: [\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n\n // Fix `import _48DQ2FD8DPGT8SPgqAmt from '../dictionary/app.json' with { type: 'json' };` syntax\n {\n test: /\\.mjs$/,\n include: [/[\\\\/]\\.intlayer[\\\\/]/],\n type: 'javascript/auto',\n enforce: 'pre',\n use: {\n loader: 'babel-loader',\n options: {\n presets: [['@babel/preset-env', { modules: 'commonjs' }]],\n plugins: [\n [\n '@babel/plugin-syntax-import-attributes',\n { deprecatedAssert: true },\n ],\n ],\n },\n },\n },\n ],\n },\n plugins: [new IntlayerPlugin(intlayerConfig)],\n };\n\n return defu(config, baseConfig) as WebpackConfig;\n};\n"],"mappings":"uPAOA,MAAa,EAAe,GAA6C,CACvE,IAAM,GAAA,EAAA,EAAA,mBAAmC,CA+CzC,OAAA,EAAA,EAAA,MA7Ce,CACb,QAAS,CACP,OAAA,EAAA,EAAA,UAAgB,CACd,cAAe,EACf,UAAY,IAAA,EAAA,EAAA,SAA0B,EAAM,CAC7C,CAAC,CACH,CACD,UAAW,CACT,QAAS,UACT,OAAQ,SACR,GAAI,KACJ,SAAU,WACV,SAAU,WACX,CACD,OAAQ,CACN,MAAO,CACL,CACE,KAAM,UACN,OAAQ,cACT,CAGD,CACE,KAAM,SACN,QAAS,CAAC,uBAAuB,CACjC,KAAM,kBACN,QAAS,MACT,IAAK,CACH,OAAQ,eACR,QAAS,CACP,QAAS,CAAC,CAAC,oBAAqB,CAAE,QAAS,WAAY,CAAC,CAAC,CACzD,QAAS,CACP,CACE,yCACA,CAAE,iBAAkB,GAAM,CAC3B,CACF,CACF,CACF,CACF,CACF,CACF,CACD,QAAS,CAAC,IAAIA,EAAAA,eAAe,EAAe,CAAC,CAC9C,CAEmB,EAAW"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{t as e}from"./decorate-EVKP5RjP.mjs";import{CUSTOM_ELEMENTS_SCHEMA as t,Component as n,Input as r}from"@angular/core";function i(e,t){if(typeof Reflect==`object`&&typeof Reflect.metadata==`function`)return Reflect.metadata(e,t)}let a=class{dictionaryKey;keyPath;get keyPathJson(){return JSON.stringify(this.keyPath)}};e([r(),i(`design:type`,String)],a.prototype,`dictionaryKey`,void 0),e([r(),i(`design:type`,Array)],a.prototype,`keyPath`,void 0),a=e([n({selector:`app-content-selector-wrapper`,standalone:!0,schemas:[t],template:`
|
|
2
|
+
<intlayer-content-selector-wrapper
|
|
3
|
+
[attr.key-path]="keyPathJson"
|
|
4
|
+
[attr.dictionary-key]="dictionaryKey"
|
|
5
|
+
>
|
|
6
|
+
<ng-content></ng-content>
|
|
7
|
+
</intlayer-content-selector-wrapper>
|
|
8
|
+
`})],a);export{a as t};
|
|
9
|
+
//# sourceMappingURL=ContentSelector.component-B9Uvy9gY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContentSelector.component-B9Uvy9gY.mjs","names":[],"sources":["../../src/editor/ContentSelector.component.ts"],"sourcesContent":["import { Component, CUSTOM_ELEMENTS_SCHEMA, Input } from '@angular/core';\n\n@Component({\n selector: 'app-content-selector-wrapper',\n standalone: true,\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n template: `\n <intlayer-content-selector-wrapper\n [attr.key-path]=\"keyPathJson\"\n [attr.dictionary-key]=\"dictionaryKey\"\n >\n <ng-content></ng-content>\n </intlayer-content-selector-wrapper>\n `,\n})\nexport class ContentSelectorWrapperComponent {\n @Input() dictionaryKey!: string;\n @Input() keyPath!: any[];\n\n get keyPathJson() {\n return JSON.stringify(this.keyPath);\n }\n}\n"],"mappings":"2OAeO,IAAA,EAAA,KAAsC,CAC3C,cACA,QAEA,IAAI,aAAc,CAChB,OAAO,KAAK,UAAU,KAAK,QAAQ,MAJpC,GAAO,CAAA,EAAA,cAAA,OAAA,CAAA,CAAA,EAAA,UAAA,gBAAA,IAAA,GAAA,IACP,GAAO,CAAA,EAAA,cAAA,MAAA,CAAA,CAAA,EAAA,UAAA,UAAA,IAAA,GAAA,MAfT,EAAU,CACT,SAAU,+BACV,WAAY,GACZ,QAAS,CAAC,EAAuB,CACjC,SAAU;;;;;;;IAQX,CAAC,CAAA,CAAA,EAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{t as e}from"../decorate-EVKP5RjP.mjs";import t from"@intlayer/config/built";import{Injectable as n,InjectionToken as r,signal as i}from"@angular/core";const a=new r(`intlayer`);let o=null,s=class{isCookieEnabled=i(!0);_locale=i(t.internationalization?.defaultLocale);locale=this._locale.asReadonly();setLocale=e=>{this._locale.set(e)}};s=e([n({providedIn:`root`})],s);const c=(e,t=!0)=>o||(o=new s,e&&o.setLocale(e),o.isCookieEnabled.set(t),o),l=(e,t=!0)=>({provide:a,useValue:u(e,t)}),u=(e,t=!0)=>c(e,t);export{a as INTLAYER_TOKEN,s as IntlayerProvider,c as createIntlayerClient,u as installIntlayer,l as provideIntlayer};
|
|
2
2
|
//# sourceMappingURL=installIntlayer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"installIntlayer.mjs","names":[],"sources":["../../../src/client/installIntlayer.ts"],"sourcesContent":["import { Injectable, InjectionToken, type Signal, signal } from '@angular/core';\nimport configuration from '@intlayer/config/built';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\n\nexport const INTLAYER_TOKEN = new InjectionToken<IntlayerProvider>('intlayer');\n\n/**\n * Singleton instance\n */\nlet instance: IntlayerProvider | null = null;\n\n@Injectable({\n providedIn: 'root',\n})\nexport class IntlayerProvider {\n isCookieEnabled = signal(true);\n private _locale = signal<LocalesValues>(\n configuration.internationalization?.defaultLocale as LocalesValues\n );\n\n readonly locale: Signal<LocalesValues> = this._locale.asReadonly();\n\n setLocale = (locale: LocalesValues) => {\n this._locale.set(locale);\n };\n}\n\n/**\n * Create and return a single IntlayerProvider instance\n */\nexport const createIntlayerClient = (\n locale?: LocalesValues,\n isCookieEnabled = true\n): IntlayerProvider => {\n if (instance) return instance;\n\n instance = new IntlayerProvider();\n\n if (locale) {\n instance.setLocale(locale);\n }\n instance.isCookieEnabled.set(isCookieEnabled);\n\n return instance;\n};\n\n/**\n * Provides Intlayer to your Angular application.\n *\n * This function should be used in your application's provider list (e.g., in `app.config.ts`)\n * to initialize the Intlayer service.\n *\n * @param locale - Initial locale to use.\n * @param isCookieEnabled - Whether to store the locale in cookies.\n * @returns A provider configuration for Intlayer.\n *\n * @example\n * ```ts\n * // app.config.ts\n * import { ApplicationConfig } from '@angular/core';\n * import { provideIntlayer } from 'angular-intlayer';\n *\n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideIntlayer({ locale: 'en' }),\n * ],\n * };\n * ```\n */\nexport const provideIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => ({\n provide: INTLAYER_TOKEN,\n useValue: installIntlayer(locale, isCookieEnabled),\n});\n\n/**\n * Helper to install the Intlayer provider.\n */\nexport const installIntlayer = (\n locale?: LocalesValues,\n isCookieEnabled = true\n) => {\n const client = createIntlayerClient(locale, isCookieEnabled);\n\n // Note: Angular editor installation will be handled differently\n // installIntlayerEditor();\n\n return client;\n};\n"],"mappings":"8JAIA,MAAa,EAAiB,IAAI,EAAiC,WAAW,CAK9E,IAAI,EAAoC,KAKjC,EAAA,KAAuB,CAC5B,gBAAkB,EAAO,GAAK,CAC9B,QAAkB,EAChB,EAAc,sBAAsB,cACrC,CAED,OAAyC,KAAK,QAAQ,YAAY,CAElE,UAAa,GAA0B,CACrC,KAAK,QAAQ,IAAI,EAAO,QAZ3B,EAAW,CACV,WAAY,OACb,CAAC,CAAA,CAAA,EAAA,CAiBF,MAAa,GACX,EACA,EAAkB,KAEd,IAEJ,EAAW,IAAI,EAEX,GACF,EAAS,UAAU,EAAO,CAE5B,EAAS,gBAAgB,IAAI,EAAgB,CAEtC,GA0BI,GACX,EACA,EAAkB,MACd,CACJ,QAAS,EACT,SAAU,EAAgB,EAAQ,EAAgB,CACnD,EAKY,GACX,EACA,EAAkB,KAEH,EAAqB,EAAQ,EAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable 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 * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"mKA6BA,MAAa,EAAW,GAA2B,CACjD,IAAM,EAAW,EAAO,EAAiB,CAEzC,OAAO,MAGE,EAFe,GAAU,EAAS,QAAQ,CAEnB,CAC9B"}
|
|
1
|
+
{"version":3,"file":"useIntl.mjs","names":[],"sources":["../../../src/client/useIntl.ts"],"sourcesContent":["import { computed, inject } from '@angular/core';\nimport { bindIntl, type WrappedIntl } from '@intlayer/core/formatters';\nimport type { LocalesValues } from '@intlayer/types/module_augmentation';\nimport { IntlayerProvider } from './installIntlayer';\n\n/**\n * Angular composable 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 * ```typescript\n * import { Component, computed } from '@angular/core';\n * import { useIntl } from 'angular-intlayer';\n *\n * @Component({ ... })\n * export class MyComponent {\n * intl = useIntl();\n * formattedPrice = computed(() =>\n * new this.intl().NumberFormat({\n * style: 'currency',\n * currency: 'USD'\n * }).format(123.45)\n * );\n * }\n * ```\n */\nexport const useIntl = (locale?: LocalesValues) => {\n const intlayer = inject(IntlayerProvider);\n\n return computed<WrappedIntl>(() => {\n const currentLocale = locale ?? intlayer.locale();\n\n return bindIntl(currentLocale);\n });\n};\n"],"mappings":"mKA6BA,MAAa,EAAW,GAA2B,CACjD,IAAM,EAAW,EAAO,EAAiB,CAEzC,OAAO,MAGE,EAFe,GAAU,EAAS,QAAQ,CAEnB,CAC9B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}
|
|
1
|
+
function e(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}export{e as t};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
<intlayer-content-selector-wrapper
|
|
3
|
-
[attr.key-path]="keyPathJson"
|
|
4
|
-
[attr.dictionary-key]="dictionaryKey"
|
|
5
|
-
>
|
|
6
|
-
<ng-content></ng-content>
|
|
7
|
-
</intlayer-content-selector-wrapper>
|
|
8
|
-
`})],a);export{a as ContentSelectorWrapperComponent};
|
|
9
|
-
//# sourceMappingURL=ContentSelector.component.mjs.map
|
|
1
|
+
import{t as e}from"../ContentSelector.component-B9Uvy9gY.mjs";export{e as ContentSelectorWrapperComponent};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{INTLAYER_TOKEN as e}from"../client/installIntlayer.mjs";import{DestroyRef as t,Injector as n,effect as r,inject as i,runInInjectionContext as a}from"@angular/core";import{isEnabled as o}from"@intlayer/editor/isEnabled";const s=()=>{if(
|
|
1
|
+
import{INTLAYER_TOKEN as e}from"../client/installIntlayer.mjs";import"../client/index.mjs";import{DestroyRef as t,Injector as n,effect as r,inject as i,runInInjectionContext as a}from"@angular/core";import{isEnabled as o}from"@intlayer/editor/isEnabled";const s=()=>{if(process.env.INTLAYER_EDITOR_ENABLED===`false`||!o)return;let s=i(t,{optional:!0}),c=i(e,{optional:!0}),l=i(n);import(`@intlayer/editor`).then(({initEditorClient:e})=>{let t=e();if(c){let e=a(l,()=>r(()=>{let e=c.locale();e&&t.currentLocale.set(e)}));s?.onDestroy(()=>e.destroy())}}),s?.onDestroy(()=>{import(`@intlayer/editor`).then(({stopEditorClient:e})=>{e()})})};export{s as useEditor};
|
|
2
2
|
//# sourceMappingURL=useEditor.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (!isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useEditor.mjs","names":[],"sources":["../../../src/editor/useEditor.ts"],"sourcesContent":["import {\n DestroyRef,\n effect,\n Injector,\n inject,\n runInInjectionContext,\n} from '@angular/core';\nimport { isEnabled } from '@intlayer/editor/isEnabled';\nimport type { Locale } from '@intlayer/types/allLocales';\nimport { INTLAYER_TOKEN, type IntlayerProvider } from '../client';\n\nexport const useEditor = () => {\n if (process.env.INTLAYER_EDITOR_ENABLED === 'false' || !isEnabled) return;\n\n const destroyRef = inject(DestroyRef, { optional: true });\n const client = inject<IntlayerProvider>(INTLAYER_TOKEN, {\n optional: true,\n } as any);\n const injector = inject(Injector);\n\n import('@intlayer/editor').then(({ initEditorClient }) => {\n const manager = initEditorClient();\n\n if (client) {\n const effectRef = runInInjectionContext(injector, () =>\n effect(() => {\n const locale = client.locale();\n if (locale) manager.currentLocale.set(locale as Locale);\n })\n );\n destroyRef?.onDestroy(() => effectRef.destroy());\n }\n });\n\n destroyRef?.onDestroy(() => {\n import('@intlayer/editor').then(({ stopEditorClient }) => {\n stopEditorClient();\n });\n });\n};\n"],"mappings":"8PAWA,MAAa,MAAkB,CAC7B,GAAI,QAAQ,IAAI,0BAA4B,SAAW,CAAC,EAAW,OAEnE,IAAM,EAAa,EAAO,EAAY,CAAE,SAAU,GAAM,CAAC,CACnD,EAAS,EAAyB,EAAgB,CACtD,SAAU,GACX,CAAQ,CACH,EAAW,EAAO,EAAS,CAEjC,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,IAAM,EAAU,GAAkB,CAElC,GAAI,EAAQ,CACV,IAAM,EAAY,EAAsB,MACtC,MAAa,CACX,IAAM,EAAS,EAAO,QAAQ,CAC1B,GAAQ,EAAQ,cAAc,IAAI,EAAiB,EACvD,CACH,CACD,GAAY,cAAgB,EAAU,SAAS,CAAC,GAElD,CAEF,GAAY,cAAgB,CAC1B,OAAO,oBAAoB,MAAM,CAAE,sBAAuB,CACxD,GAAkB,EAClB,EACF"}
|