All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.dist.asset-registries.Themes.js.map Maven / Gradle / Ivy

{"version":3,"file":"Themes.js","sourceRoot":"","sources":["../../src/asset-registries/Themes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AAKpE,MAAM,WAAW,GAAG,IAAI,GAAG,EAAqB,CAAC;AACjD,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;AAC/C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAuB,CAAC;AACrD,MAAM,kBAAkB,GAAG,IAAI,GAAG,EAAU,CAAC;AAC7C,MAAM,gBAAgB,GAAG,IAAI,GAAG,EAAU,CAAC;AAE3C,MAAM,6BAA6B,GAAG,CAAC,WAAmB,EAAE,SAAiB,EAAE,MAAmB,EAAE,EAAE;IACrG,OAAO,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;IACnD,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpC,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAChC,mBAAmB,CAAC,SAAS,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,mCAAmC,GAAG,CAAC,WAAmB,EAAE,SAAiB,EAAE,MAAmB,EAAE,EAAE;IAC3G,aAAa,CAAC,GAAG,CAAC,GAAG,WAAW,IAAI,SAAS,EAAE,EAAE,MAAM,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,KAAK,EAAE,WAAmB,EAAE,SAAiB,EAAE,iBAA0B,EAAE,EAAE;IACvG,MAAM,QAAQ,GAAG,GAAG,WAAW,IAAI,SAAS,IAAI,iBAAiB,IAAI,EAAE,EAAE,CAAC;IAC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;QACZ,wBAAwB;QACxB,IAAI,CAAC,cAAc,EAAE;YACpB,OAAO,CAAC,KAAK,CAAC,UAAU,SAAS,iCAAiC,WAAW,GAAG,CAAC,CAAC,CAAC,yBAAyB;SAC5G;QACD,OAAO;KACP;IACD,IAAI,IAAI,CAAC;IACT,IAAI;QACH,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;KAC/B;IAAC,OAAO,KAAc,EAAE;QACxB,MAAM,CAAC,GAAG,KAAc,CAAC;QACzB,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,yBAAyB;QAChE,OAAO;KACP;IAED,MAAM,UAAU,GAAI,IAA0B,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,gCAAgC;IAC1F,OAAO,UAAU,CAAC;AACnB,CAAC,CAAC;AAEF,MAAM,qBAAqB,GAAG,GAAG,EAAE;IAClC,OAAO,kBAAkB,CAAC;AAC3B,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,KAAa,EAAE,EAAE;IAC3C,OAAO,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,OAAO,EACN,6BAA6B,EAC7B,mCAAmC,EACnC,kBAAkB,EAClB,qBAAqB,EACrB,iBAAiB,GACjB,CAAC","sourcesContent":["import { DEFAULT_THEME } from \"../generated/AssetParameters.js\";\nimport type { StyleData, StyleDataCSP } from \"../ManagedStyles.js\";\nimport { mergeStyles } from \"../ManagedStyles.js\";\nimport { fireThemeRegistered } from \"../theming/ThemeRegistered.js\";\n\ntype ThemeData = {_: StyleDataCSP } | StyleDataCSP | string;\ntype ThemeLoader = (themeName: string) => Promise;\n\nconst themeStyles = new Map();\nconst loaders = new Map();\nconst customLoaders = new Map();\nconst registeredPackages = new Set();\nconst registeredThemes = new Set();\n\nconst registerThemePropertiesLoader = (packageName: string, themeName: string, loader: ThemeLoader) => {\n\tloaders.set(`${packageName}/${themeName}`, loader);\n\tregisteredPackages.add(packageName);\n\tregisteredThemes.add(themeName);\n\tfireThemeRegistered(themeName);\n};\n\nconst registerCustomThemePropertiesLoader = (packageName: string, themeName: string, loader: ThemeLoader) => {\n\tcustomLoaders.set(`${packageName}/${themeName}`, loader);\n};\n\nconst getThemeProperties = async (packageName: string, themeName: string, externalThemeName?: string) => {\n\tconst cacheKey = `${packageName}_${themeName}_${externalThemeName || \"\"}`;\n\tconst cachedStyleData = themeStyles.get(cacheKey);\n\tif (cachedStyleData !== undefined) { // it's valid for style to be an empty string\n\t\treturn cachedStyleData;\n\t}\n\n\tif (!registeredThemes.has(themeName)) {\n\t\tconst regThemesStr = [...registeredThemes.values()].join(\", \");\n\t\tconsole.warn(`You have requested a non-registered theme ${themeName} - falling back to ${DEFAULT_THEME}. Registered themes are: ${regThemesStr}`); /* eslint-disable-line */\n\t\treturn _getThemeProperties(packageName, DEFAULT_THEME);\n\t}\n\n\tconst [style, customStyle] = await Promise.all([\n\t\t_getThemeProperties(packageName, themeName),\n\t\texternalThemeName ? _getThemeProperties(packageName, externalThemeName, true) : undefined,\n\t]);\n\n\tconst styleData = mergeStyles(style, customStyle);\n\tif (styleData) {\n\t\tthemeStyles.set(cacheKey, styleData);\n\t}\n\n\treturn styleData;\n};\n\nconst _getThemeProperties = async (packageName: string, themeName: string, forCustomTheme = false) => {\n\tconst loadersMap = forCustomTheme ? customLoaders : loaders;\n\tconst loader = loadersMap.get(`${packageName}/${themeName}`);\n\tif (!loader) {\n\t\t// no themes for package\n\t\tif (!forCustomTheme) {\n\t\t\tconsole.error(`Theme [${themeName}] not registered for package [${packageName}]`); /* eslint-disable-line */\n\t\t}\n\t\treturn;\n\t}\n\tlet data;\n\ttry {\n\t\tdata = await loader(themeName);\n\t} catch (error: unknown) {\n\t\tconst e = error as Error;\n\t\tconsole.error(packageName, e.message); /* eslint-disable-line */\n\t\treturn;\n\t}\n\n\tconst themeProps = (data as {_: StyleDataCSP})._ || data; // Refactor: remove _ everywhere\n\treturn themeProps;\n};\n\nconst getRegisteredPackages = () => {\n\treturn registeredPackages;\n};\n\nconst isThemeRegistered = (theme: string) => {\n\treturn registeredThemes.has(theme);\n};\n\nexport {\n\tregisterThemePropertiesLoader,\n\tregisterCustomThemePropertiesLoader,\n\tgetThemeProperties,\n\tgetRegisteredPackages,\n\tisThemeRegistered,\n};\n\nexport type {\n\tThemeData,\n\tThemeLoader,\n};\n"]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy