@xcodekit/xcode-wasm 0.4.0 → 0.5.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/README.md CHANGED
@@ -98,6 +98,7 @@ const targets = project.getNativeTargets(); // UUID[]
98
98
  const mainApp = project.findMainAppTarget("ios"); // UUID | null
99
99
  project.getTargetName(mainApp); // "MyApp"
100
100
  project.setTargetName(mainApp, "NewName");
101
+ project.renameTarget(mainApp, "OldName", "NewName"); // cascades to groups, product refs, proxies
101
102
 
102
103
  // Build settings
103
104
  project.getBuildSetting(targetUuid, "PRODUCT_BUNDLE_IDENTIFIER");
@@ -154,13 +155,13 @@ All `XcodeProject` methods operate in Rust/WASM — only primitive strings cross
154
155
 
155
156
  ### WASM
156
157
 
157
- The WASM build (`@xcodekit/xcode-wasm`) has the same API with two differences:
158
+ The WASM build (`@xcodekit/xcode-wasm`) has the same API with minor differences:
158
159
 
159
160
  - `parse()` / `build()` work with JSON **strings** (not JS objects) — call `JSON.parse()` / `JSON.stringify()` on your side
160
161
  - `XcodeProject` is created with `new XcodeProject(content)` instead of factory methods
161
- - No `open()` / `save()` — no filesystem in WASM
162
162
 
163
163
  ```js
164
+ // Browser / Deno / Cloudflare Workers
164
165
  import { parse, build, XcodeProject } from "@xcodekit/xcode-wasm";
165
166
 
166
167
  // Low-level
@@ -174,6 +175,18 @@ xcode.setBuildSetting(target, "SWIFT_VERSION", "6.0");
174
175
  const pbxproj = xcode.toBuild();
175
176
  ```
176
177
 
178
+ ### WASM on Node.js
179
+
180
+ Use the `/node` subpath to get `open()` and `save()`:
181
+
182
+ ```js
183
+ const { XcodeProject } = require("@xcodekit/xcode-wasm/node");
184
+
185
+ const project = XcodeProject.open("project.pbxproj");
186
+ project.setBuildSetting(target, "SWIFT_VERSION", "6.0");
187
+ project.save();
188
+ ```
189
+
177
190
  ## Performance
178
191
 
179
192
  Benchmarked on Apple M4 Pro, Node.js v24. Median of 200 iterations.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Node.js wrapper for @xcodekit/xcode-wasm.
3
+ * Adds open() and save() methods using the filesystem.
4
+ *
5
+ * Usage:
6
+ * import { XcodeProject } from "@xcodekit/xcode-wasm/node";
7
+ */
8
+
9
+ const { readFileSync, writeFileSync } = require("fs");
10
+ const wasm = require("./xcode");
11
+
12
+ class XcodeProject extends wasm.XcodeProject {
13
+ #filePath = null;
14
+
15
+ static open(filePath) {
16
+ const content = readFileSync(filePath, "utf8");
17
+ const project = new XcodeProject(content);
18
+ project.#filePath = filePath;
19
+ return project;
20
+ }
21
+
22
+ static fromString(content) {
23
+ return new XcodeProject(content);
24
+ }
25
+
26
+ get filePath() {
27
+ return this.#filePath;
28
+ }
29
+
30
+ save() {
31
+ if (!this.#filePath) throw new Error("No file path set — use open() or save(path)");
32
+ writeFileSync(this.#filePath, this.toBuild());
33
+ }
34
+ }
35
+
36
+ module.exports = { ...wasm, XcodeProject };
package/package.json CHANGED
@@ -2,13 +2,14 @@
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.4.0",
5
+ "version": "0.5.0",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "xcode_bg.wasm",
9
9
  "xcode.js",
10
10
  "xcode_bg.js",
11
- "xcode.d.ts"
11
+ "xcode.d.ts",
12
+ "node-wrapper.js"
12
13
  ],
13
14
  "main": "xcode.js",
14
15
  "types": "xcode.d.ts",
@@ -28,5 +29,14 @@
28
29
  "parser",
29
30
  "wasm",
30
31
  "rust"
31
- ]
32
+ ],
33
+ "exports": {
34
+ ".": {
35
+ "import": "./xcode.js",
36
+ "types": "./xcode.d.ts"
37
+ },
38
+ "./node": {
39
+ "require": "./node-wrapper.js"
40
+ }
41
+ }
32
42
  }
package/xcode.d.ts CHANGED
@@ -30,6 +30,10 @@ export class XcodeProject {
30
30
  */
31
31
  constructor(content: string);
32
32
  removeBuildSetting(target_uuid: string, key: string): boolean;
33
+ /**
34
+ * Rename a target and cascade through the project (group paths, product refs, proxies).
35
+ */
36
+ renameTarget(target_uuid: string, old_name: string, new_name: string): boolean;
33
37
  setBuildSetting(target_uuid: string, key: string, value: string): boolean;
34
38
  setObjectProperty(uuid: string, key: string, value: string): boolean;
35
39
  setTargetName(target_uuid: string, name: string): boolean;
package/xcode_bg.js CHANGED
@@ -498,6 +498,23 @@ export class XcodeProject {
498
498
  const ret = wasm.xcodeproject_removeBuildSetting(this.__wbg_ptr, ptr0, len0, ptr1, len1);
499
499
  return ret !== 0;
500
500
  }
501
+ /**
502
+ * Rename a target and cascade through the project (group paths, product refs, proxies).
503
+ * @param {string} target_uuid
504
+ * @param {string} old_name
505
+ * @param {string} new_name
506
+ * @returns {boolean}
507
+ */
508
+ renameTarget(target_uuid, old_name, new_name) {
509
+ const ptr0 = passStringToWasm0(target_uuid, wasm.__wbindgen_export, wasm.__wbindgen_export2);
510
+ const len0 = WASM_VECTOR_LEN;
511
+ const ptr1 = passStringToWasm0(old_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
512
+ const len1 = WASM_VECTOR_LEN;
513
+ const ptr2 = passStringToWasm0(new_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
514
+ const len2 = WASM_VECTOR_LEN;
515
+ const ret = wasm.xcodeproject_renameTarget(this.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
516
+ return ret !== 0;
517
+ }
501
518
  /**
502
519
  * @param {string} target_uuid
503
520
  * @param {string} key
package/xcode_bg.wasm CHANGED
Binary file