A package manager for Scripting app that allows users to install packages from npm and download the bundled JS files.
- Search for packages on npm by name in the search page.
- Select the package you want to install.
- Click the install button, and the package manager will download the bundled JS file of the package.
- The Package Manager will create a folder with the package name in the
packagesfolder under Scripting app's iCloud Documents (if iCloud is enabled) or Scripting's App Group Documents directory, and save the downloaded JS file asindex.jsin that folder, along with thepackage.jsonfile. - You need to use the "Add to Script" feature of the Package Manager to add the downloaded package to your script. It will be added as a symlink to the script's modules directory, e.g.,
packages/dayjs/index.jswill be symlinked toscripts/your_script/modules/dayjs.js. - You can use these modules in your script by importing them with
import pkgName from './modules/pkgName', for example:import dayjs from './modules/dayjs'.
- Currently, when searching on npm and trying to download the bundled JS file from unpkg.com, you may encounter some packages that do not have a bundled file or the bundled file does not meet expectations.
- Currently, .d.ts files are not supported for download, but may be supported in the future.
- If the package is pure JS logic and does not depend on browser or Node.js, it can be used directly in Scripting app. Node.js packages are not supported at the moment, and packages that depend on browser APIs can be called through
WebViewController. - Currently, automatic installation of package dependencies is not supported. Please install packages that provide bundled single-file versions.
Contributions to improve the Package Manager are welcome.