mbler 0.2.8-rc.2 → 0.2.8-rc.3

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 RuanhoR
3
+ Copyright (c) 2025 ~ 2026 RuanhoR
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/build.d.ts CHANGED
@@ -38,10 +38,6 @@ interface MblerConfigData {
38
38
  minify?: 'oxc' | 'terser' | 'esbuild';
39
39
  build?: Partial<MblerBuildConfig>;
40
40
  }
41
- interface CliParam {
42
- params: string[];
43
- opts: Record<string, string>;
44
- }
45
41
  //#endregion
46
42
  //#region src/build/sapi.d.ts
47
43
  declare const Sapi: () => {
@@ -66,7 +62,7 @@ declare class Build {
66
62
  srcDirs: { [key in 'behavior' | 'resources']: string } | null;
67
63
  outdirs: { [key in 'behavior' | 'resources' | 'dist']: string } | null;
68
64
  mcxLanguagePluginCreator: ((ts: typeof import('typescript')) => LanguagePlugin<unknown>) | null;
69
- constructor(opts: Record<string, string>, baseBuildDir: string, resolve: (a: number) => void, isWatch?: boolean);
65
+ constructor(config: MblerConfigData, baseBuildDir: string, resolve: (a: number) => void, isWatch?: boolean);
70
66
  /**
71
67
  * Start the watch mode.
72
68
  * This will perform an initial build (if not already done) and then
@@ -161,7 +157,7 @@ declare class Build {
161
157
  */
162
158
  private handlerOtherAddon;
163
159
  }
164
- declare function build(cliParam: CliParam, work: string): Promise<number>;
165
- declare function watch(cliParam: CliParam, work: string): Promise<number>;
160
+ declare function build(config: MblerConfigData, work: string): Promise<number>;
161
+ declare function watch(config: MblerConfigData, work: string): Promise<number>;
166
162
  //#endregion
167
163
  export { Build, runTSC as McxTsc, _default as Sapi, build, watch };
@@ -8,11 +8,11 @@ import * as readline from "readline";
8
8
  import * as fs$2 from "node:fs";
9
9
  import fs$1 from "node:fs";
10
10
  import os, { homedir, tmpdir } from "node:os";
11
+ import { pathToFileURL } from "node:url";
11
12
  import { styleText } from "node:util";
12
13
  import { createMCXLanguagePlugin } from "@mbler/mcx-server";
13
14
  import { runTsc } from "@volar/typescript/lib/quickstart/runTsc.js";
14
15
  import { env } from "node:process";
15
- import { pathToFileURL } from "node:url";
16
16
  import crypto from "node:crypto";
17
17
  //#region \0rolldown/runtime.js
18
18
  var __defProp = Object.defineProperty;
@@ -97,13 +97,19 @@ var init_types = __esmMin((() => {
97
97
  var version_default;
98
98
  var init_version = __esmMin((() => {
99
99
  version_default = {
100
- commit: `commit 164fd7aeb5c239cb71de8050c1440423d89bd0e1
100
+ commit: `commit 1baf9507d75a8356a2e032f3556dd630645f0c00
101
101
  Author: ruanhor <3915264929@qq.com>
102
- Date: Thu Jun 25 17:49:27 2026 +0800
102
+ Date: Sat Jun 27 23:38:10 2026 +0800
103
103
 
104
- chore: update @mbler/mcx-core to 0.1.2-rc.6
104
+ fix: cross-platform compatibility improvements
105
+
106
+ - Use pathToFileURL for dynamic import() to support Windows paths
107
+ - Enable shell mode in spawn() on Windows for .cmd/.bat resolution
108
+ - Fix BUILD_MODULE env var syntax in example with cross-env
109
+ - Bump version: 0.2.8-rc.2 -> 0.2.8-rc.3
110
+ - Update @mbler/mcx-server dependency to 0.1.1-rc.5
105
111
  `,
106
- version: "0.2.8-rc.2"
112
+ version: "0.2.8-rc.3"
107
113
  };
108
114
  }));
109
115
  //#endregion
@@ -654,7 +660,7 @@ function join(baseDir, inputPath) {
654
660
  return path$1.isAbsolute(inputPath) ? inputPath : path$1.join(baseDir, inputPath);
655
661
  }
656
662
  async function ReadProjectMblerConfig(project) {
657
- const file = (await import(path$1.join(project, BuildConfig.ConfigFile))).default || {};
663
+ const file = (await import(pathToFileURL(path$1.join(project, BuildConfig.ConfigFile)).href)).default || {};
658
664
  for (const key in file) if (!(key in templateMblerConfig)) throw new Error(`[read config]: read config from '${project}' error: Unexpected '${key}'`);
659
665
  const config = {
660
666
  ...templateMblerConfig,
@@ -799,8 +805,7 @@ var Progress = class {
799
805
  //#region src/build/cache.ts
800
806
  var BuildCacheManager = class {
801
807
  mode;
802
- constructor(_projectRoot, mode, isWatch, _cachePath) {
803
- this.isWatch = isWatch;
808
+ constructor(_projectRoot, mode, _cachePath) {
804
809
  this.mode = this.resolveMode(mode);
805
810
  }
806
811
  getMode() {
@@ -1134,24 +1139,11 @@ var Build = class {
1134
1139
  srcDirs = null;
1135
1140
  outdirs = null;
1136
1141
  mcxLanguagePluginCreator = null;
1137
- constructor(opts, baseBuildDir, resolve, isWatch = false) {
1142
+ constructor(config, baseBuildDir, resolve, isWatch = false) {
1138
1143
  this.baseBuildDir = baseBuildDir;
1139
1144
  this.resolve = resolve;
1140
1145
  this.isWatch = isWatch;
1141
- if (this.isDebug) {
1142
- const { performance } = __require("perf_hooks");
1143
- const Module = __require("module");
1144
- const originalRequire = Module.prototype.require;
1145
- Module.prototype.require = function(id) {
1146
- const isCached = !!Module._cache[id];
1147
- const start = performance.now();
1148
- const result = originalRequire.call(this, id);
1149
- const duration = performance.now() - start;
1150
- const status = isCached ? "🔄 CACHED" : "📦 FIRST";
1151
- if (duration > 5) console.log(`[mbler Module load DEBUG]: ${status} [${duration.toFixed(2)}ms] ${id}`);
1152
- return result;
1153
- };
1154
- }
1146
+ this.currentConfig = config;
1155
1147
  }
1156
1148
  /**
1157
1149
  * Start the watch mode.
@@ -1255,21 +1247,13 @@ var Build = class {
1255
1247
  * emitted.
1256
1248
  */
1257
1249
  async build() {
1250
+ if (!this.currentConfig) throw new TypeError("[mbler Builder]: cannot load config");
1258
1251
  const buildStart = performance.now();
1259
1252
  const progress = new Progress(100);
1260
1253
  this.init = true;
1261
1254
  if (!isAbsolute(this.baseBuildDir)) throw new Error("[init build]: build dir is not absolute path");
1262
- /**
1263
- * on debug, show config load time
1264
- * This is for debug.
1265
- */
1266
- if (this.isDebug) {
1267
- const t0 = performance.now();
1268
- this.currentConfig = await ReadProjectMblerConfig(this.baseBuildDir);
1269
- console.debug(`[mbler DEBUG] config loaded in ${(performance.now() - t0).toFixed(2)}ms`);
1270
- } else this.currentConfig = await ReadProjectMblerConfig(this.baseBuildDir);
1271
1255
  if (this.currentConfig.build) this.buildConfig = this.currentConfig.build;
1272
- this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.isWatch, this.buildConfig?.cachePath);
1256
+ this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.buildConfig?.cachePath);
1273
1257
  if (this.isDebug) console.debug(`[mbler DEBUG]: init cache: cache mode: ${this.cacheManager.getMode()}`);
1274
1258
  if (this.buildConfig?.onStart) await this.buildConfig.onStart(this.currentConfig);
1275
1259
  this.loadData();
@@ -1334,7 +1318,7 @@ var Build = class {
1334
1318
  }
1335
1319
  if (!this.isWatch) {
1336
1320
  progress.update(100);
1337
- if (this.isDebug) console.debug(`[mbler DEBUG]: success build. usage time: ${performance.now() - buildStart}ms`);
1321
+ if (this.isDebug) console.debug(`[mbler DEBUG]: success build. build usage time: ${performance.now() - buildStart}ms`);
1338
1322
  }
1339
1323
  if (!this.isWatch) {
1340
1324
  const elapsed = ((performance.now() - buildStart) / 1e3).toFixed(2);
@@ -1489,7 +1473,7 @@ var Build = class {
1489
1473
  Logger.i("Watcher", "detected config change, reload config");
1490
1474
  this.currentConfig = await ReadProjectMblerConfig(this.baseBuildDir);
1491
1475
  this.buildConfig = this.currentConfig.build || null;
1492
- this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.isWatch, this.buildConfig?.cachePath);
1476
+ this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.buildConfig?.cachePath);
1493
1477
  this.loadData();
1494
1478
  if (this.isChange(oldConfig, this.currentConfig, [
1495
1479
  "name",
@@ -1670,15 +1654,15 @@ var Build = class {
1670
1654
  await Promise.all(tasks);
1671
1655
  }
1672
1656
  };
1673
- function build(cliParam, work) {
1657
+ function build(config, work) {
1674
1658
  return new Promise((resolve) => {
1675
- new Build(cliParam.opts, work, resolve).start();
1659
+ new Build(config, work, resolve).start();
1676
1660
  });
1677
1661
  }
1678
- function watch(cliParam, work) {
1662
+ function watch(config, work) {
1679
1663
  return new Promise((resolve, reject) => {
1680
1664
  try {
1681
- const build = new Build(cliParam.opts, work, resolve, true);
1665
+ const build = new Build(config, work, resolve, true);
1682
1666
  build.start().then(() => {
1683
1667
  build.watch();
1684
1668
  showText(`[${styleText("green", "mbler")}] ${styleText("bgYellow", "watching for file changes...")}`);