* @param {GMContext} context * @param name * @param isBlob * @param isBlobAuto
(context, name, isBlob, isBlobAuto)
| 231 | * @param isBlobAuto |
| 232 | */ |
| 233 | function getResource(context, name, isBlob, isBlobAuto) { |
| 234 | let res; |
| 235 | const { id, resCache, resources } = context; |
| 236 | const key = resources[name]; |
| 237 | if (key) { |
| 238 | // data URIs aren't cached in bridge, so we'll send them |
| 239 | const isData = key::slice(0, 5) === 'data:'; |
| 240 | const bucketKey = isBlob == null ? 0 : 1 + (isBlob = isBlobAuto ? !isData : isBlob); |
| 241 | res = isData && isBlob === false || ensureNestedProp(resCache, bucketKey, key, false); |
| 242 | if (!res) { |
| 243 | res = bridge.call('GetResource', { id, isBlob, key, raw: isData && key }); |
| 244 | ensureNestedProp(resCache, bucketKey, key, res); |
| 245 | } |
| 246 | } |
| 247 | return resolveOrReturn(context, res === true ? key : res); |
| 248 | } |
| 249 | |
| 250 | function findCommandIdByText(text, hub) { |
| 251 | for (const id in hub) { |
no test coverage detected