macroforge 0.1.41 → 0.1.43

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/index.d.ts CHANGED
@@ -988,8 +988,6 @@ export interface LoadConfigResult {
988
988
  hasForeignTypes: boolean
989
989
  /** Number of foreign types configured. */
990
990
  foreignTypeCount: number
991
- /** Return types mode: "vanilla", "custom", or "effect". */
992
- returnTypes: string
993
991
  }
994
992
 
995
993
  /**
package/index.js CHANGED
@@ -77,8 +77,8 @@ function requireNative() {
77
77
  try {
78
78
  const binding = require('@macroforge/bin-android-arm64')
79
79
  const bindingPackageVersion = require('@macroforge/bin-android-arm64/package.json').version
80
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
80
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
81
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
82
82
  }
83
83
  return binding
84
84
  } catch (e) {
@@ -93,8 +93,8 @@ function requireNative() {
93
93
  try {
94
94
  const binding = require('@macroforge/bin-android-arm-eabi')
95
95
  const bindingPackageVersion = require('@macroforge/bin-android-arm-eabi/package.json').version
96
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
96
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
97
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
98
98
  }
99
99
  return binding
100
100
  } catch (e) {
@@ -114,8 +114,8 @@ function requireNative() {
114
114
  try {
115
115
  const binding = require('@macroforge/bin-win32-x64-gnu')
116
116
  const bindingPackageVersion = require('@macroforge/bin-win32-x64-gnu/package.json').version
117
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
117
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
118
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
119
119
  }
120
120
  return binding
121
121
  } catch (e) {
@@ -130,8 +130,8 @@ function requireNative() {
130
130
  try {
131
131
  const binding = require('@macroforge/bin-win32-x64-msvc')
132
132
  const bindingPackageVersion = require('@macroforge/bin-win32-x64-msvc/package.json').version
133
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
133
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
134
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
135
135
  }
136
136
  return binding
137
137
  } catch (e) {
@@ -147,8 +147,8 @@ function requireNative() {
147
147
  try {
148
148
  const binding = require('@macroforge/bin-win32-ia32-msvc')
149
149
  const bindingPackageVersion = require('@macroforge/bin-win32-ia32-msvc/package.json').version
150
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
150
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
151
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
152
152
  }
153
153
  return binding
154
154
  } catch (e) {
@@ -163,8 +163,8 @@ function requireNative() {
163
163
  try {
164
164
  const binding = require('@macroforge/bin-win32-arm64-msvc')
165
165
  const bindingPackageVersion = require('@macroforge/bin-win32-arm64-msvc/package.json').version
166
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
166
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
167
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
168
168
  }
169
169
  return binding
170
170
  } catch (e) {
@@ -182,8 +182,8 @@ function requireNative() {
182
182
  try {
183
183
  const binding = require('@macroforge/bin-darwin-universal')
184
184
  const bindingPackageVersion = require('@macroforge/bin-darwin-universal/package.json').version
185
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
185
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
186
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
187
187
  }
188
188
  return binding
189
189
  } catch (e) {
@@ -198,8 +198,8 @@ function requireNative() {
198
198
  try {
199
199
  const binding = require('@macroforge/bin-darwin-x64')
200
200
  const bindingPackageVersion = require('@macroforge/bin-darwin-x64/package.json').version
201
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
201
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
202
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
203
203
  }
204
204
  return binding
205
205
  } catch (e) {
@@ -214,8 +214,8 @@ function requireNative() {
214
214
  try {
215
215
  const binding = require('@macroforge/bin-darwin-arm64')
216
216
  const bindingPackageVersion = require('@macroforge/bin-darwin-arm64/package.json').version
217
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
217
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
218
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
219
219
  }
220
220
  return binding
221
221
  } catch (e) {
@@ -234,8 +234,8 @@ function requireNative() {
234
234
  try {
235
235
  const binding = require('@macroforge/bin-freebsd-x64')
236
236
  const bindingPackageVersion = require('@macroforge/bin-freebsd-x64/package.json').version
237
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
237
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
238
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
239
239
  }
240
240
  return binding
241
241
  } catch (e) {
@@ -250,8 +250,8 @@ function requireNative() {
250
250
  try {
251
251
  const binding = require('@macroforge/bin-freebsd-arm64')
252
252
  const bindingPackageVersion = require('@macroforge/bin-freebsd-arm64/package.json').version
253
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
253
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
254
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
255
255
  }
256
256
  return binding
257
257
  } catch (e) {
@@ -271,8 +271,8 @@ function requireNative() {
271
271
  try {
272
272
  const binding = require('@macroforge/bin-linux-x64-musl')
273
273
  const bindingPackageVersion = require('@macroforge/bin-linux-x64-musl/package.json').version
274
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
274
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
275
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
276
276
  }
277
277
  return binding
278
278
  } catch (e) {
@@ -287,8 +287,8 @@ function requireNative() {
287
287
  try {
288
288
  const binding = require('@macroforge/bin-linux-x64-gnu')
289
289
  const bindingPackageVersion = require('@macroforge/bin-linux-x64-gnu/package.json').version
290
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
290
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
291
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
292
292
  }
293
293
  return binding
294
294
  } catch (e) {
@@ -305,8 +305,8 @@ function requireNative() {
305
305
  try {
306
306
  const binding = require('@macroforge/bin-linux-arm64-musl')
307
307
  const bindingPackageVersion = require('@macroforge/bin-linux-arm64-musl/package.json').version
308
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
308
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
309
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
310
310
  }
311
311
  return binding
312
312
  } catch (e) {
@@ -321,8 +321,8 @@ function requireNative() {
321
321
  try {
322
322
  const binding = require('@macroforge/bin-linux-arm64-gnu')
323
323
  const bindingPackageVersion = require('@macroforge/bin-linux-arm64-gnu/package.json').version
324
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
324
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
325
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
326
326
  }
327
327
  return binding
328
328
  } catch (e) {
@@ -339,8 +339,8 @@ function requireNative() {
339
339
  try {
340
340
  const binding = require('@macroforge/bin-linux-arm-musleabihf')
341
341
  const bindingPackageVersion = require('@macroforge/bin-linux-arm-musleabihf/package.json').version
342
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
342
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
343
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
344
344
  }
345
345
  return binding
346
346
  } catch (e) {
@@ -355,8 +355,8 @@ function requireNative() {
355
355
  try {
356
356
  const binding = require('@macroforge/bin-linux-arm-gnueabihf')
357
357
  const bindingPackageVersion = require('@macroforge/bin-linux-arm-gnueabihf/package.json').version
358
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
358
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
359
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
360
360
  }
361
361
  return binding
362
362
  } catch (e) {
@@ -373,8 +373,8 @@ function requireNative() {
373
373
  try {
374
374
  const binding = require('@macroforge/bin-linux-loong64-musl')
375
375
  const bindingPackageVersion = require('@macroforge/bin-linux-loong64-musl/package.json').version
376
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
376
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
377
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
378
378
  }
379
379
  return binding
380
380
  } catch (e) {
@@ -389,8 +389,8 @@ function requireNative() {
389
389
  try {
390
390
  const binding = require('@macroforge/bin-linux-loong64-gnu')
391
391
  const bindingPackageVersion = require('@macroforge/bin-linux-loong64-gnu/package.json').version
392
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
392
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
393
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
394
394
  }
395
395
  return binding
396
396
  } catch (e) {
@@ -407,8 +407,8 @@ function requireNative() {
407
407
  try {
408
408
  const binding = require('@macroforge/bin-linux-riscv64-musl')
409
409
  const bindingPackageVersion = require('@macroforge/bin-linux-riscv64-musl/package.json').version
410
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
410
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
411
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
412
412
  }
413
413
  return binding
414
414
  } catch (e) {
@@ -423,8 +423,8 @@ function requireNative() {
423
423
  try {
424
424
  const binding = require('@macroforge/bin-linux-riscv64-gnu')
425
425
  const bindingPackageVersion = require('@macroforge/bin-linux-riscv64-gnu/package.json').version
426
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
426
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
427
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
428
428
  }
429
429
  return binding
430
430
  } catch (e) {
@@ -440,8 +440,8 @@ function requireNative() {
440
440
  try {
441
441
  const binding = require('@macroforge/bin-linux-ppc64-gnu')
442
442
  const bindingPackageVersion = require('@macroforge/bin-linux-ppc64-gnu/package.json').version
443
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
443
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
444
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
445
445
  }
446
446
  return binding
447
447
  } catch (e) {
@@ -456,8 +456,8 @@ function requireNative() {
456
456
  try {
457
457
  const binding = require('@macroforge/bin-linux-s390x-gnu')
458
458
  const bindingPackageVersion = require('@macroforge/bin-linux-s390x-gnu/package.json').version
459
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
459
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
460
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
461
461
  }
462
462
  return binding
463
463
  } catch (e) {
@@ -476,8 +476,8 @@ function requireNative() {
476
476
  try {
477
477
  const binding = require('@macroforge/bin-openharmony-arm64')
478
478
  const bindingPackageVersion = require('@macroforge/bin-openharmony-arm64/package.json').version
479
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
479
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
480
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
481
481
  }
482
482
  return binding
483
483
  } catch (e) {
@@ -492,8 +492,8 @@ function requireNative() {
492
492
  try {
493
493
  const binding = require('@macroforge/bin-openharmony-x64')
494
494
  const bindingPackageVersion = require('@macroforge/bin-openharmony-x64/package.json').version
495
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
495
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
496
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
497
497
  }
498
498
  return binding
499
499
  } catch (e) {
@@ -508,8 +508,8 @@ function requireNative() {
508
508
  try {
509
509
  const binding = require('@macroforge/bin-openharmony-arm')
510
510
  const bindingPackageVersion = require('@macroforge/bin-openharmony-arm/package.json').version
511
- if (bindingPackageVersion !== '0.1.41' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
- throw new Error(`Native binding package version mismatch, expected 0.1.41 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
511
+ if (bindingPackageVersion !== '0.1.43' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
512
+ throw new Error(`Native binding package version mismatch, expected 0.1.43 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
513
513
  }
514
514
  return binding
515
515
  } catch (e) {
@@ -232,13 +232,11 @@ export interface Serialize<T> {
232
232
  *
233
233
  * @example
234
234
  * ```typescript
235
- * import { Result } from "macroforge/utils";
236
- *
237
- * const result = User.fromStringifiedJSON(json);
238
- * if (Result.isOk(result)) {
235
+ * const result = User.deserialize(data);
236
+ * if (result.success) {
239
237
  * const user = result.value;
240
238
  * } else {
241
- * console.error(result.error); // Validation errors
239
+ * console.error(result.errors); // Validation errors
242
240
  * }
243
241
  * ```
244
242
  */
@@ -242,13 +242,11 @@ export interface Serialize<T> {
242
242
  *
243
243
  * @example
244
244
  * ```typescript
245
- * import { Result } from "macroforge/utils";
246
- *
247
- * const result = User.fromStringifiedJSON(json);
248
- * if (Result.isOk(result)) {
245
+ * const result = User.deserialize(data);
246
+ * if (result.success) {
249
247
  * const user = result.value;
250
248
  * } else {
251
- * console.error(result.error); // Validation errors
249
+ * console.error(result.errors); // Validation errors
252
250
  * }
253
251
  * ```
254
252
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "macroforge",
3
- "version": "0.1.41",
3
+ "version": "0.1.43",
4
4
  "description": "TypeScript macro expansion engine powered by Rust and SWC",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,10 +10,15 @@
10
10
  "require": "./index.js",
11
11
  "default": "./index.js"
12
12
  },
13
- "./utils": {
14
- "types": "./js/utils/index.d.ts",
15
- "import": "./js/utils/index.mjs",
16
- "default": "./js/utils/index.mjs"
13
+ "./reexports": {
14
+ "types": "./js/reexports/index.d.ts",
15
+ "import": "./js/reexports/index.mjs",
16
+ "default": "./js/reexports/index.mjs"
17
+ },
18
+ "./reexports/effect": {
19
+ "types": "./js/reexports/effect.d.ts",
20
+ "import": "./js/reexports/effect.mjs",
21
+ "default": "./js/reexports/effect.mjs"
17
22
  },
18
23
  "./serde": {
19
24
  "types": "./js/serde/index.d.ts",
@@ -60,27 +65,23 @@
60
65
  "index.js",
61
66
  "js"
62
67
  ],
63
- "dependencies": {
64
- "@rydshift/mirror": "^0.1.5"
65
- },
66
68
  "engines": {
67
69
  "node": ">= 18"
68
70
  },
69
71
  "optionalDependencies": {
70
- "@macroforge/bin-darwin-x64": "0.1.41",
71
- "@macroforge/bin-darwin-arm64": "0.1.41",
72
- "@macroforge/bin-linux-x64-gnu": "0.1.41",
73
- "@macroforge/bin-linux-arm64-gnu": "0.1.41",
74
- "@macroforge/bin-win32-x64-msvc": "0.1.41",
75
- "@macroforge/bin-win32-arm64-msvc": "0.1.41"
72
+ "@macroforge/bin-darwin-x64": "0.1.43",
73
+ "@macroforge/bin-darwin-arm64": "0.1.43",
74
+ "@macroforge/bin-linux-x64-gnu": "0.1.43",
75
+ "@macroforge/bin-linux-arm64-gnu": "0.1.43",
76
+ "@macroforge/bin-win32-x64-msvc": "0.1.43",
77
+ "@macroforge/bin-win32-arm64-msvc": "0.1.43"
76
78
  },
77
79
  "scripts": {
78
80
  "build:serde": "bun build js/serde/index.ts --outfile js/serde/index.mjs && bun x tsc js/serde/index.ts --declaration --emitDeclarationOnly --outDir js/serde --lib ES2024 --skipLibCheck",
79
- "build:utils": "bun build js/utils/index.ts --outfile js/utils/index.mjs --external @rydshift/mirror && bun x tsc js/utils/index.ts --declaration --emitDeclarationOnly --outDir js/utils --lib ES2024 --module ESNext --moduleResolution bundler --skipLibCheck",
80
81
  "build:traits": "bun build js/traits/index.ts --outfile js/traits/index.mjs && bun x tsc js/traits/index.ts --declaration --emitDeclarationOnly --outDir js/traits --lib ES2024 --skipLibCheck",
81
- "build:js": "npm run build:serde && npm run build:utils && npm run build:traits",
82
+ "build:js": "npm run build:serde && npm run build:traits",
82
83
  "build": "npm install && npm run build:js && bun x napi build --platform --release",
83
- "clean": "rm -f macroforge.*.node pkg/*.node node_modules",
84
+ "clean": "rm -f macroforge.*.node pkg/*.node && rm -rf node_modules",
84
85
  "cleanbuild": "npm run clean && npm run build",
85
86
  "artifacts": "napi artifacts --npm-dir npm"
86
87
  }
@@ -1,43 +0,0 @@
1
- /**
2
- * # Macroforge Effect Utils Module
3
- *
4
- * This module re-exports Effect library types for use in generated macro code
5
- * when `returnTypes: 'effect'` is configured.
6
- *
7
- * ## Exit<E, A>
8
- *
9
- * Represents the result of a computation that may fail.
10
- * Used by the `Deserialize` macro for validation errors.
11
- *
12
- * ```typescript
13
- * import { Exit } from "macroforge/utils/effect";
14
- *
15
- * const result = User.fromStringifiedJSON(json);
16
- * if (Exit.isSuccess(result)) {
17
- * const user = result.value;
18
- * } else {
19
- * console.error(result.cause); // Array of field errors
20
- * }
21
- * ```
22
- *
23
- * ## Option<A>
24
- *
25
- * Represents an optional value.
26
- * Used by `PartialOrd` macro for incomparable values.
27
- *
28
- * ```typescript
29
- * import { Option } from "macroforge/utils/effect";
30
- *
31
- * const cmp = user1.compareTo(user2);
32
- * if (Option.isSome(cmp)) {
33
- * console.log(cmp.value); // -1, 0, or 1
34
- * } else {
35
- * console.log("Values are incomparable");
36
- * }
37
- * ```
38
- *
39
- * @module macroforge/utils/effect
40
- */
41
-
42
- // Re-export Exit and Option from effect for use in generated code
43
- export { Exit, Option } from "effect";
@@ -1,416 +0,0 @@
1
- /**
2
- * # Macroforge Utils Module
3
- *
4
- * This module provides Rust-like utility types for use in generated macro code.
5
- * It re-exports `Result` and `Option` from `@rydshift/mirror` to provide
6
- * ergonomic error handling and null safety in TypeScript.
7
- *
8
- * ## Result<T, E>
9
- *
10
- * A discriminated union representing either success (`Ok<T>`) or failure (`Err<E>`).
11
- * Used by the `Deserialize` macro for validation errors.
12
- *
13
- * ```typescript
14
- * import { Result } from "macroforge/utils";
15
- *
16
- * const result = User.fromStringifiedJSON(json);
17
- * if (Result.isOk(result)) {
18
- * const user = result.value;
19
- * } else {
20
- * console.error(result.error); // Array of field errors
21
- * }
22
- * ```
23
- *
24
- * ## Option<T>
25
- *
26
- * A discriminated union representing either a value (`Some<T>`) or absence (`None`).
27
- * Used by `PartialOrd` macro for incomparable values.
28
- *
29
- * ```typescript
30
- * import { Option } from "macroforge/utils";
31
- *
32
- * const cmp = user1.compareTo(user2);
33
- * if (Option.isSome(cmp)) {
34
- * console.log(cmp.value); // -1, 0, or 1
35
- * } else {
36
- * console.log("Values are incomparable");
37
- * }
38
- * ```
39
- *
40
- * @module macroforge/utils
41
- */
42
- export { Result, Option } from "@rydshift/mirror/declarative";
43
- /**
44
- * Represents a successful deserialization result.
45
- * Used when `returnTypes: 'vanilla'` is configured.
46
- */
47
- export interface DeserializeSuccess<T> {
48
- readonly success: true;
49
- readonly value: T;
50
- }
51
- /**
52
- * Represents a failed deserialization result with field errors.
53
- * Used when `returnTypes: 'vanilla'` is configured.
54
- */
55
- export interface DeserializeFailure {
56
- readonly success: false;
57
- readonly errors: Array<{
58
- field: string;
59
- message: string;
60
- }>;
61
- }
62
- /**
63
- * A simple discriminated union for deserialization results.
64
- * Used when `returnTypes: 'vanilla'` is configured.
65
- *
66
- * @example
67
- * ```typescript
68
- * const result = userDeserialize(json);
69
- * if (result.success) {
70
- * const user = result.value;
71
- * } else {
72
- * console.error(result.errors);
73
- * }
74
- * ```
75
- */
76
- export type DeserializeResult<T> = DeserializeSuccess<T> | DeserializeFailure;
77
- /**
78
- * Namespace with helper functions for working with vanilla DeserializeResult.
79
- * These mirror the Result API for familiarity.
80
- */
81
- export declare namespace DeserializeResult {
82
- /**
83
- * Creates a successful result.
84
- */
85
- function ok<T>(value: T): DeserializeResult<T>;
86
- /**
87
- * Creates a failed result with errors.
88
- */
89
- function err<T>(errors: Array<{
90
- field: string;
91
- message: string;
92
- }>): DeserializeResult<T>;
93
- /**
94
- * Type guard to check if the result is successful.
95
- */
96
- function isOk<T>(result: DeserializeResult<T>): result is DeserializeSuccess<T>;
97
- /**
98
- * Type guard to check if the result is a failure.
99
- */
100
- function isErr<T>(result: DeserializeResult<T>): result is DeserializeFailure;
101
- /**
102
- * Unwraps the value or throws an error.
103
- */
104
- function unwrap<T>(result: DeserializeResult<T>): T;
105
- /**
106
- * Unwraps the value or returns a default.
107
- */
108
- function unwrapOr<T>(result: DeserializeResult<T>, defaultValue: T): T;
109
- }
110
- /**
111
- *
112
- *
113
- * // Option types
114
-
115
- export interface Some<T> {
116
- readonly tag: "Some";
117
- readonly value: T;
118
- }
119
-
120
- export interface None {
121
- readonly tag: "None";
122
- }
123
-
124
- export type Option<T> = Some<T> | None;
125
-
126
- export namespace Option {
127
- export function some<T>(value: T): Option<T> {
128
- return { tag: "Some", value };
129
- }
130
-
131
- export function none<T>(): Option<T> {
132
- return { tag: "None" };
133
- }
134
-
135
- export function isSome<T>(opt: Option<T>): opt is Some<T> {
136
- return opt.tag === "Some";
137
- }
138
-
139
- export function isNone<T>(opt: Option<T>): opt is None {
140
- return opt.tag === "None";
141
- }
142
-
143
- export function isSomeAnd<T>(opt: Option<T>, f: (value: T) => boolean): boolean {
144
- return isSome(opt) && f(opt.value);
145
- }
146
-
147
- export function isNoneOr<T>(opt: Option<T>, f: (value: T) => boolean): boolean {
148
- return isNone(opt) || f(opt.value);
149
- }
150
-
151
- export function expect<T>(opt: Option<T>, msg: string): T {
152
- if (isSome(opt)) return opt.value;
153
- throw new Error(msg);
154
- }
155
-
156
- export function unwrap<T>(opt: Option<T>): T {
157
- if (isSome(opt)) return opt.value;
158
- throw new Error("called `Option::unwrap()` on a `None` value");
159
- }
160
-
161
- export function unwrapOr<T>(opt: Option<T>, defaultValue: T): T {
162
- return isSome(opt) ? opt.value : defaultValue;
163
- }
164
-
165
- export function unwrapOrElse<T>(opt: Option<T>, f: () => T): T {
166
- return isSome(opt) ? opt.value : f();
167
- }
168
-
169
- export function unwrapOrDefault<T>(opt: Option<T>): T {
170
- return isSome(opt) ? opt.value : ("" as unknown as T);
171
- }
172
-
173
- export function map<T, U>(opt: Option<T>, f: (value: T) => U): Option<U> {
174
- return isSome(opt) ? some(f(opt.value)) : none();
175
- }
176
-
177
- export function mapOr<T, U>(opt: Option<T>, defaultValue: U, f: (value: T) => U): U {
178
- return isSome(opt) ? f(opt.value) : defaultValue;
179
- }
180
-
181
- export function mapOrElse<T, U>(opt: Option<T>, defaultFn: () => U, f: (value: T) => U): U {
182
- return isSome(opt) ? f(opt.value) : defaultFn();
183
- }
184
-
185
- export function inspect<T>(opt: Option<T>, f: (value: T) => void): Option<T> {
186
- if (isSome(opt)) f(opt.value);
187
- return opt;
188
- }
189
-
190
- export function okOr<T, E>(opt: Option<T>, err: E): Result<T, E> {
191
- return isSome(opt) ? Result.ok(opt.value) : Result.err(err);
192
- }
193
-
194
- export function okOrElse<T, E>(opt: Option<T>, errFn: () => E): Result<T, E> {
195
- return isSome(opt) ? Result.ok(opt.value) : Result.err(errFn());
196
- }
197
-
198
- export function and<T, U>(opt: Option<T>, other: Option<U>): Option<U> {
199
- return isSome(opt) ? other : none();
200
- }
201
-
202
- export function andThen<T, U>(opt: Option<T>, f: (value: T) => Option<U>): Option<U> {
203
- return isSome(opt) ? f(opt.value) : none();
204
- }
205
-
206
- export function or<T>(opt: Option<T>, other: Option<T>): Option<T> {
207
- return isSome(opt) ? opt : other;
208
- }
209
-
210
- export function orElse<T>(opt: Option<T>, f: () => Option<T>): Option<T> {
211
- return isSome(opt) ? opt : f();
212
- }
213
-
214
- export function filter<T>(opt: Option<T>, predicate: (value: T) => boolean): Option<T> {
215
- return isSome(opt) && predicate(opt.value) ? opt : none();
216
- }
217
-
218
- export function xor<T>(opt: Option<T>, other: Option<T>): Option<T> {
219
- if (isSome(opt) && isNone(other)) return opt;
220
- if (isNone(opt) && isSome(other)) return other;
221
- return none();
222
- }
223
-
224
- export function zip<T, U>(opt: Option<T>, other: Option<U>): Option<[T, U]> {
225
- return isSome(opt) && isSome(other) ? some([opt.value, other.value]) : none();
226
- }
227
-
228
- export function zipWith<T, U, R>(opt: Option<T>, other: Option<U>, f: (a: T, b: U) => R): Option<R> {
229
- return isSome(opt) && isSome(other) ? some(f(opt.value, other.value)) : none();
230
- }
231
-
232
- export function flatten<T>(opt: Option<Option<T>>): Option<T> {
233
- return isSome(opt) ? opt.value : none();
234
- }
235
-
236
- export function transpose<T, E>(opt: Option<Result<T, E>>): Result<Option<T>, E> {
237
- if (isNone(opt)) return Result.ok(none());
238
- if (Result.isOk(opt.value)) return Result.ok(some(opt.value.value));
239
- return Result.err(opt.value.error);
240
- }
241
-
242
- export function match<T, U>(opt: Option<T>, onSome: (value: T) => U, onNone: () => U): U {
243
- return isSome(opt) ? onSome(opt.value) : onNone();
244
- }
245
- }
246
-
247
- // Result types
248
-
249
- export interface Ok<T> {
250
- readonly tag: "Ok";
251
- readonly value: T;
252
- }
253
-
254
- export interface Err<E> {
255
- readonly tag: "Err";
256
- readonly error: E;
257
- }
258
-
259
- export type Result<T, E> = Ok<T> | Err<E>;
260
-
261
- export namespace Result {
262
- export function ok<T, E = never>(value: T): Result<T, E> {
263
- return { tag: "Ok", value };
264
- }
265
-
266
- export function err<T = never, E = unknown>(error: E): Result<T, E> {
267
- return { tag: "Err", error };
268
- }
269
-
270
- export function isOk<T, E>(res: Result<T, E>): res is Ok<T> {
271
- return res.tag === "Ok";
272
- }
273
-
274
- export function isErr<T, E>(res: Result<T, E>): res is Err<E> {
275
- return res.tag === "Err";
276
- }
277
-
278
- export function isOkAnd<T, E>(res: Result<T, E>, f: (value: T) => boolean): boolean {
279
- return isOk(res) && f(res.value);
280
- }
281
-
282
- export function isErrAnd<T, E>(res: Result<T, E>, f: (error: E) => boolean): boolean {
283
- return isErr(res) && f(res.error);
284
- }
285
-
286
- export function toOk<T, E>(res: Result<T, E>): Option<T> {
287
- return isOk(res) ? Option.some(res.value) : Option.none();
288
- }
289
-
290
- export function toErr<T, E>(res: Result<T, E>): Option<E> {
291
- return isErr(res) ? Option.some(res.error) : Option.none();
292
- }
293
-
294
- export function expect<T, E>(res: Result<T, E>, msg: string): T {
295
- if (isOk(res)) return res.value;
296
- throw new Error(`${msg}: ${res.error}`);
297
- }
298
-
299
- export function expectErr<T, E>(res: Result<T, E>, msg: string): E {
300
- if (isErr(res)) return res.error;
301
- throw new Error(`${msg}: ${res.value}`);
302
- }
303
-
304
- export function unwrap<T, E>(res: Result<T, E>): T {
305
- if (isOk(res)) return res.value;
306
- throw new Error(`called \`Result::unwrap()\` on an \`Err\` value: ${(res as Err<E>).error}`);
307
- }
308
-
309
- export function unwrapErr<T, E>(res: Result<T, E>): E {
310
- if (isErr(res)) return res.error;
311
- throw new Error(`called \`Result::unwrap_err()\` on an \`Ok\` value: ${(res as Ok<T>).value}`);
312
- }
313
-
314
- export function unwrapOr<T, E>(res: Result<T, E>, defaultValue: T): T {
315
- return isOk(res) ? res.value : defaultValue;
316
- }
317
-
318
- export function unwrapOrElse<T, E>(res: Result<T, E>, f: (error: E) => T): T {
319
- return isOk(res) ? res.value : f(res.error);
320
- }
321
-
322
- export function unwrapOrDefault<T, E>(res: Result<T, E>): T {
323
- return isOk(res) ? res.value : ("" as unknown as T);
324
- }
325
-
326
- export function map<T, U, E>(res: Result<T, E>, f: (value: T) => U): Result<U, E> {
327
- return isOk(res) ? ok(f(res.value)) : err(res.error);
328
- }
329
-
330
- export function mapOr<T, U, E>(res: Result<T, E>, defaultValue: U, f: (value: T) => U): U {
331
- return isOk(res) ? f(res.value) : defaultValue;
332
- }
333
-
334
- export function mapOrElse<T, U, E>(res: Result<T, E>, defaultFn: (error: E) => U, f: (value: T) => U): U {
335
- return isOk(res) ? f(res.value) : defaultFn(res.error);
336
- }
337
-
338
- export function mapErr<T, E, F>(res: Result<T, E>, f: (error: E) => F): Result<T, F> {
339
- return isOk(res) ? ok(res.value) : err(f(res.error));
340
- }
341
-
342
- export function inspect<T, E>(res: Result<T, E>, f: (value: T) => void): Result<T, E> {
343
- if (isOk(res)) f(res.value);
344
- return res;
345
- }
346
-
347
- export function inspectErr<T, E>(res: Result<T, E>, f: (error: E) => void): Result<T, E> {
348
- if (isErr(res)) f(res.error);
349
- return res;
350
- }
351
-
352
- export function and<T, U, E>(res: Result<T, E>, other: Result<U, E>): Result<U, E> {
353
- return isOk(res) ? other : err(res.error);
354
- }
355
-
356
- export function andThen<T, U, E>(res: Result<T, E>, f: (value: T) => Result<U, E>): Result<U, E> {
357
- return isOk(res) ? f(res.value) : err(res.error);
358
- }
359
-
360
- export function or<T, E, F>(res: Result<T, E>, other: Result<T, F>): Result<T, F> {
361
- return isOk(res) ? ok(res.value) : other;
362
- }
363
-
364
- export function orElse<T, E, F>(res: Result<T, E>, f: (error: E) => Result<T, F>): Result<T, F> {
365
- return isOk(res) ? ok(res.value) : f(res.error);
366
- }
367
-
368
- export function flatten<T, E>(res: Result<Result<T, E>, E>): Result<T, E> {
369
- return isOk(res) ? res.value : err(res.error);
370
- }
371
-
372
- export function transpose<T, E>(res: Result<Option<T>, E>): Option<Result<T, E>> {
373
- if (isErr(res)) return Option.some(err(res.error));
374
- if (Option.isNone(res.value)) return Option.none();
375
- return Option.some(ok(res.value.value));
376
- }
377
-
378
- export function match<T, E, U>(res: Result<T, E>, onOk: (value: T) => U, onErr: (error: E) => U): U {
379
- return isOk(res) ? onOk(res.value) : onErr(res.error);
380
- }
381
- }
382
-
383
- // ThisError
384
-
385
- export interface ThisError<K extends string = string> {
386
- readonly kind: K;
387
- readonly message: string;
388
- readonly source?: Error;
389
- }
390
-
391
- export namespace ThisError {
392
- export function create<K extends string>(
393
- kind: K,
394
- message: string,
395
- source?: Error,
396
- ): ThisError<K> {
397
- return { kind, message, source };
398
- }
399
-
400
- export function define<K extends string>(kind: K) {
401
- return (message: string, source?: Error): ThisError<K> => ({
402
- kind,
403
- message,
404
- source,
405
- });
406
- }
407
-
408
- export function toError(e: ThisError): Error {
409
- const err = new Error(e.message);
410
- err.name = e.kind;
411
- if (e.source) err.cause = e.source;
412
- return err;
413
- }
414
- }
415
-
416
- */
@@ -1,36 +0,0 @@
1
- // js/utils/index.ts
2
- import { Result, Option } from "@rydshift/mirror/declarative";
3
- var DeserializeResult;
4
- ((DeserializeResult) => {
5
- function ok(value) {
6
- return { success: true, value };
7
- }
8
- DeserializeResult.ok = ok;
9
- function err(errors) {
10
- return { success: false, errors };
11
- }
12
- DeserializeResult.err = err;
13
- function isOk(result) {
14
- return result.success;
15
- }
16
- DeserializeResult.isOk = isOk;
17
- function isErr(result) {
18
- return !result.success;
19
- }
20
- DeserializeResult.isErr = isErr;
21
- function unwrap(result) {
22
- if (result.success)
23
- return result.value;
24
- throw new Error(`Deserialization failed: ${JSON.stringify(result.errors)}`);
25
- }
26
- DeserializeResult.unwrap = unwrap;
27
- function unwrapOr(result, defaultValue) {
28
- return result.success ? result.value : defaultValue;
29
- }
30
- DeserializeResult.unwrapOr = unwrapOr;
31
- })(DeserializeResult ||= {});
32
- export {
33
- Result,
34
- Option,
35
- DeserializeResult
36
- };
package/js/utils/index.ts DELETED
@@ -1,443 +0,0 @@
1
- /**
2
- * # Macroforge Utils Module
3
- *
4
- * This module provides Rust-like utility types for use in generated macro code.
5
- * It re-exports `Result` and `Option` from `@rydshift/mirror` to provide
6
- * ergonomic error handling and null safety in TypeScript.
7
- *
8
- * ## Result<T, E>
9
- *
10
- * A discriminated union representing either success (`Ok<T>`) or failure (`Err<E>`).
11
- * Used by the `Deserialize` macro for validation errors.
12
- *
13
- * ```typescript
14
- * import { Result } from "macroforge/utils";
15
- *
16
- * const result = User.fromStringifiedJSON(json);
17
- * if (Result.isOk(result)) {
18
- * const user = result.value;
19
- * } else {
20
- * console.error(result.error); // Array of field errors
21
- * }
22
- * ```
23
- *
24
- * ## Option<T>
25
- *
26
- * A discriminated union representing either a value (`Some<T>`) or absence (`None`).
27
- * Used by `PartialOrd` macro for incomparable values.
28
- *
29
- * ```typescript
30
- * import { Option } from "macroforge/utils";
31
- *
32
- * const cmp = user1.compareTo(user2);
33
- * if (Option.isSome(cmp)) {
34
- * console.log(cmp.value); // -1, 0, or 1
35
- * } else {
36
- * console.log("Values are incomparable");
37
- * }
38
- * ```
39
- *
40
- * @module macroforge/utils
41
- */
42
-
43
- // Re-export Result and Option from @rydshift/mirror for use in generated code
44
- export { Result, Option } from "@rydshift/mirror/declarative";
45
-
46
- // ============================================================================
47
- // Vanilla Return Types
48
- // ============================================================================
49
- // These types are used when `returnTypes: 'vanilla'` is configured.
50
- // They provide simple discriminated unions without requiring external dependencies.
51
-
52
- /**
53
- * Represents a successful deserialization result.
54
- * Used when `returnTypes: 'vanilla'` is configured.
55
- */
56
- export interface DeserializeSuccess<T> {
57
- readonly success: true;
58
- readonly value: T;
59
- }
60
-
61
- /**
62
- * Represents a failed deserialization result with field errors.
63
- * Used when `returnTypes: 'vanilla'` is configured.
64
- */
65
- export interface DeserializeFailure {
66
- readonly success: false;
67
- readonly errors: Array<{ field: string; message: string }>;
68
- }
69
-
70
- /**
71
- * A simple discriminated union for deserialization results.
72
- * Used when `returnTypes: 'vanilla'` is configured.
73
- *
74
- * @example
75
- * ```typescript
76
- * const result = userDeserialize(json);
77
- * if (result.success) {
78
- * const user = result.value;
79
- * } else {
80
- * console.error(result.errors);
81
- * }
82
- * ```
83
- */
84
- export type DeserializeResult<T> = DeserializeSuccess<T> | DeserializeFailure;
85
-
86
- /**
87
- * Namespace with helper functions for working with vanilla DeserializeResult.
88
- * These mirror the Result API for familiarity.
89
- */
90
- export namespace DeserializeResult {
91
- /**
92
- * Creates a successful result.
93
- */
94
- export function ok<T>(value: T): DeserializeResult<T> {
95
- return { success: true, value };
96
- }
97
-
98
- /**
99
- * Creates a failed result with errors.
100
- */
101
- export function err<T>(errors: Array<{ field: string; message: string }>): DeserializeResult<T> {
102
- return { success: false, errors };
103
- }
104
-
105
- /**
106
- * Type guard to check if the result is successful.
107
- */
108
- export function isOk<T>(result: DeserializeResult<T>): result is DeserializeSuccess<T> {
109
- return result.success;
110
- }
111
-
112
- /**
113
- * Type guard to check if the result is a failure.
114
- */
115
- export function isErr<T>(result: DeserializeResult<T>): result is DeserializeFailure {
116
- return !result.success;
117
- }
118
-
119
- /**
120
- * Unwraps the value or throws an error.
121
- */
122
- export function unwrap<T>(result: DeserializeResult<T>): T {
123
- if (result.success) return result.value;
124
- throw new Error(
125
- `Deserialization failed: ${JSON.stringify((result as DeserializeFailure).errors)}`,
126
- );
127
- }
128
-
129
- /**
130
- * Unwraps the value or returns a default.
131
- */
132
- export function unwrapOr<T>(result: DeserializeResult<T>, defaultValue: T): T {
133
- return result.success ? result.value : defaultValue;
134
- }
135
- }
136
-
137
- /**
138
- *
139
- *
140
- * // Option types
141
-
142
- export interface Some<T> {
143
- readonly tag: "Some";
144
- readonly value: T;
145
- }
146
-
147
- export interface None {
148
- readonly tag: "None";
149
- }
150
-
151
- export type Option<T> = Some<T> | None;
152
-
153
- export namespace Option {
154
- export function some<T>(value: T): Option<T> {
155
- return { tag: "Some", value };
156
- }
157
-
158
- export function none<T>(): Option<T> {
159
- return { tag: "None" };
160
- }
161
-
162
- export function isSome<T>(opt: Option<T>): opt is Some<T> {
163
- return opt.tag === "Some";
164
- }
165
-
166
- export function isNone<T>(opt: Option<T>): opt is None {
167
- return opt.tag === "None";
168
- }
169
-
170
- export function isSomeAnd<T>(opt: Option<T>, f: (value: T) => boolean): boolean {
171
- return isSome(opt) && f(opt.value);
172
- }
173
-
174
- export function isNoneOr<T>(opt: Option<T>, f: (value: T) => boolean): boolean {
175
- return isNone(opt) || f(opt.value);
176
- }
177
-
178
- export function expect<T>(opt: Option<T>, msg: string): T {
179
- if (isSome(opt)) return opt.value;
180
- throw new Error(msg);
181
- }
182
-
183
- export function unwrap<T>(opt: Option<T>): T {
184
- if (isSome(opt)) return opt.value;
185
- throw new Error("called `Option::unwrap()` on a `None` value");
186
- }
187
-
188
- export function unwrapOr<T>(opt: Option<T>, defaultValue: T): T {
189
- return isSome(opt) ? opt.value : defaultValue;
190
- }
191
-
192
- export function unwrapOrElse<T>(opt: Option<T>, f: () => T): T {
193
- return isSome(opt) ? opt.value : f();
194
- }
195
-
196
- export function unwrapOrDefault<T>(opt: Option<T>): T {
197
- return isSome(opt) ? opt.value : ("" as unknown as T);
198
- }
199
-
200
- export function map<T, U>(opt: Option<T>, f: (value: T) => U): Option<U> {
201
- return isSome(opt) ? some(f(opt.value)) : none();
202
- }
203
-
204
- export function mapOr<T, U>(opt: Option<T>, defaultValue: U, f: (value: T) => U): U {
205
- return isSome(opt) ? f(opt.value) : defaultValue;
206
- }
207
-
208
- export function mapOrElse<T, U>(opt: Option<T>, defaultFn: () => U, f: (value: T) => U): U {
209
- return isSome(opt) ? f(opt.value) : defaultFn();
210
- }
211
-
212
- export function inspect<T>(opt: Option<T>, f: (value: T) => void): Option<T> {
213
- if (isSome(opt)) f(opt.value);
214
- return opt;
215
- }
216
-
217
- export function okOr<T, E>(opt: Option<T>, err: E): Result<T, E> {
218
- return isSome(opt) ? Result.ok(opt.value) : Result.err(err);
219
- }
220
-
221
- export function okOrElse<T, E>(opt: Option<T>, errFn: () => E): Result<T, E> {
222
- return isSome(opt) ? Result.ok(opt.value) : Result.err(errFn());
223
- }
224
-
225
- export function and<T, U>(opt: Option<T>, other: Option<U>): Option<U> {
226
- return isSome(opt) ? other : none();
227
- }
228
-
229
- export function andThen<T, U>(opt: Option<T>, f: (value: T) => Option<U>): Option<U> {
230
- return isSome(opt) ? f(opt.value) : none();
231
- }
232
-
233
- export function or<T>(opt: Option<T>, other: Option<T>): Option<T> {
234
- return isSome(opt) ? opt : other;
235
- }
236
-
237
- export function orElse<T>(opt: Option<T>, f: () => Option<T>): Option<T> {
238
- return isSome(opt) ? opt : f();
239
- }
240
-
241
- export function filter<T>(opt: Option<T>, predicate: (value: T) => boolean): Option<T> {
242
- return isSome(opt) && predicate(opt.value) ? opt : none();
243
- }
244
-
245
- export function xor<T>(opt: Option<T>, other: Option<T>): Option<T> {
246
- if (isSome(opt) && isNone(other)) return opt;
247
- if (isNone(opt) && isSome(other)) return other;
248
- return none();
249
- }
250
-
251
- export function zip<T, U>(opt: Option<T>, other: Option<U>): Option<[T, U]> {
252
- return isSome(opt) && isSome(other) ? some([opt.value, other.value]) : none();
253
- }
254
-
255
- export function zipWith<T, U, R>(opt: Option<T>, other: Option<U>, f: (a: T, b: U) => R): Option<R> {
256
- return isSome(opt) && isSome(other) ? some(f(opt.value, other.value)) : none();
257
- }
258
-
259
- export function flatten<T>(opt: Option<Option<T>>): Option<T> {
260
- return isSome(opt) ? opt.value : none();
261
- }
262
-
263
- export function transpose<T, E>(opt: Option<Result<T, E>>): Result<Option<T>, E> {
264
- if (isNone(opt)) return Result.ok(none());
265
- if (Result.isOk(opt.value)) return Result.ok(some(opt.value.value));
266
- return Result.err(opt.value.error);
267
- }
268
-
269
- export function match<T, U>(opt: Option<T>, onSome: (value: T) => U, onNone: () => U): U {
270
- return isSome(opt) ? onSome(opt.value) : onNone();
271
- }
272
- }
273
-
274
- // Result types
275
-
276
- export interface Ok<T> {
277
- readonly tag: "Ok";
278
- readonly value: T;
279
- }
280
-
281
- export interface Err<E> {
282
- readonly tag: "Err";
283
- readonly error: E;
284
- }
285
-
286
- export type Result<T, E> = Ok<T> | Err<E>;
287
-
288
- export namespace Result {
289
- export function ok<T, E = never>(value: T): Result<T, E> {
290
- return { tag: "Ok", value };
291
- }
292
-
293
- export function err<T = never, E = unknown>(error: E): Result<T, E> {
294
- return { tag: "Err", error };
295
- }
296
-
297
- export function isOk<T, E>(res: Result<T, E>): res is Ok<T> {
298
- return res.tag === "Ok";
299
- }
300
-
301
- export function isErr<T, E>(res: Result<T, E>): res is Err<E> {
302
- return res.tag === "Err";
303
- }
304
-
305
- export function isOkAnd<T, E>(res: Result<T, E>, f: (value: T) => boolean): boolean {
306
- return isOk(res) && f(res.value);
307
- }
308
-
309
- export function isErrAnd<T, E>(res: Result<T, E>, f: (error: E) => boolean): boolean {
310
- return isErr(res) && f(res.error);
311
- }
312
-
313
- export function toOk<T, E>(res: Result<T, E>): Option<T> {
314
- return isOk(res) ? Option.some(res.value) : Option.none();
315
- }
316
-
317
- export function toErr<T, E>(res: Result<T, E>): Option<E> {
318
- return isErr(res) ? Option.some(res.error) : Option.none();
319
- }
320
-
321
- export function expect<T, E>(res: Result<T, E>, msg: string): T {
322
- if (isOk(res)) return res.value;
323
- throw new Error(`${msg}: ${res.error}`);
324
- }
325
-
326
- export function expectErr<T, E>(res: Result<T, E>, msg: string): E {
327
- if (isErr(res)) return res.error;
328
- throw new Error(`${msg}: ${res.value}`);
329
- }
330
-
331
- export function unwrap<T, E>(res: Result<T, E>): T {
332
- if (isOk(res)) return res.value;
333
- throw new Error(`called \`Result::unwrap()\` on an \`Err\` value: ${(res as Err<E>).error}`);
334
- }
335
-
336
- export function unwrapErr<T, E>(res: Result<T, E>): E {
337
- if (isErr(res)) return res.error;
338
- throw new Error(`called \`Result::unwrap_err()\` on an \`Ok\` value: ${(res as Ok<T>).value}`);
339
- }
340
-
341
- export function unwrapOr<T, E>(res: Result<T, E>, defaultValue: T): T {
342
- return isOk(res) ? res.value : defaultValue;
343
- }
344
-
345
- export function unwrapOrElse<T, E>(res: Result<T, E>, f: (error: E) => T): T {
346
- return isOk(res) ? res.value : f(res.error);
347
- }
348
-
349
- export function unwrapOrDefault<T, E>(res: Result<T, E>): T {
350
- return isOk(res) ? res.value : ("" as unknown as T);
351
- }
352
-
353
- export function map<T, U, E>(res: Result<T, E>, f: (value: T) => U): Result<U, E> {
354
- return isOk(res) ? ok(f(res.value)) : err(res.error);
355
- }
356
-
357
- export function mapOr<T, U, E>(res: Result<T, E>, defaultValue: U, f: (value: T) => U): U {
358
- return isOk(res) ? f(res.value) : defaultValue;
359
- }
360
-
361
- export function mapOrElse<T, U, E>(res: Result<T, E>, defaultFn: (error: E) => U, f: (value: T) => U): U {
362
- return isOk(res) ? f(res.value) : defaultFn(res.error);
363
- }
364
-
365
- export function mapErr<T, E, F>(res: Result<T, E>, f: (error: E) => F): Result<T, F> {
366
- return isOk(res) ? ok(res.value) : err(f(res.error));
367
- }
368
-
369
- export function inspect<T, E>(res: Result<T, E>, f: (value: T) => void): Result<T, E> {
370
- if (isOk(res)) f(res.value);
371
- return res;
372
- }
373
-
374
- export function inspectErr<T, E>(res: Result<T, E>, f: (error: E) => void): Result<T, E> {
375
- if (isErr(res)) f(res.error);
376
- return res;
377
- }
378
-
379
- export function and<T, U, E>(res: Result<T, E>, other: Result<U, E>): Result<U, E> {
380
- return isOk(res) ? other : err(res.error);
381
- }
382
-
383
- export function andThen<T, U, E>(res: Result<T, E>, f: (value: T) => Result<U, E>): Result<U, E> {
384
- return isOk(res) ? f(res.value) : err(res.error);
385
- }
386
-
387
- export function or<T, E, F>(res: Result<T, E>, other: Result<T, F>): Result<T, F> {
388
- return isOk(res) ? ok(res.value) : other;
389
- }
390
-
391
- export function orElse<T, E, F>(res: Result<T, E>, f: (error: E) => Result<T, F>): Result<T, F> {
392
- return isOk(res) ? ok(res.value) : f(res.error);
393
- }
394
-
395
- export function flatten<T, E>(res: Result<Result<T, E>, E>): Result<T, E> {
396
- return isOk(res) ? res.value : err(res.error);
397
- }
398
-
399
- export function transpose<T, E>(res: Result<Option<T>, E>): Option<Result<T, E>> {
400
- if (isErr(res)) return Option.some(err(res.error));
401
- if (Option.isNone(res.value)) return Option.none();
402
- return Option.some(ok(res.value.value));
403
- }
404
-
405
- export function match<T, E, U>(res: Result<T, E>, onOk: (value: T) => U, onErr: (error: E) => U): U {
406
- return isOk(res) ? onOk(res.value) : onErr(res.error);
407
- }
408
- }
409
-
410
- // ThisError
411
-
412
- export interface ThisError<K extends string = string> {
413
- readonly kind: K;
414
- readonly message: string;
415
- readonly source?: Error;
416
- }
417
-
418
- export namespace ThisError {
419
- export function create<K extends string>(
420
- kind: K,
421
- message: string,
422
- source?: Error,
423
- ): ThisError<K> {
424
- return { kind, message, source };
425
- }
426
-
427
- export function define<K extends string>(kind: K) {
428
- return (message: string, source?: Error): ThisError<K> => ({
429
- kind,
430
- message,
431
- source,
432
- });
433
- }
434
-
435
- export function toError(e: ThisError): Error {
436
- const err = new Error(e.message);
437
- err.name = e.kind;
438
- if (e.source) err.cause = e.source;
439
- return err;
440
- }
441
- }
442
-
443
- */