@xcodekit/xcode-wasm 0.5.0 → 0.5.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/README.md +14 -0
- package/node-wrapper.d.ts +22 -0
- package/node-wrapper.js +2 -2
- package/node-wrapper.mjs +40 -0
- package/package.json +12 -3
- package/types.d.ts +252 -0
- package/xcode_bg.wasm +0 -0
package/README.md
CHANGED
|
@@ -180,6 +180,10 @@ const pbxproj = xcode.toBuild();
|
|
|
180
180
|
Use the `/node` subpath to get `open()` and `save()`:
|
|
181
181
|
|
|
182
182
|
```js
|
|
183
|
+
// ESM
|
|
184
|
+
import { XcodeProject } from "@xcodekit/xcode-wasm/node";
|
|
185
|
+
|
|
186
|
+
// CJS
|
|
183
187
|
const { XcodeProject } = require("@xcodekit/xcode-wasm/node");
|
|
184
188
|
|
|
185
189
|
const project = XcodeProject.open("project.pbxproj");
|
|
@@ -187,6 +191,16 @@ project.setBuildSetting(target, "SWIFT_VERSION", "6.0");
|
|
|
187
191
|
project.save();
|
|
188
192
|
```
|
|
189
193
|
|
|
194
|
+
### Shared Types
|
|
195
|
+
|
|
196
|
+
Both packages ship `types.d.ts` with rich TypeScript types for the parsed JSON structure:
|
|
197
|
+
|
|
198
|
+
```ts
|
|
199
|
+
import type { ParsedProject, PBXNativeTarget, BuildSettings, ISA } from "@xcodekit/xcode-wasm/types";
|
|
200
|
+
// or
|
|
201
|
+
import type { ParsedProject, PBXNativeTarget, BuildSettings, ISA } from "@xcodekit/xcode/types";
|
|
202
|
+
```
|
|
203
|
+
|
|
190
204
|
## Performance
|
|
191
205
|
|
|
192
206
|
Benchmarked on Apple M4 Pro, Node.js v24. Median of 200 iterations.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for @xcodekit/xcode-wasm/node.
|
|
3
|
+
* Extends the base WASM XcodeProject with filesystem methods.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export { build, parse, parseAndBuild } from "./pkg/node/xcode";
|
|
7
|
+
|
|
8
|
+
import { XcodeProject as BaseXcodeProject } from "./pkg/node/xcode";
|
|
9
|
+
|
|
10
|
+
export declare class XcodeProject extends BaseXcodeProject {
|
|
11
|
+
/** Open and parse a .pbxproj file from disk. */
|
|
12
|
+
static open(filePath: string): XcodeProject;
|
|
13
|
+
|
|
14
|
+
/** Parse a .pbxproj string (no file on disk needed). */
|
|
15
|
+
static fromString(content: string): XcodeProject;
|
|
16
|
+
|
|
17
|
+
/** The file path this project was opened from, or null if fromString/constructor. */
|
|
18
|
+
get filePath(): string | null;
|
|
19
|
+
|
|
20
|
+
/** Write the project back to its original file. */
|
|
21
|
+
save(): void;
|
|
22
|
+
}
|
package/node-wrapper.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Node.js wrapper for @xcodekit/xcode-wasm.
|
|
2
|
+
* Node.js wrapper for @xcodekit/xcode-wasm/node.
|
|
3
3
|
* Adds open() and save() methods using the filesystem.
|
|
4
4
|
*
|
|
5
5
|
* Usage:
|
|
6
|
-
*
|
|
6
|
+
* const { XcodeProject } = require("@xcodekit/xcode-wasm/node");
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
const { readFileSync, writeFileSync } = require("fs");
|
package/node-wrapper.mjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ESM wrapper for @xcodekit/xcode-wasm/node.
|
|
3
|
+
* Adds open() and save() methods using the filesystem.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* import { XcodeProject } from "@xcodekit/xcode-wasm/node";
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { readFileSync, writeFileSync } from "fs";
|
|
10
|
+
import { createRequire } from "module";
|
|
11
|
+
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const wasm = require("./xcode.js");
|
|
14
|
+
|
|
15
|
+
class XcodeProject extends wasm.XcodeProject {
|
|
16
|
+
#filePath = null;
|
|
17
|
+
|
|
18
|
+
static open(filePath) {
|
|
19
|
+
const content = readFileSync(filePath, "utf8");
|
|
20
|
+
const project = new XcodeProject(content);
|
|
21
|
+
project.#filePath = filePath;
|
|
22
|
+
return project;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
static fromString(content) {
|
|
26
|
+
return new XcodeProject(content);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
get filePath() {
|
|
30
|
+
return this.#filePath;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
save() {
|
|
34
|
+
if (!this.#filePath) throw new Error("No file path set — use open() or save(path)");
|
|
35
|
+
writeFileSync(this.#filePath, this.toBuild());
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export { XcodeProject };
|
|
40
|
+
export const { parse, build, parseAndBuild } = wasm;
|
package/package.json
CHANGED
|
@@ -2,14 +2,17 @@
|
|
|
2
2
|
"name": "@xcodekit/xcode-wasm",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"description": "Parse, manipulate, and serialize Xcode .pbxproj files (WASM build)",
|
|
5
|
-
"version": "0.5.
|
|
5
|
+
"version": "0.5.1",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"files": [
|
|
8
8
|
"xcode_bg.wasm",
|
|
9
9
|
"xcode.js",
|
|
10
10
|
"xcode_bg.js",
|
|
11
11
|
"xcode.d.ts",
|
|
12
|
-
"
|
|
12
|
+
"types.d.ts",
|
|
13
|
+
"node-wrapper.js",
|
|
14
|
+
"node-wrapper.mjs",
|
|
15
|
+
"node-wrapper.d.ts"
|
|
13
16
|
],
|
|
14
17
|
"main": "xcode.js",
|
|
15
18
|
"types": "xcode.d.ts",
|
|
@@ -31,12 +34,18 @@
|
|
|
31
34
|
"rust"
|
|
32
35
|
],
|
|
33
36
|
"exports": {
|
|
37
|
+
"./types": {
|
|
38
|
+
"types": "./types.d.ts"
|
|
39
|
+
},
|
|
34
40
|
".": {
|
|
35
41
|
"import": "./xcode.js",
|
|
42
|
+
"require": "./xcode.js",
|
|
36
43
|
"types": "./xcode.d.ts"
|
|
37
44
|
},
|
|
38
45
|
"./node": {
|
|
39
|
-
"
|
|
46
|
+
"import": "./node-wrapper.mjs",
|
|
47
|
+
"require": "./node-wrapper.js",
|
|
48
|
+
"types": "./node-wrapper.d.ts"
|
|
40
49
|
}
|
|
41
50
|
}
|
|
42
51
|
}
|
package/types.d.ts
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Supplemental type definitions for @xcodekit/xcode.
|
|
3
|
+
*
|
|
4
|
+
* These provide rich types for the parsed .pbxproj JSON structure
|
|
5
|
+
* beyond what napi-rs auto-generates.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** ISA types for all known Xcode project object types. */
|
|
9
|
+
export type ISA =
|
|
10
|
+
| "PBXBuildFile"
|
|
11
|
+
| "PBXAppleScriptBuildPhase"
|
|
12
|
+
| "PBXCopyFilesBuildPhase"
|
|
13
|
+
| "PBXFrameworksBuildPhase"
|
|
14
|
+
| "PBXHeadersBuildPhase"
|
|
15
|
+
| "PBXResourcesBuildPhase"
|
|
16
|
+
| "PBXShellScriptBuildPhase"
|
|
17
|
+
| "PBXSourcesBuildPhase"
|
|
18
|
+
| "PBXRezBuildPhase"
|
|
19
|
+
| "PBXContainerItemProxy"
|
|
20
|
+
| "PBXFileReference"
|
|
21
|
+
| "PBXGroup"
|
|
22
|
+
| "PBXVariantGroup"
|
|
23
|
+
| "XCVersionGroup"
|
|
24
|
+
| "PBXFileSystemSynchronizedRootGroup"
|
|
25
|
+
| "PBXFileSystemSynchronizedBuildFileExceptionSet"
|
|
26
|
+
| "PBXFileSystemSynchronizedGroupBuildPhaseMembershipExceptionSet"
|
|
27
|
+
| "PBXNativeTarget"
|
|
28
|
+
| "PBXAggregateTarget"
|
|
29
|
+
| "PBXLegacyTarget"
|
|
30
|
+
| "PBXProject"
|
|
31
|
+
| "PBXTargetDependency"
|
|
32
|
+
| "XCBuildConfiguration"
|
|
33
|
+
| "XCConfigurationList"
|
|
34
|
+
| "PBXBuildRule"
|
|
35
|
+
| "PBXReferenceProxy"
|
|
36
|
+
| "XCSwiftPackageProductDependency"
|
|
37
|
+
| "XCRemoteSwiftPackageReference"
|
|
38
|
+
| "XCLocalSwiftPackageReference";
|
|
39
|
+
|
|
40
|
+
/** A 24-character hexadecimal UUID string. */
|
|
41
|
+
export type UUID = string;
|
|
42
|
+
|
|
43
|
+
/** Boolean as 0 | 1 integer. */
|
|
44
|
+
export type BoolNumber = 0 | 1;
|
|
45
|
+
|
|
46
|
+
/** Boolean as YES/NO string. */
|
|
47
|
+
export type BoolString = "YES" | "NO" | "YES_ERROR" | "YES_AGGRESSIVE";
|
|
48
|
+
|
|
49
|
+
/** Source tree reference types. */
|
|
50
|
+
export type SourceTree = "BUILT_PRODUCTS_DIR" | "DEVELOPER_DIR" | "SOURCE_ROOT" | "SDKROOT" | "<group>" | "<absolute>";
|
|
51
|
+
|
|
52
|
+
/** CopyFilesBuildPhase destination subfolder spec. */
|
|
53
|
+
export enum SubFolder {
|
|
54
|
+
absolutePath = 0,
|
|
55
|
+
wrapper = 1,
|
|
56
|
+
executables = 6,
|
|
57
|
+
resources = 7,
|
|
58
|
+
frameworks = 10,
|
|
59
|
+
sharedFrameworks = 11,
|
|
60
|
+
sharedSupport = 12,
|
|
61
|
+
plugins = 13,
|
|
62
|
+
javaResources = 15,
|
|
63
|
+
productsDirectory = 16,
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Container item proxy type. */
|
|
67
|
+
export enum ProxyType {
|
|
68
|
+
targetReference = 1,
|
|
69
|
+
reference = 2,
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** Common file type UTIs. */
|
|
73
|
+
export type FileType =
|
|
74
|
+
| "sourcecode.swift"
|
|
75
|
+
| "sourcecode.c.c"
|
|
76
|
+
| "sourcecode.c.h"
|
|
77
|
+
| "sourcecode.c.objc"
|
|
78
|
+
| "sourcecode.cpp.cpp"
|
|
79
|
+
| "sourcecode.cpp.objcpp"
|
|
80
|
+
| "sourcecode.javascript"
|
|
81
|
+
| "wrapper.application"
|
|
82
|
+
| "wrapper.framework"
|
|
83
|
+
| "wrapper.app-extension"
|
|
84
|
+
| "wrapper.plug-in"
|
|
85
|
+
| "wrapper.xcframework"
|
|
86
|
+
| "compiled.mach-o.dylib"
|
|
87
|
+
| "archive.ar"
|
|
88
|
+
| "folder.assetcatalog"
|
|
89
|
+
| "text.plist.xml"
|
|
90
|
+
| "text.plist.strings"
|
|
91
|
+
| "text.plist.entitlements"
|
|
92
|
+
| "text.xcconfig"
|
|
93
|
+
| "file.storyboard"
|
|
94
|
+
| "file.xib"
|
|
95
|
+
| "file.intentdefinition"
|
|
96
|
+
| "image.png"
|
|
97
|
+
| "image.jpeg"
|
|
98
|
+
| "net.daringfireball.markdown"
|
|
99
|
+
| string;
|
|
100
|
+
|
|
101
|
+
/** Common product type UTIs. */
|
|
102
|
+
export type ProductType =
|
|
103
|
+
| "com.apple.product-type.application"
|
|
104
|
+
| "com.apple.product-type.application.on-demand-install-capable"
|
|
105
|
+
| "com.apple.product-type.app-extension"
|
|
106
|
+
| "com.apple.product-type.bundle"
|
|
107
|
+
| "com.apple.product-type.framework"
|
|
108
|
+
| "com.apple.product-type.library.dynamic"
|
|
109
|
+
| "com.apple.product-type.library.static"
|
|
110
|
+
| "com.apple.product-type.tool"
|
|
111
|
+
| "com.apple.product-type.unit-test-bundle"
|
|
112
|
+
| "com.apple.product-type.ui-testing-bundle"
|
|
113
|
+
| "com.apple.product-type.application.watchapp"
|
|
114
|
+
| "com.apple.product-type.application.watchapp2"
|
|
115
|
+
| "com.apple.product-type.watchkit-extension"
|
|
116
|
+
| "com.apple.product-type.extensionkit-extension"
|
|
117
|
+
| string;
|
|
118
|
+
|
|
119
|
+
/** Build settings dictionary. */
|
|
120
|
+
export interface BuildSettings {
|
|
121
|
+
ALWAYS_SEARCH_USER_PATHS?: BoolString;
|
|
122
|
+
ASSETCATALOG_COMPILER_APPICON_NAME?: string;
|
|
123
|
+
CLANG_ENABLE_MODULES?: BoolString;
|
|
124
|
+
CLANG_ENABLE_OBJC_ARC?: BoolString;
|
|
125
|
+
CODE_SIGN_ENTITLEMENTS?: string;
|
|
126
|
+
CODE_SIGN_IDENTITY?: string;
|
|
127
|
+
CODE_SIGN_STYLE?: "Automatic" | "Manual";
|
|
128
|
+
CURRENT_PROJECT_VERSION?: string;
|
|
129
|
+
DEBUG_INFORMATION_FORMAT?: "dwarf" | "dwarf-with-dsym";
|
|
130
|
+
DEVELOPMENT_TEAM?: string;
|
|
131
|
+
GCC_OPTIMIZATION_LEVEL?: string;
|
|
132
|
+
GCC_PREPROCESSOR_DEFINITIONS?: string | string[];
|
|
133
|
+
GENERATE_INFOPLIST_FILE?: BoolString;
|
|
134
|
+
INFOPLIST_FILE?: string;
|
|
135
|
+
INFOPLIST_KEY_CFBundleDisplayName?: string;
|
|
136
|
+
IPHONEOS_DEPLOYMENT_TARGET?: string;
|
|
137
|
+
MACOSX_DEPLOYMENT_TARGET?: string;
|
|
138
|
+
TVOS_DEPLOYMENT_TARGET?: string;
|
|
139
|
+
WATCHOS_DEPLOYMENT_TARGET?: string;
|
|
140
|
+
MARKETING_VERSION?: string;
|
|
141
|
+
PRODUCT_BUNDLE_IDENTIFIER?: string;
|
|
142
|
+
PRODUCT_NAME?: string;
|
|
143
|
+
SWIFT_VERSION?: string;
|
|
144
|
+
TARGETED_DEVICE_FAMILY?: string;
|
|
145
|
+
[key: string]: string | string[] | number | undefined;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/** Base object with isa field. */
|
|
149
|
+
export interface PBXObjectBase {
|
|
150
|
+
isa: ISA;
|
|
151
|
+
[key: string]: any;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/** PBXBuildFile object. */
|
|
155
|
+
export interface PBXBuildFile extends PBXObjectBase {
|
|
156
|
+
isa: "PBXBuildFile";
|
|
157
|
+
fileRef?: UUID;
|
|
158
|
+
productRef?: UUID;
|
|
159
|
+
settings?: Record<string, any>;
|
|
160
|
+
platformFilter?: string;
|
|
161
|
+
platformFilters?: string[];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/** PBXFileReference object. */
|
|
165
|
+
export interface PBXFileReference extends PBXObjectBase {
|
|
166
|
+
isa: "PBXFileReference";
|
|
167
|
+
fileEncoding?: number;
|
|
168
|
+
lastKnownFileType?: FileType;
|
|
169
|
+
explicitFileType?: FileType;
|
|
170
|
+
includeInIndex?: BoolNumber;
|
|
171
|
+
name?: string;
|
|
172
|
+
path?: string;
|
|
173
|
+
sourceTree?: SourceTree;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** PBXGroup object. */
|
|
177
|
+
export interface PBXGroup extends PBXObjectBase {
|
|
178
|
+
isa: "PBXGroup";
|
|
179
|
+
children: UUID[];
|
|
180
|
+
name?: string;
|
|
181
|
+
path?: string;
|
|
182
|
+
sourceTree?: SourceTree;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Build phase (shared fields for all 8 types). */
|
|
186
|
+
export interface AbstractBuildPhase extends PBXObjectBase {
|
|
187
|
+
buildActionMask?: number;
|
|
188
|
+
files: UUID[];
|
|
189
|
+
runOnlyForDeploymentPostprocessing?: BoolNumber;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** PBXNativeTarget object. */
|
|
193
|
+
export interface PBXNativeTarget extends PBXObjectBase {
|
|
194
|
+
isa: "PBXNativeTarget";
|
|
195
|
+
buildConfigurationList: UUID;
|
|
196
|
+
buildPhases: UUID[];
|
|
197
|
+
buildRules: UUID[];
|
|
198
|
+
dependencies: UUID[];
|
|
199
|
+
name: string;
|
|
200
|
+
productName?: string;
|
|
201
|
+
productReference?: UUID;
|
|
202
|
+
productType: ProductType;
|
|
203
|
+
packageProductDependencies?: UUID[];
|
|
204
|
+
fileSystemSynchronizedGroups?: UUID[];
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/** PBXProject (root object). */
|
|
208
|
+
export interface PBXProject extends PBXObjectBase {
|
|
209
|
+
isa: "PBXProject";
|
|
210
|
+
buildConfigurationList: UUID;
|
|
211
|
+
compatibilityVersion: string;
|
|
212
|
+
developmentRegion: string;
|
|
213
|
+
hasScannedForEncodings: BoolNumber;
|
|
214
|
+
knownRegions: string[];
|
|
215
|
+
mainGroup: UUID;
|
|
216
|
+
productRefGroup?: UUID;
|
|
217
|
+
projectDirPath: string;
|
|
218
|
+
projectRoot: string;
|
|
219
|
+
targets: UUID[];
|
|
220
|
+
packageReferences?: UUID[];
|
|
221
|
+
attributes?: {
|
|
222
|
+
LastSwiftUpdateCheck?: string;
|
|
223
|
+
LastUpgradeCheck?: string;
|
|
224
|
+
TargetAttributes?: Record<UUID, Record<string, any>>;
|
|
225
|
+
[key: string]: any;
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/** XCBuildConfiguration object. */
|
|
230
|
+
export interface XCBuildConfiguration extends PBXObjectBase {
|
|
231
|
+
isa: "XCBuildConfiguration";
|
|
232
|
+
name: string;
|
|
233
|
+
buildSettings: BuildSettings;
|
|
234
|
+
baseConfigurationReference?: UUID;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/** XCConfigurationList object. */
|
|
238
|
+
export interface XCConfigurationList extends PBXObjectBase {
|
|
239
|
+
isa: "XCConfigurationList";
|
|
240
|
+
buildConfigurations: UUID[];
|
|
241
|
+
defaultConfigurationIsVisible?: BoolNumber;
|
|
242
|
+
defaultConfigurationName?: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** The top-level parsed .pbxproj structure. */
|
|
246
|
+
export interface ParsedProject {
|
|
247
|
+
archiveVersion: number;
|
|
248
|
+
classes: Record<string, any>;
|
|
249
|
+
objectVersion: number;
|
|
250
|
+
objects: Record<UUID, PBXObjectBase>;
|
|
251
|
+
rootObject: UUID;
|
|
252
|
+
}
|
package/xcode_bg.wasm
CHANGED
|
Binary file
|