macroforge 0.1.78 → 0.1.80
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 +28 -51
- package/js/buildtime/index.d.ts +107 -0
- package/js/buildtime/index.mjs +65 -0
- package/js/buildtime/index.ts +176 -0
- package/js/cli/svelte-check-wrapper.js +177 -0
- package/js/cli/tsc-wrapper.js +198 -0
- package/js/rules/index.d.ts +94 -0
- package/js/rules/index.mjs +9 -0
- package/js/rules/index.ts +109 -0
- package/package.json +73 -86
- package/pkg/macroforge_ts.d.ts +132 -0
- package/pkg/macroforge_ts.js +1197 -0
- package/pkg/macroforge_ts_bg.wasm +0 -0
- package/pkg/macroforge_ts_bg.wasm.d.ts +69 -0
- package/index.d.ts +0 -1341
- package/index.js +0 -605
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TSC wrapper — spawned by the CLI's `run_tsc_wrapper`.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `tsc --noEmit` with macro expansion baked into file reads.
|
|
5
|
+
* Files containing `@derive` are expanded before being passed to the
|
|
6
|
+
* TypeScript compiler.
|
|
7
|
+
*
|
|
8
|
+
* Arguments:
|
|
9
|
+
* argv[2] — tsconfig path (default: "tsconfig.json")
|
|
10
|
+
*
|
|
11
|
+
* Environment:
|
|
12
|
+
* MACROFORGE_TYPE_REGISTRY_PATH — path to pre-built type registry JSON
|
|
13
|
+
*/
|
|
14
|
+
const { createRequire } = require("module");
|
|
15
|
+
const fs = require("fs");
|
|
16
|
+
const path = require("path");
|
|
17
|
+
const cwdRequire = createRequire(process.cwd() + "/package.json");
|
|
18
|
+
const ts = cwdRequire("typescript");
|
|
19
|
+
const macros = cwdRequire("macroforge");
|
|
20
|
+
if (macros.setupExternalMacros) {
|
|
21
|
+
let resolveDecoratorNames = function (packagePath) {
|
|
22
|
+
const candidates = [packagePath];
|
|
23
|
+
for (const id of candidates) {
|
|
24
|
+
try {
|
|
25
|
+
const pkg = req(id);
|
|
26
|
+
const names = [];
|
|
27
|
+
if (pkg.__macroforgeGetManifest) {
|
|
28
|
+
names.push(
|
|
29
|
+
...(pkg.__macroforgeGetManifest().decorators || []).map(
|
|
30
|
+
(d) => d.export,
|
|
31
|
+
),
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
for (const key of Object.keys(pkg)) {
|
|
35
|
+
if (
|
|
36
|
+
key.startsWith("__macroforgeGetManifest_") &&
|
|
37
|
+
typeof pkg[key] === "function"
|
|
38
|
+
) {
|
|
39
|
+
names.push(...(pkg[key]().decorators || []).map((d) => d.export));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (names.length > 0) return [...new Set(names)];
|
|
43
|
+
} catch {}
|
|
44
|
+
}
|
|
45
|
+
return [];
|
|
46
|
+
},
|
|
47
|
+
runMacro = function (ctxJson) {
|
|
48
|
+
const ctx = JSON.parse(ctxJson);
|
|
49
|
+
const fnName = `__macroforgeRun${ctx.macro_name}`;
|
|
50
|
+
const candidates = [ctx.module_path];
|
|
51
|
+
for (const id of candidates) {
|
|
52
|
+
try {
|
|
53
|
+
const pkg = req(id);
|
|
54
|
+
const fn_ = pkg?.[fnName] || pkg?.default?.[fnName];
|
|
55
|
+
if (typeof fn_ === "function") return fn_(ctxJson);
|
|
56
|
+
} catch {}
|
|
57
|
+
}
|
|
58
|
+
throw new Error(`Macro ${fnName} not found in ${ctx.module_path}`);
|
|
59
|
+
};
|
|
60
|
+
var resolveDecoratorNames2 = resolveDecoratorNames,
|
|
61
|
+
runMacro2 = runMacro;
|
|
62
|
+
const req = createRequire(process.cwd() + "/package.json");
|
|
63
|
+
macros.setupExternalMacros(resolveDecoratorNames, runMacro);
|
|
64
|
+
}
|
|
65
|
+
const projectArg = process.argv[2] || "tsconfig.json";
|
|
66
|
+
const configPath = ts.findConfigFile(
|
|
67
|
+
process.cwd(),
|
|
68
|
+
ts.sys.fileExists,
|
|
69
|
+
projectArg,
|
|
70
|
+
);
|
|
71
|
+
if (!configPath) {
|
|
72
|
+
console.error(`[macroforge] tsconfig not found: ${projectArg}`);
|
|
73
|
+
process.exit(1);
|
|
74
|
+
}
|
|
75
|
+
const CONFIG_FILES = [
|
|
76
|
+
"macroforge.config.ts",
|
|
77
|
+
"macroforge.config.mts",
|
|
78
|
+
"macroforge.config.js",
|
|
79
|
+
"macroforge.config.mjs",
|
|
80
|
+
"macroforge.config.cjs",
|
|
81
|
+
];
|
|
82
|
+
let macroConfigPath = null;
|
|
83
|
+
let currentDir = process.cwd();
|
|
84
|
+
while (true) {
|
|
85
|
+
for (const filename of CONFIG_FILES) {
|
|
86
|
+
const candidate = path.join(currentDir, filename);
|
|
87
|
+
if (fs.existsSync(candidate)) {
|
|
88
|
+
macroConfigPath = candidate;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (macroConfigPath) break;
|
|
93
|
+
if (fs.existsSync(path.join(currentDir, "package.json"))) break;
|
|
94
|
+
const parent = path.dirname(currentDir);
|
|
95
|
+
if (parent === currentDir) break;
|
|
96
|
+
currentDir = parent;
|
|
97
|
+
}
|
|
98
|
+
if (macroConfigPath) {
|
|
99
|
+
try {
|
|
100
|
+
const configContent = fs.readFileSync(macroConfigPath, "utf8");
|
|
101
|
+
macros.loadConfig(configContent, macroConfigPath);
|
|
102
|
+
} catch {}
|
|
103
|
+
}
|
|
104
|
+
const typeRegistryPath = process.env.MACROFORGE_TYPE_REGISTRY_PATH;
|
|
105
|
+
let typeRegistryJson = void 0;
|
|
106
|
+
if (typeRegistryPath) {
|
|
107
|
+
try {
|
|
108
|
+
typeRegistryJson = fs.readFileSync(typeRegistryPath, "utf8");
|
|
109
|
+
} catch {}
|
|
110
|
+
}
|
|
111
|
+
const declarativeRegistryPath =
|
|
112
|
+
process.env.MACROFORGE_DECLARATIVE_REGISTRY_PATH;
|
|
113
|
+
let declarativeRegistryJson = void 0;
|
|
114
|
+
if (declarativeRegistryPath) {
|
|
115
|
+
try {
|
|
116
|
+
declarativeRegistryJson = fs.readFileSync(declarativeRegistryPath, "utf8");
|
|
117
|
+
} catch {}
|
|
118
|
+
}
|
|
119
|
+
const configFile = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
120
|
+
if (configFile.error) {
|
|
121
|
+
console.error(
|
|
122
|
+
ts.formatDiagnostic(configFile.error, {
|
|
123
|
+
getCanonicalFileName: (f) => f,
|
|
124
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
125
|
+
getNewLine: () => ts.sys.newLine,
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
const parsed = ts.parseJsonConfigFileContent(
|
|
131
|
+
configFile.config,
|
|
132
|
+
ts.sys,
|
|
133
|
+
path.dirname(configPath),
|
|
134
|
+
);
|
|
135
|
+
const options = { ...parsed.options, noEmit: true };
|
|
136
|
+
const formatHost = {
|
|
137
|
+
getCanonicalFileName: (f) => f,
|
|
138
|
+
getCurrentDirectory: ts.sys.getCurrentDirectory,
|
|
139
|
+
getNewLine: () => ts.sys.newLine,
|
|
140
|
+
};
|
|
141
|
+
const plugin = new macros.NativePlugin();
|
|
142
|
+
const tscExpandOpts = {};
|
|
143
|
+
if (macroConfigPath) tscExpandOpts.configPath = macroConfigPath;
|
|
144
|
+
if (typeRegistryJson) tscExpandOpts.typeRegistryJson = typeRegistryJson;
|
|
145
|
+
if (declarativeRegistryJson) {
|
|
146
|
+
tscExpandOpts.declarativeRegistryJson = declarativeRegistryJson;
|
|
147
|
+
}
|
|
148
|
+
const host = ts.createCompilerHost(options);
|
|
149
|
+
const origGetSourceFile = host.getSourceFile.bind(host);
|
|
150
|
+
// Text-level fast path: skip files that don't contain any macro markers.
|
|
151
|
+
// Matches:
|
|
152
|
+
// - `@derive` (derive macros)
|
|
153
|
+
// - `macroforge/rules` (declarative-macro-defining files that
|
|
154
|
+
// `import { macroRules } from "macroforge/rules"`)
|
|
155
|
+
// - `import macro` inside a JSDoc comment (declarative-macro-consuming
|
|
156
|
+
// files that use `/** import macro { $name } from "./file" */`)
|
|
157
|
+
function hasMacroMarkers(sourceText) {
|
|
158
|
+
if (!sourceText) return false;
|
|
159
|
+
if (sourceText.includes("@derive")) return true;
|
|
160
|
+
if (sourceText.includes("macroforge/rules")) return true;
|
|
161
|
+
if (sourceText.includes("import macro")) return true;
|
|
162
|
+
return false;
|
|
163
|
+
}
|
|
164
|
+
host.getSourceFile = (fileName, languageVersion, ...rest) => {
|
|
165
|
+
try {
|
|
166
|
+
if (
|
|
167
|
+
(fileName.endsWith(".ts") || fileName.endsWith(".tsx")) &&
|
|
168
|
+
!fileName.endsWith(".d.ts")
|
|
169
|
+
) {
|
|
170
|
+
const sourceText = ts.sys.readFile(fileName);
|
|
171
|
+
if (hasMacroMarkers(sourceText)) {
|
|
172
|
+
const result = plugin.processFile(fileName, sourceText, tscExpandOpts);
|
|
173
|
+
const text = result.code || sourceText;
|
|
174
|
+
return ts.createSourceFile(fileName, text, languageVersion, true);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} catch (e) {
|
|
178
|
+
if (process.env.MACROFORGE_DEBUG_WRAPPER) {
|
|
179
|
+
console.error(
|
|
180
|
+
`[macroforge tsc wrapper] expand failed for ${fileName}:`,
|
|
181
|
+
e,
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
return origGetSourceFile(fileName, languageVersion, ...rest);
|
|
186
|
+
};
|
|
187
|
+
const program = ts.createProgram(parsed.fileNames, options, host);
|
|
188
|
+
const diagnostics = ts.getPreEmitDiagnostics(program);
|
|
189
|
+
if (diagnostics.length) {
|
|
190
|
+
diagnostics.forEach((d) => {
|
|
191
|
+
const msg = ts.formatDiagnostic(d, formatHost);
|
|
192
|
+
console.error(msg.trimEnd());
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
const hasError = diagnostics.some(
|
|
196
|
+
(d) => d.category === ts.DiagnosticCategory.Error,
|
|
197
|
+
);
|
|
198
|
+
process.exit(hasError ? 1 : 0);
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Macroforge Rules Module
|
|
3
|
+
*
|
|
4
|
+
* Declarative pattern-matching macros for TypeScript. Define macros with
|
|
5
|
+
* `` const $name = macroRules`...` ``, invoke them as `$name(args)`, and the
|
|
6
|
+
* macroforge build pass rewrites call sites at compile time.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { macroRules } from "macroforge/rules";
|
|
12
|
+
*
|
|
13
|
+
* const $vec = macroRules`
|
|
14
|
+
* () => []
|
|
15
|
+
*
|
|
16
|
+
* ($($x:Expr),+ $(,)?) => {
|
|
17
|
+
* const __v = [];
|
|
18
|
+
* $( __v.push($x); )+
|
|
19
|
+
* __v
|
|
20
|
+
* }
|
|
21
|
+
* `;
|
|
22
|
+
*
|
|
23
|
+
* const empty = $vec();
|
|
24
|
+
* const xs = $vec(1, 2, 3);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ## Runtime behavior
|
|
28
|
+
*
|
|
29
|
+
* `macroRules` is a sentinel tag function. It throws at runtime if the
|
|
30
|
+
* macroforge build pass is not installed — if you see the runtime error,
|
|
31
|
+
* your build toolchain is not running macroforge on this file.
|
|
32
|
+
*
|
|
33
|
+
* @module macroforge/rules
|
|
34
|
+
*/
|
|
35
|
+
/**
|
|
36
|
+
* A macro invocation — a function that takes any arguments and may produce
|
|
37
|
+
* any value. The exact return type depends on the macro body; for accurate
|
|
38
|
+
* types, the macroforge build pass is responsible for erasing the macro
|
|
39
|
+
* definition and inlining the expansion at each call site. Only this
|
|
40
|
+
* placeholder shape is visible to the TypeScript type checker.
|
|
41
|
+
*/
|
|
42
|
+
export type MacroInvocation = (...args: any[]) => any;
|
|
43
|
+
/**
|
|
44
|
+
* The macro definition tag function.
|
|
45
|
+
*
|
|
46
|
+
* At build time, `` const $name = macroRules`...` `` is recognized by
|
|
47
|
+
* macroforge, the template body is parsed as a macro definition, and the
|
|
48
|
+
* declaration is erased from the output. Call sites of `$name(...)` are
|
|
49
|
+
* rewritten in place with the matching arm's body.
|
|
50
|
+
*
|
|
51
|
+
* The return type is a generic callable, so TypeScript lets users invoke
|
|
52
|
+
* `$name(...)` without complaint. At runtime (if the build pass did not
|
|
53
|
+
* run) the tag itself throws — any caller would already have seen the
|
|
54
|
+
* compile-time rewrite.
|
|
55
|
+
*/
|
|
56
|
+
export declare function macroRules(_strings: TemplateStringsArray, ..._values: unknown[]): MacroInvocation;
|
|
57
|
+
/**
|
|
58
|
+
* Configuration for a macro's reverse-monomorphization behavior.
|
|
59
|
+
*
|
|
60
|
+
* Currently a type-only declaration — the object form
|
|
61
|
+
* `macroRules({ expand, runtime, call, mode })` is part of the reverse-mono
|
|
62
|
+
* follow-up and is not yet wired through the build pass. The type is
|
|
63
|
+
* exported now so consumer code can start using the shape.
|
|
64
|
+
*/
|
|
65
|
+
export interface MacroConfig {
|
|
66
|
+
/**
|
|
67
|
+
* Controls how the macro emits in dev vs. prod builds.
|
|
68
|
+
*
|
|
69
|
+
* - `"auto"` (default): dev expands inline, prod shares runtime when safe.
|
|
70
|
+
* - `"expand-only"`: always expand inline at every call site.
|
|
71
|
+
* - `"share-only"`: always emit calls to a shared runtime helper.
|
|
72
|
+
* - `"share-anyway"`: share even past the megamorphism threshold.
|
|
73
|
+
*/
|
|
74
|
+
readonly mode?: "auto" | "expand-only" | "share-only" | "share-anyway";
|
|
75
|
+
/**
|
|
76
|
+
* The expand-form macro template (used for dev + `expand-only` + type-check).
|
|
77
|
+
*/
|
|
78
|
+
readonly expand?: unknown;
|
|
79
|
+
/**
|
|
80
|
+
* The shared runtime body, emitted once per module when the macro
|
|
81
|
+
* is in a sharing mode.
|
|
82
|
+
*/
|
|
83
|
+
readonly runtime?: string;
|
|
84
|
+
/**
|
|
85
|
+
* The call-form template that replaces call sites when the macro
|
|
86
|
+
* is in a sharing mode.
|
|
87
|
+
*/
|
|
88
|
+
readonly call?: unknown;
|
|
89
|
+
/**
|
|
90
|
+
* Above this count of distinct types calling the shared runtime,
|
|
91
|
+
* the megamorphism analyzer emits a warning. Default: 4.
|
|
92
|
+
*/
|
|
93
|
+
readonly megamorphismThreshold?: number;
|
|
94
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// js/rules/index.ts
|
|
2
|
+
function macroRules(_strings, ..._values) {
|
|
3
|
+
throw new Error(
|
|
4
|
+
"macroforge/rules: macros are compile-time only \u2014 they should have been erased by the macroforge build pass. If you're seeing this at runtime, the macroforge plugin is not installed or not running on this file."
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
macroRules
|
|
9
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* # Macroforge Rules Module
|
|
3
|
+
*
|
|
4
|
+
* Declarative pattern-matching macros for TypeScript. Define macros with
|
|
5
|
+
* `` const $name = macroRules`...` ``, invoke them as `$name(args)`, and the
|
|
6
|
+
* macroforge build pass rewrites call sites at compile time.
|
|
7
|
+
*
|
|
8
|
+
* Example:
|
|
9
|
+
*
|
|
10
|
+
* ```typescript
|
|
11
|
+
* import { macroRules } from "macroforge/rules";
|
|
12
|
+
*
|
|
13
|
+
* const $vec = macroRules`
|
|
14
|
+
* () => []
|
|
15
|
+
*
|
|
16
|
+
* ($($x:Expr),+ $(,)?) => {
|
|
17
|
+
* const __v = [];
|
|
18
|
+
* $( __v.push($x); )+
|
|
19
|
+
* __v
|
|
20
|
+
* }
|
|
21
|
+
* `;
|
|
22
|
+
*
|
|
23
|
+
* const empty = $vec();
|
|
24
|
+
* const xs = $vec(1, 2, 3);
|
|
25
|
+
* ```
|
|
26
|
+
*
|
|
27
|
+
* ## Runtime behavior
|
|
28
|
+
*
|
|
29
|
+
* `macroRules` is a sentinel tag function. It throws at runtime if the
|
|
30
|
+
* macroforge build pass is not installed — if you see the runtime error,
|
|
31
|
+
* your build toolchain is not running macroforge on this file.
|
|
32
|
+
*
|
|
33
|
+
* @module macroforge/rules
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* A macro invocation — a function that takes any arguments and may produce
|
|
38
|
+
* any value. The exact return type depends on the macro body; for accurate
|
|
39
|
+
* types, the macroforge build pass is responsible for erasing the macro
|
|
40
|
+
* definition and inlining the expansion at each call site. Only this
|
|
41
|
+
* placeholder shape is visible to the TypeScript type checker.
|
|
42
|
+
*/
|
|
43
|
+
export type MacroInvocation = (...args: any[]) => any;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* The macro definition tag function.
|
|
47
|
+
*
|
|
48
|
+
* At build time, `` const $name = macroRules`...` `` is recognized by
|
|
49
|
+
* macroforge, the template body is parsed as a macro definition, and the
|
|
50
|
+
* declaration is erased from the output. Call sites of `$name(...)` are
|
|
51
|
+
* rewritten in place with the matching arm's body.
|
|
52
|
+
*
|
|
53
|
+
* The return type is a generic callable, so TypeScript lets users invoke
|
|
54
|
+
* `$name(...)` without complaint. At runtime (if the build pass did not
|
|
55
|
+
* run) the tag itself throws — any caller would already have seen the
|
|
56
|
+
* compile-time rewrite.
|
|
57
|
+
*/
|
|
58
|
+
export function macroRules(
|
|
59
|
+
_strings: TemplateStringsArray,
|
|
60
|
+
..._values: unknown[]
|
|
61
|
+
): MacroInvocation {
|
|
62
|
+
throw new Error(
|
|
63
|
+
"macroforge/rules: macros are compile-time only — they should have been erased by the macroforge build pass. " +
|
|
64
|
+
"If you're seeing this at runtime, the macroforge plugin is not installed or not running on this file.",
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Configuration for a macro's reverse-monomorphization behavior.
|
|
70
|
+
*
|
|
71
|
+
* Currently a type-only declaration — the object form
|
|
72
|
+
* `macroRules({ expand, runtime, call, mode })` is part of the reverse-mono
|
|
73
|
+
* follow-up and is not yet wired through the build pass. The type is
|
|
74
|
+
* exported now so consumer code can start using the shape.
|
|
75
|
+
*/
|
|
76
|
+
export interface MacroConfig {
|
|
77
|
+
/**
|
|
78
|
+
* Controls how the macro emits in dev vs. prod builds.
|
|
79
|
+
*
|
|
80
|
+
* - `"auto"` (default): dev expands inline, prod shares runtime when safe.
|
|
81
|
+
* - `"expand-only"`: always expand inline at every call site.
|
|
82
|
+
* - `"share-only"`: always emit calls to a shared runtime helper.
|
|
83
|
+
* - `"share-anyway"`: share even past the megamorphism threshold.
|
|
84
|
+
*/
|
|
85
|
+
readonly mode?: "auto" | "expand-only" | "share-only" | "share-anyway";
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The expand-form macro template (used for dev + `expand-only` + type-check).
|
|
89
|
+
*/
|
|
90
|
+
readonly expand?: unknown;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The shared runtime body, emitted once per module when the macro
|
|
94
|
+
* is in a sharing mode.
|
|
95
|
+
*/
|
|
96
|
+
readonly runtime?: string;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The call-form template that replaces call sites when the macro
|
|
100
|
+
* is in a sharing mode.
|
|
101
|
+
*/
|
|
102
|
+
readonly call?: unknown;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Above this count of distinct types calling the shared runtime,
|
|
106
|
+
* the megamorphism analyzer emits a warning. Default: 4.
|
|
107
|
+
*/
|
|
108
|
+
readonly megamorphismThreshold?: number;
|
|
109
|
+
}
|
package/package.json
CHANGED
|
@@ -1,92 +1,79 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
},
|
|
6
|
-
"dependencies": {
|
|
7
|
-
"@napi-rs/cli": "^3.5.1"
|
|
8
|
-
},
|
|
9
|
-
"description": "TypeScript macro expansion engine powered by Rust and SWC",
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">= 24"
|
|
12
|
-
},
|
|
13
|
-
"exports": {
|
|
14
|
-
".": {
|
|
15
|
-
"default": "./index.js",
|
|
16
|
-
"require": "./index.js",
|
|
17
|
-
"types": "./index.d.ts"
|
|
2
|
+
"author": "macroforge contributors",
|
|
3
|
+
"bugs": {
|
|
4
|
+
"url": "https://github.com/macroforge-ts/macroforge-ts/issues"
|
|
18
5
|
},
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
"description": "TypeScript macro expansion engine powered by Rust, Oxc, and WebAssembly",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./pkg/macroforge_ts.js",
|
|
10
|
+
"types": "./pkg/macroforge_ts.d.ts",
|
|
11
|
+
"default": "./pkg/macroforge_ts.js"
|
|
12
|
+
},
|
|
13
|
+
"./buildtime": {
|
|
14
|
+
"import": "./js/buildtime/index.mjs",
|
|
15
|
+
"types": "./js/buildtime/index.d.ts",
|
|
16
|
+
"default": "./js/buildtime/index.mjs"
|
|
17
|
+
},
|
|
18
|
+
"./reexports": {
|
|
19
|
+
"import": "./js/reexports/index.mjs",
|
|
20
|
+
"types": "./js/reexports/index.d.ts",
|
|
21
|
+
"default": "./js/reexports/index.mjs"
|
|
22
|
+
},
|
|
23
|
+
"./reexports/effect": {
|
|
24
|
+
"import": "./js/reexports/effect.mjs",
|
|
25
|
+
"types": "./js/reexports/effect.d.ts",
|
|
26
|
+
"default": "./js/reexports/effect.mjs"
|
|
27
|
+
},
|
|
28
|
+
"./rules": {
|
|
29
|
+
"import": "./js/rules/index.mjs",
|
|
30
|
+
"types": "./js/rules/index.d.ts",
|
|
31
|
+
"default": "./js/rules/index.mjs"
|
|
32
|
+
},
|
|
33
|
+
"./serde": {
|
|
34
|
+
"import": "./js/serde/index.mjs",
|
|
35
|
+
"types": "./js/serde/index.d.ts",
|
|
36
|
+
"default": "./js/serde/index.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./traits": {
|
|
39
|
+
"import": "./js/traits/index.mjs",
|
|
40
|
+
"types": "./js/traits/index.d.ts",
|
|
41
|
+
"default": "./js/traits/index.mjs"
|
|
42
|
+
}
|
|
23
43
|
},
|
|
24
|
-
"
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
44
|
+
"files": [
|
|
45
|
+
"js",
|
|
46
|
+
"pkg"
|
|
47
|
+
],
|
|
48
|
+
"homepage": "https://github.com/macroforge-ts/macroforge-ts#readme",
|
|
49
|
+
"keywords": [
|
|
50
|
+
"typescript",
|
|
51
|
+
"macros",
|
|
52
|
+
"derive",
|
|
53
|
+
"codegen",
|
|
54
|
+
"oxc",
|
|
55
|
+
"wasm",
|
|
56
|
+
"webassembly"
|
|
57
|
+
],
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"main": "./pkg/macroforge_ts.js",
|
|
60
|
+
"name": "macroforge",
|
|
61
|
+
"repository": {
|
|
62
|
+
"type": "git",
|
|
63
|
+
"url": "git+https://github.com/macroforge-ts/macroforge-ts.git"
|
|
28
64
|
},
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
65
|
+
"scripts": {
|
|
66
|
+
"build": "deno task build:wasm",
|
|
67
|
+
"build:buildtime": "deno run -A npm:esbuild js/buildtime/index.ts --bundle --outfile=js/buildtime/index.mjs --format=esm && deno run -A npm:typescript/tsc js/buildtime/index.ts --declaration --emitDeclarationOnly --outDir js/buildtime --lib ES2024 --skipLibCheck",
|
|
68
|
+
"build:js": "deno task build:serde && deno task build:traits && deno task build:rules && deno task build:buildtime",
|
|
69
|
+
"build:rules": "deno run -A npm:esbuild js/rules/index.ts --bundle --outfile=js/rules/index.mjs --format=esm && deno run -A npm:typescript/tsc js/rules/index.ts --declaration --emitDeclarationOnly --outDir js/rules --lib ES2024 --skipLibCheck",
|
|
70
|
+
"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",
|
|
71
|
+
"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",
|
|
72
|
+
"build:wasm": "deno install --node-modules-dir && deno task build:js && cargo build --release --target wasm32-unknown-unknown && deno run -A ../../tooling/scripts/bench.mjs --wasm-bindgen ../target/wasm32-unknown-unknown/release/macroforge_ts.wasm pkg",
|
|
73
|
+
"clean": "rm -rf pkg node_modules",
|
|
74
|
+
"cleanbuild": "deno task clean && deno task build"
|
|
33
75
|
},
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"types": "./js/traits/index.d.ts"
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
"files": [
|
|
41
|
-
"index.d.ts",
|
|
42
|
-
"index.js",
|
|
43
|
-
"js"
|
|
44
|
-
],
|
|
45
|
-
"homepage": "https://github.com/macroforge-ts/core#readme",
|
|
46
|
-
"keywords": [
|
|
47
|
-
"typescript",
|
|
48
|
-
"macros",
|
|
49
|
-
"derive",
|
|
50
|
-
"codegen",
|
|
51
|
-
"swc"
|
|
52
|
-
],
|
|
53
|
-
"license": "MIT",
|
|
54
|
-
"main": "index.js",
|
|
55
|
-
"name": "macroforge",
|
|
56
|
-
"napi": {
|
|
57
|
-
"binaryName": "macroforge",
|
|
58
|
-
"packageName": "@macroforge/bin",
|
|
59
|
-
"targets": [
|
|
60
|
-
"x86_64-apple-darwin",
|
|
61
|
-
"aarch64-apple-darwin",
|
|
62
|
-
"x86_64-unknown-linux-gnu",
|
|
63
|
-
"aarch64-unknown-linux-gnu",
|
|
64
|
-
"x86_64-pc-windows-msvc",
|
|
65
|
-
"aarch64-pc-windows-msvc"
|
|
66
|
-
]
|
|
67
|
-
},
|
|
68
|
-
"optionalDependencies": {
|
|
69
|
-
"@macroforge/bin-darwin-arm64": "0.1.78",
|
|
70
|
-
"@macroforge/bin-darwin-x64": "0.1.78",
|
|
71
|
-
"@macroforge/bin-linux-arm64-gnu": "0.1.78",
|
|
72
|
-
"@macroforge/bin-linux-x64-gnu": "0.1.78",
|
|
73
|
-
"@macroforge/bin-win32-arm64-msvc": "0.1.78",
|
|
74
|
-
"@macroforge/bin-win32-x64-msvc": "0.1.78"
|
|
75
|
-
},
|
|
76
|
-
"repository": {
|
|
77
|
-
"type": "git",
|
|
78
|
-
"url": "git+https://github.com/macroforge-ts/core.git"
|
|
79
|
-
},
|
|
80
|
-
"scripts": {
|
|
81
|
-
"artifacts": "napi artifacts --npm-dir npm",
|
|
82
|
-
"build": "deno install --node-modules-dir && deno task build:js && deno run -A npm:@napi-rs/cli/napi build --platform --release && cargo install --path . --force",
|
|
83
|
-
"build:js": "deno task build:serde && deno task build:traits",
|
|
84
|
-
"build:serde": "deno run -A npm:esbuild js/serde/index.ts --bundle --outfile=js/serde/index.mjs --format=esm && deno run -A npm:typescript/tsc js/serde/index.ts --declaration --emitDeclarationOnly --outDir js/serde --lib ES2024 --skipLibCheck",
|
|
85
|
-
"build:traits": "deno run -A npm:esbuild js/traits/index.ts --bundle --outfile=js/traits/index.mjs --format=esm && deno run -A npm:typescript/tsc js/traits/index.ts --declaration --emitDeclarationOnly --outDir js/traits --lib ES2024 --skipLibCheck",
|
|
86
|
-
"clean": "rm -f macroforge.*.node || true; rm -f pkg/*.node || true; rm -rf node_modules",
|
|
87
|
-
"cleanbuild": "deno task clean && deno task build"
|
|
88
|
-
},
|
|
89
|
-
"type": "commonjs",
|
|
90
|
-
"types": "index.d.ts",
|
|
91
|
-
"version": "0.1.78"
|
|
76
|
+
"type": "commonjs",
|
|
77
|
+
"types": "./pkg/macroforge_ts.d.ts",
|
|
78
|
+
"version": "0.1.80"
|
|
92
79
|
}
|