-
Notifications
You must be signed in to change notification settings - Fork 8
/
src.19911aa5.js.map
1 lines (1 loc) · 20.5 KB
/
src.19911aa5.js.map
1
{"version":3,"sources":["../../node_modules/@fluent/sequence/esm/map_sync.js","../../node_modules/@fluent/sequence/esm/map_async.js","../../node_modules/@fluent/sequence/esm/index.js","../../node_modules/cached-iterable/src/cached_iterable.mjs","../../node_modules/cached-iterable/src/cached_sync_iterable.mjs","../../node_modules/cached-iterable/src/cached_async_iterable.mjs","../../node_modules/cached-iterable/src/index.mjs","../../src/index.js"],"names":["mapBundleSync","bundles","ids","Array","isArray","map","id","getBundleForId","bundle","hasMessage","mapBundleAsync","foundBundles","length","fill","remainingCount","index","entries","CachedIterable","from","iterable","CachedSyncIterable","constructor","Symbol","iterator","Object","TypeError","cached","cur","next","push","touchNext","count","idx","last","done","CachedAsyncIterable","asyncIterator","MESSAGE_ID_ATTRIBUTE","DEPRECATED_MESSAGE_ID_ATTRIBUTE","FluentElement","HTMLElement","getMessage","messageId","args","unsafeArgs","whitelist","_bundles","_providerBundles","message","formatted","value","attributes","errors","preparedArgs","assign","escaper","document","createElement","name","arg","innerText","innerHTML","formatPattern","forEach","includes","errorEvent","CustomEvent","bubbles","detail","dispatchEvent","Error","connectedCallback","target","render","disconnectedCallback","providerBundles","newBundles","cacheBundles","attributeWhitelist","newValue","messageArgs","messageUnsafeArgs","observedAttributes","attributeChangedCallback","oldValue","toLowerCase","FluentProvider","_listeners","addEventListener","bundlesSubscribe","bundlesUnsubscribe","removeEventListener","event","provider","currentTarget","i","findIndex","splice","el","semiSafeInnerHTML","template","content","childNodes","node","appendChild","customElements","define","getAttribute","firstElementChild","setAttribute"],"mappings":";AAuBC,aAhBM,SAASA,EAAcC,EAASC,GAC/B,OAACC,MAAMC,QAAQF,GAGZA,EAAIG,IAAIC,GAAMC,EAAeN,EAASK,IAFlCC,EAAeN,EAASC,GAOvC,SAASK,EAAeN,EAASK,GACxB,IAAA,MAAME,KAAUP,EACbO,GAAAA,EAAOC,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ACM,GAAA,KAAKmC,kBAAmB,CACpB5D,MAAAA,EAAU,KAAKP,WAAW,CAC9BC,UAAW,KAAKiE,aAAatE,IAAyB,KAAKsE,aAAarE,GACxEK,KAAM,KAAKqC,YACXpC,WAAY,KAAKqC,kBACjBpC,UAAW,KAAKA,YAGdG,IACFxB,OAAOR,QAAQgC,EAAQG,YAAYY,QAAQ,EAAEL,EAAMR,MAC5C0D,KAAAA,kBAAkBC,aAAanD,EAAMR,KAG5CiD,EAAkB,KAAKS,kBAAmB5D,QAOpDyD,eAAeC,OAAO,kBAAmBpB","file":"src.19911aa5.js","sourceRoot":"example/elm","sourcesContent":["/*\n * Synchronously map an identifier or an array of identifiers to the best\n * `FluentBundle` instance(s).\n *\n * @param bundles - An iterable of bundles to sift through.\n * @param ids - An id or ids to map.\n */\nexport function mapBundleSync(bundles, ids) {\n if (!Array.isArray(ids)) {\n return getBundleForId(bundles, ids);\n }\n return ids.map(id => getBundleForId(bundles, id));\n}\n/*\n * Find the best `FluentBundle` with the translation for `id`.\n */\nfunction getBundleForId(bundles, id) {\n for (const bundle of bundles) {\n if (bundle.hasMessage(id)) {\n return bundle;\n }\n }\n return null;\n}\n","/*\n * Asynchronously map an identifier or an array of identifiers to the best\n * `FluentBundle` instance(s).\n *\n * @param bundles - An iterable of bundles to sift through.\n * @param ids - An id or ids to map.\n */\nexport async function mapBundleAsync(bundles, ids) {\n if (!Array.isArray(ids)) {\n for await (const bundle of bundles) {\n if (bundle.hasMessage(ids)) {\n return bundle;\n }\n }\n return null;\n }\n const foundBundles = new Array(ids.length).fill(null);\n let remainingCount = ids.length;\n for await (const bundle of bundles) {\n for (const [index, id] of ids.entries()) {\n if (!foundBundles[index] && bundle.hasMessage(id)) {\n foundBundles[index] = bundle;\n remainingCount--;\n }\n // Return early when all ids have been mapped to bundles.\n if (remainingCount === 0) {\n return foundBundles;\n }\n }\n }\n return foundBundles;\n}\n","/*\n * @module fluent-sequence\n * @overview Manage ordered sequences of FluentBundles.\n */\nexport { mapBundleSync } from \"./map_sync.js\";\nexport { mapBundleAsync } from \"./map_async.js\";\n","/*\n * Base CachedIterable class.\n */\nexport default class CachedIterable extends Array {\n /**\n * Create a `CachedIterable` instance from an iterable or, if another\n * instance of `CachedIterable` is passed, return it without any\n * modifications.\n *\n * @param {Iterable} iterable\n * @returns {CachedIterable}\n */\n static from(iterable) {\n if (iterable instanceof this) {\n return iterable;\n }\n\n return new this(iterable);\n }\n}\n","import CachedIterable from \"./cached_iterable.mjs\";\n\n/*\n * CachedSyncIterable caches the elements yielded by an iterable.\n *\n * It can be used to iterate over an iterable many times without depleting the\n * iterable.\n */\nexport default class CachedSyncIterable extends CachedIterable {\n /**\n * Create an `CachedSyncIterable` instance.\n *\n * @param {Iterable} iterable\n * @returns {CachedSyncIterable}\n */\n constructor(iterable) {\n super();\n\n if (Symbol.iterator in Object(iterable)) {\n this.iterator = iterable[Symbol.iterator]();\n } else {\n throw new TypeError(\"Argument must implement the iteration protocol.\");\n }\n }\n\n [Symbol.iterator]() {\n const cached = this;\n let cur = 0;\n\n return {\n next() {\n if (cached.length <= cur) {\n cached.push(cached.iterator.next());\n }\n return cached[cur++];\n }\n };\n }\n\n /**\n * This method allows user to consume the next element from the iterator\n * into the cache.\n *\n * @param {number} count - number of elements to consume\n */\n touchNext(count = 1) {\n let idx = 0;\n while (idx++ < count) {\n const last = this[this.length - 1];\n if (last && last.done) {\n break;\n }\n this.push(this.iterator.next());\n }\n // Return the last cached {value, done} object to allow the calling\n // code to decide if it needs to call touchNext again.\n return this[this.length - 1];\n }\n}\n","import CachedIterable from \"./cached_iterable.mjs\";\n\n/*\n * CachedAsyncIterable caches the elements yielded by an async iterable.\n *\n * It can be used to iterate over an iterable many times without depleting the\n * iterable.\n */\nexport default class CachedAsyncIterable extends CachedIterable {\n /**\n * Create an `CachedAsyncIterable` instance.\n *\n * @param {Iterable} iterable\n * @returns {CachedAsyncIterable}\n */\n constructor(iterable) {\n super();\n\n if (Symbol.asyncIterator in Object(iterable)) {\n this.iterator = iterable[Symbol.asyncIterator]();\n } else if (Symbol.iterator in Object(iterable)) {\n this.iterator = iterable[Symbol.iterator]();\n } else {\n throw new TypeError(\"Argument must implement the iteration protocol.\");\n }\n }\n\n /**\n * Asynchronous iterator caching the yielded elements.\n *\n * Elements yielded by the original iterable will be cached and available\n * synchronously. Returns an async generator object implementing the\n * iterator protocol over the elements of the original (async or sync)\n * iterable.\n */\n [Symbol.asyncIterator]() {\n const cached = this;\n let cur = 0;\n\n return {\n async next() {\n if (cached.length <= cur) {\n cached.push(cached.iterator.next());\n }\n return cached[cur++];\n }\n };\n }\n\n /**\n * This method allows user to consume the next element from the iterator\n * into the cache.\n *\n * @param {number} count - number of elements to consume\n */\n async touchNext(count = 1) {\n let idx = 0;\n while (idx++ < count) {\n const last = this[this.length - 1];\n if (last && (await last).done) {\n break;\n }\n this.push(this.iterator.next());\n }\n // Return the last cached {value, done} object to allow the calling\n // code to decide if it needs to call touchNext again.\n return this[this.length - 1];\n }\n}\n","export {default as CachedSyncIterable} from \"./cached_sync_iterable.mjs\";\nexport {default as CachedAsyncIterable} from \"./cached_async_iterable.mjs\";\n","import { mapBundleSync } from \"@fluent/sequence\";\nimport { CachedSyncIterable } from \"cached-iterable\";\n\nconst MESSAGE_ID_ATTRIBUTE = \"messageid\";\nconst DEPRECATED_MESSAGE_ID_ATTRIBUTE = \"messageId\";\n\nclass FluentElement extends HTMLElement {\n getMessage({ messageId, args, unsafeArgs, whitelist = [] }) {\n const bundles = this._bundles || this._providerBundles;\n if (bundles) {\n const bundle = mapBundleSync(bundles, messageId);\n\n if (bundle) {\n const message = bundle.getMessage(messageId);\n\n if (message) {\n const formatted = { value: null, attributes: {} };\n let errors = [];\n\n const preparedArgs = Object.assign({}, unsafeArgs || {});\n const escaper = document.createElement(\"div\");\n for (let [name, arg] of Object.entries(args || {})) {\n if (typeof arg === \"string\") {\n escaper.innerText = arg;\n preparedArgs[name] = escaper.innerHTML;\n }\n else {\n preparedArgs[name] = arg;\n }\n }\n if (message.value) {\n formatted.value = bundle.formatPattern(message.value, preparedArgs, errors);\n }\n\n Object.entries(message.attributes).forEach(([name, value]) => {\n if (whitelist.includes(name)) {\n formatted.attributes[name] = bundle.formatPattern(value, preparedArgs, errors);\n }\n });\n\n if (errors.length > 0) {\n const errorEvent = new CustomEvent(\"fluent-web-error\", {\n bubbles: true,\n detail: {\n messageId,\n args: preparedArgs,\n message,\n errors,\n },\n });\n this.dispatchEvent(errorEvent);\n }\n\n return formatted;\n } else {\n const errorEvent = new CustomEvent(\"fluent-web-error\", {\n bubbles: true,\n detail: {\n messageId,\n args,\n errors: [new Error(\"Message object not found\")],\n },\n });\n this.dispatchEvent(errorEvent);\n }\n }\n }\n\n return null;\n }\n\n connectedCallback() {\n this.dispatchEvent(\n new CustomEvent(\"fluent-bundles-subscribe\", {\n bubbles: true,\n target: this,\n })\n );\n this.render();\n }\n disconnectedCallback() {\n this.dispatchEvent(\n new CustomEvent(\"fluent-bundles-unsubscribe\", {\n bubbles: true,\n target: this,\n })\n );\n }\n\n set providerBundles(newBundles) {\n this._providerBundles = cacheBundles(this, newBundles);\n this.render();\n }\n\n set bundles(newBundles) {\n this._bundles = cacheBundles(this, newBundles);\n this.render();\n }\n\n set attributeWhitelist(whitelist) {\n this.whitelist = whitelist;\n this.render();\n }\n\n set args(newValue) {\n this.messageArgs = newValue;\n this.render();\n }\n\n set unsafeArgs(newValue) {\n this.messageUnsafeArgs = newValue;\n this.render();\n }\n\n static get observedAttributes() {\n return [MESSAGE_ID_ATTRIBUTE, DEPRECATED_MESSAGE_ID_ATTRIBUTE];\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n if (name.toLowerCase() === MESSAGE_ID_ATTRIBUTE && oldValue !== newValue) {\n this.render();\n }\n }\n}\n\nclass FluentProvider extends HTMLElement {\n constructor() {\n super();\n this._listeners = [];\n }\n connectedCallback() {\n this._listeners = [];\n this.addEventListener(\"fluent-bundles-subscribe\", bundlesSubscribe);\n this.addEventListener(\"fluent-bundles-unsubscribe\", bundlesUnsubscribe);\n }\n disconnectedCallback() {\n this._listeners = [];\n this.removeEventListener(\"fluent-bundles-subscribe\", bundlesSubscribe);\n this.removeEventListener(\"fluent-bundles-unsubscribe\", bundlesUnsubscribe);\n }\n get bundles() {\n return this._bundles;\n }\n set bundles(newBundles) {\n this._bundles = cacheBundles(this, newBundles);\n this._listeners.forEach((target) => {\n target.providerBundles = this._bundles;\n });\n }\n}\nfunction bundlesSubscribe(event) {\n const provider = event.currentTarget;\n provider._listeners.push(event.target);\n event.target.providerBundles = provider._bundles;\n}\nfunction bundlesUnsubscribe(event) {\n const provider = event.currentTarget;\n const i = provider._listeners.findIndex(event.target);\n if (i >= 0) {\n provider._listeners.splice(i, 1);\n }\n}\n\nfunction cacheBundles(el, bundles) {\n // Allow iterables (usually an array) or null\n if (bundles) {\n // Already cached, don't cache it twice\n if (bundles.constructor === CachedSyncIterable) {\n return bundles;\n }\n // Iterable check: https://stackoverflow.com/a/32538867/2782048\n if (typeof bundles[Symbol.iterator] === \"function\") {\n return CachedSyncIterable.from(bundles);\n }\n }\n if (bundles !== null) {\n el.dispatchEvent(\n new CustomEvent(\"fluent-web-error\", {\n bubbles: true,\n detail: {\n bundles,\n errors: [new Error(\"bundles property must be iterable or null\")],\n },\n }),\n );\n }\n return null;\n}\n\nfunction semiSafeInnerHTML(el, message) {\n if (message.value && message.value !== \"{???}\") {\n const template = document.createElement(\"template\");\n template.innerHTML = message.value;\n el.innerHTML = \"\";\n Array.from(template.content.childNodes).forEach((node) => {\n el.appendChild(node);\n });\n }\n}\n\ncustomElements.define(\n \"fluent-text\",\n class extends FluentElement {\n render() {\n const message = this.getMessage({\n messageId: this.getAttribute(MESSAGE_ID_ATTRIBUTE) || this.getAttribute(DEPRECATED_MESSAGE_ID_ATTRIBUTE),\n args: this.messageArgs,\n unsafeArgs: this.messageUnsafeArgs,\n });\n\n if (message) {\n semiSafeInnerHTML(this, message);\n }\n }\n }\n);\n\ncustomElements.define(\n \"fluent-element\",\n class extends FluentElement {\n render() {\n if (this.firstElementChild) {\n const message = this.getMessage({\n messageId: this.getAttribute(MESSAGE_ID_ATTRIBUTE) || this.getAttribute(DEPRECATED_MESSAGE_ID_ATTRIBUTE),\n args: this.messageArgs,\n unsafeArgs: this.messageUnsafeArgs,\n whitelist: this.whitelist\n });\n\n if (message) {\n Object.entries(message.attributes).forEach(([name, value]) => {\n this.firstElementChild.setAttribute(name, value);\n });\n\n semiSafeInnerHTML(this.firstElementChild, message);\n }\n }\n }\n }\n);\n\ncustomElements.define(\"fluent-provider\", FluentProvider);\n"]}