mbler 0.2.8-rc.2 → 0.2.8-rc.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/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 };
@@ -97,13 +97,13 @@ 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 16d7601ca78c6e6179b16bb2ee694ae0f51bf038
101
101
  Author: ruanhor <3915264929@qq.com>
102
- Date: Thu Jun 25 17:49:27 2026 +0800
102
+ Date: Sun Jun 28 00:17:14 2026 +0800
103
103
 
104
- chore: update @mbler/mcx-core to 0.1.2-rc.6
104
+ fix: use forward slash normalization instead of pathToFileURL for Windows dynamic import compat; add version.d.ts to eslint allowDefaultProject
105
105
  `,
106
- version: "0.2.8-rc.2"
106
+ version: "0.2.8-rc.4"
107
107
  };
108
108
  }));
109
109
  //#endregion
@@ -654,7 +654,7 @@ function join(baseDir, inputPath) {
654
654
  return path$1.isAbsolute(inputPath) ? inputPath : path$1.join(baseDir, inputPath);
655
655
  }
656
656
  async function ReadProjectMblerConfig(project) {
657
- const file = (await import(path$1.join(project, BuildConfig.ConfigFile))).default || {};
657
+ const file = (await import(path$1.join(project, BuildConfig.ConfigFile).replace(/\\/g, "/"))).default || {};
658
658
  for (const key in file) if (!(key in templateMblerConfig)) throw new Error(`[read config]: read config from '${project}' error: Unexpected '${key}'`);
659
659
  const config = {
660
660
  ...templateMblerConfig,
@@ -799,8 +799,7 @@ var Progress = class {
799
799
  //#region src/build/cache.ts
800
800
  var BuildCacheManager = class {
801
801
  mode;
802
- constructor(_projectRoot, mode, isWatch, _cachePath) {
803
- this.isWatch = isWatch;
802
+ constructor(_projectRoot, mode, _cachePath) {
804
803
  this.mode = this.resolveMode(mode);
805
804
  }
806
805
  getMode() {
@@ -1134,24 +1133,11 @@ var Build = class {
1134
1133
  srcDirs = null;
1135
1134
  outdirs = null;
1136
1135
  mcxLanguagePluginCreator = null;
1137
- constructor(opts, baseBuildDir, resolve, isWatch = false) {
1136
+ constructor(config, baseBuildDir, resolve, isWatch = false) {
1138
1137
  this.baseBuildDir = baseBuildDir;
1139
1138
  this.resolve = resolve;
1140
1139
  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
- }
1140
+ this.currentConfig = config;
1155
1141
  }
1156
1142
  /**
1157
1143
  * Start the watch mode.
@@ -1255,21 +1241,13 @@ var Build = class {
1255
1241
  * emitted.
1256
1242
  */
1257
1243
  async build() {
1244
+ if (!this.currentConfig) throw new TypeError("[mbler Builder]: cannot load config");
1258
1245
  const buildStart = performance.now();
1259
1246
  const progress = new Progress(100);
1260
1247
  this.init = true;
1261
1248
  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
1249
  if (this.currentConfig.build) this.buildConfig = this.currentConfig.build;
1272
- this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.isWatch, this.buildConfig?.cachePath);
1250
+ this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.buildConfig?.cachePath);
1273
1251
  if (this.isDebug) console.debug(`[mbler DEBUG]: init cache: cache mode: ${this.cacheManager.getMode()}`);
1274
1252
  if (this.buildConfig?.onStart) await this.buildConfig.onStart(this.currentConfig);
1275
1253
  this.loadData();
@@ -1334,7 +1312,7 @@ var Build = class {
1334
1312
  }
1335
1313
  if (!this.isWatch) {
1336
1314
  progress.update(100);
1337
- if (this.isDebug) console.debug(`[mbler DEBUG]: success build. usage time: ${performance.now() - buildStart}ms`);
1315
+ if (this.isDebug) console.debug(`[mbler DEBUG]: success build. build usage time: ${performance.now() - buildStart}ms`);
1338
1316
  }
1339
1317
  if (!this.isWatch) {
1340
1318
  const elapsed = ((performance.now() - buildStart) / 1e3).toFixed(2);
@@ -1489,7 +1467,7 @@ var Build = class {
1489
1467
  Logger.i("Watcher", "detected config change, reload config");
1490
1468
  this.currentConfig = await ReadProjectMblerConfig(this.baseBuildDir);
1491
1469
  this.buildConfig = this.currentConfig.build || null;
1492
- this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.isWatch, this.buildConfig?.cachePath);
1470
+ this.cacheManager = new BuildCacheManager(this.baseBuildDir, this.buildConfig?.cache, this.buildConfig?.cachePath);
1493
1471
  this.loadData();
1494
1472
  if (this.isChange(oldConfig, this.currentConfig, [
1495
1473
  "name",
@@ -1670,15 +1648,15 @@ var Build = class {
1670
1648
  await Promise.all(tasks);
1671
1649
  }
1672
1650
  };
1673
- function build(cliParam, work) {
1651
+ function build(config, work) {
1674
1652
  return new Promise((resolve) => {
1675
- new Build(cliParam.opts, work, resolve).start();
1653
+ new Build(config, work, resolve).start();
1676
1654
  });
1677
1655
  }
1678
- function watch(cliParam, work) {
1656
+ function watch(config, work) {
1679
1657
  return new Promise((resolve, reject) => {
1680
1658
  try {
1681
- const build = new Build(cliParam.opts, work, resolve, true);
1659
+ const build = new Build(config, work, resolve, true);
1682
1660
  build.start().then(() => {
1683
1661
  build.watch();
1684
1662
  showText(`[${styleText("green", "mbler")}] ${styleText("bgYellow", "watching for file changes...")}`);