macroforge 0.1.30 → 0.1.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "macroforge",
3
- "version": "0.1.30",
3
+ "version": "0.1.31",
4
4
  "description": "TypeScript macro expansion engine powered by Rust and SWC",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,17 +10,20 @@
10
10
  "require": "./index.js",
11
11
  "default": "./index.js"
12
12
  },
13
- "./result": {
14
- "types": "./result.d.ts",
15
- "import": "./result.mjs",
16
- "require": "./result.js",
17
- "default": "./result.mjs"
13
+ "./utils": {
14
+ "types": "./js/utils/index.d.ts",
15
+ "import": "./js/utils/index.mjs",
16
+ "default": "./js/utils/index.mjs"
18
17
  },
19
18
  "./serde": {
20
- "types": "./serde.d.ts",
21
- "import": "./serde.mjs",
22
- "require": "./serde.js",
23
- "default": "./serde.mjs"
19
+ "types": "./js/serde/index.d.ts",
20
+ "import": "./js/serde/index.mjs",
21
+ "default": "./js/serde/index.mjs"
22
+ },
23
+ "./traits": {
24
+ "types": "./js/traits/index.d.ts",
25
+ "import": "./js/traits/index.mjs",
26
+ "default": "./js/traits/index.mjs"
24
27
  }
25
28
  },
26
29
  "repository": {
@@ -55,29 +58,30 @@
55
58
  "files": [
56
59
  "index.d.ts",
57
60
  "index.js",
58
- "result.js",
59
- "result.mjs",
60
- "result.d.ts",
61
- "serde.js",
62
- "serde.mjs",
63
- "serde.d.ts"
61
+ "js"
64
62
  ],
65
63
  "dependencies": {
66
- "@rydshift/mirror": "^0.1.2"
64
+ "@rydshift/mirror": "^0.1.3"
67
65
  },
68
66
  "engines": {
69
67
  "node": ">= 18"
70
68
  },
71
69
  "optionalDependencies": {
72
- "@macroforge/bin-darwin-x64": "0.1.30",
73
- "@macroforge/bin-darwin-arm64": "0.1.30",
74
- "@macroforge/bin-linux-x64-gnu": "0.1.30",
75
- "@macroforge/bin-linux-arm64-gnu": "0.1.30",
76
- "@macroforge/bin-win32-x64-msvc": "0.1.30",
77
- "@macroforge/bin-win32-arm64-msvc": "0.1.30"
70
+ "@macroforge/bin-darwin-x64": "0.1.31",
71
+ "@macroforge/bin-darwin-arm64": "0.1.31",
72
+ "@macroforge/bin-linux-x64-gnu": "0.1.31",
73
+ "@macroforge/bin-linux-arm64-gnu": "0.1.31",
74
+ "@macroforge/bin-win32-x64-msvc": "0.1.31",
75
+ "@macroforge/bin-win32-arm64-msvc": "0.1.31"
78
76
  },
79
77
  "scripts": {
80
- "build": "bun x napi build --platform --release",
78
+ "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
+ "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": "npm install && npm run build:js && bun x napi build --platform --release",
83
+ "clean": "rm -f macroforge.*.node pkg/*.node node_modules",
84
+ "cleanbuild": "npm run clean && npm run build",
81
85
  "artifacts": "napi artifacts --npm-dir npm"
82
86
  }
83
87
  }
package/result.d.ts DELETED
@@ -1,2 +0,0 @@
1
- // Re-export Result from @rydshift/mirror for use in generated code
2
- export { Result } from "@rydshift/mirror";
package/result.js DELETED
@@ -1,7 +0,0 @@
1
- // Re-export Result from @rydshift/mirror for use in generated code
2
- // Using CommonJS for compatibility with the rest of the package
3
- const mirror = require("@rydshift/mirror");
4
- const Result = mirror.Result;
5
-
6
- module.exports = { Result };
7
- module.exports.Result = Result;
package/result.mjs DELETED
@@ -1,2 +0,0 @@
1
- // Re-export Result from @rydshift/mirror for use in generated code (ESM)
2
- export { Result } from "@rydshift/mirror";
package/serde.d.ts DELETED
@@ -1,51 +0,0 @@
1
- /**
2
- * Serde runtime helpers for macroforge Serialize/Deserialize macros.
3
- */
4
-
5
- export interface SerializeContext {
6
- /** Get the ID for an already-registered object, or undefined if not seen */
7
- getId(obj: object): number | undefined;
8
- /** Register an object and return its assigned ID */
9
- register(obj: object): number;
10
- }
11
-
12
- export declare namespace SerializeContext {
13
- function create(): SerializeContext;
14
- }
15
-
16
- export interface DeserializeContext {
17
- /** Register an object with a known ID */
18
- register(id: number, instance: any): void;
19
- /** Get an object by ID, or return a PendingRef if not yet available */
20
- getOrDefer(refId: number): any;
21
- /** Assign a value to a property, deferring if it's a PendingRef */
22
- assignOrDefer(target: any, prop: string | number, value: any): void;
23
- /** Manually add a patch for later resolution */
24
- addPatch(target: any, prop: string | number, refId: number): void;
25
- /** Track an object for optional freezing */
26
- trackForFreeze(obj: object): void;
27
- /** Apply all deferred patches (call after deserialization is complete) */
28
- applyPatches(): void;
29
- /** Freeze all tracked objects (call after applyPatches if immutability is desired) */
30
- freezeAll(): void;
31
- }
32
-
33
- export declare namespace DeserializeContext {
34
- function create(): DeserializeContext;
35
- }
36
-
37
- /** Marker interface for forward references that need patching */
38
- export interface PendingRef {
39
- readonly __pendingRef: true;
40
- readonly id: number;
41
- }
42
-
43
- export declare namespace PendingRef {
44
- function create(id: number): PendingRef;
45
- function is(value: any): value is PendingRef;
46
- }
47
-
48
- export interface DeserializeOptions {
49
- /** If true, freeze all deserialized objects after patching */
50
- freeze?: boolean;
51
- }
package/serde.js DELETED
@@ -1,99 +0,0 @@
1
- "use strict";
2
- /**
3
- * Serde runtime helpers for macroforge Serialize/Deserialize macros.
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PendingRef = exports.DeserializeContext = exports.SerializeContext = void 0;
7
-
8
- // ============================================================================
9
- // Serialization Context
10
- // ============================================================================
11
-
12
- var SerializeContext;
13
- (function (SerializeContext) {
14
- function create() {
15
- const ids = new WeakMap();
16
- let nextId = 0;
17
- return {
18
- getId: (obj) => ids.get(obj),
19
- register: (obj) => {
20
- const id = nextId++;
21
- ids.set(obj, id);
22
- return id;
23
- },
24
- };
25
- }
26
- SerializeContext.create = create;
27
- })(SerializeContext || (exports.SerializeContext = SerializeContext = {}));
28
-
29
- // ============================================================================
30
- // Deserialization Context
31
- // ============================================================================
32
-
33
- var DeserializeContext;
34
- (function (DeserializeContext) {
35
- function create() {
36
- const registry = new Map();
37
- const patches = [];
38
- const toFreeze = [];
39
- return {
40
- register: (id, instance) => {
41
- registry.set(id, instance);
42
- },
43
- getOrDefer: (refId) => {
44
- if (registry.has(refId)) {
45
- return registry.get(refId);
46
- }
47
- return PendingRef.create(refId);
48
- },
49
- assignOrDefer: (target, prop, value) => {
50
- if (PendingRef.is(value)) {
51
- target[prop] = null;
52
- patches.push({ target, prop, refId: value.id });
53
- }
54
- else {
55
- target[prop] = value;
56
- }
57
- },
58
- addPatch: (target, prop, refId) => {
59
- patches.push({ target, prop, refId });
60
- },
61
- trackForFreeze: (obj) => {
62
- toFreeze.push(obj);
63
- },
64
- applyPatches: () => {
65
- for (const { target, prop, refId } of patches) {
66
- if (!registry.has(refId)) {
67
- throw new Error(`Unresolved reference: __ref ${refId}`);
68
- }
69
- target[prop] = registry.get(refId);
70
- }
71
- },
72
- freezeAll: () => {
73
- for (const obj of toFreeze) {
74
- Object.freeze(obj);
75
- }
76
- },
77
- };
78
- }
79
- DeserializeContext.create = create;
80
- })(DeserializeContext || (exports.DeserializeContext = DeserializeContext = {}));
81
-
82
- // ============================================================================
83
- // Pending Reference Marker
84
- // ============================================================================
85
-
86
- var PendingRef;
87
- (function (PendingRef) {
88
- function create(id) {
89
- return { __pendingRef: true, id };
90
- }
91
- PendingRef.create = create;
92
- function is(value) {
93
- return (value !== null &&
94
- typeof value === "object" &&
95
- value.__pendingRef === true &&
96
- typeof value.id === "number");
97
- }
98
- PendingRef.is = is;
99
- })(PendingRef || (exports.PendingRef = PendingRef = {}));