macroforge 0.1.65 → 0.1.72
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 +17 -12
- package/index.js +58 -54
- package/js/serde/index.mjs +24 -18
- package/js/serde/index.ts +3 -1
- package/package.json +83 -82
package/README.md
CHANGED
|
@@ -5,23 +5,23 @@ TypeScript macro expansion engine - write compile-time macros in Rust
|
|
|
5
5
|
[](https://crates.io/crates/macroforge_ts)
|
|
6
6
|
[](https://docs.rs/macroforge_ts)
|
|
7
7
|
|
|
8
|
-
This crate provides a TypeScript macro expansion engine that brings Rust-like derive macros
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
This crate provides a TypeScript macro expansion engine that brings Rust-like derive macros to
|
|
9
|
+
TypeScript. It is designed to be used via NAPI bindings from Node.js, enabling compile-time code
|
|
10
|
+
generation for TypeScript projects.
|
|
11
11
|
|
|
12
12
|
## Overview
|
|
13
13
|
|
|
14
|
-
Macroforge processes TypeScript source files containing `@derive` decorators and expands them
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
Macroforge processes TypeScript source files containing `@derive` decorators and expands them into
|
|
15
|
+
concrete implementations. For example, a class decorated with `@derive(Debug, Clone)` will have
|
|
16
|
+
`toString()` and `clone()` methods automatically generated.
|
|
17
17
|
|
|
18
18
|
## Architecture
|
|
19
19
|
|
|
20
20
|
The crate is organized into several key components:
|
|
21
21
|
|
|
22
22
|
- **NAPI Bindings** (`NativePlugin`, `expand_sync`, `transform_sync`): Entry points for Node.js
|
|
23
|
-
- **Position Mapping** (`NativePositionMapper`, `NativeMapper`): Bidirectional source mapping
|
|
24
|
-
|
|
23
|
+
- **Position Mapping** (`NativePositionMapper`, `NativeMapper`): Bidirectional source mapping for
|
|
24
|
+
IDE integration
|
|
25
25
|
- **Macro Host** (`host` module): Core expansion engine with registry and dispatcher
|
|
26
26
|
- **Built-in Macros** (`builtin` module): Standard derive macros (Debug, Clone, Serialize, etc.)
|
|
27
27
|
|
|
@@ -50,6 +50,7 @@ const result = expand_sync(code, filepath, { keep_decorators: false });
|
|
|
50
50
|
## Re-exports for Macro Authors
|
|
51
51
|
|
|
52
52
|
This crate re-exports several dependencies for convenience when writing custom macros:
|
|
53
|
+
|
|
53
54
|
- `ts_syn`: TypeScript syntax types for AST manipulation
|
|
54
55
|
- `macros`: Macro attributes and quote templates
|
|
55
56
|
- `swc_core`, `swc_common`, `swc_ecma_ast`: SWC compiler infrastructure
|
|
@@ -69,7 +70,8 @@ macroforge_ts = "0.1.38"
|
|
|
69
70
|
|
|
70
71
|
- **`TransformResult`** - Result of transforming TypeScript code through the macro system.
|
|
71
72
|
- **`MacroDiagnostic`** - A diagnostic message produced during macro expansion.
|
|
72
|
-
- **`MappingSegmentResult`** - A segment mapping a range in the original source to a range in the
|
|
73
|
+
- **`MappingSegmentResult`** - A segment mapping a range in the original source to a range in the
|
|
74
|
+
expanded source.
|
|
73
75
|
- **`GeneratedRegionResult`** - A region in the expanded source that was generated by a macro.
|
|
74
76
|
- **`SourceMappingResult`** - Complete source mapping information for a macro expansion.
|
|
75
77
|
- **`ExpandResult`** - Result of expanding macros in TypeScript source code.
|
|
@@ -84,8 +86,10 @@ macroforge_ts = "0.1.38"
|
|
|
84
86
|
- **`unchanged`** - Creates a no-op result with the original code unchanged.
|
|
85
87
|
- **`new`** - Creates a new position mapper from source mapping data.
|
|
86
88
|
- **`is_empty`** - Checks if this mapper has no mapping data.
|
|
87
|
-
- **`original_to_expanded`** - Converts a position in the original source to the corresponding
|
|
88
|
-
|
|
89
|
+
- **`original_to_expanded`** - Converts a position in the original source to the corresponding
|
|
90
|
+
position in expanded source.
|
|
91
|
+
- **`expanded_to_original`** - Converts a position in the expanded source back to the original
|
|
92
|
+
source position.
|
|
89
93
|
- **`generated_by`** - Returns the name of the macro that generated code at the given position.
|
|
90
94
|
- **`map_span_to_original`** - Maps a span (start + length) from expanded source to original source.
|
|
91
95
|
- **`map_span_to_expanded`** - Maps a span (start + length) from original source to expanded source.
|
|
@@ -95,7 +99,8 @@ macroforge_ts = "0.1.38"
|
|
|
95
99
|
|
|
96
100
|
## API Reference
|
|
97
101
|
|
|
98
|
-
See the [full API documentation](https://macroforge.dev/docs/api/reference/rust/macroforge_ts) on
|
|
102
|
+
See the [full API documentation](https://macroforge.dev/docs/api/reference/rust/macroforge_ts) on
|
|
103
|
+
the Macroforge website.
|
|
99
104
|
|
|
100
105
|
## License
|
|
101
106
|
|
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.
|
|
81
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
80
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
97
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
96
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
118
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
117
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
134
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
133
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
150
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
167
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
166
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
186
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
185
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
202
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
201
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
218
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
217
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
238
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
237
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
254
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
253
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
275
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
274
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
291
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
290
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
309
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
308
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
325
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
324
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
343
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
342
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
359
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
358
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
377
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
376
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
393
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
392
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
411
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
410
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
427
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
426
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
443
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
459
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
480
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
479
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
496
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
495
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 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.
|
|
512
|
-
throw new Error(`Native binding package version mismatch, expected 0.1.
|
|
511
|
+
if (bindingPackageVersion !== '0.1.72' && 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.72 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
513
513
|
}
|
|
514
514
|
return binding
|
|
515
515
|
} catch (e) {
|
|
@@ -536,13 +536,17 @@ if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
|
536
536
|
wasiBindingError = err
|
|
537
537
|
}
|
|
538
538
|
}
|
|
539
|
-
if (!nativeBinding) {
|
|
539
|
+
if (!nativeBinding || process.env.NAPI_RS_FORCE_WASI) {
|
|
540
540
|
try {
|
|
541
541
|
wasiBinding = require('@macroforge/bin-wasm32-wasi')
|
|
542
542
|
nativeBinding = wasiBinding
|
|
543
543
|
} catch (err) {
|
|
544
544
|
if (process.env.NAPI_RS_FORCE_WASI) {
|
|
545
|
-
wasiBindingError
|
|
545
|
+
if (!wasiBindingError) {
|
|
546
|
+
wasiBindingError = err
|
|
547
|
+
} else {
|
|
548
|
+
wasiBindingError.cause = err
|
|
549
|
+
}
|
|
546
550
|
loadErrors.push(err)
|
|
547
551
|
}
|
|
548
552
|
}
|
package/js/serde/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// js/serde/index.ts
|
|
2
2
|
var SerializeContext;
|
|
3
|
-
((
|
|
3
|
+
((SerializeContext2) => {
|
|
4
4
|
function create() {
|
|
5
|
-
const ids = new WeakMap;
|
|
5
|
+
const ids = /* @__PURE__ */ new WeakMap();
|
|
6
6
|
let nextId = 0;
|
|
7
7
|
return {
|
|
8
8
|
getId: (obj) => ids.get(obj),
|
|
@@ -13,12 +13,12 @@ var SerializeContext;
|
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
|
-
|
|
17
|
-
})(SerializeContext
|
|
16
|
+
SerializeContext2.create = create;
|
|
17
|
+
})(SerializeContext || (SerializeContext = {}));
|
|
18
18
|
var DeserializeContext;
|
|
19
|
-
((
|
|
19
|
+
((DeserializeContext2) => {
|
|
20
20
|
function create() {
|
|
21
|
-
const registry = new Map;
|
|
21
|
+
const registry = /* @__PURE__ */ new Map();
|
|
22
22
|
const patches = [];
|
|
23
23
|
const toFreeze = [];
|
|
24
24
|
return {
|
|
@@ -60,32 +60,38 @@ var DeserializeContext;
|
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
})(DeserializeContext
|
|
63
|
+
DeserializeContext2.create = create;
|
|
64
|
+
})(DeserializeContext || (DeserializeContext = {}));
|
|
65
65
|
var PendingRef;
|
|
66
|
-
((
|
|
66
|
+
((PendingRef2) => {
|
|
67
67
|
function create(id) {
|
|
68
68
|
return { __pendingRef: true, id };
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
PendingRef2.create = create;
|
|
71
71
|
function is(value) {
|
|
72
72
|
return value !== null && typeof value === "object" && value.__pendingRef === true && typeof value.id === "number";
|
|
73
73
|
}
|
|
74
|
-
|
|
75
|
-
})(PendingRef
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
PendingRef2.is = is;
|
|
75
|
+
})(PendingRef || (PendingRef = {}));
|
|
76
|
+
var DeserializeError = class extends Error {
|
|
77
|
+
/**
|
|
78
|
+
* Array of field-level validation errors.
|
|
79
|
+
*/
|
|
78
80
|
errors;
|
|
81
|
+
/**
|
|
82
|
+
* Creates a new deserialization error.
|
|
83
|
+
* @param errors - Array of field validation errors
|
|
84
|
+
*/
|
|
79
85
|
constructor(errors) {
|
|
80
86
|
const message = errors.map((e) => `${e.field}: ${e.message}`).join("; ");
|
|
81
87
|
super(message);
|
|
82
88
|
this.name = "DeserializeError";
|
|
83
89
|
this.errors = errors;
|
|
84
90
|
}
|
|
85
|
-
}
|
|
91
|
+
};
|
|
86
92
|
export {
|
|
87
|
-
|
|
88
|
-
PendingRef,
|
|
93
|
+
DeserializeContext,
|
|
89
94
|
DeserializeError,
|
|
90
|
-
|
|
95
|
+
PendingRef,
|
|
96
|
+
SerializeContext
|
|
91
97
|
};
|
package/js/serde/index.ts
CHANGED
|
@@ -217,7 +217,9 @@ export namespace DeserializeContext {
|
|
|
217
217
|
*/
|
|
218
218
|
export function create(): DeserializeContext {
|
|
219
219
|
const registry = new Map<number, any>();
|
|
220
|
-
const patches: Array<
|
|
220
|
+
const patches: Array<
|
|
221
|
+
{ target: any; prop: string | number; refId: number }
|
|
222
|
+
> = [];
|
|
221
223
|
const toFreeze: object[] = [];
|
|
222
224
|
|
|
223
225
|
return {
|
package/package.json
CHANGED
|
@@ -1,88 +1,89 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
},
|
|
6
|
-
"description": "TypeScript macro expansion engine powered by Rust and SWC",
|
|
7
|
-
"engines": {
|
|
8
|
-
"node": ">= 18"
|
|
9
|
-
},
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"default": "./index.js",
|
|
13
|
-
"require": "./index.js",
|
|
14
|
-
"types": "./index.d.ts"
|
|
2
|
+
"author": "macroforge contributors",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/macroforge-ts/core/issues"
|
|
15
5
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"types": "./js/reexports/index.d.ts"
|
|
6
|
+
"description": "TypeScript macro expansion engine powered by Rust and SWC",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">= 18"
|
|
20
9
|
},
|
|
21
|
-
"
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"default": "./index.js",
|
|
13
|
+
"require": "./index.js",
|
|
14
|
+
"types": "./index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./reexports": {
|
|
17
|
+
"default": "./js/reexports/index.mjs",
|
|
18
|
+
"import": "./js/reexports/index.mjs",
|
|
19
|
+
"types": "./js/reexports/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./reexports/effect": {
|
|
22
|
+
"default": "./js/reexports/effect.mjs",
|
|
23
|
+
"import": "./js/reexports/effect.mjs",
|
|
24
|
+
"types": "./js/reexports/effect.d.ts"
|
|
25
|
+
},
|
|
26
|
+
"./serde": {
|
|
27
|
+
"default": "./js/serde/index.mjs",
|
|
28
|
+
"import": "./js/serde/index.mjs",
|
|
29
|
+
"types": "./js/serde/index.d.ts"
|
|
30
|
+
},
|
|
31
|
+
"./traits": {
|
|
32
|
+
"default": "./js/traits/index.mjs",
|
|
33
|
+
"import": "./js/traits/index.mjs",
|
|
34
|
+
"types": "./js/traits/index.d.ts"
|
|
35
|
+
}
|
|
25
36
|
},
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
"files": [
|
|
38
|
+
"index.d.ts",
|
|
39
|
+
"index.js",
|
|
40
|
+
"js"
|
|
41
|
+
],
|
|
42
|
+
"homepage": "https://github.com/macroforge-ts/core#readme",
|
|
43
|
+
"keywords": [
|
|
44
|
+
"typescript",
|
|
45
|
+
"macros",
|
|
46
|
+
"derive",
|
|
47
|
+
"codegen",
|
|
48
|
+
"swc"
|
|
49
|
+
],
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"main": "index.js",
|
|
52
|
+
"name": "macroforge",
|
|
53
|
+
"napi": {
|
|
54
|
+
"binaryName": "macroforge",
|
|
55
|
+
"packageName": "@macroforge/bin",
|
|
56
|
+
"targets": [
|
|
57
|
+
"x86_64-apple-darwin",
|
|
58
|
+
"aarch64-apple-darwin",
|
|
59
|
+
"x86_64-unknown-linux-gnu",
|
|
60
|
+
"aarch64-unknown-linux-gnu",
|
|
61
|
+
"x86_64-pc-windows-msvc",
|
|
62
|
+
"aarch64-pc-windows-msvc"
|
|
63
|
+
]
|
|
30
64
|
},
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
"packageName": "@macroforge/bin",
|
|
56
|
-
"targets": [
|
|
57
|
-
"x86_64-apple-darwin",
|
|
58
|
-
"aarch64-apple-darwin",
|
|
59
|
-
"x86_64-unknown-linux-gnu",
|
|
60
|
-
"aarch64-unknown-linux-gnu",
|
|
61
|
-
"x86_64-pc-windows-msvc",
|
|
62
|
-
"aarch64-pc-windows-msvc"
|
|
63
|
-
]
|
|
64
|
-
},
|
|
65
|
-
"optionalDependencies": {
|
|
66
|
-
"@macroforge/bin-darwin-arm64": "0.1.65",
|
|
67
|
-
"@macroforge/bin-darwin-x64": "0.1.65",
|
|
68
|
-
"@macroforge/bin-linux-arm64-gnu": "0.1.65",
|
|
69
|
-
"@macroforge/bin-linux-x64-gnu": "0.1.65",
|
|
70
|
-
"@macroforge/bin-win32-arm64-msvc": "0.1.65",
|
|
71
|
-
"@macroforge/bin-win32-x64-msvc": "0.1.65"
|
|
72
|
-
},
|
|
73
|
-
"repository": {
|
|
74
|
-
"type": "git",
|
|
75
|
-
"url": "git+https://github.com/macroforge-ts/core.git"
|
|
76
|
-
},
|
|
77
|
-
"scripts": {
|
|
78
|
-
"artifacts": "napi artifacts --npm-dir npm",
|
|
79
|
-
"build": "npm install && npm run build:js && bun x napi build --platform --release",
|
|
80
|
-
"build:js": "npm run build:serde && npm run build:traits",
|
|
81
|
-
"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",
|
|
82
|
-
"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",
|
|
83
|
-
"clean": "rm -f macroforge.*.node pkg/*.node && rm -rf node_modules",
|
|
84
|
-
"cleanbuild": "npm run clean && npm run build"
|
|
85
|
-
},
|
|
86
|
-
"types": "index.d.ts",
|
|
87
|
-
"version": "0.1.65"
|
|
65
|
+
"optionalDependencies": {
|
|
66
|
+
"@macroforge/bin-darwin-arm64": "0.1.72",
|
|
67
|
+
"@macroforge/bin-darwin-x64": "0.1.72",
|
|
68
|
+
"@macroforge/bin-linux-arm64-gnu": "0.1.72",
|
|
69
|
+
"@macroforge/bin-linux-x64-gnu": "0.1.72",
|
|
70
|
+
"@macroforge/bin-win32-arm64-msvc": "0.1.72",
|
|
71
|
+
"@macroforge/bin-win32-x64-msvc": "0.1.72"
|
|
72
|
+
},
|
|
73
|
+
"repository": {
|
|
74
|
+
"type": "git",
|
|
75
|
+
"url": "git+https://github.com/macroforge-ts/core.git"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"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",
|
|
80
|
+
"build:js": "deno task build:serde && deno task build:traits",
|
|
81
|
+
"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
|
+
"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",
|
|
83
|
+
"clean": "rm -f macroforge.*.node || true; rm -f pkg/*.node || true; rm -rf node_modules",
|
|
84
|
+
"cleanbuild": "deno task clean && deno task build"
|
|
85
|
+
},
|
|
86
|
+
"type": "commonjs",
|
|
87
|
+
"types": "index.d.ts",
|
|
88
|
+
"version": "0.1.72"
|
|
88
89
|
}
|