@kimesh/kit 0.2.5 → 0.2.6

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.
Files changed (2) hide show
  1. package/dist/index.mjs +25 -3
  2. package/package.json +4 -4
package/dist/index.mjs CHANGED
@@ -2552,12 +2552,34 @@ function kimeshPlugin(options = {}) {
2552
2552
  //#endregion
2553
2553
  //#region src/config.ts
2554
2554
  /**
2555
+ * Wrap a function with defineKmConfig injected into globalThis.
2556
+ * This allows kimesh.config.ts to use defineKmConfig without explicit import (like Nuxt).
2557
+ *
2558
+ * @internal
2559
+ */
2560
+ async function withDefineKmConfig(fn) {
2561
+ const key = "defineKmConfig";
2562
+ const globalSelf = globalThis;
2563
+ if (!globalSelf[key]) {
2564
+ globalSelf[key] = defineKmConfig;
2565
+ globalSelf[key].count = 0;
2566
+ }
2567
+ globalSelf[key].count++;
2568
+ try {
2569
+ return await fn();
2570
+ } finally {
2571
+ globalSelf[key].count--;
2572
+ if (!globalSelf[key].count) delete globalSelf[key];
2573
+ }
2574
+ }
2575
+ /**
2555
2576
  * Load kimesh.config.ts using c12
2556
2577
  */
2557
2578
  async function loadConfig(options = {}) {
2558
- const { config, configFile } = await loadConfig$1({
2579
+ const root = options.root || process.cwd();
2580
+ const { config, configFile } = await withDefineKmConfig(() => loadConfig$1({
2559
2581
  name: "kimesh",
2560
- cwd: options.root || process.cwd(),
2582
+ cwd: root,
2561
2583
  configFile: options.configFile,
2562
2584
  defaultConfig: {
2563
2585
  name: "kimesh-app",
@@ -2566,7 +2588,7 @@ async function loadConfig(options = {}) {
2566
2588
  host: "localhost"
2567
2589
  }
2568
2590
  }
2569
- });
2591
+ }));
2570
2592
  if (configFile) consola.debug(`[Kimesh] Config loaded from: ${configFile}`);
2571
2593
  return config || {};
2572
2594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimesh/kit",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Build-time engine for Kimesh framework",
5
5
  "type": "module",
6
6
  "repository": {
@@ -30,9 +30,9 @@
30
30
  "vue": "^3.5.0"
31
31
  },
32
32
  "dependencies": {
33
- "@kimesh/auto-import": "0.2.5",
34
- "@kimesh/layers": "0.2.5",
35
- "@kimesh/router-generator": "0.2.5",
33
+ "@kimesh/auto-import": "0.2.6",
34
+ "@kimesh/layers": "0.2.6",
35
+ "@kimesh/router-generator": "0.2.6",
36
36
  "@vitejs/plugin-vue": "^6.0.3",
37
37
  "c12": "^3.3.3",
38
38
  "consola": "^3.4.2",