macroforge 0.1.75 → 0.1.77

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.
@@ -155,6 +155,18 @@ export interface DeserializeContext {
155
155
  * Call this after `applyPatches()` if immutable objects are desired.
156
156
  */
157
157
  freezeAll(): void;
158
+ /**
159
+ * Pushes validation errors onto the context.
160
+ * Called by `deserializeWithContext` instead of throwing.
161
+ * @param errors - Array of field validation errors to accumulate
162
+ */
163
+ pushErrors(errors: FieldError[]): void;
164
+ /**
165
+ * Returns all accumulated validation errors.
166
+ * Called by the wrapper `deserialize` function after processing.
167
+ * @returns Array of all accumulated field errors
168
+ */
169
+ getErrors(): FieldError[];
158
170
  }
159
171
  /**
160
172
  * Factory functions for creating deserialization contexts.
@@ -21,6 +21,7 @@ var DeserializeContext;
21
21
  const registry = /* @__PURE__ */ new Map();
22
22
  const patches = [];
23
23
  const toFreeze = [];
24
+ const errors = [];
24
25
  return {
25
26
  register: (id, instance) => {
26
27
  registry.set(id, instance);
@@ -57,7 +58,13 @@ var DeserializeContext;
57
58
  for (const obj of toFreeze) {
58
59
  Object.freeze(obj);
59
60
  }
60
- }
61
+ },
62
+ pushErrors: (errs) => {
63
+ for (const e of errs) {
64
+ errors.push(e);
65
+ }
66
+ },
67
+ getErrors: () => errors
61
68
  };
62
69
  }
63
70
  DeserializeContext2.create = create;
package/js/serde/index.ts CHANGED
@@ -184,6 +184,20 @@ export interface DeserializeContext {
184
184
  * Call this after `applyPatches()` if immutable objects are desired.
185
185
  */
186
186
  freezeAll(): void;
187
+
188
+ /**
189
+ * Pushes validation errors onto the context.
190
+ * Called by `deserializeWithContext` instead of throwing.
191
+ * @param errors - Array of field validation errors to accumulate
192
+ */
193
+ pushErrors(errors: FieldError[]): void;
194
+
195
+ /**
196
+ * Returns all accumulated validation errors.
197
+ * Called by the wrapper `deserialize` function after processing.
198
+ * @returns Array of all accumulated field errors
199
+ */
200
+ getErrors(): FieldError[];
187
201
  }
188
202
 
189
203
  /**
@@ -221,6 +235,7 @@ export namespace DeserializeContext {
221
235
  { target: any; prop: string | number; refId: number }
222
236
  > = [];
223
237
  const toFreeze: object[] = [];
238
+ const errors: FieldError[] = [];
224
239
 
225
240
  return {
226
241
  register: (id, instance) => {
@@ -265,6 +280,14 @@ export namespace DeserializeContext {
265
280
  Object.freeze(obj);
266
281
  }
267
282
  },
283
+
284
+ pushErrors: (errs) => {
285
+ for (const e of errs) {
286
+ errors.push(e);
287
+ }
288
+ },
289
+
290
+ getErrors: () => errors,
268
291
  };
269
292
  }
270
293
  }
package/package.json CHANGED
@@ -3,6 +3,9 @@
3
3
  "bugs": {
4
4
  "url": "https://github.com/macroforge-ts/core/issues"
5
5
  },
6
+ "dependencies": {
7
+ "@napi-rs/cli": "^3.5.1"
8
+ },
6
9
  "description": "TypeScript macro expansion engine powered by Rust and SWC",
7
10
  "engines": {
8
11
  "node": ">= 18"
@@ -63,12 +66,12 @@
63
66
  ]
64
67
  },
65
68
  "optionalDependencies": {
66
- "@macroforge/bin-darwin-arm64": "0.1.75",
67
- "@macroforge/bin-darwin-x64": "0.1.75",
68
- "@macroforge/bin-linux-arm64-gnu": "0.1.75",
69
- "@macroforge/bin-linux-x64-gnu": "0.1.75",
70
- "@macroforge/bin-win32-arm64-msvc": "0.1.75",
71
- "@macroforge/bin-win32-x64-msvc": "0.1.75"
69
+ "@macroforge/bin-darwin-arm64": "0.1.77",
70
+ "@macroforge/bin-darwin-x64": "0.1.77",
71
+ "@macroforge/bin-linux-arm64-gnu": "0.1.77",
72
+ "@macroforge/bin-linux-x64-gnu": "0.1.77",
73
+ "@macroforge/bin-win32-arm64-msvc": "0.1.77",
74
+ "@macroforge/bin-win32-x64-msvc": "0.1.77"
72
75
  },
73
76
  "repository": {
74
77
  "type": "git",
@@ -76,7 +79,7 @@
76
79
  },
77
80
  "scripts": {
78
81
  "artifacts": "napi artifacts --npm-dir npm",
79
- "build": "deno install --node-modules-dir && deno task build:js && deno run -A npm:@napi-rs/cli/napi build --platform --release",
82
+ "build": "deno install --node-modules-dir && deno task build:js && deno run -A npm:@napi-rs/cli/napi build --platform --release && cargo install --path . --force",
80
83
  "build:js": "deno task build:serde && deno task build:traits",
81
84
  "build:serde": "deno run -A npm:esbuild js/serde/index.ts --bundle --outfile=js/serde/index.mjs --format=esm && deno run -A npm:typescript/tsc js/serde/index.ts --declaration --emitDeclarationOnly --outDir js/serde --lib ES2024 --skipLibCheck",
82
85
  "build:traits": "deno run -A npm:esbuild js/traits/index.ts --bundle --outfile=js/traits/index.mjs --format=esm && deno run -A npm:typescript/tsc js/traits/index.ts --declaration --emitDeclarationOnly --outDir js/traits --lib ES2024 --skipLibCheck",
@@ -85,5 +88,5 @@
85
88
  },
86
89
  "type": "commonjs",
87
90
  "types": "index.d.ts",
88
- "version": "0.1.75"
91
+ "version": "0.1.77"
89
92
  }