├── .gitignore
├── .npmrc
├── .prettierrc
├── .vscode
└── settings.json
├── README.md
├── apps
├── template-ref
│ ├── .editorconfig
│ ├── .gitattributes
│ ├── .gitignore
│ ├── app.tscn
│ ├── icon.svg
│ ├── icon.svg.import
│ ├── package.json
│ ├── project.godot
│ ├── tsconfig.json
│ ├── typings
│ │ ├── .gdignore
│ │ ├── app.nodes.gen.d.ts
│ │ ├── godot.minimal.d.ts
│ │ ├── godot.mix.d.ts
│ │ ├── godot.worker.d.ts
│ │ ├── godot0.gen.d.ts
│ │ ├── godot1.gen.d.ts
│ │ ├── godot2.gen.d.ts
│ │ ├── godot3.gen.d.ts
│ │ ├── godot4.gen.d.ts
│ │ ├── godot5.gen.d.ts
│ │ ├── godot6.gen.d.ts
│ │ ├── godot7.gen.d.ts
│ │ ├── godot8.gen.d.ts
│ │ ├── jsb.editor.bundle.d.ts
│ │ └── jsb.runtime.bundle.d.ts
│ └── vue
│ │ ├── .gdignore
│ │ ├── src
│ │ ├── .gdignore
│ │ ├── Test.vue
│ │ └── main.ts
│ │ └── vite.config.ts
├── v-model
│ ├── .editorconfig
│ ├── .gitattributes
│ ├── .gitignore
│ ├── app.tscn
│ ├── icon.svg
│ ├── icon.svg.import
│ ├── package.json
│ ├── project.godot
│ ├── tsconfig.json
│ ├── typings
│ │ ├── .gdignore
│ │ ├── app.nodes.gen.d.ts
│ │ ├── godot.minimal.d.ts
│ │ ├── godot.mix.d.ts
│ │ ├── godot.worker.d.ts
│ │ ├── godot0.gen.d.ts
│ │ ├── godot1.gen.d.ts
│ │ ├── godot2.gen.d.ts
│ │ ├── godot3.gen.d.ts
│ │ ├── godot4.gen.d.ts
│ │ ├── godot5.gen.d.ts
│ │ ├── godot6.gen.d.ts
│ │ ├── godot7.gen.d.ts
│ │ ├── godot8.gen.d.ts
│ │ ├── jsb.editor.bundle.d.ts
│ │ └── jsb.runtime.bundle.d.ts
│ └── vue
│ │ ├── .gdignore
│ │ ├── src
│ │ ├── .gdignore
│ │ ├── Test.vue
│ │ └── main.ts
│ │ └── vite.config.ts
└── v-on
│ ├── .editorconfig
│ ├── .gitattributes
│ ├── .gitignore
│ ├── app.tscn
│ ├── icon.svg
│ ├── icon.svg.import
│ ├── package.json
│ ├── project.godot
│ ├── tsconfig.json
│ ├── typings
│ ├── .gdignore
│ ├── app.nodes.gen.d.ts
│ ├── godot.minimal.d.ts
│ ├── godot.mix.d.ts
│ ├── godot.worker.d.ts
│ ├── godot0.gen.d.ts
│ ├── godot1.gen.d.ts
│ ├── godot2.gen.d.ts
│ ├── godot3.gen.d.ts
│ ├── godot4.gen.d.ts
│ ├── godot5.gen.d.ts
│ ├── godot6.gen.d.ts
│ ├── godot7.gen.d.ts
│ ├── godot8.gen.d.ts
│ ├── jsb.editor.bundle.d.ts
│ └── jsb.runtime.bundle.d.ts
│ └── vue
│ ├── .gdignore
│ ├── src
│ ├── .gdignore
│ ├── Test.vue
│ └── main.ts
│ └── vite.config.ts
├── intro-medias
└── demo.gif
├── package-lock.json
├── package.json
├── packages
└── runtime-tscn
│ ├── README.md
│ ├── package.json
│ ├── src
│ ├── index.ts
│ ├── nodeOps.ts
│ └── patchProp.ts
│ ├── tsconfig.json
│ └── typings
│ ├── godot.minimal.d.ts
│ ├── godot.mix.d.ts
│ ├── godot0.gen.d.ts
│ ├── godot1.gen.d.ts
│ ├── godot2.gen.d.ts
│ ├── godot3.gen.d.ts
│ ├── godot4.gen.d.ts
│ ├── godot5.gen.d.ts
│ ├── godot6.gen.d.ts
│ ├── godot7.gen.d.ts
│ ├── jsb.editor.bundle.d.ts
│ └── jsb.runtime.bundle.d.ts
└── turbo.json
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # Dependencies
4 | node_modules
5 | .pnp
6 | .pnp.js
7 |
8 | # Local env files
9 | .env
10 | .env.local
11 | .env.development.local
12 | .env.test.local
13 | .env.production.local
14 |
15 | # Testing
16 | coverage
17 |
18 | # Turbo
19 | .turbo
20 |
21 | # Vercel
22 | .vercel
23 |
24 | # Build Outputs
25 | .next/
26 | out/
27 | build
28 | dist
29 |
30 |
31 | # Debug
32 | npm-debug.log*
33 | yarn-debug.log*
34 | yarn-error.log*
35 |
36 | # Misc
37 | .DS_Store
38 | *.pem
39 |
40 | example/
41 |
--------------------------------------------------------------------------------
/.npmrc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/.npmrc
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "tabWidth": 2,
3 | "useTabs": false,
4 | "singleQuote": true,
5 | "trailingComma": "all",
6 | "arrowParens": "always",
7 | "semi": false,
8 | "exclude": ["node_modules", "dist", "build"]
9 | }
10 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "editor.formatOnSave": true,
3 | "editor.defaultFormatter": "esbenp.prettier-vscode",
4 | "editor.codeActionsOnSave": {
5 | "source.fixAll": "explicit",
6 | "source.organizeImports": "explicit"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Vue Godot
2 |
3 | A small simple project that bridges Vue.js and Godot.
4 |
5 | This project is for:
6 |
7 | - Write game UI using Vue.js
8 | - Write cross platform applications using Vue.js with Godot as the runtime
9 |
10 | This project is far from production ready. follow me on [@juryxiong](https://x.com/juryxiong) for updates.
11 |
12 | ```vue
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
30 | ```
31 |
32 | ```ts
33 | // main.ts
34 | import { createApp } from '@vue-godot/runtime-tscn'
35 | import { Control } from 'godot'
36 | import Test from './Test.vue'
37 |
38 | export default class App extends Control {
39 | _ready() {
40 | const app = createApp(Test)
41 | app.mount(this)
42 | }
43 | }
44 | ```
45 |
46 | 
47 |
48 | ## Getting Started
49 |
50 | Download GodotJS editor from https://github.com/ialex32x/GodotJS-Build/releases
51 |
52 | ```bash
53 | npm install
54 | npm run build:demo
55 | ```
56 |
57 | Open GodotJS editor and open `apps/v-on/project.godot`
58 |
--------------------------------------------------------------------------------
/apps/template-ref/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 |
--------------------------------------------------------------------------------
/apps/template-ref/.gitattributes:
--------------------------------------------------------------------------------
1 | # Normalize EOL for all files that Git considers text files.
2 | * text=auto eol=lf
3 |
--------------------------------------------------------------------------------
/apps/template-ref/.gitignore:
--------------------------------------------------------------------------------
1 | # Godot 4+ specific ignores
2 | .godot/
3 | /android/
4 |
--------------------------------------------------------------------------------
/apps/template-ref/app.tscn:
--------------------------------------------------------------------------------
1 | [gd_scene load_steps=2 format=3 uid="uid://75hgd8tc3add"]
2 |
3 | [ext_resource type="Script" uid="uid://drocoh834d6p3" path="res://dist/app.js" id="1_j6dmo"]
4 |
5 | [node name="app" type="Control"]
6 | layout_mode = 3
7 | anchors_preset = 15
8 | anchor_right = 1.0
9 | anchor_bottom = 1.0
10 | grow_horizontal = 2
11 | grow_vertical = 2
12 | script = ExtResource("1_j6dmo")
13 |
--------------------------------------------------------------------------------
/apps/template-ref/icon.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/apps/template-ref/icon.svg.import:
--------------------------------------------------------------------------------
1 | [remap]
2 |
3 | importer="texture"
4 | type="CompressedTexture2D"
5 | uid="uid://qpidkdfstni7"
6 | path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"
7 | metadata={
8 | "vram_texture": false
9 | }
10 |
11 | [deps]
12 |
13 | source_file="res://icon.svg"
14 | dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"]
15 |
16 | [params]
17 |
18 | compress/mode=0
19 | compress/high_quality=false
20 | compress/lossy_quality=0.7
21 | compress/hdr_compression=1
22 | compress/normal_map=0
23 | compress/channel_pack=0
24 | mipmaps/generate=false
25 | mipmaps/limit=-1
26 | roughness/mode=0
27 | roughness/src_normal=""
28 | process/fix_alpha_border=true
29 | process/premult_alpha=false
30 | process/normal_map_invert_y=false
31 | process/hdr_as_srgb=false
32 | process/hdr_clamp_exposure=false
33 | process/size_limit=0
34 | detect_3d/compress_to=1
35 | svg/scale=1.0
36 | editor/scale_with_editor_scale=false
37 | editor/convert_colors_with_editor_theme=false
38 |
--------------------------------------------------------------------------------
/apps/template-ref/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@vue-godot/example-template-ref",
3 | "version": "1.0.0",
4 | "description": "",
5 | "license": "ISC",
6 | "author": "",
7 | "type": "commonjs",
8 | "main": "index.js",
9 | "scripts": {
10 | "build": "vite build -c vue/vite.config.ts"
11 | },
12 | "devDependencies": {
13 | "@types/node": "^20.11.18",
14 | "@vitejs/plugin-vue": "^5.2.4",
15 | "vite": "^6.3.5"
16 | },
17 | "dependencies": {
18 | "@vue-godot/runtime-tscn": "*",
19 | "@vue/runtime-core": "^3.5.14"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/apps/template-ref/project.godot:
--------------------------------------------------------------------------------
1 | ; Engine configuration file.
2 | ; It's best edited using the editor UI and not directly,
3 | ; since the parameters that go here are not all obvious.
4 | ;
5 | ; Format:
6 | ; [section] ; section goes between []
7 | ; param=value ; assign values to parameters
8 |
9 | config_version=5
10 |
11 | [application]
12 |
13 | config/name="template-ref demo"
14 | run/main_scene="uid://75hgd8tc3add"
15 | config/features=PackedStringArray("4.4", "Forward Plus")
16 | config/icon="res://icon.svg"
17 |
--------------------------------------------------------------------------------
/apps/template-ref/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | /* Visit https://aka.ms/tsconfig to read more about this file */
4 |
5 | /* Projects */
6 | "incremental": true /* Save .tsbuildinfo files to allow for incremental compilation of projects. */,
7 | // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8 | "tsBuildInfoFile": ".godot/.tsbuildinfo" /* Specify the path to .tsbuildinfo incremental compilation file. */,
9 | // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
10 | // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11 | // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12 |
13 | /* Language and Environment */
14 | "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15 | "lib": [
16 | "es2020"
17 | ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
18 | // "jsx": "preserve", /* Specify what JSX code is generated. */
19 | "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */,
20 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
21 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
22 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
23 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
24 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
25 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
26 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
27 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
28 |
29 | /* Modules */
30 | "module": "ESNext" /* Specify what module code is generated. */,
31 | "rootDir": "./" /* Specify the root folder within your source files. */,
32 | "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
33 | "baseUrl": "./",
34 | "paths": {
35 | "godot": ["./typings/godot.minimal.d.ts"]
36 | },
37 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
38 | "typeRoots": [
39 | /* Specify multiple folders that act like './node_modules/@types'. */
40 | "./node_modules/@types"
41 | ],
42 | // "types": [], /* Specify type package names to be included without being referenced in a source file. */
43 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
44 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
45 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
46 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
47 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
48 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
49 | // "resolveJsonModule": true, /* Enable importing .json files. */
50 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
51 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */
52 |
53 | /* JavaScript Support */
54 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
55 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
56 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
57 |
58 | /* Emit */
59 | // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
60 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */
61 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
62 | "sourceMap": true /* Create source map files for emitted JavaScript files. */,
63 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
64 | // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
65 | "outDir": ".godot/GodotJS" /* Specify an output folder for all emitted files. */,
66 | // "removeComments": true, /* Disable emitting comments. */
67 | // "noEmit": true, /* Disable emitting files from a compilation. */
68 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
69 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
70 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
71 | "sourceRoot": "../../../" /* Specify the root path for debuggers to find the reference source code. */,
72 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
73 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
74 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
75 | "newLine": "crlf" /* Set the newline character for emitting files. */,
76 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
77 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
78 | "noEmitOnError": false /* Disable emitting files if any type checking errors are reported. */,
79 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
80 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
81 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
82 |
83 | /* Interop Constraints */
84 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
85 | // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
86 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
87 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
88 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
89 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
90 |
91 | /* Type Checking */
92 | "strict": true /* Enable all strict type-checking options. */,
93 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
94 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
95 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
96 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
97 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
98 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
99 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
100 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
101 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
102 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
103 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
104 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
105 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
106 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
107 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
108 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
109 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
110 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
111 |
112 | /* Completeness */
113 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
114 | "skipLibCheck": true /* Skip type checking all .d.ts files. */
115 | },
116 | "include": [
117 | "vue/src/**/*.ts",
118 | "vue/src/**/*.d.ts",
119 | "vue/src/**/*.vue",
120 | "typings/**/*.d.ts"
121 | ],
122 | "exclude": ["node_modules", "dist"]
123 | }
124 |
--------------------------------------------------------------------------------
/apps/template-ref/typings/.gdignore:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/apps/template-ref/typings/app.nodes.gen.d.ts:
--------------------------------------------------------------------------------
1 | declare module "godot" {
2 | interface SceneNodes {
3 | "app.tscn": {},
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/apps/template-ref/typings/godot.minimal.d.ts:
--------------------------------------------------------------------------------
1 |
2 | declare module "godot-jsb" {
3 | import { Object as GDObject, PackedByteArray, PropertyUsageFlags, PropertyHint, MethodFlags, Variant, Callable0, Callable1, Callable2, Callable3, Callable4, Callable5, StringName, MultiplayerAPI, MultiplayerPeer } from "godot";
4 |
5 | const DEV_ENABLED: boolean;
6 | const TOOLS_ENABLED: boolean;
7 |
8 | /** version of GodotJS */
9 | const version: string;
10 |
11 | /** impl currently used */
12 | const impl: string;
13 |
14 | /**
15 | * Create godot Callable with a bound object `self`.
16 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
17 | */
18 | function callable(self: GDObject, fn: () => R): Callable0;
19 | /**
20 | * Create godot Callable with a bound object `self`.
21 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
22 | */
23 | function callable(self: GDObject, fn: (v1: T1) => R): Callable1;
24 | /**
25 | * Create godot Callable with a bound object `self`.
26 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
27 | */
28 | function callable(self: GDObject, fn: (v1: T1, v2: T2) => R): Callable2;
29 | /**
30 | * Create godot Callable with a bound object `self`.
31 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
32 | */
33 | function callable(self: GDObject, fn: (v1: T1, v2: T2, v3: T3) => R): Callable3;
34 | /**
35 | * Create godot Callable with a bound object `self`.
36 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
37 | */
38 | function callable(self: GDObject, fn: (v1: T1, v2: T2, v3: T3, v4: T4) => R): Callable4;
39 | /**
40 | * Create godot Callable with a bound object `self`.
41 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
42 | */
43 | function callable(self: GDObject, fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => R): Callable5;
44 |
45 | /**
46 | * Create godot Callable without a bound object.
47 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
48 | */
49 | function callable(fn: () => R): Callable0;
50 | /**
51 | * Create godot Callable without a bound object.
52 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
53 | */
54 | function callable(fn: (v1: T1) => R): Callable1;
55 | /**
56 | * Create godot Callable without a bound object.
57 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
58 | */
59 | function callable(fn: (v1: T1, v2: T2) => R): Callable2;
60 | /**
61 | * Create godot Callable without a bound object.
62 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
63 | */
64 | function callable(fn: (v1: T1, v2: T2, v3: T3) => R): Callable3;
65 | /**
66 | * Create godot Callable without a bound object.
67 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
68 | */
69 | function callable(fn: (v1: T1, v2: T2, v3: T3, v4: T4) => R): Callable4;
70 | /**
71 | * Create godot Callable without a bound object.
72 | * @deprecated [WARNING] avoid using this function directly, use `Callable.create` instead.
73 | */
74 | function callable(fn: (v1: T1, v2: T2, v3: T3, v4: T4, v5: T5) => R): Callable5;
75 |
76 | /**
77 | * Explicitly convert a `PackedByteArray`(aka `Vector`) into a javascript `ArrayBuffer`
78 | * @deprecated [WARNING] This free function '_to_array_buffer' is deprecated and will be removed in a future version, use 'PackedByteArray.to_array_buffer()' instead.
79 | */
80 | function to_array_buffer(packed: PackedByteArray): ArrayBuffer;
81 |
82 | interface ScriptPropertyInfo {
83 | name: string;
84 | type: Variant.Type;
85 | class_?: Function;
86 | hint?: number;
87 | hint_string?: string;
88 | usage?: number;
89 | }
90 |
91 | namespace internal {
92 | type OnReadyEvaluatorFunc = (self: any) => any;
93 |
94 | interface RPCConfig {
95 | mode?: MultiplayerAPI.RPCMode,
96 | sync?: boolean,
97 | transfer_mode?: MultiplayerPeer.TransferMode,
98 | transfer_channel?: number,
99 | }
100 |
101 | function add_script_signal(target: any, name: string): void;
102 | function add_script_property(target: any, details: ScriptPropertyInfo): void;
103 | function add_script_ready(target: any, details: { name: string, evaluator: string | OnReadyEvaluatorFunc }): void;
104 | function add_script_tool(target: any): void;
105 | function add_script_icon(target: any, path: string): void;
106 | function add_script_rpc(target: any, propertyKey: string, config: RPCConfig): void;
107 |
108 | // 0: deprecated, 1: experimental, 2: help
109 | function set_script_doc(target: any, propertyKey?: string, field: 0 | 1 | 2, message: string): void;
110 |
111 | function add_module(id: string, obj: any): void;
112 | function find_module(id: string): any;
113 | function notify_microtasks_run(): void;
114 |
115 | /**
116 | * Get the transformed type name of a Variant.Type
117 | */
118 | function get_type_name(type: Variant.Type): StringName;
119 | }
120 |
121 | namespace editor {
122 | interface PrimitiveConstantInfo {
123 | name: string;
124 | type: Variant.Type;
125 | value: number; /* only if type is literal */
126 | }
127 |
128 | interface ConstantInfo {
129 | name: string;
130 | value: number; /** int64_t */
131 | }
132 |
133 | interface EnumInfo {
134 | name: string;
135 |
136 | literals: Array;
137 | is_bitfield: boolean;
138 | }
139 |
140 | interface DefaultArgumentInfo {
141 | type: Variant.Type;
142 | value: any;
143 | }
144 |
145 | // we treat godot MethodInfo/MethodBind as the same thing here for simplicity
146 | //NOTE some fields will not be set if it's actually a MethodInfo struct
147 | interface MethodBind {
148 | id: number;
149 | name: string;
150 |
151 | hint_flags: MethodFlags;
152 | is_static: boolean;
153 | is_const: boolean;
154 | is_vararg: boolean;
155 | argument_count: number; /** int32_t */
156 |
157 | args_: Array;
158 | default_arguments?: Array;
159 | return_: PropertyInfo | undefined;
160 | }
161 |
162 | interface PropertyInfo {
163 | name: string;
164 | type: Variant.Type;
165 | class_name: string;
166 | hint: PropertyHint;
167 | hint_string: string;
168 | usage: PropertyUsageFlags;
169 | }
170 |
171 | interface PropertySetGetInfo {
172 | name: string;
173 |
174 | type: Variant.Type;
175 | index: number;
176 | setter: string;
177 | getter: string;
178 |
179 | info: PropertyInfo;
180 | }
181 |
182 | interface PrimitiveGetSetInfo {
183 | name: string;
184 | type: Variant.Type;
185 | }
186 |
187 | interface SignalInfo {
188 | name: string;
189 | method_: MethodBind;
190 | }
191 |
192 | interface ArgumentInfo {
193 | name: string;
194 | type: Variant.Type;
195 | }
196 |
197 | interface ConstructorInfo {
198 | arguments: Array
199 | }
200 |
201 | interface OperatorInfo {
202 | name: string;
203 | return_type: Variant.Type;
204 | left_type: Variant.Type;
205 | right_type: Variant.Type;
206 | }
207 |
208 | interface BasicClassInfo {
209 | name: string;
210 | methods: Array;
211 | enums?: Array;
212 | }
213 |
214 | // godot class
215 | interface ClassInfo extends BasicClassInfo {
216 | super: string;
217 |
218 | properties: Array;
219 | virtual_methods: Array;
220 | signals: Array;
221 | constants?: Array;
222 | }
223 |
224 | // variant class
225 | interface PrimitiveClassInfo extends BasicClassInfo {
226 | // self type
227 | type: Variant.Type;
228 |
229 | // valid only if has_indexing
230 | element_type?: Variant.Type;
231 |
232 | // true only if is_keyed
233 | is_keyed: boolean;
234 |
235 | constructors: Array;
236 | operators: Array;
237 | properties: Array;
238 | constants?: Array;
239 | }
240 |
241 | interface SingletonInfo {
242 | name: string;
243 | class_name: string;
244 | user_created: boolean;
245 | editor_only: boolean;
246 | }
247 |
248 | interface GlobalConstantInfo {
249 | name: string;
250 | values: { [name: string]: number /** int64_t */ };
251 | }
252 |
253 | interface ClassDoc {
254 | brief_description: string;
255 |
256 | constants: { [name: string]: { description: string } };
257 | methods: { [name: string]: { description: string } };
258 | properties: { [name: string]: { description: string } };
259 | signals: { [name: string]: { description: string } };
260 | }
261 |
262 | function get_class_doc(class_name: string): ClassDoc | undefined;
263 |
264 | /**
265 | * get a list of all classes registered in ClassDB
266 | */
267 | function get_classes(): Array;
268 |
269 | function get_primitive_types(): Array;
270 |
271 | function get_singletons(): Array;
272 |
273 | function get_global_constants(): Array;
274 |
275 | function get_utility_functions(): Array;
276 |
277 | function delete_file(filepath: string): void;
278 |
279 | const VERSION_DOCS_URL: string;
280 | }
281 | }
282 |
283 |
--------------------------------------------------------------------------------
/apps/template-ref/typings/godot.mix.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | declare module "godot" {
3 | export const IntegerType: unique symbol;
4 | export const FloatType: unique symbol;
5 |
6 | /** A built-in type representing a method or a standalone function.
7 | *
8 | * @link https://docs.godotengine.org/en/4.2/classes/class_callable.html
9 | */
10 | interface AnyCallable {
11 | /** Returns `true` if this [Callable] has no target to call the method on. */
12 | is_null(): boolean
13 |
14 | /** Returns `true` if this [Callable] is a custom callable. Custom callables are created from [method bind] or [method unbind]. In GDScript, lambda functions are also custom callables. */
15 | is_custom(): boolean
16 |
17 | /** Returns `true` if this [Callable] is a standard callable. This method is the opposite of [method is_custom]. Returns `false` if this callable is a lambda function. */
18 | is_standard(): boolean
19 |
20 | /** Returns `true` if the callable's object exists and has a valid method name assigned, or is a custom callable. */
21 | is_valid(): boolean
22 |
23 | /** Returns the object on which this [Callable] is called. */
24 | get_object(): Object
25 |
26 | /** Returns the ID of this [Callable]'s object (see [method Object.get_instance_id]). */
27 | get_object_id(): int64
28 |
29 | /** Returns the name of the method represented by this [Callable]. If the callable is a GDScript lambda function, returns the function's name or `""`. */
30 | get_method(): StringName
31 |
32 | /** Returns the total amount of arguments bound (or unbound) via successive [method bind] or [method unbind] calls. If the amount of arguments unbound is greater than the ones bound, this function returns a value less than zero. */
33 | get_bound_arguments_count(): int64
34 |
35 | /** Return the bound arguments (as long as [method get_bound_arguments_count] is greater than zero), or empty (if [method get_bound_arguments_count] is less than or equal to zero). */
36 | get_bound_arguments(): Array
37 |
38 | /** Returns the 32-bit hash value of this [Callable]'s object.
39 | *
40 | * **Note:** [Callable]s with equal content will always produce identical hash values. However, the reverse is not true. Returning identical hash values does *not* imply the callables are equal, because different callables can have identical hash values due to hash collisions. The engine uses a 32-bit hash algorithm for [method hash].
41 | */
42 | hash(): int64
43 |
44 | /** Returns a copy of this [Callable] with one or more arguments bound. When called, the bound arguments are passed *after* the arguments supplied by [method call]. See also [method unbind].
45 | *
46 | * **Note:** When this method is chained with other similar methods, the order in which the argument list is modified is read from right to left.
47 | */
48 | bind(...vargargs: any[]): AnyCallable
49 |
50 | /** Returns a copy of this [Callable] with one or more arguments bound, reading them from an array. When called, the bound arguments are passed *after* the arguments supplied by [method call]. See also [method unbind].
51 | *
52 | * **Note:** When this method is chained with other similar methods, the order in which the argument list is modified is read from right to left.
53 | */
54 | bindv(arguments_: GArray): AnyCallable
55 |
56 | /** Returns a copy of this [Callable] with a number of arguments unbound. In other words, when the new callable is called the last few arguments supplied by the user are ignored, according to [param argcount]. The remaining arguments are passed to the callable. This allows to use the original callable in a context that attempts to pass more arguments than this callable can handle, e.g. a signal with a fixed number of arguments. See also [method bind].
57 | *
58 | * **Note:** When this method is chained with other similar methods, the order in which the argument list is modified is read from right to left.
59 | *
60 | */
61 | unbind(argcount: int64): AnyCallable
62 |
63 | /** Calls the method represented by this [Callable]. Arguments can be passed and should match the method's signature. */
64 | call(...vargargs: any[]): any
65 |
66 | /** Calls the method represented by this [Callable]. Unlike [method call], this method expects all arguments to be contained inside the [param arguments] [Array]. */
67 | callv(arguments_: GArray): any
68 |
69 | /** Calls the method represented by this [Callable] in deferred mode, i.e. at the end of the current frame. Arguments can be passed and should match the method's signature.
70 | *
71 | *
72 | * **Note:** Deferred calls are processed at idle time. Idle time happens mainly at the end of process and physics frames. In it, deferred calls will be run until there are none left, which means you can defer calls from other deferred calls and they'll still be run in the current idle time cycle. This means you should not call a method deferred from itself (or from a method called by it), as this causes infinite recursion the same way as if you had called the method directly.
73 | * See also [method Object.call_deferred].
74 | */
75 | call_deferred(...vargargs: any[]): void
76 | }
77 |
78 | /** A built-in type representing a signal of an [Object].
79 | *
80 | * @link https://docs.godotengine.org/en/4.2/classes/class_signal.html
81 | */
82 | interface AnySignal {
83 | /** Returns `true` if the signal's name does not exist in its object, or the object is not valid. */
84 | is_null(): boolean
85 |
86 | /** Returns the object emitting this signal. */
87 | get_object(): Object
88 |
89 | /** Returns the ID of the object emitting this signal (see [method Object.get_instance_id]). */
90 | get_object_id(): int64
91 |
92 | /** Returns the name of this signal. */
93 | get_name(): StringName
94 |
95 | /** Returns `true` if the specified [Callable] is connected to this signal. */
96 | is_connected(callable: AnyCallable): boolean
97 |
98 | /** Returns an [Array] of connections for this signal. Each connection is represented as a [Dictionary] that contains three entries:
99 | * - `signal` is a reference to this signal;
100 | * - `callable` is a reference to the connected [Callable];
101 | * - `flags` is a combination of [enum Object.ConnectFlags].
102 | */
103 | get_connections(): Array
104 | }
105 |
106 | interface Callable0 extends AnyCallable {
107 | call(): R;
108 | }
109 |
110 | interface Callable1 extends AnyCallable {
111 | call(v1: T1): R;
112 | }
113 |
114 | interface Callable2 extends AnyCallable {
115 | call(v1: T1, v2, T2): R;
116 | }
117 |
118 | interface Callable3 extends AnyCallable {
119 | call(v1: T1, v2: T2, v3: T3): R;
120 | }
121 |
122 | interface Callable4 extends AnyCallable {
123 | call(v1: T1, v2: T2, v3: T3, v4: T4): R;
124 | }
125 |
126 | interface Callable5 extends AnyCallable {
127 | call(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R;
128 | }
129 |
130 | interface Signal0 extends AnySignal {
131 | connect(callable: Callable0, flags: int64 = 0): void;
132 | disconnect(callable: Callable0): void;
133 | is_connected(callable: Callable0): boolean;
134 | emit(): void;
135 |
136 | as_promise(): Promise;
137 | }
138 |
139 | interface Signal1 extends AnySignal {
140 | connect(callable: Callable1, flags: int64 = 0): void;
141 | disconnect(callable: Callable1): void;
142 | is_connected(callable: Callable1): boolean;
143 | emit(v1: T1): void;
144 |
145 | // the first argument is used as the resolved value
146 | as_promise(): Promise;
147 | }
148 |
149 | interface Signal2 extends AnySignal {
150 | connect(callable: Callable2, flags: int64 = 0): void;
151 | disconnect(callable: Callable2): void;
152 | is_connected(callable: Callable2): boolean;
153 | emit(v1: T1, v2: T2): void;
154 |
155 | // the first argument is used as the resolved value
156 | as_promise(): Promise;
157 | }
158 |
159 | interface Signal3 extends AnySignal {
160 | connect(callable: Callable3, flags: int64 = 0): void;
161 | disconnect(callable: Callable3): void;
162 | is_connected(callable: Callable3): boolean;
163 | emit(v1: T1, v2: T2, v3: T3): void;
164 |
165 | // the first argument is used as the resolved value
166 | as_promise(): Promise;
167 | }
168 |
169 | interface Signal4 extends AnySignal {
170 | connect(callable: Callable4, flags: int64 = 0): void;
171 | disconnect(callable: Callable4): void;
172 | is_connected(callable: Callable4): boolean;
173 | emit(v1: T1, v2: T2, v3: T3, v4: T4): void;
174 |
175 | // the first argument is used as the resolved value
176 | as_promise(): Promise;
177 | }
178 |
179 | interface Signal5 extends AnySignal {
180 | connect(callable: Callable5, flags: int64 = 0): void;
181 | disconnect(callable: Callable5): void;
182 | is_connected(callable: Callable5): boolean;
183 | emit(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): void;
184 |
185 | // the first argument is used as the resolved value
186 | as_promise(): Promise;
187 | }
188 |
189 | type NodePathMap = { [K in string]?: Node };
190 |
191 | type StaticNodePath