narraleaf-studio 0.2.0
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/README.md +95 -0
- package/dist/_api.d.ts +8963 -0
- package/dist/plugin.d.ts +87 -0
- package/dist/plugin.js +6 -0
- package/dist/runtime.d.ts +19 -0
- package/dist/runtime.js +6 -0
- package/package.json +50 -0
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# narraleaf-studio
|
|
2
|
+
|
|
3
|
+
TypeScript declarations for the [NarraLeaf Studio](https://github.com/NarraLeaf/NarraLeaf-Studio)
|
|
4
|
+
plugin API.
|
|
5
|
+
|
|
6
|
+
This package contains **types only**. Studio itself supplies the implementation
|
|
7
|
+
at load time through an import map — there is no runtime code here.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
yarn add -D narraleaf-studio
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
// Studio entry — runs in the editor
|
|
17
|
+
import { definePlugin } from "narraleaf-studio/plugin";
|
|
18
|
+
|
|
19
|
+
export default definePlugin({
|
|
20
|
+
setup(app) {
|
|
21
|
+
app.services.blueprintNodes.registerMany(myNodes());
|
|
22
|
+
app.services.ui.notifications.info(`${app.manifest.name} loaded`);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
// Runtime entry — runs inside the game
|
|
29
|
+
import { defineRuntimePlugin } from "narraleaf-studio/runtime";
|
|
30
|
+
|
|
31
|
+
export default defineRuntimePlugin({
|
|
32
|
+
setup(app) {
|
|
33
|
+
app.game.blueprintNodes.registerMany(myNodes());
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
| Subpath | Surface |
|
|
39
|
+
| -------------------------- | ---------------------------------------------------------------- |
|
|
40
|
+
| `narraleaf-studio/plugin` | Editor: `definePlugin`, `PluginApp`, `PluginServices`, `ui` |
|
|
41
|
+
| `narraleaf-studio/runtime` | Game: `defineRuntimePlugin`, `RuntimePluginApp` |
|
|
42
|
+
|
|
43
|
+
The two are physically isolated at runtime. Importing `narraleaf-studio/plugin`
|
|
44
|
+
from a runtime entry throws — the runtime host has no Studio services.
|
|
45
|
+
|
|
46
|
+
## You must mark these external
|
|
47
|
+
|
|
48
|
+
Both specifiers have to be `external` in your bundler. Studio resolves them (and
|
|
49
|
+
`react`, `react-dom`) through an import map, so bundling them produces a second,
|
|
50
|
+
broken React instance and a plugin that fails to load.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
// esbuild
|
|
54
|
+
external: [
|
|
55
|
+
"narraleaf-studio/plugin",
|
|
56
|
+
"narraleaf-studio/runtime",
|
|
57
|
+
"react",
|
|
58
|
+
"react-dom",
|
|
59
|
+
"react-dom/client",
|
|
60
|
+
"react/jsx-runtime",
|
|
61
|
+
]
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If you forget, this package's stub throws at import with a message saying so.
|
|
65
|
+
|
|
66
|
+
## How these types are produced
|
|
67
|
+
|
|
68
|
+
Generated directly from Studio's source by `packages/plugin-types/build.mjs`,
|
|
69
|
+
not written by hand:
|
|
70
|
+
|
|
71
|
+
| Output | Generated from |
|
|
72
|
+
| ----------------- | ---------------------------------------------------------------- |
|
|
73
|
+
| `dist/plugin.d.ts` | `src/renderer/plugin/index.ts` |
|
|
74
|
+
| `dist/runtime.d.ts` | `src/renderer/lib/ui-editor/runtime/plugins/runtimePluginApi.ts` |
|
|
75
|
+
|
|
76
|
+
Only what those entry points explicitly export is public. The build fails if the
|
|
77
|
+
generated declarations do not typecheck on their own, so a release cannot ship a
|
|
78
|
+
bundle that does not compile.
|
|
79
|
+
|
|
80
|
+
## Versioning
|
|
81
|
+
|
|
82
|
+
This package versions independently of Studio: it changes when the plugin API
|
|
83
|
+
changes, which is far less often than the app ships. Studio does not yet enforce
|
|
84
|
+
a compatibility range at install time, so treat a major bump as "recompile your
|
|
85
|
+
plugin and check it still typechecks".
|
|
86
|
+
|
|
87
|
+
## Getting started
|
|
88
|
+
|
|
89
|
+
See the plugin authoring guide in the
|
|
90
|
+
[NarraLeaf/Plugins](https://github.com/NarraLeaf/Plugins) registry, which has a
|
|
91
|
+
working starter template.
|
|
92
|
+
|
|
93
|
+
## License
|
|
94
|
+
|
|
95
|
+
MPL-2.0
|