Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
package.dist.prod.Render.js.map Maven / Gradle / Ivy
{
"version": 3,
"sources": ["../../src/Render.ts"],
"sourcesContent": ["import EventProvider from \"./EventProvider.js\";\nimport RenderQueue from \"./RenderQueue.js\";\nimport { getAllRegisteredTags } from \"./CustomElementsRegistry.js\";\nimport { isRtlAware } from \"./locale/RTLAwareRegistry.js\";\nimport type UI5Element from \"./UI5Element.js\";\nimport type { PromiseResolve, Timeout } from \"./types.js\";\n\ntype BeforeComponentRenderCallback = (webComponent: UI5Element) => void;\n\nconst registeredElements = new Set();\nconst eventProvider = new EventProvider();\n\nconst invalidatedWebComponents = new RenderQueue(); // Queue for invalidated web components\n\nlet renderTaskPromise: Promise | undefined,\n\trenderTaskPromiseResolve: PromiseResolve | undefined;\n\nlet mutationObserverTimer: Timeout | undefined;\n\nlet queuePromise: Promise | null;\n\n/**\n * Schedules a render task (if not already scheduled) to render the component\n *\n * @param webComponent\n * @returns {Promise}\n */\nconst renderDeferred = async (webComponent: UI5Element) => {\n\t// Enqueue the web component\n\tinvalidatedWebComponents.add(webComponent);\n\n\t// Schedule a rendering task\n\tawait scheduleRenderTask();\n};\n\n/**\n * Renders a component synchronously and adds it to the registry of rendered components\n *\n * @param webComponent\n */\nconst renderImmediately = (webComponent: UI5Element) => {\n\teventProvider.fireEvent(\"beforeComponentRender\", webComponent);\n\tregisteredElements.add(webComponent);\n\twebComponent._render();\n};\n\n/**\n * Cancels the rendering of a component, if awaiting to be rendered, and removes it from the registry of rendered components\n *\n * @param webComponent\n */\nconst cancelRender = (webComponent: UI5Element) => {\n\tinvalidatedWebComponents.remove(webComponent);\n\tregisteredElements.delete(webComponent);\n};\n\n/**\n * Schedules a rendering task, if not scheduled already\n */\nconst scheduleRenderTask = async () => {\n\tif (!queuePromise) {\n\t\tqueuePromise = new Promise(resolve => {\n\t\t\twindow.requestAnimationFrame(() => {\n\t\t\t\t// Render all components in the queue\n\n\t\t\t\t// console.log(`--------------------RENDER TASK START------------------------------`); // eslint-disable-line\n\t\t\t\tinvalidatedWebComponents.process(renderImmediately);\n\t\t\t\t// console.log(`--------------------RENDER TASK END------------------------------`); // eslint-disable-line\n\n\t\t\t\t// Resolve the promise so that callers of renderDeferred can continue\n\t\t\t\tqueuePromise = null;\n\t\t\t\tresolve();\n\n\t\t\t\t// Wait for Mutation observer before the render task is considered finished\n\t\t\t\tif (!mutationObserverTimer) {\n\t\t\t\t\tmutationObserverTimer = setTimeout(() => {\n\t\t\t\t\t\tmutationObserverTimer = undefined;\n\t\t\t\t\t\tif (invalidatedWebComponents.isEmpty()) {\n\t\t\t\t\t\t\t_resolveTaskPromise();\n\t\t\t\t\t\t}\n\t\t\t\t\t}, 200);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t}\n\n\tawait queuePromise;\n};\n\n/**\n * return a promise that will be resolved once all invalidated web components are rendered\n */\nconst whenDOMUpdated = () => {\n\tif (renderTaskPromise) {\n\t\treturn renderTaskPromise;\n\t}\n\n\trenderTaskPromise = new Promise(resolve => {\n\t\trenderTaskPromiseResolve = resolve;\n\t\twindow.requestAnimationFrame(() => {\n\t\t\tif (invalidatedWebComponents.isEmpty()) {\n\t\t\t\trenderTaskPromise = undefined;\n\t\t\t\tresolve();\n\t\t\t}\n\t\t});\n\t});\n\n\treturn renderTaskPromise;\n};\n\nconst whenAllCustomElementsAreDefined = () => {\n\tconst definedPromises = getAllRegisteredTags().map(tag => customElements.whenDefined(tag));\n\treturn Promise.all(definedPromises);\n};\n\nconst renderFinished = async () => {\n\tawait whenAllCustomElementsAreDefined();\n\tawait whenDOMUpdated();\n};\n\nconst _resolveTaskPromise = () => {\n\tif (!invalidatedWebComponents.isEmpty()) {\n\t\t// More updates are pending. Resolve will be called again\n\t\treturn;\n\t}\n\n\tif (renderTaskPromiseResolve) {\n\t\trenderTaskPromiseResolve();\n\t\trenderTaskPromiseResolve = undefined;\n\t\trenderTaskPromise = undefined;\n\t}\n};\n\n/**\n * Re-renders all UI5 Elements on the page, with the option to specify filters to rerender only some components.\n *\n * Usage:\n * reRenderAllUI5Elements() -> re-renders all components\n * reRenderAllUI5Elements({tag: \"ui5-button\"}) -> re-renders only instances of ui5-button\n * reRenderAllUI5Elements({rtlAware: true}) -> re-renders only rtlAware components\n * reRenderAllUI5Elements({languageAware: true}) -> re-renders only languageAware components\n * reRenderAllUI5Elements({themeAware: true}) -> re-renders only themeAware components\n * reRenderAllUI5Elements({rtlAware: true, languageAware: true}) -> re-renders components that are rtlAware or languageAware\n * etc...\n *\n * @public\n * @param {object|undefined} filters - Object with keys that can be \"rtlAware\" or \"languageAware\"\n * @returns {Promise}\n */\nconst reRenderAllUI5Elements = async (filters?: {tag?: string, rtlAware?: boolean, languageAware?: boolean, themeAware?: boolean}) => {\n\tregisteredElements.forEach((element: UI5Element) => {\n\t\tconst ctor = element.constructor as typeof UI5Element;\n\t\tconst tag = ctor.getMetadata().getTag();\n\t\tconst rtlAware = isRtlAware(ctor);\n\t\tconst languageAware = ctor.getMetadata().isLanguageAware();\n\t\tconst themeAware = ctor.getMetadata().isThemeAware();\n\t\tif (!filters || (filters.tag === tag) || (filters.rtlAware && rtlAware) || (filters.languageAware && languageAware) || (filters.themeAware && themeAware)) {\n\t\t\trenderDeferred(element);\n\t\t}\n\t});\n\tawait renderFinished();\n};\n\nconst attachBeforeComponentRender = (listener: BeforeComponentRenderCallback) => {\n\teventProvider.attachEvent(\"beforeComponentRender\", listener);\n};\n\nconst detachBeforeComponentRender = (listener: BeforeComponentRenderCallback) => {\n\teventProvider.detachEvent(\"beforeComponentRender\", listener);\n};\n\nexport {\n\trenderDeferred,\n\trenderImmediately,\n\tcancelRender,\n\trenderFinished,\n\treRenderAllUI5Elements,\n\tattachBeforeComponentRender,\n\tdetachBeforeComponentRender,\n};\n"],
"mappings": "aAAA,OAAOA,MAAmB,qBAC1B,OAAOC,MAAiB,mBACxB,OAAS,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B,MAAOC,GAAgG,CACrIpB,EAAmB,QAASqB,GAAwB,CACnD,MAAMC,EAAOD,EAAQ,YACfJ,EAAMK,EAAK,YAAY,EAAE,OAAO,EAChCC,EAAWxB,EAAWuB,CAAI,EAC1BE,EAAgBF,EAAK,YAAY,EAAE,gBAAgB,EACnDG,EAAaH,EAAK,YAAY,EAAE,aAAa,GAC/C,CAACF,GAAYA,EAAQ,MAAQH,GAASG,EAAQ,UAAYG,GAAcH,EAAQ,eAAiBI,GAAmBJ,EAAQ,YAAcK,IAC7IlB,EAAec,CAAO,CAExB,CAAC,EACD,MAAMH,EAAe,CACtB,EAEMQ,EAA+BC,GAA4C,CAChF1B,EAAc,YAAY,wBAAyB0B,CAAQ,CAC5D,EAEMC,EAA+BD,GAA4C,CAChF1B,EAAc,YAAY,wBAAyB0B,CAAQ,CAC5D,EAEA,OACCpB,KAAA,eACAG,KAAA,kBACAC,KAAA,aACAO,KAAA,eACAC,KAAA,uBACAO,KAAA,4BACAE,KAAA",
"names": ["EventProvider", "RenderQueue", "getAllRegisteredTags", "isRtlAware", "registeredElements", "eventProvider", "invalidatedWebComponents", "renderTaskPromise", "renderTaskPromiseResolve", "mutationObserverTimer", "queuePromise", "renderDeferred", "webComponent", "scheduleRenderTask", "renderImmediately", "cancelRender", "resolve", "_resolveTaskPromise", "whenDOMUpdated", "whenAllCustomElementsAreDefined", "definedPromises", "tag", "renderFinished", "reRenderAllUI5Elements", "filters", "element", "ctor", "rtlAware", "languageAware", "themeAware", "attachBeforeComponentRender", "listener", "detachBeforeComponentRender"]
}