@ringozz/godot 4.7.1-8 → 4.7.2-570
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 +128 -123
- package/gen/classes/DisplayServer.ts +3 -4
- package/gen/classes/Light3D.ts +4 -2
- package/gen/classes/RandomNumberGenerator.ts +2 -2
- package/gen/heap-types/GodotArray.ts +4 -1
- package/gen/heap-types/GodotDictionary.ts +6 -1
- package/package.json +16 -7
- package/src/assets.d.ts +130 -116
- package/src/boot.browser.ts +41 -0
- package/src/boot.ts +16 -26
- package/src/debug.ts +354 -236
- package/src/index.ts +52 -40
- package/src/load.ts +231 -210
- package/src/preload.ts +216 -198
- package/src/runtime.ts +84 -72
- package/src/web-image.ts +118 -118
package/src/assets.d.ts
CHANGED
|
@@ -1,116 +1,130 @@
|
|
|
1
|
-
/**********************************************************************
|
|
2
|
-
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
-
***********************************************************************/
|
|
4
|
-
|
|
5
|
-
// Ambient types for Godot asset imports, resolved by `@ringozz/godot/preload`
|
|
6
|
-
// into modules that export a `materialize` promise (files staged into MEMFS) and
|
|
7
|
-
// default to the load promise (`const { materialize, load } = loadAsset(path,
|
|
8
|
-
// Class, files, deps, import.meta.hot.data)` — `load` memoized on the module's
|
|
9
|
-
// HMR data, so re-evaluations return the same fulfilled promise). The default is
|
|
10
|
-
// a stable module singleton, so it can be passed to React's `use()` under
|
|
11
|
-
// `<Suspense>`.
|
|
12
|
-
|
|
13
|
-
declare module '*.tres' {
|
|
14
|
-
import type { Resource } from '@ringozz/godot/Resource';
|
|
15
|
-
const asset: Promise<Resource>;
|
|
16
|
-
export default asset;
|
|
17
|
-
export const materialize: Promise<unknown>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
declare module '*.po' {
|
|
21
|
-
import type { Translation } from '@ringozz/godot/Translation';
|
|
22
|
-
const asset: Promise<Translation>;
|
|
23
|
-
export default asset;
|
|
24
|
-
export const materialize: Promise<unknown>;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
declare module '*.gltf' {
|
|
28
|
-
import type { PackedScene } from '@ringozz/godot/PackedScene';
|
|
29
|
-
const asset: Promise<PackedScene>;
|
|
30
|
-
export default asset;
|
|
31
|
-
export const materialize: Promise<unknown>;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
declare module '*.tscn' {
|
|
35
|
-
import type { PackedScene } from '@ringozz/godot/PackedScene';
|
|
36
|
-
const asset: Promise<PackedScene>;
|
|
37
|
-
export default asset;
|
|
38
|
-
export const materialize: Promise<unknown>;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
declare module '*.obj' {
|
|
42
|
-
import type { PackedScene } from '@ringozz/godot/PackedScene';
|
|
43
|
-
const asset: Promise<PackedScene>;
|
|
44
|
-
export default asset;
|
|
45
|
-
export const materialize: Promise<unknown>;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
declare module '*.jpg' {
|
|
49
|
-
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
50
|
-
const asset: Promise<CompressedTexture2D>;
|
|
51
|
-
export default asset;
|
|
52
|
-
export const materialize: Promise<unknown>;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
declare module '*.jpeg' {
|
|
56
|
-
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
57
|
-
const asset: Promise<CompressedTexture2D>;
|
|
58
|
-
export default asset;
|
|
59
|
-
export const materialize: Promise<unknown>;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
declare module '*.png' {
|
|
63
|
-
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
64
|
-
const asset: Promise<CompressedTexture2D>;
|
|
65
|
-
export default asset;
|
|
66
|
-
export const materialize: Promise<unknown>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
declare module '*.webp' {
|
|
70
|
-
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
71
|
-
const asset: Promise<CompressedTexture2D>;
|
|
72
|
-
export default asset;
|
|
73
|
-
export const materialize: Promise<unknown>;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
declare module '*.svg' {
|
|
77
|
-
import type { Texture2D } from '@ringozz/godot/Texture2D';
|
|
78
|
-
const asset: Promise<Texture2D>;
|
|
79
|
-
export default asset;
|
|
80
|
-
export const materialize: Promise<unknown>;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
declare module '*.exr' {
|
|
84
|
-
import type { TextureLayered } from '@ringozz/godot/TextureLayered';
|
|
85
|
-
const asset: Promise<TextureLayered>;
|
|
86
|
-
export default asset;
|
|
87
|
-
export const materialize: Promise<unknown>;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
declare module '*.hdr' {
|
|
91
|
-
import type { TextureLayered } from '@ringozz/godot/TextureLayered';
|
|
92
|
-
const asset: Promise<TextureLayered>;
|
|
93
|
-
export default asset;
|
|
94
|
-
export const materialize: Promise<unknown>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
declare module '*.wav' {
|
|
98
|
-
import type { AudioStreamWAV } from '@ringozz/godot/AudioStreamWAV';
|
|
99
|
-
const asset: Promise<AudioStreamWAV>;
|
|
100
|
-
export default asset;
|
|
101
|
-
export const materialize: Promise<unknown>;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
declare module '*.
|
|
105
|
-
import type {
|
|
106
|
-
const asset: Promise<
|
|
107
|
-
export default asset;
|
|
108
|
-
export const materialize: Promise<unknown>;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
declare module '*.
|
|
112
|
-
import type {
|
|
113
|
-
const asset: Promise<
|
|
114
|
-
export default asset;
|
|
115
|
-
export const materialize: Promise<unknown>;
|
|
116
|
-
}
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
+
***********************************************************************/
|
|
4
|
+
|
|
5
|
+
// Ambient types for Godot asset imports, resolved by `@ringozz/godot/preload`
|
|
6
|
+
// into modules that export a `materialize` promise (files staged into MEMFS) and
|
|
7
|
+
// default to the load promise (`const { materialize, load } = loadAsset(path,
|
|
8
|
+
// Class, files, deps, import.meta.hot.data)` — `load` memoized on the module's
|
|
9
|
+
// HMR data, so re-evaluations return the same fulfilled promise). The default is
|
|
10
|
+
// a stable module singleton, so it can be passed to React's `use()` under
|
|
11
|
+
// `<Suspense>`.
|
|
12
|
+
|
|
13
|
+
declare module '*.tres' {
|
|
14
|
+
import type { Resource } from '@ringozz/godot/Resource';
|
|
15
|
+
const asset: Promise<Resource>;
|
|
16
|
+
export default asset;
|
|
17
|
+
export const materialize: Promise<unknown>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module '*.po' {
|
|
21
|
+
import type { Translation } from '@ringozz/godot/Translation';
|
|
22
|
+
const asset: Promise<Translation>;
|
|
23
|
+
export default asset;
|
|
24
|
+
export const materialize: Promise<unknown>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
declare module '*.gltf' {
|
|
28
|
+
import type { PackedScene } from '@ringozz/godot/PackedScene';
|
|
29
|
+
const asset: Promise<PackedScene>;
|
|
30
|
+
export default asset;
|
|
31
|
+
export const materialize: Promise<unknown>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
declare module '*.tscn' {
|
|
35
|
+
import type { PackedScene } from '@ringozz/godot/PackedScene';
|
|
36
|
+
const asset: Promise<PackedScene>;
|
|
37
|
+
export default asset;
|
|
38
|
+
export const materialize: Promise<unknown>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
declare module '*.obj' {
|
|
42
|
+
import type { PackedScene } from '@ringozz/godot/PackedScene';
|
|
43
|
+
const asset: Promise<PackedScene>;
|
|
44
|
+
export default asset;
|
|
45
|
+
export const materialize: Promise<unknown>;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
declare module '*.jpg' {
|
|
49
|
+
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
50
|
+
const asset: Promise<CompressedTexture2D>;
|
|
51
|
+
export default asset;
|
|
52
|
+
export const materialize: Promise<unknown>;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare module '*.jpeg' {
|
|
56
|
+
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
57
|
+
const asset: Promise<CompressedTexture2D>;
|
|
58
|
+
export default asset;
|
|
59
|
+
export const materialize: Promise<unknown>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
declare module '*.png' {
|
|
63
|
+
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
64
|
+
const asset: Promise<CompressedTexture2D>;
|
|
65
|
+
export default asset;
|
|
66
|
+
export const materialize: Promise<unknown>;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare module '*.webp' {
|
|
70
|
+
import type { CompressedTexture2D } from '@ringozz/godot/CompressedTexture2D';
|
|
71
|
+
const asset: Promise<CompressedTexture2D>;
|
|
72
|
+
export default asset;
|
|
73
|
+
export const materialize: Promise<unknown>;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare module '*.svg' {
|
|
77
|
+
import type { Texture2D } from '@ringozz/godot/Texture2D';
|
|
78
|
+
const asset: Promise<Texture2D>;
|
|
79
|
+
export default asset;
|
|
80
|
+
export const materialize: Promise<unknown>;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
declare module '*.exr' {
|
|
84
|
+
import type { TextureLayered } from '@ringozz/godot/TextureLayered';
|
|
85
|
+
const asset: Promise<TextureLayered>;
|
|
86
|
+
export default asset;
|
|
87
|
+
export const materialize: Promise<unknown>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare module '*.hdr' {
|
|
91
|
+
import type { TextureLayered } from '@ringozz/godot/TextureLayered';
|
|
92
|
+
const asset: Promise<TextureLayered>;
|
|
93
|
+
export default asset;
|
|
94
|
+
export const materialize: Promise<unknown>;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
declare module '*.wav' {
|
|
98
|
+
import type { AudioStreamWAV } from '@ringozz/godot/AudioStreamWAV';
|
|
99
|
+
const asset: Promise<AudioStreamWAV>;
|
|
100
|
+
export default asset;
|
|
101
|
+
export const materialize: Promise<unknown>;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
declare module '*.ttf' {
|
|
105
|
+
import type { FontFile } from '@ringozz/godot/FontFile';
|
|
106
|
+
const asset: Promise<FontFile>;
|
|
107
|
+
export default asset;
|
|
108
|
+
export const materialize: Promise<unknown>;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
declare module '*.otf' {
|
|
112
|
+
import type { FontFile } from '@ringozz/godot/FontFile';
|
|
113
|
+
const asset: Promise<FontFile>;
|
|
114
|
+
export default asset;
|
|
115
|
+
export const materialize: Promise<unknown>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
declare module '*.ogg' {
|
|
119
|
+
import type { AudioStreamOggVorbis } from '@ringozz/godot/AudioStreamOggVorbis';
|
|
120
|
+
const asset: Promise<AudioStreamOggVorbis>;
|
|
121
|
+
export default asset;
|
|
122
|
+
export const materialize: Promise<unknown>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
declare module '*.mp3' {
|
|
126
|
+
import type { AudioStreamMP3 } from '@ringozz/godot/AudioStreamMP3';
|
|
127
|
+
const asset: Promise<AudioStreamMP3>;
|
|
128
|
+
export default asset;
|
|
129
|
+
export const materialize: Promise<unknown>;
|
|
130
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**********************************************************************
|
|
2
|
+
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
|
+
***********************************************************************/
|
|
4
|
+
|
|
5
|
+
// Web boot leaf (the `browser`-field replacement for `boot.ts`): boots the
|
|
6
|
+
// Godot wasm engine and hands the module to `runtime.ts` as the native module
|
|
7
|
+
// *namespace* (whose `.default` is the wasm module). This module is a leaf — it
|
|
8
|
+
// imports nothing from the godot class graph, so a web entry can call
|
|
9
|
+
// `preloadGodot()` *before* importing the app without pulling in `runtime.ts`.
|
|
10
|
+
// `runtime.ts` statically imports this module too — by package self-reference
|
|
11
|
+
// (`@ringozz/godot/boot`, whose `exports` `./boot` entry's `browser` condition
|
|
12
|
+
// selects this file), the same resolution as the entrypoint's import, so both
|
|
13
|
+
// sides are guaranteed the same module instance and `nativeModule` below is the
|
|
14
|
+
// handoff — no global needed.
|
|
15
|
+
|
|
16
|
+
let nativeModule: unknown = null;
|
|
17
|
+
|
|
18
|
+
/** The cached wasm module import (its namespace), or `null` until `preloadGodot()` completes. */
|
|
19
|
+
export function getNativeModule(): unknown {
|
|
20
|
+
return nativeModule;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Boots the Godot wasm engine so `@ringozz/godot/runtime` can read the native
|
|
25
|
+
* module synchronously via {@link getNativeModule} — keeping the shared module
|
|
26
|
+
* graph top-level-await free (which is what lets Bun's HMR module loader
|
|
27
|
+
* evaluate sibling importers in order). Returns the wasm module's namespace
|
|
28
|
+
* (the native module is its `.default`, which `runtime.ts` destructures).
|
|
29
|
+
* Idempotent: subsequent calls return the cached import without re-booting.
|
|
30
|
+
*
|
|
31
|
+
* A web entry must `await preloadGodot()` before importing the app:
|
|
32
|
+
*
|
|
33
|
+
* ```ts
|
|
34
|
+
* import { preloadGodot } from '@ringozz/godot/boot';
|
|
35
|
+
* await preloadGodot();
|
|
36
|
+
* await import('./app.ts');
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export async function preloadGodot(): Promise<unknown> {
|
|
40
|
+
return nativeModule ??= await import('@ringozz/godot-web-wasm32');
|
|
41
|
+
}
|
package/src/boot.ts
CHANGED
|
@@ -2,36 +2,26 @@
|
|
|
2
2
|
Copyright (c) Vladimir Davidovich. All rights reserved.
|
|
3
3
|
***********************************************************************/
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
5
|
+
// Desktop boot leaf: resolves the native addon for the current host and
|
|
6
|
+
// hands it to `runtime.ts` as the native module *namespace* (whose `.default`
|
|
7
|
+
// is the addon's `module.exports`). `runtime.ts` imports this module by package
|
|
8
|
+
// self-reference (`@ringozz/godot/boot`), whose `exports` `./boot` entry's
|
|
9
|
+
// `browser` condition selects `boot.browser.ts` when bundling for
|
|
10
|
+
// `target: 'browser'` — so the Bun-only `import.meta.require` below never
|
|
11
|
+
// reaches a web bundle.
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
const { platform, arch } = globalThis.process ?? {};
|
|
14
|
+
const mapping: any = {
|
|
15
|
+
'darwin-arm64': 'macos-arm64',
|
|
16
|
+
'win32-x64': 'windows-x86_64',
|
|
17
|
+
};
|
|
13
18
|
|
|
14
|
-
/** The
|
|
19
|
+
/** The native addon's module namespace (sync dlopen; engine boots on first call). */
|
|
15
20
|
export function getNativeModule(): unknown {
|
|
16
|
-
return
|
|
21
|
+
return import.meta.require(`@ringozz/godot-${mapping[`${platform}-${arch}`]}`);
|
|
17
22
|
}
|
|
18
23
|
|
|
19
|
-
/**
|
|
20
|
-
* Boots the Godot wasm engine so `@ringozz/godot/runtime` can read the native
|
|
21
|
-
* module synchronously via {@link getNativeModule} — keeping the shared module
|
|
22
|
-
* graph top-level-await free (which is what lets Bun's HMR module loader
|
|
23
|
-
* evaluate sibling importers in order). Returns the wasm module's namespace
|
|
24
|
-
* (the native module is its `.default`, which `runtime.ts` destructures).
|
|
25
|
-
* Idempotent: subsequent calls return the cached import without re-booting.
|
|
26
|
-
*
|
|
27
|
-
* A web entry must `await preloadGodot()` before importing the app:
|
|
28
|
-
*
|
|
29
|
-
* ```ts
|
|
30
|
-
* import { preloadGodot } from '@ringozz/godot/boot';
|
|
31
|
-
* await preloadGodot();
|
|
32
|
-
* await import('./app.ts');
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
24
|
+
/** Desktop boots synchronously at import — nothing to preload. */
|
|
35
25
|
export async function preloadGodot(): Promise<unknown> {
|
|
36
|
-
return
|
|
26
|
+
return undefined;
|
|
37
27
|
}
|