-
Notifications
You must be signed in to change notification settings - Fork 1
Advanced Plugin Topics
Topher Anselmo edited this page Oct 16, 2023
·
4 revisions
All of the script files that belong to a plugin are directly inserted/mounted into a <script> tag in the document. They are automatically combined and wrapped inside of a helper function that exposes the tmcp API object. This means that all of the scripts for a plugin are included in their own closure, and can benefit from top-level await.
The electron remote package is available, so you can use require() to access needed APIs. Typically you'd require the remote into an object, and use that to require anything else:
const remote = require('@electron/remote');
const fs = remote.require('fs');
const path = remote.require('path');
// etc.You can use this require function to load any node_modules you may want to install into your plugin's folder:
const remote = require('@electron/remote');
const path = remote.require('path');
const somePackage = remote.require(path.join(__dirname, 'node_modules', 'package_name'));