mhx 2026.1.2 → 2026.1.4

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/npm/index.js CHANGED
@@ -1,11 +1,14 @@
1
1
  import * as mhx from "../dist/index.js";
2
- import { initMhxFfi } from "../dist/mhx_ffi.js";
2
+ import * as mhxFfi from "../dist/mhx_ffi.js";
3
3
 
4
- initMhxFfi({
5
- on_fetch_success: mhx.on_fetch_success,
6
- on_fetch_error: mhx.on_fetch_error,
7
- on_mutation_observed: mhx.on_mutation_observed,
8
- });
4
+ globalThis.mhx_ffi = mhxFfi;
5
+ if (mhxFfi.initMhxFfi) {
6
+ mhxFfi.initMhxFfi({
7
+ on_fetch_success: mhx.on_fetch_success,
8
+ on_fetch_error: mhx.on_fetch_error,
9
+ on_mutation_observed: mhx.on_mutation_observed,
10
+ });
11
+ }
9
12
 
10
13
  export const init_mhx = mhx.init_mhx;
11
14
  export const process = mhx.process;
@@ -0,0 +1,26 @@
1
+ import { copyFileSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { join } from "node:path";
3
+
4
+ const root = process.cwd();
5
+ const distDir = join(root, "dist");
6
+ const buildMain = join(root, "_build/js/release/build/main/main.js");
7
+ const buildFfi = join(root, "src/ffi/mhx_ffi.js");
8
+
9
+ mkdirSync(distDir, { recursive: true });
10
+
11
+ let mainJs = readFileSync(buildMain, "utf8");
12
+ const exportsBlock = `
13
+ export const init_mhx = f4ah6o$mhx$core$$init_mhx;
14
+ export const process = f4ah6o$mhx$core$$process;
15
+ export const handle_event = f4ah6o$mhx$core$$handle_event;
16
+ export const get_instance = f4ah6o$mhx$core$$get_instance;
17
+ export const version = f4ah6o$mhx$$version;
18
+ export const on_fetch_success = f4ah6o$mhx$network$$on_fetch_success;
19
+ export const on_fetch_error = f4ah6o$mhx$network$$on_fetch_error;
20
+ export const on_mutation_observed = f4ah6o$mhx$core$$on_mutation_observed;
21
+ `;
22
+ if (!mainJs.includes("export const init_mhx")) {
23
+ mainJs += `\n${exportsBlock}`;
24
+ }
25
+ writeFileSync(join(distDir, "index.js"), mainJs);
26
+ copyFileSync(buildFfi, join(distDir, "mhx_ffi.js"));
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "mhx",
3
- "version": "2026.1.2",
3
+ "version": "2026.1.4",
4
4
  "type": "module",
5
- "exports": "./npm/index.js",
5
+ "exports": {
6
+ ".": "./npm/index.js",
7
+ "./ffi": "./dist/mhx_ffi.js"
8
+ },
6
9
  "files": [
7
10
  "dist",
8
11
  "npm",
@@ -11,7 +14,7 @@
11
14
  ],
12
15
  "scripts": {
13
16
  "build:moon": "moon fmt && moon check && moon test && moon build --target js",
14
- "build": "pnpm build:moon && mkdir -p dist && cp _build/js/release/build/main/main.js dist/index.js && cp src/ffi/mhx_ffi.js dist/mhx_ffi.js"
17
+ "build": "pnpm build:moon && node npm/postbuild.mjs"
15
18
  },
16
19
  "license": "Apache-2.0",
17
20
  "repository": {