| 271 | |
| 272 | /** `key` must be already verified to start with S_SCRIPT_PRE */ |
| 273 | export function updateScriptMap(key, val) { |
| 274 | if ((key = +key.slice(S_SCRIPT_PRE.length))) { |
| 275 | if (val) { |
| 276 | const oldScript = scriptMap[key]; |
| 277 | if (oldScript) { |
| 278 | const i1 = aliveScripts.indexOf(oldScript); |
| 279 | const i2 = removedScripts.indexOf(oldScript); |
| 280 | if (i1 >= 0) aliveScripts[i1] = val; |
| 281 | if (i2 >= 0) removedScripts[i2] = val; |
| 282 | val[INFERRED] ??= oldScript[INFERRED]; |
| 283 | } |
| 284 | scriptMap[key] = val; |
| 285 | } else { |
| 286 | delete scriptMap[key]; |
| 287 | } |
| 288 | return true; |
| 289 | } |
| 290 | } |