gtac-types 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +435 -0
- package/bin/gtac.js +35 -0
- package/index.js +6 -0
- package/lib/build.js +186 -0
- package/package.json +51 -0
- package/src/index.d.ts +22 -0
- package/src/runtime/shared/constants.ts +146 -0
- package/src/runtime/shared/utils.ts +26 -0
- package/src/types/client/animations.d.ts +902 -0
- package/src/types/client/events.d.ts +809 -0
- package/src/types/client/functions.d.ts +715 -0
- package/src/types/client/gta.d.ts +724 -0
- package/src/types/client/natives.d.ts +1091 -0
- package/src/types/element.d.ts +853 -0
- package/src/types/event.d.ts +100 -0
- package/src/types/misc.d.ts +256 -0
- package/src/types/resource.d.ts +252 -0
- package/src/types/server/client.d.ts +144 -0
- package/src/types/server/events.d.ts +407 -0
- package/src/types/server/functions.d.ts +890 -0
- package/src/types/vec.d.ts +594 -0
- package/src/types/xml.d.ts +232 -0
- package/templates/meta.xml +4 -0
- package/templates/tsconfig.json +12 -0
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GTAC XML and File I/O Type Definitions
|
|
3
|
+
*
|
|
4
|
+
* Defines the types for XML document manipulation and file I/O operations.
|
|
5
|
+
* The `xml` global provides a DOM-like API for creating, loading, saving,
|
|
6
|
+
* and traversing XML documents. `FileObject` is the handle type used by
|
|
7
|
+
* the file I/O functions (`fileOpen`, `fileRead`, `fileWrite`, etc.).
|
|
8
|
+
*
|
|
9
|
+
* All declarations are global — no import required.
|
|
10
|
+
*
|
|
11
|
+
* @module types/xml
|
|
12
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Load an XML file and read its contents
|
|
16
|
+
* const doc = xml.loadFile("data/config.xml");
|
|
17
|
+
* if (doc) {
|
|
18
|
+
* const root = xml.documentElement;
|
|
19
|
+
* const settings = xml.findChild(root, "settings");
|
|
20
|
+
* if (settings) {
|
|
21
|
+
* const value = xml.getAttribute(settings, "difficulty");
|
|
22
|
+
* console.log("Difficulty: " + value);
|
|
23
|
+
* }
|
|
24
|
+
* }
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* // Create a new XML document and save it
|
|
28
|
+
* const doc = xml.createDocument("root");
|
|
29
|
+
* const child = xml.createElement("item");
|
|
30
|
+
* xml.setAttribute(child, "id", "1");
|
|
31
|
+
* xml.setText(child, "Hello World");
|
|
32
|
+
* xml.appendChild(xml.documentElement, child);
|
|
33
|
+
* xml.saveFile("data/output.xml");
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
// ===== XML =====
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* An XML document handle (opaque type).
|
|
40
|
+
*
|
|
41
|
+
* Represents a parsed or created XML document. Use the `xml` API to create,
|
|
42
|
+
* load, and save documents. The internal structure is engine-defined.
|
|
43
|
+
*
|
|
44
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
45
|
+
*/
|
|
46
|
+
type XmlDocument = {}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* An XML element node handle (opaque type).
|
|
50
|
+
*
|
|
51
|
+
* Represents a single element node in an XML document tree. Elements have
|
|
52
|
+
* a name, text content, attributes, parent, and children. Use the `xml` API
|
|
53
|
+
* to navigate and manipulate the tree.
|
|
54
|
+
*
|
|
55
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
56
|
+
*/
|
|
57
|
+
type XmlElement = {}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* XML document manipulation API.
|
|
61
|
+
*
|
|
62
|
+
* Provides a complete set of DOM-like functions for creating, loading,
|
|
63
|
+
* saving, and traversing XML documents. The API is stateful: `loadFile()`
|
|
64
|
+
* and `createDocument()` set the current `documentElement` which is used
|
|
65
|
+
* implicitly by other functions.
|
|
66
|
+
*
|
|
67
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* // Create a simple XML structure
|
|
71
|
+
* xml.createDocument("players");
|
|
72
|
+
* xml.saveFile("players.xml");
|
|
73
|
+
*/
|
|
74
|
+
declare var xml: {
|
|
75
|
+
/**
|
|
76
|
+
* Creates a new, empty XML document with the specified root element name.
|
|
77
|
+
* The root element becomes the current `documentElement`.
|
|
78
|
+
*
|
|
79
|
+
* @param rootName - The tag name for the root element (e.g. `"settings"`).
|
|
80
|
+
* @returns A new `XmlDocument` handle.
|
|
81
|
+
*/
|
|
82
|
+
createDocument(rootName: string): XmlDocument;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Loads an XML file from the filesystem.
|
|
86
|
+
* On success, the document's root element becomes the current `documentElement`.
|
|
87
|
+
*
|
|
88
|
+
* @param path - File path to the XML file (relative to resource root).
|
|
89
|
+
* @returns The loaded `XmlDocument`, or `null` if the file could not be loaded.
|
|
90
|
+
*/
|
|
91
|
+
loadFile(path: string): XmlDocument | null;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* The root element of the currently loaded or created XML document.
|
|
95
|
+
* This is set automatically by `loadFile()` and `createDocument()`.
|
|
96
|
+
*/
|
|
97
|
+
documentElement: XmlElement;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Saves the current XML document to a file on disk.
|
|
101
|
+
*
|
|
102
|
+
* @param path - Output file path (relative to resource root).
|
|
103
|
+
* @returns `true` if the file was saved successfully, `false` on error.
|
|
104
|
+
*/
|
|
105
|
+
saveFile(path: string): boolean;
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Creates a new, unattached XML element node.
|
|
109
|
+
* The element is not added to any document until `appendChild()` is called.
|
|
110
|
+
*
|
|
111
|
+
* @param name - The tag name for the new element (e.g. `"entry"`).
|
|
112
|
+
* @returns A new `XmlElement` handle.
|
|
113
|
+
*/
|
|
114
|
+
createElement(name: string): XmlElement;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Appends a child element to a parent element.
|
|
118
|
+
* The child becomes the last child of the parent.
|
|
119
|
+
*
|
|
120
|
+
* @param parent - The parent `XmlElement` to append to.
|
|
121
|
+
* @param child - The `XmlElement` to add as a child.
|
|
122
|
+
*/
|
|
123
|
+
appendChild(parent: XmlElement, child: XmlElement): void;
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Removes a child element from its parent.
|
|
127
|
+
* The child is detached but not destroyed; it can be re-added elsewhere.
|
|
128
|
+
*
|
|
129
|
+
* @param parent - The parent `XmlElement`.
|
|
130
|
+
* @param child - The `XmlElement` to remove.
|
|
131
|
+
*/
|
|
132
|
+
removeChild(parent: XmlElement, child: XmlElement): void;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Gets the value of an attribute on an element.
|
|
136
|
+
*
|
|
137
|
+
* @param element - The `XmlElement` to query.
|
|
138
|
+
* @param name - The attribute name.
|
|
139
|
+
* @returns The attribute value as a string, or an empty string if not set.
|
|
140
|
+
*/
|
|
141
|
+
getAttribute(element: XmlElement, name: string): string;
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Sets an attribute on an element. Creates the attribute if it doesn't exist.
|
|
145
|
+
*
|
|
146
|
+
* @param element - The target `XmlElement`.
|
|
147
|
+
* @param name - The attribute name.
|
|
148
|
+
* @param value - The attribute value to set.
|
|
149
|
+
*/
|
|
150
|
+
setAttribute(element: XmlElement, name: string, value: string): void;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Removes an attribute from an element.
|
|
154
|
+
*
|
|
155
|
+
* @param element - The target `XmlElement`.
|
|
156
|
+
* @param name - The attribute name to remove.
|
|
157
|
+
*/
|
|
158
|
+
removeAttribute(element: XmlElement, name: string): void;
|
|
159
|
+
|
|
160
|
+
/**
|
|
161
|
+
* Gets all direct child elements of a parent element.
|
|
162
|
+
* Does not return text nodes or nested children (non-recursive).
|
|
163
|
+
*
|
|
164
|
+
* @param element - The parent `XmlElement`.
|
|
165
|
+
* @returns An array of direct child `XmlElement` handles.
|
|
166
|
+
*/
|
|
167
|
+
getChildren(element: XmlElement): XmlElement[];
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Gets the text content of an element.
|
|
171
|
+
*
|
|
172
|
+
* @param element - The `XmlElement` to read from.
|
|
173
|
+
* @returns The text content as a string.
|
|
174
|
+
*/
|
|
175
|
+
getText(element: XmlElement): string;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Sets the text content of an element.
|
|
179
|
+
*
|
|
180
|
+
* @param element - The target `XmlElement`.
|
|
181
|
+
* @param text - The text string to set.
|
|
182
|
+
*/
|
|
183
|
+
setText(element: XmlElement, text: string): void;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Gets the tag name of an element.
|
|
187
|
+
*
|
|
188
|
+
* @param element - The `XmlElement` to query.
|
|
189
|
+
* @returns The element's tag name (e.g. `"entry"`, `"root"`).
|
|
190
|
+
*/
|
|
191
|
+
getName(element: XmlElement): string;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Gets the parent element of a given element.
|
|
195
|
+
*
|
|
196
|
+
* @param element - The child `XmlElement`.
|
|
197
|
+
* @returns The parent `XmlElement`, or `null` if this is the root element.
|
|
198
|
+
*/
|
|
199
|
+
getParent(element: XmlElement): XmlElement | null;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Finds the first direct child element with a given tag name.
|
|
203
|
+
* This is a non-recursive search; only immediate children are checked.
|
|
204
|
+
*
|
|
205
|
+
* @param element - The parent `XmlElement` to search within.
|
|
206
|
+
* @param name - The tag name to search for.
|
|
207
|
+
* @returns The first matching `XmlElement`, or `null` if not found.
|
|
208
|
+
*/
|
|
209
|
+
findChild(element: XmlElement, name: string): XmlElement | null;
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
// ===== File =====
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* An open file handle (opaque type).
|
|
216
|
+
*
|
|
217
|
+
* Returned by `fileOpen()` and used with `fileRead()`, `fileWrite()`,
|
|
218
|
+
* `fileClose()`, `fileGetSize()`, and `fileGetPath()`. The internal
|
|
219
|
+
* representation is engine-defined.
|
|
220
|
+
*
|
|
221
|
+
* @see https://wiki.gtaconnected.com — GTA Connected Wiki
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* // Open, read, and close a file
|
|
225
|
+
* const file = fileOpen("data.txt");
|
|
226
|
+
* if (file) {
|
|
227
|
+
* const content = fileRead(file);
|
|
228
|
+
* console.log("File contents: " + content);
|
|
229
|
+
* fileClose(file);
|
|
230
|
+
* }
|
|
231
|
+
*/
|
|
232
|
+
type FileObject = {}
|