@ringozz/godot 0.1.0 → 0.1.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.
Files changed (2) hide show
  1. package/README.md +62 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # @ringozz/godot
2
+
3
+ Node-API bindings for the Godot Engine — call Godot classes, value types, and utility functions from JavaScript.
4
+
5
+ This is the core runtime package. The React layer is a separate package ([`@ringozz/react-godot`](../react-godot/README.md)).
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ bun add @ringozz/godot
11
+ ```
12
+
13
+ The package ships no engine binary itself — it auto-selects a platform addon from its optional dependencies on install: `@ringozz/godot-macos-arm64`, `@ringozz/godot-windows-x86_64`, or `@ringozz/godot-web-wasm32` (the WASM build is installed everywhere and used on web). No `project.godot` is required — the engine boots from engine defaults with `res://` = your working directory.
14
+
15
+ ## Usage
16
+
17
+ The engine is already running when you import — `getGodot()` returns the instance synchronously. Pump frames with `runGodot()`:
18
+
19
+ ```ts
20
+ import { runGodot } from '@ringozz/godot';
21
+ import { Engine } from '@ringozz/godot/Engine';
22
+ import { SceneTree } from '@ringozz/godot/SceneTree';
23
+
24
+ const tree = Engine.getMainLoop() as SceneTree;
25
+ const root = tree.root;
26
+
27
+ const label = new Label();
28
+ label.text = 'hello from godot-node';
29
+ root.addChild(label);
30
+
31
+ const done = runGodot(); // pumps frames until aborted
32
+ ```
33
+
34
+ ### What's exported where
35
+
36
+ | Specifier | Contents |
37
+ |---|---|
38
+ | `@ringozz/godot` | Value types (`Vector3`, `Color`, …), global enums, heap types, utility functions, global constants, `runGodot()`, RAF polyfills |
39
+ | `@ringozz/godot/ClassName` | Classes, one per module — e.g. `@ringozz/godot/Label`, `@ringozz/godot/Node` |
40
+ | `@ringozz/godot/runtime` | Low-level dispatch: `_C`, `_S`, `_get`, `_set`, `_R`, `_G`, `_P`, `getGodot`, `GodotVar` |
41
+ | `@ringozz/godot/debug` | `initDebug()`, `dumpStr`, `dumpTreeStr`, `statsStr`, `gc` |
42
+
43
+ Class-scoped enums use bare names (import `ProcessMode` from `@ringozz/godot/Node`, not `NodeProcessMode`).
44
+
45
+ ### Debugging
46
+
47
+ ```ts
48
+ import { initDebug } from '@ringozz/godot/debug';
49
+ initDebug();
50
+ // singletons + helpers now on globalThis.$: $.Engine, $.dumpTreeStr(root), $.statsStr(), $.gc()
51
+ ```
52
+
53
+ `initDebug` also registers an `uncaughtException` handler that keeps the process alive, and adds `getBoundingClientRect()` to `CanvasItem`/`Node3D`.
54
+
55
+ ## Notes
56
+
57
+ - **Memory**: non-RefCounted objects (`Node`, `Node2D`, `Node3D`, …) must call `free()` explicitly. RefCounted objects are managed by Godot's ref counting; calling `free()` clears the JS wrapper (decrements the ref).
58
+ - **Class-registration tree-shaking**: `ClassDB.instantiate('X')` requires the JS class to be value-imported (`import { Label } from '@ringozz/godot/Label'`). If a class is only type-used (e.g. `as Label` casts), bundlers may drop its registration side effect, and wrappers fall back to an ancestor class. Render through JSX is unaffected. Workaround: keep a value reference (`void Label;`).
59
+
60
+ ## Development
61
+
62
+ `gen/` is generated (and gitignored) by `dev/codegen.ts` from `godot --dump-extension-api-with-docs`. Regenerate + typecheck with `bun run prebuild`. Build the native addon with `bun run build`. See [`AGENTS.md`](../../AGENTS.md) for the full workflow.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ringozz/godot",
3
3
  "author": "Vladimir Davidovich",
4
- "version": "0.1.0",
4
+ "version": "0.1.1",
5
5
  "description": "Node-API bindings for Godot Engine — call Godot classes from JavaScript",
6
6
  "type": "module",
7
7
  "main": "./src/index.ts",
@@ -14,7 +14,8 @@
14
14
  },
15
15
  "files": [
16
16
  "src/",
17
- "gen/"
17
+ "gen/",
18
+ "*.md"
18
19
  ],
19
20
  "godot": {
20
21
  "version_major": 4,