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

package.dist.prod.Runtimes.js.map Maven / Gradle / Ivy

{
  "version": 3,
  "sources": ["../../src/Runtimes.ts"],
  "sourcesContent": ["import VersionInfo from \"./generated/VersionInfo.js\";\nimport getSharedResource from \"./getSharedResource.js\";\n\ntype RuntimeData = VersionInfo & {\n\talias: string,\n\tdescription: string,\n};\n\nlet currentRuntimeIndex: number;\nlet currentRuntimeAlias = \"\";\n\nconst compareCache = new Map();\n\n/**\n * Central registry where all runtimes register themselves by pushing an object.\n * The index in the registry servers as an ID for the runtime.\n * @type {*}\n */\nconst Runtimes = getSharedResource>(\"Runtimes\", []);\n\n/**\n * Registers the current runtime in the shared runtimes resource registry\n */\nconst registerCurrentRuntime = () => {\n\tif (currentRuntimeIndex === undefined) {\n\t\tcurrentRuntimeIndex = Runtimes.length;\n\t\tconst versionInfo = VersionInfo;\n\n\t\tRuntimes.push({\n\t\t\t...versionInfo,\n\t\t\talias: currentRuntimeAlias,\n\t\t\tdescription: `Runtime ${currentRuntimeIndex} - ver ${versionInfo.version}${currentRuntimeAlias ? ` (${currentRuntimeAlias})` : \"\"}`,\n\t\t});\n\t}\n};\n\n/**\n * Returns the index of the current runtime's object in the shared runtimes resource registry\n * @returns {*}\n */\nconst getCurrentRuntimeIndex = () => {\n\treturn currentRuntimeIndex;\n};\n\n/**\n * Compares two runtimes and returns 1 if the first is of a bigger version, -1 if the second is of a bigger version, and 0 if equal\n * @param index1 The index of the first runtime to compare\n * @param index2 The index of the second runtime to compare\n * @returns {number}\n */\nconst compareRuntimes = (index1: number, index2: number) => {\n\tconst cacheIndex = `${index1},${index2}`;\n\tif (compareCache.has(cacheIndex)) {\n\t\treturn compareCache.get(cacheIndex)!;\n\t}\n\n\tconst runtime1 = Runtimes[index1];\n\tconst runtime2 = Runtimes[index2];\n\n\tif (!runtime1 || !runtime2) {\n\t\tthrow new Error(\"Invalid runtime index supplied\");\n\t}\n\n\t// If any of the two is a next version, bigger buildTime wins\n\tif (runtime1.isNext || runtime2.isNext) {\n\t\treturn runtime1.buildTime - runtime2.buildTime;\n\t}\n\n\t// If major versions differ, bigger one wins\n\tconst majorDiff = runtime1.major - runtime2.major;\n\tif (majorDiff) {\n\t\treturn majorDiff;\n\t}\n\n\t// If minor versions differ, bigger one wins\n\tconst minorDiff = runtime1.minor - runtime2.minor;\n\tif (minorDiff) {\n\t\treturn minorDiff;\n\t}\n\n\t// If patch versions differ, bigger one wins\n\tconst patchDiff = runtime1.patch - runtime2.patch;\n\tif (patchDiff) {\n\t\treturn patchDiff;\n\t}\n\n\t// Bigger suffix wins, f.e. rc10 > rc9\n\t// Important: suffix is alphanumeric, must use natural compare\n\tconst collator = new Intl.Collator(undefined, { numeric: true, sensitivity: \"base\" });\n\tconst result = collator.compare(runtime1.suffix, runtime2.suffix);\n\n\tcompareCache.set(cacheIndex, result);\n\treturn result;\n};\n\n/**\n * Set an alias for the the current app/library/microfrontend which will appear in debug messages and console warnings\n * @param alias\n */\nconst setRuntimeAlias = (alias: string) => {\n\tcurrentRuntimeAlias = alias;\n};\n\nconst getAllRuntimes = () => {\n\treturn Runtimes;\n};\n\nexport {\n\tgetCurrentRuntimeIndex,\n\tregisterCurrentRuntime,\n\tcompareRuntimes,\n\tsetRuntimeAlias,\n\tgetAllRuntimes,\n};\n"],
  "mappings": "aAAA,OAAOA,MAAiB,6BACxB,OAAOC,MAAuB,yBAO9B,IAAIC,EACAC,EAAsB,GAE1B,MAAMC,EAAe,IAAI,IAOnBC,EAAWJ,EAAsC,WAAY,CAAC,CAAC,EAK/DK,EAAyB,IAAM,CACpC,GAAIJ,IAAwB,OAAW,CACtCA,EAAsBG,EAAS,OAC/B,MAAME,EAAcP,EAEpBK,EAAS,KAAK,CACb,GAAGE,EACH,MAAOJ,EACP,YAAa,WAAWD,CAAmB,UAAUK,EAAY,OAAO,GAAGJ,EAAsB,KAAKA,CAAmB,IAAM,EAAE,EAClI,CAAC,CACF,CACD,EAMMK,EAAyB,IACvBN,EASFO,EAAkB,CAACC,EAAgBC,IAAmB,CAC3D,MAAMC,EAAa,GAAGF,CAAM,IAAIC,CAAM,GACtC,GAAIP,EAAa,IAAIQ,CAAU,EAC9B,OAAOR,EAAa,IAAIQ,CAAU,EAGnC,MAAMC,EAAWR,EAASK,CAAM,EAC1BI,EAAWT,EAASM,CAAM,EAEhC,GAAI,CAACE,GAAY,CAACC,EACjB,MAAM,IAAI,MAAM,gCAAgC,EAIjD,GAAID,EAAS,QAAUC,EAAS,OAC/B,OAAOD,EAAS,UAAYC,EAAS,UAItC,MAAMC,EAAYF,EAAS,MAAQC,EAAS,MAC5C,GAAIC,EACH,OAAOA,EAIR,MAAMC,EAAYH,EAAS,MAAQC,EAAS,MAC5C,GAAIE,EACH,OAAOA,EAIR,MAAMC,EAAYJ,EAAS,MAAQC,EAAS,MAC5C,GAAIG,EACH,OAAOA,EAMR,MAAMC,EADW,IAAI,KAAK,SAAS,OAAW,CAAE,QAAS,GAAM,YAAa,MAAO,CAAC,EAC5D,QAAQL,EAAS,OAAQC,EAAS,MAAM,EAEhE,OAAAV,EAAa,IAAIQ,EAAYM,CAAM,EAC5BA,CACR,EAMMC,EAAmBC,GAAkB,CAC1CjB,EAAsBiB,CACvB,EAEMC,EAAiB,IACfhB,EAGR,OACCG,KAAA,uBACAF,KAAA,uBACAG,KAAA,gBACAU,KAAA,gBACAE,KAAA",
  "names": ["VersionInfo", "getSharedResource", "currentRuntimeIndex", "currentRuntimeAlias", "compareCache", "Runtimes", "registerCurrentRuntime", "versionInfo", "getCurrentRuntimeIndex", "compareRuntimes", "index1", "index2", "cacheIndex", "runtime1", "runtime2", "majorDiff", "minorDiff", "patchDiff", "result", "setRuntimeAlias", "alias", "getAllRuntimes"]
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy