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.ManagedStyles.js.map Maven / Gradle / Ivy
{
"version": 3,
"sources": ["../../src/ManagedStyles.ts"],
"sourcesContent": ["import type { StyleData, StyleDataCSP } from \"./types.js\";\nimport { getCurrentRuntimeIndex, compareRuntimes } from \"./Runtimes.js\";\n\nconst isSSR = typeof document === \"undefined\";\n\nconst getStyleId = (name: string, value: string) => {\n\treturn value ? `${name}|${value}` : name;\n};\n\nconst shouldUpdate = (runtimeIndex: string | undefined) => {\n\tif (runtimeIndex === undefined) {\n\t\treturn true;\n\t}\n\treturn compareRuntimes(getCurrentRuntimeIndex(), parseInt(runtimeIndex)) === 1; // 1 means the current is newer, 0 means the same, -1 means the resource's runtime is newer\n};\n\nconst createStyle = (data: StyleData, name: string, value = \"\", theme?: string) => {\n\tconst content = typeof data === \"string\" ? data : data.content;\n\tconst currentRuntimeIndex = getCurrentRuntimeIndex();\n\n\tconst stylesheet = new CSSStyleSheet();\n\tstylesheet.replaceSync(content);\n\t(stylesheet as Record)._ui5StyleId = getStyleId(name, value); // set an id so that we can find the style later\n\tif (theme) {\n\t\t(stylesheet as Record)._ui5RuntimeIndex = currentRuntimeIndex;\n\t\t(stylesheet as Record)._ui5Theme = theme;\n\t}\n\tdocument.adoptedStyleSheets = [...document.adoptedStyleSheets, stylesheet];\n};\n\nconst updateStyle = (data: StyleData, name: string, value = \"\", theme?: string) => {\n\tconst content = typeof data === \"string\" ? data : data.content;\n\tconst currentRuntimeIndex = getCurrentRuntimeIndex();\n\n\tconst stylesheet = document.adoptedStyleSheets.find(sh => (sh as Record)._ui5StyleId === getStyleId(name, value));\n\tif (!stylesheet) {\n\t\treturn;\n\t}\n\n\tif (!theme) {\n\t\tstylesheet.replaceSync(content || \"\");\n\t} else {\n\t\tconst stylesheetRuntimeIndex: string | undefined = (stylesheet as Record)._ui5RuntimeIndex;\n\t\tconst stylesheetTheme: string | undefined = (stylesheet as Record)._ui5Theme;\n\t\tif (stylesheetTheme !== theme || shouldUpdate(stylesheetRuntimeIndex)) {\n\t\t\tstylesheet.replaceSync(content || \"\");\n\t\t\t(stylesheet as Record)._ui5RuntimeIndex = String(currentRuntimeIndex);\n\t\t\t(stylesheet as Record)._ui5Theme = theme;\n\t\t}\n\t}\n};\n\nconst hasStyle = (name: string, value = \"\"): boolean => {\n\tif (isSSR) {\n\t\treturn true;\n\t}\n\n\treturn !!document.adoptedStyleSheets.find(sh => (sh as Record)._ui5StyleId === getStyleId(name, value));\n};\n\nconst removeStyle = (name: string, value = \"\") => {\n\tdocument.adoptedStyleSheets = document.adoptedStyleSheets.filter(sh => (sh as Record)._ui5StyleId !== getStyleId(name, value));\n};\n\nconst createOrUpdateStyle = (data: StyleData, name: string, value = \"\", theme?: string) => {\n\tif (hasStyle(name, value)) {\n\t\tupdateStyle(data, name, value, theme);\n\t} else {\n\t\tcreateStyle(data, name, value, theme);\n\t}\n};\n\nconst mergeStyles = (style1?: StyleData, style2?: StyleData) => {\n\tif (style1 === undefined) {\n\t\treturn style2;\n\t}\n\tif (style2 === undefined) {\n\t\treturn style1;\n\t}\n\tconst style2Content = typeof style2 === \"string\" ? style2 : style2.content;\n\tif (typeof style1 === \"string\") {\n\t\treturn `${style1} ${style2Content}`;\n\t}\n\treturn {\n\t\tcontent: `${style1.content} ${style2Content}`,\n\t\tpackageName: style1.packageName,\n\t\tfileName: style1.fileName,\n\t};\n};\n\nexport {\n\tcreateStyle,\n\thasStyle,\n\tupdateStyle,\n\tremoveStyle,\n\tcreateOrUpdateStyle,\n\tmergeStyles,\n};\n\nexport type {\n\tStyleData,\n\tStyleDataCSP,\n};\n"],
"mappings": "aACA,OAAS,0BAAAA,EAAwB,mBAAAC,MAAuB,gBAExD,MAAMC,EAAQ,OAAO,SAAa,IAE5BC,EAAa,CAACC,EAAcC,IAC1BA,EAAQ,GAAGD,CAAI,IAAIC,CAAK,GAAKD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mB,CACtFO,EAASb,EAAMC,CAAK,EACvBS,EAAYL,EAAML,EAAMC,EAAOK,CAAK,EAEpCF,EAAYC,EAAML,EAAMC,EAAOK,CAAK,CAEtC,EAEMU,EAAc,CAACC,EAAoBC,IAAuB,CAC/D,GAAID,IAAW,OACd,OAAOC,EAER,GAAIA,IAAW,OACd,OAAOD,EAER,MAAME,EAAgB,OAAOD,GAAW,SAAWA,EAASA,EAAO,QACnE,OAAI,OAAOD,GAAW,SACd,GAAGA,CAAM,IAAIE,CAAa,GAE3B,CACN,QAAS,GAAGF,EAAO,OAAO,IAAIE,CAAa,GAC3C,YAAaF,EAAO,YACpB,SAAUA,EAAO,QAClB,CACD,EAEA,OACCb,KAAA,YACAS,KAAA,SACAH,KAAA,YACAI,KAAA,YACAC,KAAA,oBACAC,KAAA",
"names": ["getCurrentRuntimeIndex", "compareRuntimes", "isSSR", "getStyleId", "name", "value", "shouldUpdate", "runtimeIndex", "createStyle", "data", "theme", "content", "currentRuntimeIndex", "stylesheet", "updateStyle", "sh", "stylesheetRuntimeIndex", "hasStyle", "removeStyle", "createOrUpdateStyle", "mergeStyles", "style1", "style2", "style2Content"]
}