UNPKG

vue-intlayer

Version:

Easily internationalize i18n your Vue applications with type-safe multilingual content management.

38 lines (37 loc) 840 B
import i from "@intlayer/config/built"; import { v4 as a } from "uuid"; import { inject as u, reactive as l } from "vue"; const { editor: n } = i, o = { postMessage: () => null, allowedOrigins: [ n?.applicationURL, n?.editorURL, n?.cmsURL ], senderId: "" }; let t = null; const r = Symbol("Communicator"), m = (e = { postMessage: () => null }) => t || (t = l({ ...o, ...e, senderId: a() }), t), g = (e, s = { postMessage: () => null }) => { const c = m(s); e.provide(r, c); }, C = () => { try { return u(r, o); } catch { return console.warn( "useCommunicator: inject can only be used in setup(). Returning default communicator." ), { postMessage: () => null, senderId: "" }; } }; export { m as createCommunicator, g as installCommunicator, C as useCommunicator };