@xcodekit/xcode-wasm 0.6.0 → 0.6.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/node-wrapper.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Node.js wrapper for @xcodekit/xcode-wasm/node.
2
+ * CJS wrapper for @xcodekit/xcode-wasm/node.
3
3
  *
4
4
  * Usage:
5
5
  * const { XcodeProject, parse, build } = require("@xcodekit/xcode-wasm/node");
@@ -9,8 +9,14 @@ const { readFileSync, writeFileSync } = require("fs");
9
9
  const wasm = require("./xcode");
10
10
 
11
11
  class XcodeProject extends wasm.XcodeProject {
12
+ /** @type {string | null} */
12
13
  #filePath = null;
13
14
 
15
+ /**
16
+ * Open and parse a .pbxproj file from disk.
17
+ * @param {string} filePath
18
+ * @returns {XcodeProject}
19
+ */
14
20
  static open(filePath) {
15
21
  const content = readFileSync(filePath, "utf8");
16
22
  const project = new XcodeProject(content);
@@ -18,14 +24,21 @@ class XcodeProject extends wasm.XcodeProject {
18
24
  return project;
19
25
  }
20
26
 
27
+ /**
28
+ * Parse a .pbxproj string (no file on disk needed).
29
+ * @param {string} content
30
+ * @returns {XcodeProject}
31
+ */
21
32
  static fromString(content) {
22
33
  return new XcodeProject(content);
23
34
  }
24
35
 
36
+ /** The file path this project was opened from, or null if fromString/constructor. */
25
37
  get filePath() {
26
38
  return this.#filePath;
27
39
  }
28
40
 
41
+ /** Write the project back to its original file. Throws if no file path is set. */
29
42
  save() {
30
43
  if (!this.#filePath) throw new Error("No file path set — use open() or save(path)");
31
44
  writeFileSync(this.#filePath, this.toBuild());
package/node-wrapper.mjs CHANGED
@@ -6,14 +6,17 @@
6
6
  */
7
7
 
8
8
  import { readFileSync, writeFileSync } from "fs";
9
- import { createRequire } from "module";
10
-
11
- const require = createRequire(import.meta.url);
12
- const wasm = require("./xcode.js");
9
+ import * as wasm from "./xcode.js";
13
10
 
14
11
  class XcodeProject extends wasm.XcodeProject {
12
+ /** @type {string | null} */
15
13
  #filePath = null;
16
14
 
15
+ /**
16
+ * Open and parse a .pbxproj file from disk.
17
+ * @param {string} filePath
18
+ * @returns {XcodeProject}
19
+ */
17
20
  static open(filePath) {
18
21
  const content = readFileSync(filePath, "utf8");
19
22
  const project = new XcodeProject(content);
@@ -21,14 +24,21 @@ class XcodeProject extends wasm.XcodeProject {
21
24
  return project;
22
25
  }
23
26
 
27
+ /**
28
+ * Parse a .pbxproj string (no file on disk needed).
29
+ * @param {string} content
30
+ * @returns {XcodeProject}
31
+ */
24
32
  static fromString(content) {
25
33
  return new XcodeProject(content);
26
34
  }
27
35
 
36
+ /** The file path this project was opened from, or null if fromString/constructor. */
28
37
  get filePath() {
29
38
  return this.#filePath;
30
39
  }
31
40
 
41
+ /** Write the project back to its original file. Throws if no file path is set. */
32
42
  save() {
33
43
  if (!this.#filePath) throw new Error("No file path set — use open() or save(path)");
34
44
  writeFileSync(this.#filePath, this.toBuild());
@@ -36,4 +46,21 @@ class XcodeProject extends wasm.XcodeProject {
36
46
  }
37
47
 
38
48
  export { XcodeProject };
39
- export const { parse, build, parseAndBuild } = wasm;
49
+
50
+ /**
51
+ * Parse a .pbxproj string into a JSON-compatible object.
52
+ * @type {(text: string) => any}
53
+ */
54
+ export const parse = wasm.parse;
55
+
56
+ /**
57
+ * Serialize a JSON object back to .pbxproj format.
58
+ * @type {(project: object) => string}
59
+ */
60
+ export const build = wasm.build;
61
+
62
+ /**
63
+ * Parse and immediately re-serialize. Stays in WASM, zero marshalling.
64
+ * @type {(text: string) => string}
65
+ */
66
+ export const parseAndBuild = wasm.parseAndBuild;
package/package.json CHANGED
@@ -2,7 +2,7 @@
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.6.0",
5
+ "version": "0.6.1",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "xcode_bg.wasm",
package/xcode_bg.wasm CHANGED
Binary file