@ringozz/godot 4.7.1-10 → 4.7.1-12

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 CHANGED
@@ -74,7 +74,7 @@ const tex = await loadResourceAsync('res://textures/icon.jpg', Texture2D); //
74
74
  - `loadResourceAsync(path, cls, files?)` — generic over the Godot class: `cls.name` is the `ResourceLoader` type hint, and the return type is `InstanceType<typeof cls>`. Loads in the background (`loadThreadedRequest` + status polling). Godot default arguments apply: the napi dispatch truncates trailing `undefined` args, so `loadThreadedRequest` uses its default `CACHE_MODE_REUSE` and the resource stays cached in the engine (scene re-references don't re-read the file). On web it only works for paths already staged into MEMFS (generated asset modules handle this). When the asset's `files` map is passed, the staged product files (`.ctex`/`.scn`/native sources) are deleted from MEMFS after the resource loads — only the `.import` sidecars are kept, since they route imported source paths to their products. The decoded texture bytes don't linger in the JS heap.
75
75
  - `loadAsset(path, cls, files, deps, data)` — the generated asset modules' entry point (also usable directly): returns `{ materialize, load }`. It checks the engine's `ResourceCache` first (when the asset is already loaded, `load` resolves to the cached instance and staging is skipped), stages the bundled files via Godot's `copyToFS` (zero-copy handover of the fetched bytes; a no-op on desktop where the files already exist), loads via `loadResourceAsync`, and memoizes `load` on `data` (pass `import.meta.hot.data`) so HMR re-evaluations reuse the same fulfilled promise.
76
76
 
77
- Asset imports are resolved by `@ringozz/godot/preload` (a Bun plugin, registered via `bunfig.toml` preload for `bun run`/`bun test` and via `[serve.static] plugins` for `Bun.serve`'s fullstack HTML routes; the module's default export is the single plugin object) into a module per asset:
77
+ Asset imports are resolved by `@ringozz/godot/preload` (a Bun plugin, registered via `bunfig.toml` preload for `bun run`/`bun test` and via `[serve.static] plugins` for `Bun.serve`'s fullstack HTML routes; the module's default export is the single plugin object) into a module per asset. Only **JS imports** are virtualized — HTML asset references (`<link rel="icon">`, `<img src>`) and CSS `url()` refs fall through to Bun's normal (content-hashed) asset handling, so favicons and other web assets co-exist with Godot imports:
78
78
 
79
79
  ```ts
80
80
  import foo from './models/foo.gltf';
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ringozz/godot",
3
3
  "author": "Vladimir Davidovich",
4
- "version": "4.7.1-10",
4
+ "version": "4.7.1-12",
5
5
  "description": "Node-API bindings for Godot Engine — call Godot classes from JavaScript",
6
6
  "keywords": [
7
7
  "godot"
@@ -38,7 +38,7 @@
38
38
  "optionalDependencies": {
39
39
  "@ringozz/godot-macos-arm64": "^4.7.1-3",
40
40
  "@ringozz/godot-windows-x86_64": "^4.7.1-3",
41
- "@ringozz/godot-web-wasm32": "^4.7.1-10"
41
+ "@ringozz/godot-web-wasm32": "^4.7.1-11"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "@types/bun": "*"
package/src/preload.ts CHANGED
@@ -175,6 +175,22 @@ const assetPlugin: BunPlugin = {
175
175
  name: 'godot-assets',
176
176
  setup(build) {
177
177
  build.onResolve({ filter: ASSET_RE }, (args) => {
178
+ // Only JS module imports of Godot source assets become `godot`
179
+ // modules. `Bun.build` reports JS imports as `import-statement`
180
+ // (and `dynamic-import`/`require-*`) but HTML asset references
181
+ // (<link>/<img>) and CSS url() refs as `internal`/`url-token` —
182
+ // those fall through so Bun copies/hashes the file normally. The
183
+ // runtime preload (bun run / bun test) reports JS imports with no
184
+ // kind (`undefined`), so treat that as a JS import too.
185
+ if (
186
+ args.kind !== undefined &&
187
+ args.kind !== 'import-statement' &&
188
+ args.kind !== 'dynamic-import' &&
189
+ args.kind !== 'require-call' &&
190
+ args.kind !== 'require-resolve'
191
+ ) {
192
+ return;
193
+ }
178
194
  const importerAbs = args.importer?.startsWith(`${NS}:`)
179
195
  ? args.importer.slice(NS.length + 1)
180
196
  : args.importer;