A Paperlib extension is essentially an
npm package. Therefore, the development of a Paperlib extension is similar to the development of an
npm package. However, there are some restrictions. This section will explain the restrictions and conventions:
- In the callback of the event listener, please avoid
floating promise. That is, if your callback function contains any
AsyncFunction, please be sure to
.catchthe error exception. Because the error in the
floating promisecannot be caught in Paperlib, it will cause the extension to crash.
- The extension must be able to be packaged as an
npmpackage that conforms to the
- The extension must be able to be packaged as a single
jsfile, and it is recommended to
minifyto reduce the download size. (Except for
- Use the appropriate tools to remove the
PLAPI, PLMainAPI, PLExtAPI, and keep the usage statements of
PLAPI, PLMainAPI, PLExtAPIin the code after packaging. This ensures the normal operation of the extension in Paperlib. In our provided development environment, we use the
rollup-extension-modifyextension to achieve this. The reason for this constraint is that the
PLAPI, PLMainAPI, PLExtAPIprovided by the
paperlib-api/apipackage are only used for code type autocompletion during development, do not contain any functionality, and should not appear in the final code of a extension. After a extension is loaded, the
PLAPI, PLMainAPI, PLExtAPIobjects will be automatically globally injected into its
VMfor directly using.
manifest_versionfield must be included in
package.jsonto indicate the API version used by the extension. Please keep it consistent with the version of the
paperlib-apipackage you actually installed. We recommend that you always use the latest API version.
mainfield must be included in
package.json, pointing to the entry file of the extension.
- The keywords in
paperlibso that it can be searched in the extension marketplace.
package.jsonmust be consistent with the
idfield in the main code of the extension.
package.jsonmust comply with the
package.jsonmust contain a brief description of the extension.
package.jsonmust contain the author information of the extension.
package.jsondoes not contain dependencies. That is, all dependencies are
devDependencies. Please package the related functions in the dependencies into the
.jsfile of the extension through any bundling tool.
- It is recommended to correctly set the
package.jsonto only include the release files.