@xcodekit/xcode-wasm 0.6.0 → 0.6.2

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.mjs CHANGED
@@ -6,14 +6,20 @@
6
6
  */
7
7
 
8
8
  import { readFileSync, writeFileSync } from "fs";
9
- import { createRequire } from "module";
9
+ import * as wasm from "./xcode.js";
10
+ import wasmModule from "./xcode_bg.wasm";
10
11
 
11
- const require = createRequire(import.meta.url);
12
- const wasm = require("./xcode.js");
12
+ await wasm.default(wasmModule);
13
13
 
14
14
  class XcodeProject extends wasm.XcodeProject {
15
+ /** @type {string | null} */
15
16
  #filePath = null;
16
17
 
18
+ /**
19
+ * Open and parse a .pbxproj file from disk.
20
+ * @param {string} filePath
21
+ * @returns {XcodeProject}
22
+ */
17
23
  static open(filePath) {
18
24
  const content = readFileSync(filePath, "utf8");
19
25
  const project = new XcodeProject(content);
@@ -21,14 +27,21 @@ class XcodeProject extends wasm.XcodeProject {
21
27
  return project;
22
28
  }
23
29
 
30
+ /**
31
+ * Parse a .pbxproj string (no file on disk needed).
32
+ * @param {string} content
33
+ * @returns {XcodeProject}
34
+ */
24
35
  static fromString(content) {
25
36
  return new XcodeProject(content);
26
37
  }
27
38
 
39
+ /** The file path this project was opened from, or null if fromString/constructor. */
28
40
  get filePath() {
29
41
  return this.#filePath;
30
42
  }
31
43
 
44
+ /** Write the project back to its original file. Throws if no file path is set. */
32
45
  save() {
33
46
  if (!this.#filePath) throw new Error("No file path set — use open() or save(path)");
34
47
  writeFileSync(this.#filePath, this.toBuild());
@@ -36,4 +49,21 @@ class XcodeProject extends wasm.XcodeProject {
36
49
  }
37
50
 
38
51
  export { XcodeProject };
39
- export const { parse, build, parseAndBuild } = wasm;
52
+
53
+ /**
54
+ * Parse a .pbxproj string into a JSON-compatible object.
55
+ * @type {(text: string) => any}
56
+ */
57
+ export const parse = wasm.parse;
58
+
59
+ /**
60
+ * Serialize a JSON object back to .pbxproj format.
61
+ * @type {(project: object) => string}
62
+ */
63
+ export const build = wasm.build;
64
+
65
+ /**
66
+ * Parse and immediately re-serialize. Stays in WASM, zero marshalling.
67
+ * @type {(text: string) => string}
68
+ */
69
+ export const parseAndBuild = wasm.parseAndBuild;
package/package.json CHANGED
@@ -2,22 +2,19 @@
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.2",
6
6
  "license": "MIT",
7
7
  "files": [
8
8
  "xcode_bg.wasm",
9
9
  "xcode.js",
10
- "xcode_bg.js",
11
10
  "xcode.d.ts",
12
11
  "types.d.ts",
13
- "node-wrapper.js",
14
12
  "node-wrapper.mjs",
15
13
  "node-wrapper.d.ts"
16
14
  ],
17
15
  "main": "xcode.js",
18
16
  "types": "xcode.d.ts",
19
17
  "sideEffects": [
20
- "./xcode.js",
21
18
  "./snippets/*"
22
19
  ],
23
20
  "repository": {
@@ -38,14 +35,14 @@
38
35
  "types": "./types.d.ts"
39
36
  },
40
37
  ".": {
38
+ "types": "./xcode.d.ts",
41
39
  "import": "./xcode.js",
42
- "require": "./xcode.js",
43
- "types": "./xcode.d.ts"
40
+ "default": "./xcode.js"
44
41
  },
45
42
  "./node": {
43
+ "types": "./node-wrapper.d.ts",
46
44
  "import": "./node-wrapper.mjs",
47
- "require": "./node-wrapper.js",
48
- "types": "./node-wrapper.d.ts"
45
+ "default": "./node-wrapper.mjs"
49
46
  }
50
47
  }
51
48
  }
package/xcode.d.ts CHANGED
@@ -64,3 +64,69 @@ export function parse(text: string): any;
64
64
  * Parse and immediately re-serialize a .pbxproj string.
65
65
  */
66
66
  export function parseAndBuild(text: string): string;
67
+
68
+ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
69
+
70
+ export interface InitOutput {
71
+ readonly memory: WebAssembly.Memory;
72
+ readonly __wbg_xcodeproject_free: (a: number, b: number) => void;
73
+ readonly build: (a: number, b: number) => void;
74
+ readonly parse: (a: number, b: number, c: number) => void;
75
+ readonly parseAndBuild: (a: number, b: number, c: number) => void;
76
+ readonly xcodeproject_addBuildFile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
77
+ readonly xcodeproject_addDependency: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
78
+ readonly xcodeproject_addFile: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
79
+ readonly xcodeproject_addFileSystemSyncGroup: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
80
+ readonly xcodeproject_addFramework: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
81
+ readonly xcodeproject_addGroup: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
82
+ readonly xcodeproject_archiveVersion: (a: number) => bigint;
83
+ readonly xcodeproject_createNativeTarget: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number) => void;
84
+ readonly xcodeproject_embedExtension: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
85
+ readonly xcodeproject_ensureBuildPhase: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
86
+ readonly xcodeproject_findMainAppTarget: (a: number, b: number, c: number, d: number) => void;
87
+ readonly xcodeproject_findObjectsByIsa: (a: number, b: number, c: number, d: number) => void;
88
+ readonly xcodeproject_findOrphanedReferences: (a: number, b: number) => void;
89
+ readonly xcodeproject_getBuildSetting: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
90
+ readonly xcodeproject_getGroupChildren: (a: number, b: number, c: number, d: number) => void;
91
+ readonly xcodeproject_getNativeTargets: (a: number, b: number) => void;
92
+ readonly xcodeproject_getObjectProperty: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
93
+ readonly xcodeproject_getTargetName: (a: number, b: number, c: number, d: number) => void;
94
+ readonly xcodeproject_getUniqueId: (a: number, b: number, c: number, d: number) => void;
95
+ readonly xcodeproject_mainGroupUuid: (a: number, b: number) => void;
96
+ readonly xcodeproject_new: (a: number, b: number, c: number) => void;
97
+ readonly xcodeproject_objectVersion: (a: number) => bigint;
98
+ readonly xcodeproject_removeBuildSetting: (a: number, b: number, c: number, d: number, e: number) => number;
99
+ readonly xcodeproject_renameTarget: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
100
+ readonly xcodeproject_setBuildSetting: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
101
+ readonly xcodeproject_setObjectProperty: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => number;
102
+ readonly xcodeproject_setTargetName: (a: number, b: number, c: number, d: number, e: number) => number;
103
+ readonly xcodeproject_toBuild: (a: number, b: number) => void;
104
+ readonly xcodeproject_toJSON: (a: number, b: number) => void;
105
+ readonly __wbindgen_export: (a: number, b: number) => number;
106
+ readonly __wbindgen_export2: (a: number, b: number, c: number, d: number) => number;
107
+ readonly __wbindgen_export3: (a: number) => void;
108
+ readonly __wbindgen_add_to_stack_pointer: (a: number) => number;
109
+ readonly __wbindgen_export4: (a: number, b: number, c: number) => void;
110
+ }
111
+
112
+ export type SyncInitInput = BufferSource | WebAssembly.Module;
113
+
114
+ /**
115
+ * Instantiates the given `module`, which can either be bytes or
116
+ * a precompiled `WebAssembly.Module`.
117
+ *
118
+ * @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
119
+ *
120
+ * @returns {InitOutput}
121
+ */
122
+ export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
123
+
124
+ /**
125
+ * If `module_or_path` is {RequestInfo} or {URL}, makes a request and
126
+ * for everything else, calls `WebAssembly.instantiate` directly.
127
+ *
128
+ * @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
129
+ *
130
+ * @returns {Promise<InitOutput>}
131
+ */
132
+ export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;