nibs-cli 4.1.0 → 4.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 +56 -6
- package/dist/cli.js +1 -1
- package/dist/commands/rollup-config.js +2 -0
- package/package.json +5 -1
package/README.md
CHANGED
|
@@ -124,7 +124,7 @@ config:
|
|
|
124
124
|
| `nibs new <directory>` | Create a new project |
|
|
125
125
|
| `nibs build [directory]` | Build project (default command) |
|
|
126
126
|
| `nibs watch [directory]` | Watch project and rebuild on changes |
|
|
127
|
-
| `nibs import <file
|
|
127
|
+
| `nibs import <file>` | Import an existing .naiscript and create a project directory |
|
|
128
128
|
| `nibs help` | Show help information |
|
|
129
129
|
|
|
130
130
|
## Writing Scripts with Imports
|
|
@@ -203,6 +203,60 @@ const utils = {
|
|
|
203
203
|
|
|
204
204
|
You can mix both styles in the same file if needed.
|
|
205
205
|
|
|
206
|
+
## Using npm Packages
|
|
207
|
+
|
|
208
|
+
NIBS can bundle npm packages into your scripts. Since the build system uses Rollup with node module resolution, any package you install in your project directory can be imported and inlined into the final `.naiscript` output.
|
|
209
|
+
|
|
210
|
+
### Setup
|
|
211
|
+
|
|
212
|
+
Initialize a `package.json` in your project directory and install packages:
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
cd my-script
|
|
216
|
+
npm init -y
|
|
217
|
+
npm install lodash-es
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
Then import them in your TypeScript files:
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
import { debounce } from "lodash-es";
|
|
224
|
+
|
|
225
|
+
const debouncedSave = debounce(async () => {
|
|
226
|
+
await api.v1.storage.set("data", myData);
|
|
227
|
+
}, 500);
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
The build system resolves the import from `node_modules/`, inlines the package code, and produces a single self-contained `.naiscript` file with no external dependencies.
|
|
231
|
+
|
|
232
|
+
### Runtime Constraints
|
|
233
|
+
|
|
234
|
+
**NovelAI scripts run inside a Web Worker sandbox powered by the QuickJS runtime.** This is a very different environment from Node.js or a browser page. Packages you use must be compatible with these constraints:
|
|
235
|
+
|
|
236
|
+
- **No Node.js APIs** - `fs`, `path`, `http`, `child_process`, `Buffer`, and all other Node.js built-in modules are unavailable
|
|
237
|
+
- **No DOM APIs** - `document`, `window`, `localStorage`, and other browser page APIs are unavailable (scripts run in a Web Worker, not a page)
|
|
238
|
+
- **No network access** - `fetch`, `XMLHttpRequest`, and WebSocket are unavailable
|
|
239
|
+
- **QuickJS engine** - The JavaScript engine is QuickJS, not V8. Most ES2023 features are supported, but some newer APIs or V8-specific behaviors may not be available
|
|
240
|
+
|
|
241
|
+
### What Works
|
|
242
|
+
|
|
243
|
+
- **Pure logic packages** - Algorithms, data structures, parsers, math libraries, string manipulation, validation
|
|
244
|
+
- **ESM packages** - Packages that ship ES module builds (check for `"module"` or `"exports"` fields in the package's `package.json`)
|
|
245
|
+
|
|
246
|
+
### What Won't Work
|
|
247
|
+
|
|
248
|
+
- Packages that depend on Node.js built-in modules (e.g., `axios`, `fs-extra`)
|
|
249
|
+
- Packages that access the DOM (e.g., `react`, `jquery`)
|
|
250
|
+
- Packages that use network APIs (e.g., `node-fetch`, `socket.io-client`)
|
|
251
|
+
- Packages that ship only CommonJS builds (no ESM entry point) — these may fail to bundle correctly
|
|
252
|
+
|
|
253
|
+
### Tips
|
|
254
|
+
|
|
255
|
+
- Check a package's dependencies and source before installing — if it imports `fs`, `http`, or `path`, it won't work
|
|
256
|
+
- Prefer packages with `-es` or `esm` variants (e.g., `lodash-es` instead of `lodash`)
|
|
257
|
+
- Keep your bundle small — every dependency gets inlined into the final script
|
|
258
|
+
- Test your built `.naiscript` in NovelAI after adding new packages to catch runtime incompatibilities early
|
|
259
|
+
|
|
206
260
|
## NovelAI API Reference
|
|
207
261
|
|
|
208
262
|
The build system automatically downloads NovelAI type definitions. In supported editors you get full completion and IDE documentation.
|
|
@@ -324,11 +378,7 @@ nibs build
|
|
|
324
378
|
|
|
325
379
|
### Can I use npm packages?
|
|
326
380
|
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
- Browser-native APIs
|
|
330
|
-
- The NovelAI API (`api.v1.*`)
|
|
331
|
-
- Your own code
|
|
381
|
+
Yes, as of v4.2! Install packages with `npm install` in your project directory and import them normally. The build system bundles them into your `.naiscript` file. However, NovelAI scripts run in a **Web Worker sandbox under the QuickJS runtime**, so packages must be pure JavaScript logic with no Node.js, DOM, or network dependencies. See [Using npm Packages](#using-npm-packages) for details.
|
|
332
382
|
|
|
333
383
|
### How do I add another project?
|
|
334
384
|
|
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ async function ensureTypesFile(projectPath) {
|
|
|
28
28
|
await (0, utils_1.fetchExternalTypes)(projectPath);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
-
commander_1.program.description("NovelAI Script Build System").version("4.
|
|
31
|
+
commander_1.program.description("NovelAI Script Build System").version("4.2.0");
|
|
32
32
|
commander_1.program.command("new [directory]").action((directory = ".") => {
|
|
33
33
|
const projectPath = (0, path_1.resolve)((0, process_1.cwd)(), directory);
|
|
34
34
|
(0, new_1.createNewProject)(projectPath);
|
|
@@ -5,12 +5,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.rollupInputOptions = rollupInputOptions;
|
|
7
7
|
exports.rollupOutputOptions = rollupOutputOptions;
|
|
8
|
+
const plugin_node_resolve_1 = require("@rollup/plugin-node-resolve");
|
|
8
9
|
const plugin_typescript_1 = __importDefault(require("@rollup/plugin-typescript"));
|
|
9
10
|
const path_1 = require("path");
|
|
10
11
|
function rollupInputOptions(project) {
|
|
11
12
|
return {
|
|
12
13
|
input: (0, path_1.join)(project.path, "src", "index.ts"),
|
|
13
14
|
plugins: [
|
|
15
|
+
(0, plugin_node_resolve_1.nodeResolve)(),
|
|
14
16
|
{
|
|
15
17
|
name: "watch-project-yaml",
|
|
16
18
|
buildStart() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nibs-cli",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"description": "Project build tool for NovelAI scripts - bundles TypeScript files into single scripts",
|
|
5
5
|
"bin": {
|
|
6
6
|
"nibs": "dist/cli.js"
|
|
@@ -26,11 +26,15 @@
|
|
|
26
26
|
"typescript": "^5.3.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
29
30
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
30
31
|
"commander": "^14.0.2",
|
|
31
32
|
"inquirer": "^13.0.2",
|
|
32
33
|
"prettier": "^3.7.4",
|
|
33
34
|
"rollup": "^4.53.3",
|
|
34
35
|
"yaml": "^2.8.2"
|
|
36
|
+
},
|
|
37
|
+
"repository": {
|
|
38
|
+
"url": "https://github.com/LaneRendell/NovelAI_Script_BuildSystem"
|
|
35
39
|
}
|
|
36
40
|
}
|