Showing the changes to player/javascript (1 of 2 files). Show all
Unified · Split
| @@ -375,6 +375,8 @@ function process_timers() { · 374 unmodified lines | |||
| 375 | - Module id supports mpv path enhancements, e.g. ~/foo, ~~/bar, ~~desktop/baz | 375 | - Module id supports mpv path enhancements, e.g. ~/foo, ~~/bar, ~~desktop/baz |
| 376 | *********************************************************************/ | 376 | *********************************************************************/ |
| 377 | 377 | ||
| 378 | mp.module_paths = ["~~/scripts/modules.js"]; // global modules search paths | ||
| 379 | |||
| 378 | // Internal meta top-dirs. Users should not rely on these names. | 380 | // Internal meta top-dirs. Users should not rely on these names. |
| 379 | var MODULES_META = "~~modules", | 381 | var MODULES_META = "~~modules", |
| 380 | SCRIPTDIR_META = "~~scriptdir", // relative script path -> meta absolute id | 382 | SCRIPTDIR_META = "~~scriptdir", // relative script path -> meta absolute id |
| @@ -389,10 +391,14 @@ function resolve_module_file(id) { · 8 unmodified lines | |||
| 389 | return mp.utils.join_path(main_script[0], rest); | 391 | return mp.utils.join_path(main_script[0], rest); |
| 390 | 392 | ||
| 391 | if (base == MODULES_META) { | 393 | if (base == MODULES_META) { |
| 392 | var path = mp.find_config_file("scripts/modules.js/" + rest); | 394 | for (var i = 0; i < mp.module_paths.length; i++) { |
| 393 | if (!path) | 395 | try { |
| 394 | throw(Error("Cannot find module file '" + rest + "'")); | 396 | var f = mp.utils.join_path(mp.module_paths[i], rest); |
| 395 | return path; | 397 | mp.utils.read_file(f, 1); // throws on any error |
| 398 | return f; | ||
| 399 | } catch (e) {} | ||
| 400 | } | ||
| 401 | throw(Error("Cannot find module file '" + rest + "'")); | ||
| 396 | } | 402 | } |
| 397 | 403 | ||
| 398 | return id + ".js"; | 404 | return id + ".js"; |