godot-export-presets 0.1.0

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Hello Invent LTD
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,110 @@
1
+ # godot-export-presets
2
+
3
+ Read and write Godot export_presets.cfg files.
4
+
5
+ This library provides a simple way to programmatically manage Godot export presets. It handles parsing the config file format, merging presets, and includes base presets for common platforms.
6
+
7
+ The parsing and serialization logic is based on Godot's source code, specifically the `ConfigFile`, `VariantParser`, and `VariantWriter` implementations from the Godot engine repository. This attempts to ensure compatibility with Godot's native export preset format.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install godot-export-presets
13
+ ```
14
+
15
+ Requires Node.js 18 or higher.
16
+
17
+ ## Quick Start
18
+
19
+ ```typescript
20
+ import { loadExportPresets, findPreset, saveExportPresets } from 'godot-export-presets';
21
+
22
+ // Load existing presets
23
+ const presets = await loadExportPresets('./export_presets.cfg');
24
+
25
+ // Find preset by platform name
26
+ const androidPreset = findPreset(presets, { platform: 'Android' });
27
+ if (androidPreset) {
28
+ androidPreset.export_path = 'game.apk';
29
+ }
30
+
31
+ // Save
32
+ await saveExportPresets('./export_presets.cfg', presets);
33
+ ```
34
+
35
+ ## Examples
36
+
37
+ ### Basic Reading and Writing
38
+
39
+ Load a file, find a preset by name, make changes, and save:
40
+
41
+ ```typescript
42
+ import { loadExportPresets, findPreset, saveExportPresets } from 'godot-export-presets';
43
+
44
+ const presets = await loadExportPresets('./export_presets.cfg');
45
+ console.log(`Found ${presets.presets.length} presets`);
46
+
47
+ // Find preset by platform (case-insensitive)
48
+ const androidPreset = findPreset(presets, { platform: 'android' });
49
+ if (androidPreset) {
50
+ androidPreset.export_path = 'game.apk';
51
+ }
52
+
53
+ // Or find by preset name
54
+ const iosPreset = findPreset(presets, { name: 'iOS' });
55
+ if (iosPreset) {
56
+ iosPreset.export_path = 'game.ipa';
57
+ }
58
+
59
+ await saveExportPresets('./export_presets.cfg', presets);
60
+ ```
61
+
62
+ ### Using Base Presets
63
+
64
+ The library includes base presets for Android and iOS on Godot 3.x and 4.x:
65
+
66
+ ```typescript
67
+ import { getBasePreset, getMajorVersion } from 'godot-export-presets';
68
+
69
+ // Get base preset for Android (Godot 4.x)
70
+ const baseAndroid = getBasePreset('Android', 4);
71
+
72
+ // Extract version from string
73
+ const version = getMajorVersion('4.3.2'); // returns 4
74
+ const baseForVersion = getBasePreset('iOS', version);
75
+ ```
76
+
77
+ ## API Overview
78
+
79
+ Main functions:
80
+
81
+ - `loadExportPresets(filePath)` - Load presets from file
82
+ - `saveExportPresets(filePath, presets)` - Save presets to file
83
+ - `parseExportPresets(content)` - Parse from string
84
+ - `serializeExportPresets(presets)` - Serialize to string
85
+ - `findPreset(presets, criteria)` - Find preset by platform/name/index
86
+ - `getPreset(presets, index)` - Get preset by index
87
+ - `setPreset(presets, preset, index?)` - Add or update preset
88
+ - `removePreset(presets, index)` - Remove preset
89
+ - `mergePresets(...presets)` - Merge multiple presets
90
+ - `getBasePreset(platform, version)` - Get base preset
91
+ - `getMajorVersion(version)` - Extract major version from string
92
+
93
+ For full TypeScript types and API details, see the type definitions in `dist/index.d.ts`.
94
+
95
+ ## Implementation Notes
96
+
97
+ This library is based on Godot's source code. The parsing logic follows Godot's `VariantParser` implementation, and the serialization follows `VariantWriter` and `String::property_name_encode`. The base presets are extracted from real Godot export configurations.
98
+
99
+ This implementation was created with tool assistance using Cursor and Claude, porting Godot's C++ logic to TypeScript while maintaining compatibility with the original format.
100
+
101
+ Key Godot source files referenced:
102
+ - `core/io/config_file.cpp` - ConfigFile parsing and writing
103
+ - `core/variant/variant_parser.cpp` - Variant parsing logic
104
+ - `core/string/ustring.cpp` - String encoding for keys
105
+ - `editor/export/editor_export.cpp` - Export preset structure
106
+
107
+ ## License
108
+
109
+ MIT
110
+