├── .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 | 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 | ![demo](./intro-medias/demo.gif) 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 = (keyof Map & string) | { 192 | [K in keyof Map & string]: Map[K] extends Node 193 | ? `${K}/${StaticNodePath}` 194 | : never 195 | }[keyof Map & string]; 196 | 197 | type ResolveNodePath = Path extends keyof Map 198 | ? Map[Path] 199 | : Path extends `${infer Key extends keyof Map & string}/${infer SubPath}` 200 | ? Map[Key] extends Node 201 | ? ResolveNodePath 202 | : Default 203 | : Default; 204 | 205 | /** 206 | * GArray elements are exposed with a subset of JavaScript's standard Array API. Array indexes are exposed as 207 | * enumerable properties, thus if you want to perform more complex operations you can convert to a regular 208 | * JavaScript array with [...g_array.proxy()]. 209 | */ 210 | class GArrayProxy { 211 | [Symbol.iterator](): IteratorObject>; 212 | /** 213 | * Gets the length of the array. This is a number one higher than the highest index in the array. 214 | */ 215 | get length(): number; 216 | /** 217 | * Removes the last element from an array and returns it. 218 | * If the array is empty, undefined is returned and the array is not modified. 219 | */ 220 | pop(): T | undefined; 221 | /** 222 | * Appends new elements to the end of an array, and returns the new length of the array. 223 | * @param items New elements to add to the array. 224 | */ 225 | push(...items: Array>): number; 226 | /** 227 | * Returns the index of the first occurrence of a value in an array, or -1 if it is not present. 228 | * @param searchElement The value to locate in the array. 229 | * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. 230 | */ 231 | indexOf(searchElement: T, fromIndex?: number): number; 232 | /** 233 | * Determines whether an array includes a certain element, returning true or false as appropriate. 234 | * @param searchElement The element to search for. 235 | */ 236 | includes(searchElement: T): boolean; 237 | toJSON(key?: any): any; 238 | toString(): string; 239 | [n: number]: T | GProxyValueWrap; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826 240 | } 241 | 242 | // Ideally this would be a class, but TS currently doesn't provide a way to type a class with mapped properties. 243 | /** 244 | * GObject entries are exposed as enumerable properties, so Object.keys(), Object.entries() etc. will work. 245 | */ 246 | type GDictionaryProxy = { 247 | [K in keyof T & string]: T[K] | GProxyValueWrap; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826 248 | } & ('toString' extends keyof T ? {} : { 249 | toString(): string; 250 | }); 251 | 252 | type GProxyValueWrap = V extends GArray 253 | ? GArrayProxy 254 | : V extends GDictionary 255 | ? GDictionaryProxy 256 | : V; 257 | } 258 | -------------------------------------------------------------------------------- /apps/template-ref/typings/godot.worker.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare module "godot.worker" { 3 | import { Object as GDObject } from "godot"; 4 | 5 | class JSWorker { 6 | constructor(path: string); 7 | 8 | postMessage(message: any): void; 9 | terminate(): void; 10 | 11 | onready?: () => void; 12 | onmessage?: (message: any) => void; 13 | 14 | //TODO not implemented yet 15 | onerror?: (error: any) => void; 16 | 17 | ontransfer?: (obj: GDObject) => void; 18 | } 19 | 20 | // only available in worker scripts 21 | const JSWorkerParent: { 22 | onmessage?: (message: any) => void, 23 | 24 | close(): void, 25 | 26 | transfer(obj: GDObject): void, 27 | 28 | postMessage(message: any): void, 29 | 30 | } | undefined; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /apps/template-ref/typings/jsb.editor.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "jsb.editor.codegen" { 2 | import * as jsb from "godot-jsb"; 3 | export class TypeDB { 4 | singletons: { 5 | [name: string]: jsb.editor.SingletonInfo; 6 | }; 7 | classes: { 8 | [name: string]: jsb.editor.ClassInfo; 9 | }; 10 | primitive_types: { 11 | [name: string]: jsb.editor.PrimitiveClassInfo; 12 | }; 13 | primitive_type_names: { 14 | [type: number]: string; 15 | }; 16 | globals: { 17 | [name: string]: jsb.editor.GlobalConstantInfo; 18 | }; 19 | utilities: { 20 | [name: string]: jsb.editor.MethodBind; 21 | }; 22 | class_docs: { 23 | [name: string]: jsb.editor.ClassDoc | false; 24 | }; 25 | constructor(); 26 | find_doc(class_name: string): jsb.editor.ClassDoc | undefined; 27 | is_primitive_type(name: string): boolean; 28 | is_valid_method_name(name: string): boolean; 29 | make_classname(class_name: string, used_as_input: boolean): string; 30 | make_typename(info: jsb.editor.PropertyInfo, used_as_input: boolean): string; 31 | make_arg(info: jsb.editor.PropertyInfo, type_replacer?: (name: string) => string): string; 32 | make_literal_value(value: jsb.editor.DefaultArgumentInfo): string; 33 | replace_type_inplace(name: string | undefined, type_replacer?: (name: string) => string): string; 34 | make_arg_default_value(method_info: jsb.editor.MethodBind, index: number, type_replacer?: (name: string) => string): string; 35 | make_args(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 36 | make_return(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 37 | make_signal_type(method_info: jsb.editor.MethodBind): string; 38 | } 39 | export class TSDCodeGen { 40 | private _split_index; 41 | private _outDir; 42 | private _splitter; 43 | private _types; 44 | constructor(outDir: string); 45 | private make_path; 46 | private new_splitter; 47 | private split; 48 | private cleanup; 49 | has_class(name?: string): boolean; 50 | emit(): Promise; 51 | private emit_utility; 52 | private emit_global; 53 | private emit_mock; 54 | private emit_singleton; 55 | private emit_godot_primitive; 56 | private emit_godot_class; 57 | } 58 | export class SceneTSDCodeGen { 59 | private _out_dir; 60 | private _scene_paths; 61 | private _types; 62 | constructor(out_dir: string, scene_paths: string[]); 63 | private make_path; 64 | emit(): Promise; 65 | private emit_children_node_types; 66 | private emit_scene_node_types; 67 | } 68 | } 69 | declare module "jsb.editor.main" { 70 | import { PackedStringArray } from "godot"; 71 | export function auto_complete(pattern: string): PackedStringArray; 72 | export function run_npm_install(): void; 73 | } 74 | -------------------------------------------------------------------------------- /apps/template-ref/typings/jsb.runtime.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "godot.annotations" { 2 | import { PropertyHint, PropertyUsageFlags, Variant, MultiplayerAPI, MultiplayerPeer } from "godot"; 3 | import * as jsb from "godot-jsb"; 4 | export interface EnumPlaceholder { 5 | } 6 | export interface TypePairPlaceholder { 7 | } 8 | export function EnumType(type: any): EnumPlaceholder; 9 | export function TypePair(key: ClassDescriptor, value: ClassDescriptor): TypePairPlaceholder; 10 | export type ClassDescriptor = Function | Symbol | EnumPlaceholder | TypePairPlaceholder; 11 | /** 12 | * 13 | */ 14 | export function signal(): (target: any, key: string) => void; 15 | export function export_multiline(): (target: any, key: string) => void; 16 | export function export_range(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 17 | export function export_range_i(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 18 | /** String as a path to a file, custom filter provided as hint. */ 19 | export function export_file(filter: string): (target: any, key: string) => void; 20 | export function export_dir(filter: string): (target: any, key: string) => void; 21 | export function export_global_file(filter: string): (target: any, key: string) => void; 22 | export function export_global_dir(filter: string): (target: any, key: string) => void; 23 | export function export_exp_easing(hint?: "" | "attenuation" | "positive_only" | "attenuation,positive_only"): (target: any, key: string) => void; 24 | /** 25 | * A Shortcut for `export_(Variant.Type.TYPE_ARRAY, { class_: clazz })` 26 | */ 27 | export function export_array(clazz: ClassDescriptor): (target: any, key: string) => void; 28 | /** 29 | * A Shortcut for `export_(Variant.Type.TYPE_DICTIONARY, { class_: [key_class, value_class] })` 30 | */ 31 | export function export_dictionary(key_class: ClassDescriptor, value_class: ClassDescriptor): (target: any, key: string) => void; 32 | export function export_object(class_: ClassDescriptor): (target: any, key: string) => void; 33 | /** 34 | * [low level export] 35 | */ 36 | export function export_(type: Variant.Type, details?: { 37 | class_?: ClassDescriptor; 38 | hint?: PropertyHint; 39 | hint_string?: string; 40 | usage?: PropertyUsageFlags; 41 | }): (target: any, key: string) => void; 42 | /** 43 | * In Godot, class members can be exported. 44 | * This means their value gets saved along with the resource (such as the scene) they're attached to. 45 | * They will also be available for editing in the property editor. 46 | * Exporting is done by using the `@export_var` (or `@export_`) annotation. 47 | */ 48 | export function export_var(type: Variant.Type, details?: { 49 | class_?: ClassDescriptor; 50 | hint?: PropertyHint; 51 | hint_string?: string; 52 | usage?: PropertyUsageFlags; 53 | }): (target: any, key: string) => void; 54 | /** 55 | * NOTE only int value enums are allowed 56 | */ 57 | export function export_enum(enum_type: any): (target: any, key: string) => void; 58 | /** 59 | * NOTE only int value enums are allowed 60 | */ 61 | export function export_flags(enum_type: any): (target: any, key: string) => void; 62 | export interface RPCConfig { 63 | mode?: MultiplayerAPI.RPCMode; 64 | sync?: "call_remote" | "call_local"; 65 | transfer_mode?: MultiplayerPeer.TransferMode; 66 | transfer_channel?: number; 67 | } 68 | export function rpc(config?: RPCConfig): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 69 | /** 70 | * auto initialized on ready (before _ready called) 71 | * @param evaluator for now, only string is accepted 72 | */ 73 | export function onready(evaluator: string | jsb.internal.OnReadyEvaluatorFunc): (target: any, key: string) => void; 74 | export function tool(): (target: any) => void; 75 | export function icon(path: string): (target: any) => void; 76 | export function deprecated(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 77 | export function experimental(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 78 | export function help(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 79 | } 80 | declare module "godot.typeloader" { 81 | /** 82 | * @param type the loaded type or function in godot module 83 | */ 84 | export type TypeLoadedCallback = (type: any) => void; 85 | export function on_type_loaded(type_name: string | string[], callback: TypeLoadedCallback): void; 86 | } 87 | declare module "jsb.core" { } 88 | declare const ProxyTarget: unique symbol; 89 | declare const proxy_unwrap: (value: any) => any; 90 | declare const proxyable_prototypes: any[]; 91 | declare const proxy_wrap: (value: any) => any; 92 | -------------------------------------------------------------------------------- /apps/template-ref/vue/.gdignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/apps/template-ref/vue/.gdignore -------------------------------------------------------------------------------- /apps/template-ref/vue/src/.gdignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/apps/template-ref/vue/src/.gdignore -------------------------------------------------------------------------------- /apps/template-ref/vue/src/Test.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 23 | -------------------------------------------------------------------------------- /apps/template-ref/vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from '@vue-godot/runtime-tscn' 2 | import { Control } from 'godot' 3 | import Test from './Test.vue' 4 | 5 | export default class App extends Control { 6 | _ready() { 7 | const app = createApp(Test) 8 | app.mount(this) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /apps/template-ref/vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import vue from '@vitejs/plugin-vue' 2 | import { defineConfig } from 'vite' 3 | 4 | export default defineConfig({ 5 | plugins: [ 6 | vue({ 7 | template: { 8 | compilerOptions: { 9 | // treat all tags with uppercase letters as custom elements 10 | isCustomElement: (tag) => tag[0] === tag[0].toUpperCase(), 11 | }, 12 | }, 13 | }), 14 | ], 15 | define: { 16 | 'process.env': {}, 17 | }, 18 | resolve: { 19 | // `vue` → `@vue/runtime-core` so the DOM renderer is tree-shaken 20 | alias: { vue: '@vue/runtime-core' }, 21 | }, 22 | build: { 23 | lib: { 24 | entry: 'vue/src/main.ts', 25 | formats: ['cjs'], 26 | fileName: () => 'app.js', 27 | }, 28 | // everything provided by the engine/runtime stays external 29 | rollupOptions: { 30 | external: ['godot'], 31 | output: { 32 | exports: 'named', 33 | }, 34 | }, 35 | target: 'es2020', 36 | minify: false, 37 | }, 38 | }) 39 | -------------------------------------------------------------------------------- /apps/v-model/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | -------------------------------------------------------------------------------- /apps/v-model/.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize EOL for all files that Git considers text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /apps/v-model/.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | .godot/ 3 | /android/ 4 | -------------------------------------------------------------------------------- /apps/v-model/app.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://75hgd8tc3add"] 2 | 3 | [ext_resource type="Script" uid="uid://csn1utf25clgd" 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/v-model/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/v-model/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/v-model/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vue-godot/example-v-model", 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/v-model/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="v-model demo" 14 | run/main_scene="uid://75hgd8tc3add" 15 | config/features=PackedStringArray("4.4", "Forward Plus") 16 | config/icon="res://icon.svg" 17 | -------------------------------------------------------------------------------- /apps/v-model/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/v-model/typings/.gdignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /apps/v-model/typings/app.nodes.gen.d.ts: -------------------------------------------------------------------------------- 1 | declare module "godot" { 2 | interface SceneNodes { 3 | "app.tscn": {}, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /apps/v-model/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/v-model/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 = (keyof Map & string) | { 192 | [K in keyof Map & string]: Map[K] extends Node 193 | ? `${K}/${StaticNodePath}` 194 | : never 195 | }[keyof Map & string]; 196 | 197 | type ResolveNodePath = Path extends keyof Map 198 | ? Map[Path] 199 | : Path extends `${infer Key extends keyof Map & string}/${infer SubPath}` 200 | ? Map[Key] extends Node 201 | ? ResolveNodePath 202 | : Default 203 | : Default; 204 | 205 | /** 206 | * GArray elements are exposed with a subset of JavaScript's standard Array API. Array indexes are exposed as 207 | * enumerable properties, thus if you want to perform more complex operations you can convert to a regular 208 | * JavaScript array with [...g_array.proxy()]. 209 | */ 210 | class GArrayProxy { 211 | [Symbol.iterator](): IteratorObject>; 212 | /** 213 | * Gets the length of the array. This is a number one higher than the highest index in the array. 214 | */ 215 | get length(): number; 216 | /** 217 | * Removes the last element from an array and returns it. 218 | * If the array is empty, undefined is returned and the array is not modified. 219 | */ 220 | pop(): T | undefined; 221 | /** 222 | * Appends new elements to the end of an array, and returns the new length of the array. 223 | * @param items New elements to add to the array. 224 | */ 225 | push(...items: Array>): number; 226 | /** 227 | * Returns the index of the first occurrence of a value in an array, or -1 if it is not present. 228 | * @param searchElement The value to locate in the array. 229 | * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. 230 | */ 231 | indexOf(searchElement: T, fromIndex?: number): number; 232 | /** 233 | * Determines whether an array includes a certain element, returning true or false as appropriate. 234 | * @param searchElement The element to search for. 235 | */ 236 | includes(searchElement: T): boolean; 237 | toJSON(key?: any): any; 238 | toString(): string; 239 | [n: number]: T | GProxyValueWrap; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826 240 | } 241 | 242 | // Ideally this would be a class, but TS currently doesn't provide a way to type a class with mapped properties. 243 | /** 244 | * GObject entries are exposed as enumerable properties, so Object.keys(), Object.entries() etc. will work. 245 | */ 246 | type GDictionaryProxy = { 247 | [K in keyof T & string]: T[K] | GProxyValueWrap; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826 248 | } & ('toString' extends keyof T ? {} : { 249 | toString(): string; 250 | }); 251 | 252 | type GProxyValueWrap = V extends GArray 253 | ? GArrayProxy 254 | : V extends GDictionary 255 | ? GDictionaryProxy 256 | : V; 257 | } 258 | -------------------------------------------------------------------------------- /apps/v-model/typings/godot.worker.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare module "godot.worker" { 3 | import { Object as GDObject } from "godot"; 4 | 5 | class JSWorker { 6 | constructor(path: string); 7 | 8 | postMessage(message: any): void; 9 | terminate(): void; 10 | 11 | onready?: () => void; 12 | onmessage?: (message: any) => void; 13 | 14 | //TODO not implemented yet 15 | onerror?: (error: any) => void; 16 | 17 | ontransfer?: (obj: GDObject) => void; 18 | } 19 | 20 | // only available in worker scripts 21 | const JSWorkerParent: { 22 | onmessage?: (message: any) => void, 23 | 24 | close(): void, 25 | 26 | transfer(obj: GDObject): void, 27 | 28 | postMessage(message: any): void, 29 | 30 | } | undefined; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /apps/v-model/typings/jsb.editor.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "jsb.editor.codegen" { 2 | import * as jsb from "godot-jsb"; 3 | export class TypeDB { 4 | singletons: { 5 | [name: string]: jsb.editor.SingletonInfo; 6 | }; 7 | classes: { 8 | [name: string]: jsb.editor.ClassInfo; 9 | }; 10 | primitive_types: { 11 | [name: string]: jsb.editor.PrimitiveClassInfo; 12 | }; 13 | primitive_type_names: { 14 | [type: number]: string; 15 | }; 16 | globals: { 17 | [name: string]: jsb.editor.GlobalConstantInfo; 18 | }; 19 | utilities: { 20 | [name: string]: jsb.editor.MethodBind; 21 | }; 22 | class_docs: { 23 | [name: string]: jsb.editor.ClassDoc | false; 24 | }; 25 | constructor(); 26 | find_doc(class_name: string): jsb.editor.ClassDoc | undefined; 27 | is_primitive_type(name: string): boolean; 28 | is_valid_method_name(name: string): boolean; 29 | make_classname(class_name: string, used_as_input: boolean): string; 30 | make_typename(info: jsb.editor.PropertyInfo, used_as_input: boolean): string; 31 | make_arg(info: jsb.editor.PropertyInfo, type_replacer?: (name: string) => string): string; 32 | make_literal_value(value: jsb.editor.DefaultArgumentInfo): string; 33 | replace_type_inplace(name: string | undefined, type_replacer?: (name: string) => string): string; 34 | make_arg_default_value(method_info: jsb.editor.MethodBind, index: number, type_replacer?: (name: string) => string): string; 35 | make_args(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 36 | make_return(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 37 | make_signal_type(method_info: jsb.editor.MethodBind): string; 38 | } 39 | export class TSDCodeGen { 40 | private _split_index; 41 | private _outDir; 42 | private _splitter; 43 | private _types; 44 | constructor(outDir: string); 45 | private make_path; 46 | private new_splitter; 47 | private split; 48 | private cleanup; 49 | has_class(name?: string): boolean; 50 | emit(): Promise; 51 | private emit_utility; 52 | private emit_global; 53 | private emit_mock; 54 | private emit_singleton; 55 | private emit_godot_primitive; 56 | private emit_godot_class; 57 | } 58 | export class SceneTSDCodeGen { 59 | private _out_dir; 60 | private _scene_paths; 61 | private _types; 62 | constructor(out_dir: string, scene_paths: string[]); 63 | private make_path; 64 | emit(): Promise; 65 | private emit_children_node_types; 66 | private emit_scene_node_types; 67 | } 68 | } 69 | declare module "jsb.editor.main" { 70 | import { PackedStringArray } from "godot"; 71 | export function auto_complete(pattern: string): PackedStringArray; 72 | export function run_npm_install(): void; 73 | } 74 | -------------------------------------------------------------------------------- /apps/v-model/typings/jsb.runtime.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "godot.annotations" { 2 | import { PropertyHint, PropertyUsageFlags, Variant, MultiplayerAPI, MultiplayerPeer } from "godot"; 3 | import * as jsb from "godot-jsb"; 4 | export interface EnumPlaceholder { 5 | } 6 | export interface TypePairPlaceholder { 7 | } 8 | export function EnumType(type: any): EnumPlaceholder; 9 | export function TypePair(key: ClassDescriptor, value: ClassDescriptor): TypePairPlaceholder; 10 | export type ClassDescriptor = Function | Symbol | EnumPlaceholder | TypePairPlaceholder; 11 | /** 12 | * 13 | */ 14 | export function signal(): (target: any, key: string) => void; 15 | export function export_multiline(): (target: any, key: string) => void; 16 | export function export_range(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 17 | export function export_range_i(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 18 | /** String as a path to a file, custom filter provided as hint. */ 19 | export function export_file(filter: string): (target: any, key: string) => void; 20 | export function export_dir(filter: string): (target: any, key: string) => void; 21 | export function export_global_file(filter: string): (target: any, key: string) => void; 22 | export function export_global_dir(filter: string): (target: any, key: string) => void; 23 | export function export_exp_easing(hint?: "" | "attenuation" | "positive_only" | "attenuation,positive_only"): (target: any, key: string) => void; 24 | /** 25 | * A Shortcut for `export_(Variant.Type.TYPE_ARRAY, { class_: clazz })` 26 | */ 27 | export function export_array(clazz: ClassDescriptor): (target: any, key: string) => void; 28 | /** 29 | * A Shortcut for `export_(Variant.Type.TYPE_DICTIONARY, { class_: [key_class, value_class] })` 30 | */ 31 | export function export_dictionary(key_class: ClassDescriptor, value_class: ClassDescriptor): (target: any, key: string) => void; 32 | export function export_object(class_: ClassDescriptor): (target: any, key: string) => void; 33 | /** 34 | * [low level export] 35 | */ 36 | export function export_(type: Variant.Type, details?: { 37 | class_?: ClassDescriptor; 38 | hint?: PropertyHint; 39 | hint_string?: string; 40 | usage?: PropertyUsageFlags; 41 | }): (target: any, key: string) => void; 42 | /** 43 | * In Godot, class members can be exported. 44 | * This means their value gets saved along with the resource (such as the scene) they're attached to. 45 | * They will also be available for editing in the property editor. 46 | * Exporting is done by using the `@export_var` (or `@export_`) annotation. 47 | */ 48 | export function export_var(type: Variant.Type, details?: { 49 | class_?: ClassDescriptor; 50 | hint?: PropertyHint; 51 | hint_string?: string; 52 | usage?: PropertyUsageFlags; 53 | }): (target: any, key: string) => void; 54 | /** 55 | * NOTE only int value enums are allowed 56 | */ 57 | export function export_enum(enum_type: any): (target: any, key: string) => void; 58 | /** 59 | * NOTE only int value enums are allowed 60 | */ 61 | export function export_flags(enum_type: any): (target: any, key: string) => void; 62 | export interface RPCConfig { 63 | mode?: MultiplayerAPI.RPCMode; 64 | sync?: "call_remote" | "call_local"; 65 | transfer_mode?: MultiplayerPeer.TransferMode; 66 | transfer_channel?: number; 67 | } 68 | export function rpc(config?: RPCConfig): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 69 | /** 70 | * auto initialized on ready (before _ready called) 71 | * @param evaluator for now, only string is accepted 72 | */ 73 | export function onready(evaluator: string | jsb.internal.OnReadyEvaluatorFunc): (target: any, key: string) => void; 74 | export function tool(): (target: any) => void; 75 | export function icon(path: string): (target: any) => void; 76 | export function deprecated(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 77 | export function experimental(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 78 | export function help(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 79 | } 80 | declare module "godot.typeloader" { 81 | /** 82 | * @param type the loaded type or function in godot module 83 | */ 84 | export type TypeLoadedCallback = (type: any) => void; 85 | export function on_type_loaded(type_name: string | string[], callback: TypeLoadedCallback): void; 86 | } 87 | declare module "jsb.core" { } 88 | declare const ProxyTarget: unique symbol; 89 | declare const proxy_unwrap: (value: any) => any; 90 | declare const proxyable_prototypes: any[]; 91 | declare const proxy_wrap: (value: any) => any; 92 | -------------------------------------------------------------------------------- /apps/v-model/vue/.gdignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/apps/v-model/vue/.gdignore -------------------------------------------------------------------------------- /apps/v-model/vue/src/.gdignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/apps/v-model/vue/src/.gdignore -------------------------------------------------------------------------------- /apps/v-model/vue/src/Test.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | -------------------------------------------------------------------------------- /apps/v-model/vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from '@vue-godot/runtime-tscn' 2 | import { Control } from 'godot' 3 | import Test from './Test.vue' 4 | 5 | export default class App extends Control { 6 | _ready() { 7 | const app = createApp(Test) 8 | app.mount(this) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /apps/v-model/vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import vue from '@vitejs/plugin-vue' 2 | import { defineConfig } from 'vite' 3 | 4 | export default defineConfig({ 5 | plugins: [ 6 | vue({ 7 | template: { 8 | compilerOptions: { 9 | // treat all tags with uppercase letters as custom elements 10 | isCustomElement: (tag) => tag[0] === tag[0].toUpperCase(), 11 | }, 12 | }, 13 | }), 14 | ], 15 | define: { 16 | 'process.env': {}, 17 | }, 18 | resolve: { 19 | // `vue` → `@vue/runtime-core` so the DOM renderer is tree-shaken 20 | alias: { vue: '@vue/runtime-core' }, 21 | }, 22 | build: { 23 | lib: { 24 | entry: 'vue/src/main.ts', 25 | formats: ['cjs'], 26 | fileName: () => 'app.js', 27 | }, 28 | // everything provided by the engine/runtime stays external 29 | rollupOptions: { 30 | external: ['godot'], 31 | output: { 32 | exports: 'named', 33 | }, 34 | }, 35 | target: 'es2020', 36 | }, 37 | }) 38 | -------------------------------------------------------------------------------- /apps/v-on/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | -------------------------------------------------------------------------------- /apps/v-on/.gitattributes: -------------------------------------------------------------------------------- 1 | # Normalize EOL for all files that Git considers text files. 2 | * text=auto eol=lf 3 | -------------------------------------------------------------------------------- /apps/v-on/.gitignore: -------------------------------------------------------------------------------- 1 | # Godot 4+ specific ignores 2 | .godot/ 3 | /android/ 4 | -------------------------------------------------------------------------------- /apps/v-on/app.tscn: -------------------------------------------------------------------------------- 1 | [gd_scene load_steps=2 format=3 uid="uid://75hgd8tc3add"] 2 | 3 | [ext_resource type="Script" uid="uid://jymebxopj7tu" 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/v-on/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /apps/v-on/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/v-on/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vue-godot/example-v-on", 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/v-on/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="v-on demo" 14 | run/main_scene="uid://75hgd8tc3add" 15 | config/features=PackedStringArray("4.4", "Forward Plus") 16 | config/icon="res://icon.svg" 17 | -------------------------------------------------------------------------------- /apps/v-on/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/v-on/typings/.gdignore: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /apps/v-on/typings/app.nodes.gen.d.ts: -------------------------------------------------------------------------------- 1 | declare module "godot" { 2 | interface SceneNodes { 3 | "app.tscn": {}, 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /apps/v-on/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/v-on/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 = (keyof Map & string) | { 192 | [K in keyof Map & string]: Map[K] extends Node 193 | ? `${K}/${StaticNodePath}` 194 | : never 195 | }[keyof Map & string]; 196 | 197 | type ResolveNodePath = Path extends keyof Map 198 | ? Map[Path] 199 | : Path extends `${infer Key extends keyof Map & string}/${infer SubPath}` 200 | ? Map[Key] extends Node 201 | ? ResolveNodePath 202 | : Default 203 | : Default; 204 | 205 | /** 206 | * GArray elements are exposed with a subset of JavaScript's standard Array API. Array indexes are exposed as 207 | * enumerable properties, thus if you want to perform more complex operations you can convert to a regular 208 | * JavaScript array with [...g_array.proxy()]. 209 | */ 210 | class GArrayProxy { 211 | [Symbol.iterator](): IteratorObject>; 212 | /** 213 | * Gets the length of the array. This is a number one higher than the highest index in the array. 214 | */ 215 | get length(): number; 216 | /** 217 | * Removes the last element from an array and returns it. 218 | * If the array is empty, undefined is returned and the array is not modified. 219 | */ 220 | pop(): T | undefined; 221 | /** 222 | * Appends new elements to the end of an array, and returns the new length of the array. 223 | * @param items New elements to add to the array. 224 | */ 225 | push(...items: Array>): number; 226 | /** 227 | * Returns the index of the first occurrence of a value in an array, or -1 if it is not present. 228 | * @param searchElement The value to locate in the array. 229 | * @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0. 230 | */ 231 | indexOf(searchElement: T, fromIndex?: number): number; 232 | /** 233 | * Determines whether an array includes a certain element, returning true or false as appropriate. 234 | * @param searchElement The element to search for. 235 | */ 236 | includes(searchElement: T): boolean; 237 | toJSON(key?: any): any; 238 | toString(): string; 239 | [n: number]: T | GProxyValueWrap; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826 240 | } 241 | 242 | // Ideally this would be a class, but TS currently doesn't provide a way to type a class with mapped properties. 243 | /** 244 | * GObject entries are exposed as enumerable properties, so Object.keys(), Object.entries() etc. will work. 245 | */ 246 | type GDictionaryProxy = { 247 | [K in keyof T & string]: T[K] | GProxyValueWrap; // More accurate get type blocked by https://github.com/microsoft/TypeScript/issues/43826 248 | } & ('toString' extends keyof T ? {} : { 249 | toString(): string; 250 | }); 251 | 252 | type GProxyValueWrap = V extends GArray 253 | ? GArrayProxy 254 | : V extends GDictionary 255 | ? GDictionaryProxy 256 | : V; 257 | } 258 | -------------------------------------------------------------------------------- /apps/v-on/typings/godot.worker.d.ts: -------------------------------------------------------------------------------- 1 | 2 | declare module "godot.worker" { 3 | import { Object as GDObject } from "godot"; 4 | 5 | class JSWorker { 6 | constructor(path: string); 7 | 8 | postMessage(message: any): void; 9 | terminate(): void; 10 | 11 | onready?: () => void; 12 | onmessage?: (message: any) => void; 13 | 14 | //TODO not implemented yet 15 | onerror?: (error: any) => void; 16 | 17 | ontransfer?: (obj: GDObject) => void; 18 | } 19 | 20 | // only available in worker scripts 21 | const JSWorkerParent: { 22 | onmessage?: (message: any) => void, 23 | 24 | close(): void, 25 | 26 | transfer(obj: GDObject): void, 27 | 28 | postMessage(message: any): void, 29 | 30 | } | undefined; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /apps/v-on/typings/jsb.editor.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "jsb.editor.codegen" { 2 | import * as jsb from "godot-jsb"; 3 | export class TypeDB { 4 | singletons: { 5 | [name: string]: jsb.editor.SingletonInfo; 6 | }; 7 | classes: { 8 | [name: string]: jsb.editor.ClassInfo; 9 | }; 10 | primitive_types: { 11 | [name: string]: jsb.editor.PrimitiveClassInfo; 12 | }; 13 | primitive_type_names: { 14 | [type: number]: string; 15 | }; 16 | globals: { 17 | [name: string]: jsb.editor.GlobalConstantInfo; 18 | }; 19 | utilities: { 20 | [name: string]: jsb.editor.MethodBind; 21 | }; 22 | class_docs: { 23 | [name: string]: jsb.editor.ClassDoc | false; 24 | }; 25 | constructor(); 26 | find_doc(class_name: string): jsb.editor.ClassDoc | undefined; 27 | is_primitive_type(name: string): boolean; 28 | is_valid_method_name(name: string): boolean; 29 | make_classname(class_name: string, used_as_input: boolean): string; 30 | make_typename(info: jsb.editor.PropertyInfo, used_as_input: boolean): string; 31 | make_arg(info: jsb.editor.PropertyInfo, type_replacer?: (name: string) => string): string; 32 | make_literal_value(value: jsb.editor.DefaultArgumentInfo): string; 33 | replace_type_inplace(name: string | undefined, type_replacer?: (name: string) => string): string; 34 | make_arg_default_value(method_info: jsb.editor.MethodBind, index: number, type_replacer?: (name: string) => string): string; 35 | make_args(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 36 | make_return(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 37 | make_signal_type(method_info: jsb.editor.MethodBind): string; 38 | } 39 | export class TSDCodeGen { 40 | private _split_index; 41 | private _outDir; 42 | private _splitter; 43 | private _types; 44 | constructor(outDir: string); 45 | private make_path; 46 | private new_splitter; 47 | private split; 48 | private cleanup; 49 | has_class(name?: string): boolean; 50 | emit(): Promise; 51 | private emit_utility; 52 | private emit_global; 53 | private emit_mock; 54 | private emit_singleton; 55 | private emit_godot_primitive; 56 | private emit_godot_class; 57 | } 58 | export class SceneTSDCodeGen { 59 | private _out_dir; 60 | private _scene_paths; 61 | private _types; 62 | constructor(out_dir: string, scene_paths: string[]); 63 | private make_path; 64 | emit(): Promise; 65 | private emit_children_node_types; 66 | private emit_scene_node_types; 67 | } 68 | } 69 | declare module "jsb.editor.main" { 70 | import { PackedStringArray } from "godot"; 71 | export function auto_complete(pattern: string): PackedStringArray; 72 | export function run_npm_install(): void; 73 | } 74 | -------------------------------------------------------------------------------- /apps/v-on/typings/jsb.runtime.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "godot.annotations" { 2 | import { PropertyHint, PropertyUsageFlags, Variant, MultiplayerAPI, MultiplayerPeer } from "godot"; 3 | import * as jsb from "godot-jsb"; 4 | export interface EnumPlaceholder { 5 | } 6 | export interface TypePairPlaceholder { 7 | } 8 | export function EnumType(type: any): EnumPlaceholder; 9 | export function TypePair(key: ClassDescriptor, value: ClassDescriptor): TypePairPlaceholder; 10 | export type ClassDescriptor = Function | Symbol | EnumPlaceholder | TypePairPlaceholder; 11 | /** 12 | * 13 | */ 14 | export function signal(): (target: any, key: string) => void; 15 | export function export_multiline(): (target: any, key: string) => void; 16 | export function export_range(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 17 | export function export_range_i(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 18 | /** String as a path to a file, custom filter provided as hint. */ 19 | export function export_file(filter: string): (target: any, key: string) => void; 20 | export function export_dir(filter: string): (target: any, key: string) => void; 21 | export function export_global_file(filter: string): (target: any, key: string) => void; 22 | export function export_global_dir(filter: string): (target: any, key: string) => void; 23 | export function export_exp_easing(hint?: "" | "attenuation" | "positive_only" | "attenuation,positive_only"): (target: any, key: string) => void; 24 | /** 25 | * A Shortcut for `export_(Variant.Type.TYPE_ARRAY, { class_: clazz })` 26 | */ 27 | export function export_array(clazz: ClassDescriptor): (target: any, key: string) => void; 28 | /** 29 | * A Shortcut for `export_(Variant.Type.TYPE_DICTIONARY, { class_: [key_class, value_class] })` 30 | */ 31 | export function export_dictionary(key_class: ClassDescriptor, value_class: ClassDescriptor): (target: any, key: string) => void; 32 | export function export_object(class_: ClassDescriptor): (target: any, key: string) => void; 33 | /** 34 | * [low level export] 35 | */ 36 | export function export_(type: Variant.Type, details?: { 37 | class_?: ClassDescriptor; 38 | hint?: PropertyHint; 39 | hint_string?: string; 40 | usage?: PropertyUsageFlags; 41 | }): (target: any, key: string) => void; 42 | /** 43 | * In Godot, class members can be exported. 44 | * This means their value gets saved along with the resource (such as the scene) they're attached to. 45 | * They will also be available for editing in the property editor. 46 | * Exporting is done by using the `@export_var` (or `@export_`) annotation. 47 | */ 48 | export function export_var(type: Variant.Type, details?: { 49 | class_?: ClassDescriptor; 50 | hint?: PropertyHint; 51 | hint_string?: string; 52 | usage?: PropertyUsageFlags; 53 | }): (target: any, key: string) => void; 54 | /** 55 | * NOTE only int value enums are allowed 56 | */ 57 | export function export_enum(enum_type: any): (target: any, key: string) => void; 58 | /** 59 | * NOTE only int value enums are allowed 60 | */ 61 | export function export_flags(enum_type: any): (target: any, key: string) => void; 62 | export interface RPCConfig { 63 | mode?: MultiplayerAPI.RPCMode; 64 | sync?: "call_remote" | "call_local"; 65 | transfer_mode?: MultiplayerPeer.TransferMode; 66 | transfer_channel?: number; 67 | } 68 | export function rpc(config?: RPCConfig): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 69 | /** 70 | * auto initialized on ready (before _ready called) 71 | * @param evaluator for now, only string is accepted 72 | */ 73 | export function onready(evaluator: string | jsb.internal.OnReadyEvaluatorFunc): (target: any, key: string) => void; 74 | export function tool(): (target: any) => void; 75 | export function icon(path: string): (target: any) => void; 76 | export function deprecated(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 77 | export function experimental(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 78 | export function help(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 79 | } 80 | declare module "godot.typeloader" { 81 | /** 82 | * @param type the loaded type or function in godot module 83 | */ 84 | export type TypeLoadedCallback = (type: any) => void; 85 | export function on_type_loaded(type_name: string | string[], callback: TypeLoadedCallback): void; 86 | } 87 | declare module "jsb.core" { } 88 | declare const ProxyTarget: unique symbol; 89 | declare const proxy_unwrap: (value: any) => any; 90 | declare const proxyable_prototypes: any[]; 91 | declare const proxy_wrap: (value: any) => any; 92 | -------------------------------------------------------------------------------- /apps/v-on/vue/.gdignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/apps/v-on/vue/.gdignore -------------------------------------------------------------------------------- /apps/v-on/vue/src/.gdignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/apps/v-on/vue/src/.gdignore -------------------------------------------------------------------------------- /apps/v-on/vue/src/Test.vue: -------------------------------------------------------------------------------- 1 | 7 | 8 | -------------------------------------------------------------------------------- /apps/v-on/vue/src/main.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from '@vue-godot/runtime-tscn' 2 | import { Control } from 'godot' 3 | import Test from './Test.vue' 4 | 5 | export default class App extends Control { 6 | _ready() { 7 | const app = createApp(Test) 8 | app.mount(this) 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /apps/v-on/vue/vite.config.ts: -------------------------------------------------------------------------------- 1 | import vue from '@vitejs/plugin-vue' 2 | import { defineConfig } from 'vite' 3 | 4 | export default defineConfig({ 5 | plugins: [ 6 | vue({ 7 | template: { 8 | compilerOptions: { 9 | // treat all tags with uppercase letters as custom elements 10 | isCustomElement: (tag) => tag[0] === tag[0].toUpperCase(), 11 | }, 12 | }, 13 | }), 14 | ], 15 | define: { 16 | 'process.env': {}, 17 | }, 18 | resolve: { 19 | // `vue` → `@vue/runtime-core` so the DOM renderer is tree-shaken 20 | alias: { vue: '@vue/runtime-core' }, 21 | }, 22 | build: { 23 | lib: { 24 | entry: 'vue/src/main.ts', 25 | formats: ['cjs'], 26 | fileName: () => 'app.js', 27 | }, 28 | // everything provided by the engine/runtime stays external 29 | rollupOptions: { 30 | external: ['godot'], 31 | output: { 32 | exports: 'named', 33 | }, 34 | }, 35 | target: 'es2020', 36 | }, 37 | }) 38 | -------------------------------------------------------------------------------- /intro-medias/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/portwatcher/vue-godot/a192052f1dba1f4b87dc47cf8d9a5036d11639ef/intro-medias/demo.gif -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vue-godot", 3 | "scripts": { 4 | "build": "turbo run build", 5 | "build:runtime": "turbo run build --filter=@vue-godot/runtime-tscn", 6 | "build:demo": "turbo run build --filter=\"./apps/*\"" 7 | }, 8 | "repository": { 9 | "type": "git", 10 | "url": "git+https://github.com/portwatcher/vue-godot" 11 | }, 12 | "devDependencies": { 13 | "@types/node": "^22.15.18", 14 | "prettier": "^3.5.3", 15 | "turbo": "^2.4.4", 16 | "typescript": "5.8.2" 17 | }, 18 | "engines": { 19 | "node": ">=18" 20 | }, 21 | "author": { 22 | "name": "portwatcher", 23 | "url": "https://juryquinn.com" 24 | }, 25 | "license": "MIT", 26 | "packageManager": "npm@10.9.0", 27 | "workspaces": [ 28 | "apps/*", 29 | "packages/*" 30 | ] 31 | } 32 | -------------------------------------------------------------------------------- /packages/runtime-tscn/README.md: -------------------------------------------------------------------------------- 1 | # @vue-godot/runtime-tscn 2 | 3 | This package is part of the [Vue Godot](../../README.md) project. 4 | 5 | It provides a Vue runtime renderer for Godot TSCN files. This allows you to use Vue.js to define and manipulate Godot scene tree (TSCN) files programmatically. 6 | 7 | ## Features 8 | 9 | - Render Vue components into Godot scene nodes. 10 | - Manipulate Godot node properties using Vue's reactivity system. 11 | 12 | ## Installation 13 | 14 | ``` 15 | npm install @vue-godot/runtime-tscn 16 | ``` 17 | -------------------------------------------------------------------------------- /packages/runtime-tscn/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@vue-godot/runtime-tscn", 3 | "version": "0.0.1", 4 | "description": "Vue runtime renderer for Godot TSCN files", 5 | "type": "module", 6 | "main": "./dist/index.js", 7 | "module": "./dist/index.js", 8 | "types": "./dist/index.d.ts", 9 | "exports": { 10 | ".": { 11 | "types": "./dist/index.d.ts", 12 | "import": "./dist/index.js", 13 | "default": "./dist/index.js" 14 | } 15 | }, 16 | "files": [ 17 | "dist" 18 | ], 19 | "scripts": { 20 | "build": "npx tsc -p ." 21 | }, 22 | "dependencies": { 23 | "@vue/runtime-core": "^3.3.0", 24 | "@vue/shared": "^3.3.0" 25 | }, 26 | "peerDependencies": { 27 | "vue": "3.3.0" 28 | }, 29 | "keywords": [ 30 | "vue", 31 | "godot", 32 | "tscn", 33 | "renderer" 34 | ], 35 | "author": "Portwatcher", 36 | "license": "MIT", 37 | "devDependencies": { 38 | "@types/node": "^22.13.10", 39 | "ts-node": "^10.9.2", 40 | "typescript": "^5.8.2" 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /packages/runtime-tscn/src/index.ts: -------------------------------------------------------------------------------- 1 | import { createRenderer, RendererOptions } from '@vue/runtime-core' 2 | import { Node } from 'godot' 3 | import { nodeOps } from './nodeOps' 4 | import { patchProp } from './patchProp' 5 | 6 | const ops: RendererOptions = { 7 | ...nodeOps, 8 | patchProp, 9 | } 10 | 11 | export const { createApp } = createRenderer(ops) 12 | -------------------------------------------------------------------------------- /packages/runtime-tscn/src/nodeOps.ts: -------------------------------------------------------------------------------- 1 | import type { RendererOptions } from '@vue/runtime-core' 2 | import { ClassDB, Label, Node } from 'godot' 3 | 4 | export const nodeOps: Omit, 'patchProp'> = { 5 | insert: (child, parent, anchor) => { 6 | if (!parent) { 7 | console.warn('parent node is null') 8 | return 9 | } 10 | 11 | if (anchor) { 12 | child.add_sibling(anchor) 13 | } else { 14 | parent.add_child(child) 15 | } 16 | }, 17 | 18 | remove: (child) => { 19 | const parent = child.get_parent() 20 | if (parent) { 21 | parent.remove_child(child) 22 | } 23 | child.queue_free() 24 | }, 25 | 26 | createElement: (tag, isSVG, isCustomElement, vnodeProps): Node => { 27 | return ClassDB.can_instantiate(tag) ? ClassDB.instantiate(tag) : new Node() 28 | }, 29 | 30 | createText: (text): Node => { 31 | const label = new Label() 32 | label.text = text 33 | return label 34 | }, 35 | 36 | createComment: (text): Node => { 37 | const node = new Node() 38 | node.set_meta('comment', text) 39 | return node 40 | }, 41 | 42 | setText: (node, text) => { 43 | if (node instanceof Label) { 44 | node.text = text 45 | } else { 46 | console.warn("vue-godot doesn't support setText on non-Label nodes") 47 | } 48 | }, 49 | 50 | setElementText: (node, text) => { 51 | if (node instanceof Label) { 52 | node.text = text 53 | } else { 54 | console.warn( 55 | "vue-godot doesn't support setElementText on non-Label nodes", 56 | ) 57 | } 58 | }, 59 | 60 | parentNode: (node) => node.get_parent() || null, 61 | 62 | nextSibling: (node) => { 63 | const index = node.get_index() + 1 64 | if (index >= node.get_parent()?.get_child_count()) { 65 | return null 66 | } 67 | return node.get_parent()?.get_child(index) 68 | }, 69 | 70 | querySelector: (selector) => { 71 | console.warn("vue-godot doesn't support querySelector") 72 | return null 73 | }, 74 | 75 | setScopeId(node, id) { 76 | console.warn("vue-godot doesn't support setScopeId") 77 | }, 78 | 79 | insertStaticContent(content, parent, anchor, isSVG) { 80 | console.warn("vue-godot doesn't support insertStaticContent") 81 | return [new Node(), new Node()] 82 | }, 83 | } 84 | -------------------------------------------------------------------------------- /packages/runtime-tscn/src/patchProp.ts: -------------------------------------------------------------------------------- 1 | import { RendererOptions } from '@vue/runtime-core' 2 | import { Callable, Node } from 'godot' 3 | 4 | type TSCNRendererOptions = RendererOptions 5 | 6 | export const patchProp: TSCNRendererOptions['patchProp'] = function ( 7 | el: Node, 8 | key: string, 9 | prev: any, 10 | next: any, 11 | ) { 12 | if (key.startsWith('on')) { 13 | const signalName = key.slice(2).replace(/^[A-Z]/, (s) => s.toLowerCase()) 14 | const prevHandler = prev as Function | null 15 | const nextHandler = next as Function | null 16 | 17 | // Disconnect previous handler 18 | if (prevHandler && typeof prevHandler === 'function') { 19 | try { 20 | const callableToDisconnect = Callable.create( 21 | el, 22 | prevHandler as (...args: any[]) => any, 23 | ) 24 | el.disconnect(signalName, callableToDisconnect as any) 25 | } catch (e) { 26 | console.warn( 27 | `[vue-godot] Error trying to disconnect signal "${signalName}" on ${ 28 | el.get_path()?.toString() || el.get_name().toString() 29 | }:`, 30 | e, 31 | ) 32 | } 33 | } 34 | 35 | // Connect new handler 36 | if (nextHandler && typeof nextHandler === 'function') { 37 | try { 38 | const callableToConnect = Callable.create( 39 | el, 40 | nextHandler as (...args: any[]) => any, 41 | ) 42 | el.connect(signalName, callableToConnect as any) 43 | } catch (e) { 44 | console.warn( 45 | `[vue-godot] Error trying to connect signal "${signalName}" on ${ 46 | el.get_path()?.toString() || el.get_name().toString() 47 | }:`, 48 | e, 49 | ) 50 | } 51 | } 52 | } else if (el.has_method('set')) { 53 | el.set(key, next) // Universal Godot setter 54 | } else { 55 | console.warn(`object ${el.get_path()} has no method "set"`) 56 | ;(el as any)[key] = next 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /packages/runtime-tscn/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": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ 16 | // "jsx": "preserve", /* Specify what JSX code is generated. */ 17 | "experimentalDecorators": true /* Enable experimental support for legacy experimental decorators. */, 18 | // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ 19 | // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ 20 | // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ 21 | // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ 22 | // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ 23 | // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ 24 | // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ 25 | // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ 26 | 27 | /* Modules */ 28 | "module": "ESNext" /* Specify what module code is generated. */, 29 | "rootDir": "src" /* Specify the root folder within your source files. */, 30 | "moduleResolution": "bundler" /* Specify how TypeScript looks up a file from a given module specifier. */, 31 | // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ 32 | // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ 33 | // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ 34 | "typeRoots": [ 35 | /* Specify multiple folders that act like './node_modules/@types'. */ 36 | "../../node_modules/@types", 37 | "./typings" 38 | ], 39 | "types": [ 40 | "node" 41 | ] /* Specify type package names to be included without being referenced in a source file. */, 42 | // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ 43 | // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ 44 | // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ 45 | // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ 46 | // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ 47 | // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ 48 | // "resolveJsonModule": true, /* Enable importing .json files. */ 49 | // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ 50 | // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ 51 | 52 | /* JavaScript Support */ 53 | // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ 54 | // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ 55 | // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ 56 | 57 | /* Emit */ 58 | "declaration": true /* Generate .d.ts files from TypeScript and JavaScript files in your project. */, 59 | // "declarationMap": true, /* Create sourcemaps for d.ts files. */ 60 | // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ 61 | "sourceMap": true /* Create source map files for emitted JavaScript files. */, 62 | // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ 63 | // "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. */ 64 | "outDir": "dist" /* Specify an output folder for all emitted files. */, 65 | // "removeComments": true, /* Disable emitting comments. */ 66 | // "noEmit": true, /* Disable emitting files from a compilation. */ 67 | // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ 68 | // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ 69 | // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ 70 | // "sourceRoot": "../../../" /* Specify the root path for debuggers to find the reference source code. */, 71 | // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ 72 | // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ 73 | // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ 74 | "newLine": "crlf" /* Set the newline character for emitting files. */, 75 | // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ 76 | // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ 77 | "noEmitOnError": false /* Disable emitting files if any type checking errors are reported. */, 78 | // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ 79 | // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ 80 | // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ 81 | 82 | /* Interop Constraints */ 83 | // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ 84 | // "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. */ 85 | // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ 86 | "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, 87 | // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ 88 | "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, 89 | 90 | /* Type Checking */ 91 | "strict": true /* Enable all strict type-checking options. */, 92 | // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ 93 | // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ 94 | // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ 95 | // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ 96 | // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ 97 | // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ 98 | // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ 99 | // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ 100 | // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ 101 | // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ 102 | // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ 103 | // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ 104 | // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ 105 | // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ 106 | // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ 107 | // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ 108 | // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ 109 | // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ 110 | 111 | /* Completeness */ 112 | // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ 113 | "skipLibCheck": true /* Skip type checking all .d.ts files. */ 114 | }, 115 | "include": ["src/**/*", "typings/**/*"] 116 | } 117 | -------------------------------------------------------------------------------- /packages/runtime-tscn/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 | -------------------------------------------------------------------------------- /packages/runtime-tscn/typings/godot.mix.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | declare module "godot" { 3 | /** A built-in type representing a method or a standalone function. 4 | * 5 | * @link https://docs.godotengine.org/en/4.2/classes/class_callable.html 6 | */ 7 | interface AnyCallable { 8 | /** Returns `true` if this [Callable] has no target to call the method on. */ 9 | is_null(): boolean 10 | 11 | /** 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. */ 12 | is_custom(): boolean 13 | 14 | /** 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. */ 15 | is_standard(): boolean 16 | 17 | /** Returns `true` if the callable's object exists and has a valid method name assigned, or is a custom callable. */ 18 | is_valid(): boolean 19 | 20 | /** Returns the object on which this [Callable] is called. */ 21 | get_object(): Object 22 | 23 | /** Returns the ID of this [Callable]'s object (see [method Object.get_instance_id]). */ 24 | get_object_id(): int64 25 | 26 | /** Returns the name of the method represented by this [Callable]. If the callable is a GDScript lambda function, returns the function's name or `""`. */ 27 | get_method(): StringName 28 | 29 | /** 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. */ 30 | get_bound_arguments_count(): int64 31 | 32 | /** 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). */ 33 | get_bound_arguments(): Array 34 | 35 | /** Returns the 32-bit hash value of this [Callable]'s object. 36 | * 37 | * **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]. 38 | */ 39 | hash(): int64 40 | 41 | /** 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]. 42 | * 43 | * **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. 44 | */ 45 | bind(...vargargs: any[]): AnyCallable 46 | 47 | /** 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]. 48 | * 49 | * **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. 50 | */ 51 | bindv(arguments_: GArray): AnyCallable 52 | 53 | /** 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]. 54 | * 55 | * **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. 56 | * 57 | */ 58 | unbind(argcount: int64): AnyCallable 59 | 60 | /** Calls the method represented by this [Callable]. Arguments can be passed and should match the method's signature. */ 61 | call(...vargargs: any[]): any 62 | 63 | /** Calls the method represented by this [Callable]. Unlike [method call], this method expects all arguments to be contained inside the [param arguments] [Array]. */ 64 | callv(arguments_: GArray): any 65 | 66 | /** 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. 67 | * 68 | * 69 | * **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. 70 | * See also [method Object.call_deferred]. 71 | */ 72 | call_deferred(...vargargs: any[]): void 73 | } 74 | 75 | /** A built-in type representing a signal of an [Object]. 76 | * 77 | * @link https://docs.godotengine.org/en/4.2/classes/class_signal.html 78 | */ 79 | interface AnySignal { 80 | /** Returns `true` if the signal's name does not exist in its object, or the object is not valid. */ 81 | is_null(): boolean 82 | 83 | /** Returns the object emitting this signal. */ 84 | get_object(): Object 85 | 86 | /** Returns the ID of the object emitting this signal (see [method Object.get_instance_id]). */ 87 | get_object_id(): int64 88 | 89 | /** Returns the name of this signal. */ 90 | get_name(): StringName 91 | 92 | /** Returns `true` if the specified [Callable] is connected to this signal. */ 93 | is_connected(callable: AnyCallable): boolean 94 | 95 | /** Returns an [Array] of connections for this signal. Each connection is represented as a [Dictionary] that contains three entries: 96 | * - `signal` is a reference to this signal; 97 | * - `callable` is a reference to the connected [Callable]; 98 | * - `flags` is a combination of [enum Object.ConnectFlags]. 99 | */ 100 | get_connections(): Array 101 | } 102 | 103 | interface Callable0 extends AnyCallable { 104 | call(): R; 105 | } 106 | 107 | interface Callable1 extends AnyCallable { 108 | call(v1: T1): R; 109 | } 110 | 111 | interface Callable2 extends AnyCallable { 112 | call(v1: T1, v2, T2): R; 113 | } 114 | 115 | interface Callable3 extends AnyCallable { 116 | call(v1: T1, v2: T2, v3: T3): R; 117 | } 118 | 119 | interface Callable4 extends AnyCallable { 120 | call(v1: T1, v2: T2, v3: T3, v4: T4): R; 121 | } 122 | 123 | interface Callable5 extends AnyCallable { 124 | call(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): R; 125 | } 126 | 127 | interface Signal0 extends AnySignal { 128 | connect(callable: Callable0, flags: int64 = 0): void; 129 | disconnect(callable: Callable0): void; 130 | is_connected(callable: Callable0): boolean; 131 | emit(): void; 132 | 133 | as_promise(): Promise; 134 | } 135 | 136 | interface Signal1 extends AnySignal { 137 | connect(callable: Callable1, flags: int64 = 0): void; 138 | disconnect(callable: Callable1): void; 139 | is_connected(callable: Callable1): boolean; 140 | emit(v1: T1): void; 141 | 142 | // the first argument is used as the resolved value 143 | as_promise(): Promise; 144 | } 145 | 146 | interface Signal2 extends AnySignal { 147 | connect(callable: Callable2, flags: int64 = 0): void; 148 | disconnect(callable: Callable2): void; 149 | is_connected(callable: Callable2): boolean; 150 | emit(v1: T1, v2: T2): void; 151 | 152 | // the first argument is used as the resolved value 153 | as_promise(): Promise; 154 | } 155 | 156 | interface Signal3 extends AnySignal { 157 | connect(callable: Callable3, flags: int64 = 0): void; 158 | disconnect(callable: Callable3): void; 159 | is_connected(callable: Callable3): boolean; 160 | emit(v1: T1, v2: T2, v3: T3): void; 161 | 162 | // the first argument is used as the resolved value 163 | as_promise(): Promise; 164 | } 165 | 166 | interface Signal4 extends AnySignal { 167 | connect(callable: Callable4, flags: int64 = 0): void; 168 | disconnect(callable: Callable4): void; 169 | is_connected(callable: Callable4): boolean; 170 | emit(v1: T1, v2: T2, v3: T3, v4: T4): void; 171 | 172 | // the first argument is used as the resolved value 173 | as_promise(): Promise; 174 | } 175 | 176 | interface Signal5 extends AnySignal { 177 | connect(callable: Callable5, flags: int64 = 0): void; 178 | disconnect(callable: Callable5): void; 179 | is_connected(callable: Callable5): boolean; 180 | emit(v1: T1, v2: T2, v3: T3, v4: T4, v5: T5): void; 181 | 182 | // the first argument is used as the resolved value 183 | as_promise(): Promise; 184 | } 185 | 186 | } -------------------------------------------------------------------------------- /packages/runtime-tscn/typings/jsb.editor.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "jsb.editor.codegen" { 2 | import * as jsb from "godot-jsb"; 3 | export class TypeDB { 4 | singletons: { 5 | [name: string]: jsb.editor.SingletonInfo; 6 | }; 7 | classes: { 8 | [name: string]: jsb.editor.ClassInfo; 9 | }; 10 | primitive_types: { 11 | [name: string]: jsb.editor.PrimitiveClassInfo; 12 | }; 13 | primitive_type_names: { 14 | [type: number]: string; 15 | }; 16 | globals: { 17 | [name: string]: jsb.editor.GlobalConstantInfo; 18 | }; 19 | utilities: { 20 | [name: string]: jsb.editor.MethodBind; 21 | }; 22 | class_docs: { 23 | [name: string]: jsb.editor.ClassDoc | false; 24 | }; 25 | constructor(); 26 | find_doc(class_name: string): jsb.editor.ClassDoc | undefined; 27 | is_primitive_type(name: string): boolean; 28 | is_valid_method_name(name: string): boolean; 29 | make_classname(class_name: string, used_as_input: boolean): string; 30 | make_typename(info: jsb.editor.PropertyInfo, used_as_input: boolean): string; 31 | make_arg(info: jsb.editor.PropertyInfo, type_replacer?: (name: string) => string): string; 32 | make_literal_value(value: jsb.editor.DefaultArgumentInfo): string; 33 | replace_type_inplace(name: string | undefined, type_replacer?: (name: string) => string): string; 34 | make_arg_default_value(method_info: jsb.editor.MethodBind, index: number, type_replacer?: (name: string) => string): string; 35 | make_args(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 36 | make_return(method_info: jsb.editor.MethodBind, type_replacer?: (name: string) => string): string; 37 | make_signal_type(method_info: jsb.editor.MethodBind): string; 38 | } 39 | export default class TSDCodeGen { 40 | private _split_index; 41 | private _outDir; 42 | private _splitter; 43 | private _types; 44 | constructor(outDir: string); 45 | private make_path; 46 | private new_splitter; 47 | private split; 48 | private cleanup; 49 | has_class(name?: string): boolean; 50 | emit(): void; 51 | private emit_mock; 52 | private emit_singletons; 53 | private emit_utilities; 54 | private emit_globals; 55 | private emit_godot; 56 | private emit_godot_primitive; 57 | private emit_godot_class; 58 | } 59 | } 60 | declare module "jsb.editor.main" { 61 | import { PackedStringArray } from "godot"; 62 | export function auto_complete(pattern: string): PackedStringArray; 63 | export function run_npm_install(): void; 64 | } 65 | -------------------------------------------------------------------------------- /packages/runtime-tscn/typings/jsb.runtime.bundle.d.ts: -------------------------------------------------------------------------------- 1 | declare module "godot.annotations" { 2 | import { PropertyHint, PropertyUsageFlags, Variant, MultiplayerAPI, MultiplayerPeer } from "godot"; 3 | import * as jsb from "godot-jsb"; 4 | /** 5 | * 6 | */ 7 | export function signal(): (target: any, key: string) => void; 8 | export function export_multiline(): (target: any, key: string) => void; 9 | export function export_range(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 10 | export function export_range_i(min: number, max: number, step?: number, ...extra_hints: string[]): (target: any, key: string) => void; 11 | /** String as a path to a file, custom filter provided as hint. */ 12 | export function export_file(filter: string): (target: any, key: string) => void; 13 | export function export_dir(filter: string): (target: any, key: string) => void; 14 | export function export_global_file(filter: string): (target: any, key: string) => void; 15 | export function export_global_dir(filter: string): (target: any, key: string) => void; 16 | export function export_exp_easing(hint?: "" | "attenuation" | "positive_only" | "attenuation,positive_only"): (target: any, key: string) => void; 17 | export function export_(type: Variant.Type, details?: { 18 | class_?: Function; 19 | hint?: PropertyHint; 20 | hint_string?: string; 21 | usage?: PropertyUsageFlags; 22 | }): (target: any, key: string) => void; 23 | /** 24 | * In Godot, class members can be exported. 25 | * This means their value gets saved along with the resource (such as the scene) they're attached to. 26 | * They will also be available for editing in the property editor. 27 | * Exporting is done by using the `@export_var` (or `@export_`) annotation. 28 | */ 29 | export function export_var(type: Variant.Type, details?: { 30 | class_?: Function; 31 | hint?: PropertyHint; 32 | hint_string?: string; 33 | usage?: PropertyUsageFlags; 34 | }): (target: any, key: string) => void; 35 | /** 36 | * NOTE only int value enums are allowed 37 | */ 38 | export function export_enum(enum_type: any): (target: any, key: string) => void; 39 | /** 40 | * NOTE only int value enums are allowed 41 | */ 42 | export function export_flags(enum_type: any): (target: any, key: string) => void; 43 | export interface RPCConfig { 44 | mode?: MultiplayerAPI.RPCMode; 45 | sync?: "call_remote" | "call_local"; 46 | transfer_mode?: MultiplayerPeer.TransferMode; 47 | transfer_channel?: number; 48 | } 49 | export function rpc(config?: RPCConfig): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 50 | /** 51 | * auto initialized on ready (before _ready called) 52 | * @param evaluator for now, only string is accepted 53 | */ 54 | export function onready(evaluator: string | jsb.internal.OnReadyEvaluatorFunc): (target: any, key: string) => void; 55 | export function tool(): (target: any) => void; 56 | export function icon(path: string): (target: any) => void; 57 | export function deprecated(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 58 | export function experimental(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 59 | export function help(message?: string): (target: any, propertyKey?: PropertyKey, descriptor?: PropertyDescriptor) => void; 60 | } 61 | declare module "godot.typeloader" { 62 | /** 63 | * @param type the loaded type or function in godot module 64 | */ 65 | export type TypeLoadedCallback = (type: any) => void; 66 | export function on_type_loaded(type_name: string | string[], callback: TypeLoadedCallback): void; 67 | } 68 | declare module "jsb.core" { } 69 | -------------------------------------------------------------------------------- /turbo.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://turbo.build/schema.json", 3 | "ui": "tui", 4 | "tasks": { 5 | "build": { 6 | "dependsOn": ["^build"], 7 | "inputs": ["$TURBO_DEFAULT$", ".env*"], 8 | "outputs": ["dist/**"] 9 | }, 10 | "dev": { 11 | "cache": false, 12 | "persistent": true 13 | } 14 | } 15 | } 16 | --------------------------------------------------------------------------------