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

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

{"version":3,"file":"Icons.js","sourceRoot":"","sources":["../../src/asset-registries/Icons.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAC1E,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,0BAA0B,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAIjD,MAAM,oBAAoB,GAAG,QAAQ,CAAC,CAAC,uBAAuB;AA2B9D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAsB,CAAC;AAC9C,MAAM,QAAQ,GAAG,iBAAiB,CAAwB,mBAAmB,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AAC1F,MAAM,sBAAsB,GAAG,iBAAiB,CAA8D,mBAAmB,EAAE,IAAI,GAAG,EAAE,CAAC,CAAC;AAE9I,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAExC,MAAM,kBAAkB,GAAG,CAAC,cAAsB,EAAE,MAAkB,EAAE,EAAE;IACzE,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACrC,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,KAAK,EAAE,cAAsB,EAAE,EAAE;IAChE,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;QAChD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,EAAE;YACjC,MAAM,IAAI,KAAK,CAAC,gCAAgC,cAAc,uGAAuG,CAAC,CAAC;SACvK;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAE,CAAC;QAC/C,sBAAsB,CAAC,GAAG,CAAC,cAAc,EAAE,SAAS,CAAC,cAAc,CAA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,GAAG,KAAK,IAAI,EAAE;IACtC,+DAA+D;IAC/D,MAAM,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,MAAM,WAAW,CAAC,WAAW,CAAC,CAAC;IAC/B,MAAM,WAAW,CAAC,mBAAmB,CAAC,CAAC;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;AACpC,CAAC,CAAC;AAEF,OAAO,EACN,kBAAkB,EAClB,WAAW,EACX,eAAe,EACf,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACnB,CAAC","sourcesContent":["import getSharedResource from \"../getSharedResource.js\";\nimport { getIconCollectionByAlias } from \"./util/IconCollectionsAlias.js\";\nimport { registerIconCollectionForTheme } from \"./util/IconCollectionsByTheme.js\";\nimport getEffectiveIconCollection from \"./util/getIconCollectionByTheme.js\";\nimport { getI18nBundle } from \"../i18nBundle.js\";\nimport type { I18nText } from \"../i18nBundle.js\";\nimport type { TemplateFunction } from \"../renderer/executeTemplate.js\";\n\nconst DEFAULT_THEME_FAMILY = \"legacy\"; // includes sap_fiori_*\n\ntype IconLoader = (collectionName: string) => Promise>;\n\ntype CollectionData = {\n\tcollection: string,\n\tpackageName: string,\n\tthemeFamily?: \"legacy\" | \"sap_horizon\",\n\tversion?: string,\n\tdata: Record,\n\t\tltr?: boolean,\n\t\tacc?: I18nText,\n\t}>,\n};\n\ntype IconData = {\n\tcollection: string,\n\tpackageName: string,\n\tpathData: string | Array,\n\tltr?: boolean,\n\taccData?: I18nText,\n\tcustomTemplate?: TemplateFunction,\n\tviewBox?: string,\n};\n\nconst loaders = new Map();\nconst registry = getSharedResource>(\"SVGIcons.registry\", new Map());\nconst iconCollectionPromises = getSharedResource>>>(\"SVGIcons.promises\", new Map());\n\nconst ICON_NOT_FOUND = \"ICON_NOT_FOUND\";\n\nconst registerIconLoader = (collectionName: string, loader: IconLoader) => {\n\tloaders.set(collectionName, loader);\n};\n\nconst _loadIconCollectionOnce = async (collectionName: string) => {\n\tif (!iconCollectionPromises.has(collectionName)) {\n\t\tif (!loaders.has(collectionName)) {\n\t\t\tthrow new Error(`No loader registered for the ${collectionName} icons collection. Probably you forgot to import the \"AllIcons.js\" module for the respective package.`);\n\t\t}\n\n\t\tconst loadIcons = loaders.get(collectionName)!;\n\t\ticonCollectionPromises.set(collectionName, loadIcons(collectionName));\n\t}\n\n\treturn iconCollectionPromises.get(collectionName);\n};\n\nconst _fillRegistry = (bundleData: CollectionData) => {\n\tObject.keys(bundleData.data).forEach(iconName => {\n\t\tconst iconData = bundleData.data[iconName];\n\n\t\tregisterIcon(iconName, {\n\t\t\tpathData: (iconData.path || iconData.paths)!,\n\t\t\tltr: iconData.ltr,\n\t\t\taccData: iconData.acc,\n\t\t\tcollection: bundleData.collection,\n\t\t\tpackageName: bundleData.packageName,\n\t\t});\n\t});\n};\n\n// set\nconst registerIcon = (name: string, iconData: IconData) => { // eslint-disable-line\n\tconst key = `${iconData.collection}/${name}`;\n\n\tregistry.set(key, {\n\t\tpathData: iconData.pathData,\n\t\tltr: iconData.ltr,\n\t\taccData: iconData.accData,\n\t\tpackageName: iconData.packageName,\n\t\tcustomTemplate: iconData.customTemplate,\n\t\tviewBox: iconData.viewBox,\n\t\tcollection: iconData.collection,\n\t});\n};\n\n/**\n * Processes the full icon name and splits it into - \"name\", \"collection\".\n * - removes legacy protocol (\"sap-icon://\")\n * - resolves aliases (f.e \"SAP-icons-TNT/actor\" => \"tnt/actor\")\n *\n * @param { string } name\n * @return { object }\n */\nconst processName = (name: string) => {\n\t// silently support ui5-compatible URIs\n\tif (name.startsWith(\"sap-icon://\")) {\n\t\tname = name.replace(\"sap-icon://\", \"\");\n\t}\n\n\tlet collection: string;\n\t[name, collection] = name.split(\"/\").reverse();\n\n\tname = name.replace(\"icon-\", \"\");\n\tif (collection) {\n\t\tcollection = getIconCollectionByAlias(collection);\n\t}\n\treturn { name, collection };\n};\n\nconst getIconDataSync = (iconName: string) => {\n\tconst { name, collection } = processName(iconName);\n\treturn getRegisteredIconData(collection, name);\n};\n\nconst getIconData = async (iconName: string) => {\n\tconst { name, collection } = processName(iconName);\n\n\tlet iconData: string | CollectionData | Array = ICON_NOT_FOUND;\n\ttry {\n\t\ticonData = (await _loadIconCollectionOnce(getEffectiveIconCollection(collection)))!;\n\t} catch (error: unknown) {\n\t\tconst e = error as Error;\n\t\tconsole.error(e.message); /* eslint-disable-line */\n\t}\n\n\tif (iconData === ICON_NOT_FOUND) {\n\t\treturn iconData;\n\t}\n\n\tconst registeredIconData = getRegisteredIconData(collection, name);\n\n\tif (registeredIconData) {\n\t\treturn registeredIconData;\n\t}\n\n\t// not filled by another await. many getters will await on the same loader, but fill only once\n\tif (Array.isArray(iconData)) {\n\t\ticonData.forEach(data => {\n\t\t\t_fillRegistry(data);\n\t\t\tregisterIconCollectionForTheme(collection, { [data.themeFamily || DEFAULT_THEME_FAMILY]: data.collection });\n\t\t});\n\t} else {\n\t\t_fillRegistry(iconData as CollectionData);\n\t}\n\n\treturn getRegisteredIconData(collection, name);\n};\n\nconst getRegisteredIconData = (collection: string, name: string) => {\n\tconst registryKey = `${getEffectiveIconCollection(collection)}/${name}`;\n\treturn registry.get(registryKey);\n};\n\n/**\n * Returns the accessible name for the given icon,\n * or undefined if accessible name is not present.\n *\n * @param { string } name\n * @return { Promise }\n */\nconst getIconAccessibleName = async (name: string | undefined): Promise => {\n\tif (!name) {\n\t\treturn;\n\t}\n\n\tlet iconData: typeof ICON_NOT_FOUND | IconData | undefined = getIconDataSync(name);\n\n\tif (!iconData) {\n\t\ticonData = await getIconData(name);\n\t}\n\n\tif (iconData && iconData !== ICON_NOT_FOUND && iconData.accData) {\n\t\tconst i18nBundle = await getI18nBundle(iconData.packageName);\n\t\treturn i18nBundle.getText(iconData.accData);\n\t}\n};\n\n// test page usage only\nconst _getRegisteredNames = async () => {\n\t// fetch one icon of each collection to trigger the bundle load\n\tawait getIconData(\"edit\");\n\tawait getIconData(\"tnt/arrow\");\n\tawait getIconData(\"business-suite/3d\");\n\treturn Array.from(registry.keys());\n};\n\nexport {\n\tregisterIconLoader,\n\tgetIconData,\n\tgetIconDataSync,\n\tgetIconAccessibleName,\n\tregisterIcon,\n\t_getRegisteredNames,\n};\n\nexport type {\n\tIconData,\n\tCollectionData,\n};\n"]}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy