doc: you don't need to use api.srcDir anymore in plugins

Massimo Melina committed May 28, 2023 at 14:35 UTC 6ad98134edbed2e6195462e76ac972cb96a3d863
1 file changed +8 -10
dev-plugins.md
+8 -10
@@ -109,8 +109,6 @@ Based on `type`, other properties are supported:
109
110 The `api` object you get as parameter of the `init` contains the following:
111
112 -- `require: function` use this instead of standard `require` function to access modules already loaded by HFS.
113 -
112 - `getConfig(key: string): any` get config's value set up by using `exports.config`.
113
114 - `setConfig(key: string, value: any)` set config's value set up by using `exports.config`.
@@ -128,15 +126,15 @@ The `api` object you get as parameter of the `init` contains the following:
126
127 - `events: EventEmitter` this is the main events emitter used by HFS.
128
131 -- `srcDir: string` this can be useful if you need to import some extra function not available in `api`.
129 +- `require: function` use this instead of standard `require` function to access modules already loaded by HFS. Example:
130 ```js
133 - exports.init = api => {
134 - const { watchLoad } = api.require(api.srcDir + '/watchLoad')
135 - }
131 + const { watchLoad } = api.require('./watchLoad')
132 ```
137 - You *should* try to keep this kind of behavior at its minimum, as name of sources and of elements in them are subject to change.
138 - If you need something for your plugin that's not covered by `api`, you can test it with this method,
139 - but you should then discuss it on the forum because an addition to `api` is your best option for making a future-proof plugin.
133 +
134 + You *should* try to keep this kind of behavior at its minimum, as name of sources and elements can change, and your
135 + plugin can become incompatible with future versions.
136 + If you need something for your plugin that's not covered by `api`, you can test it with this method, but you should
137 + then discuss it on the forum because an addition to `api` is your best option for making a future-proof plugin.
138
139 ## Front-end specific
140
@@ -145,7 +143,7 @@ The following information applies to the default front-end, and may not apply to
143 Once your script is loaded into the frontend (via `frontend_js`), you will have access to the `HFS` object in the global scope.
144
145 The HFS objects contains many properties:
148 -- `onEvent` this is the main API function inside the frontend. Refer to dedicated section below.
146 +- `onEvent` this is the main API function inside the frontend. Refer to dedicated section below.
147 - `apiCall`
148 - `reloadList`
149 - `logout`