@kimesh/kit 0.2.48 → 0.2.49

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 +12 -5
  2. package/package.json +5 -9
package/dist/index.mjs CHANGED
@@ -255,27 +255,34 @@ function createKimesh(options) {
255
255
  }
256
256
  };
257
257
  }
258
- let currentKimesh;
258
+ const KIMESH_CONTEXT_KEY = "__kimesh_context__";
259
+ function _getContext() {
260
+ return globalThis[KIMESH_CONTEXT_KEY];
261
+ }
262
+ function _setContext(kimesh) {
263
+ globalThis[KIMESH_CONTEXT_KEY] = kimesh;
264
+ }
259
265
  /**
260
266
  * Set the current Kimesh context (internal use)
261
267
  */
262
268
  function _setKimeshContext(kimesh) {
263
- currentKimesh = kimesh;
269
+ _setContext(kimesh);
264
270
  }
265
271
  /**
266
272
  * Get the current Kimesh context
267
273
  * @throws Error if not in a Kimesh context
268
274
  */
269
275
  function useKimesh() {
270
- if (!currentKimesh) throw new Error("[kimesh] useKimesh() called outside of Kimesh context. Make sure you're calling this within a module setup function.");
271
- return currentKimesh;
276
+ const ctx = _getContext();
277
+ if (!ctx) throw new Error("[kimesh] useKimesh() called outside of Kimesh context. Make sure you're calling this within a module setup function.");
278
+ return ctx;
272
279
  }
273
280
  /**
274
281
  * Try to get the current Kimesh context
275
282
  * @returns Kimesh instance or undefined if not in context
276
283
  */
277
284
  function tryUseKimesh() {
278
- return currentKimesh;
285
+ return _getContext();
279
286
  }
280
287
  //#endregion
281
288
  //#region src/core/module.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kimesh/kit",
3
- "version": "0.2.48",
3
+ "version": "0.2.49",
4
4
  "description": "Build-time engine for Kimesh framework",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,9 +27,9 @@
27
27
  "test:watch": "vitest"
28
28
  },
29
29
  "dependencies": {
30
- "@kimesh/auto-import": "0.2.48",
31
- "@kimesh/layers": "0.2.48",
32
- "@kimesh/router-generator": "0.2.48",
30
+ "@kimesh/auto-import": "0.2.49",
31
+ "@kimesh/layers": "0.2.49",
32
+ "@kimesh/router-generator": "0.2.49",
33
33
  "@vitejs/plugin-vue": "^6.0.5",
34
34
  "c12": "^3.3.3",
35
35
  "consola": "^3.4.2",
@@ -46,14 +46,10 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^25.0.8",
49
- "tsdown": "^0.21.2",
49
+ "tsdown": "^0.21.4",
50
50
  "typescript": "^5.9.3",
51
51
  "unplugin-vue-components": "^31.0.0",
52
52
  "vite": "^8.0.0",
53
53
  "vue": "^3.5.30"
54
- },
55
- "peerDependencies": {
56
- "vite": "^8.0.0",
57
- "vue": "^3.5.0"
58
54
  }
59
55
  }