From 756960bf3cd6110c85b97f3edbd3bf0e2a2b91d4 Mon Sep 17 00:00:00 2001 From: "Avi Halachmi (:avih)" Date: Fri, 7 Feb 2020 17:35:48 +0200 Subject: js: require: directory-scripts: first look at /modules/ Also, add the function mp.get_script_directory() to let scripts know if they're loaded as a directory and where. --- DOCS/interface-changes.rst | 2 ++ DOCS/man/javascript.rst | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'DOCS') diff --git a/DOCS/interface-changes.rst b/DOCS/interface-changes.rst index 3e0347bc7f..efbfdc510e 100644 --- a/DOCS/interface-changes.rst +++ b/DOCS/interface-changes.rst @@ -28,6 +28,8 @@ Interface changes - directories in ~/.mpv/scripts/ (or equivalent) now have special semantics (see mpv Lua scripting docs) - names starting with "." in ~/.mpv/scripts/ (or equivalent) are now ignored + - js modules: ~~/scripts/modules.js/ is no longer used, global paths can be + set with custom init (see docs), dir-scripts first look at /modules/ --- mpv 0.32.0 --- - change behavior when using legacy option syntax with options that start with two dashes (``--`` instead of a ``-``). Now, using the recommended diff --git a/DOCS/man/javascript.rst b/DOCS/man/javascript.rst index 49ddb481e4..0a43d213b6 100644 --- a/DOCS/man/javascript.rst +++ b/DOCS/man/javascript.rst @@ -139,6 +139,8 @@ success, ``fn`` is called always a-sync, ``error`` is empty string on success. ``mp.get_script_name()`` +``mp.get_script_directory()`` + ``mp.osd_message(text [,duration])`` ``mp.get_wakeup_pipe()`` @@ -309,7 +311,8 @@ or ``~/x``. Otherwise it's considered a global module id and searched according load ``x.js`` at one of the array paths, and id ``foo/x`` tries to load ``x.js`` inside dir ``foo`` at one of the paths. -The ``mp.module_paths`` array is empty by default. +The ``mp.module_paths`` array is empty by default except for scripts which are +loaded as a directory where it contains one item - ``/modules/``. ``mp.module_paths`` may be updated from a script (preferably via custom init - see below) which will affect future calls to ``require`` for global module id's which are not already loaded/cached. -- cgit v1.2.3