@deepseek-ai/cordis-plugin-loader 1.0.1-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-present Shigma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,48 @@
1
+ # @cordisjs/plugin-loader
2
+
3
+ Runtime plugin loader for Cordis. The loader owns an `EntryTree`, imports plugin
4
+ modules by name, applies their config, and keeps the running plugin graph in
5
+ sync with entry updates.
6
+
7
+ ## Usage
8
+
9
+ ```ts
10
+ import { Context } from 'cordis'
11
+ import Loader from '@cordisjs/plugin-loader'
12
+
13
+ const root = new Context()
14
+ await root.plugin(Loader, { baseUrl: import.meta.url })
15
+
16
+ const id = await root.loader.create({
17
+ name: './plugins/example',
18
+ config: { enabled: true },
19
+ })
20
+
21
+ await root.loader.await()
22
+ root.loader.update(id, { config: { enabled: false } })
23
+ ```
24
+
25
+ ## Entry Options
26
+
27
+ | Field | Description |
28
+ | --- | --- |
29
+ | `id` | Stable id for resolving, updating, and removing the entry. |
30
+ | `name` | Module specifier imported by the loader. |
31
+ | `config` | Config passed to the plugin. |
32
+ | `group` | Marks the entry as a group whose `config` is a child entry list. |
33
+ | `disabled` | Stops the entry and prevents it from starting. |
34
+ | `inject` | Adds required services or intercept config for this entry. |
35
+
36
+ ## API
37
+
38
+ | API | Description |
39
+ | --- | --- |
40
+ | `loader.create(options, parent?, position?)` | Add and start an entry. |
41
+ | `loader.update(id, options, parent?, position?)` | Update, move, and restart an entry. |
42
+ | `loader.remove(id)` | Stop and delete an entry. |
43
+ | `loader.resolve(id)` | Resolve an entry by id, including nested `a:b` ids. |
44
+ | `loader.resolveGroup(id)` | Resolve the root group or a nested group. |
45
+ | `loader.await()` | Wait for pending entry imports and fiber reloads. |
46
+ | `loader.locate(fiber?)` | Return the loader entry id that owns a fiber. |
47
+
48
+ For file-backed trees, use `@cordisjs/plugin-include`.