@power-plant/core 0.0.44 → 0.0.46

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/dist/context.cjs CHANGED
@@ -8,21 +8,22 @@ const globalStore = globalThis;
8
8
  const GLOBAL_CONTEXT_KEY = "$$__power_plant_{key}_context__";
9
9
  function createContextStore(key) {
10
10
  const contextKey = GLOBAL_CONTEXT_KEY.replace("{key}", (0, _stryke_string_format_snake_case.snakeCase)(key.trim().replace(/^[_-]*/g, "").replace(/[_-]*$/g, "")));
11
+ const asyncLocalStorage = new node_async_hooks.AsyncLocalStorage();
11
12
  globalStore[contextKey] ?? (globalStore[contextKey] = {
12
- asyncLocalStorage: new node_async_hooks.AsyncLocalStorage(),
13
+ asyncLocalStorage,
13
14
  use() {
14
- const instance = this.asyncLocalStorage.getStore();
15
+ const instance = asyncLocalStorage.getStore();
15
16
  if (instance === void 0) throw new Error(`The ${(0, _stryke_string_format_title_case.titleCase)(key.trim().replace(/^[_-]*/g, "").replace(/[_-]*$/g, ""))} context is not available. Please ensure that the context has been initialized before using it.`);
16
17
  return instance;
17
18
  },
18
19
  tryUse() {
19
- return this.asyncLocalStorage.getStore();
20
+ return asyncLocalStorage.getStore();
20
21
  },
21
22
  call(instance, callback) {
22
- return this.asyncLocalStorage.run(instance, callback);
23
+ return asyncLocalStorage.run(instance, callback);
23
24
  },
24
25
  async callAsync(instance, callback) {
25
- return this.asyncLocalStorage.run(instance, callback);
26
+ return asyncLocalStorage.run(instance, callback);
26
27
  }
27
28
  });
28
29
  return globalStore[contextKey];
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.cts","names":[],"sources":["../src/context.ts"],"mappings":";;;;;;UA0BiB,aAAa,iBAAiB;EAC7C,mBAAmB,kBAAkB;EACrC,WAAW;EACX,cAAc;EACd,OAAO,GAAG,UAAU,UAAU,gBAAgB,MAAM;EACpD,YAAY,GACV,UAAU,UACV,gBAAgB,IAAI,QAAQ,OACzB,QAAQ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iB;;;;cAKjB,kBAAU;;;;;;cAOV,4BAAoB;;;;cAKpB,qBAAa;;;;;;;;cASb,qBAvGJ,GAAC,UAAA,gBAAA,gBAAA,MAAA;;;;cA4GG,cA5GJ,GAAC,UAAA,gBAAA,gBAAA,MAAA;;;;;;;;cAqHG,0BApHC,GAAC,UAAA,gBAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cAyHF,mBAzHC,GAAC,UAAA,gBAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cA8HF,kBAAgB,aAAA;;;;cAMhB,4BAA0B,kBAAA;;;;;;;;;;iBAWvB,oBACd,OACA,yBACA,oBAEiC,iBAAiB,OAAO,UAAU;;;;;;;;;;;;;iBAerD,aACd,OACA,yBACA,oBAAe,iBAAA,OAAA,UAAA;;;;;;;;;;;;;iBAiBD,WAAW,OAAO,yBAAyB,oBAAe,iBAAA,OAAA,UAAA;;;;;;cAS7D,8BAAsB;;;;cAKtB,uBAAe;;;;;;;;cASf,uBA/MJ,GAAC,UAAA,iCAAA,gBAAA,MAAA;;;;cAoNG,gBApNJ,GAAC,UAAA,iCAAA,gBAAA,MAAA;;;;;;;;cA6NG,4BA5NC,GAAC,UAAA,iCAAA,gBAAA,IAAA,QAAA,OAAA,QAAA;;;;cAiOF,qBAjOC,GAAC,UAAA,iCAAA,gBAAA,IAAA,QAAA,OAAA,QAAA"}
package/dist/context.mjs CHANGED
@@ -7,21 +7,22 @@ const globalStore = globalThis;
7
7
  const GLOBAL_CONTEXT_KEY = "$$__power_plant_{key}_context__";
8
8
  function createContextStore(key) {
9
9
  const contextKey = GLOBAL_CONTEXT_KEY.replace("{key}", snakeCase(key.trim().replace(/^[_-]*/g, "").replace(/[_-]*$/g, "")));
10
+ const asyncLocalStorage = new AsyncLocalStorage();
10
11
  globalStore[contextKey] ?? (globalStore[contextKey] = {
11
- asyncLocalStorage: new AsyncLocalStorage(),
12
+ asyncLocalStorage,
12
13
  use() {
13
- const instance = this.asyncLocalStorage.getStore();
14
+ const instance = asyncLocalStorage.getStore();
14
15
  if (instance === void 0) throw new Error(`The ${titleCase(key.trim().replace(/^[_-]*/g, "").replace(/[_-]*$/g, ""))} context is not available. Please ensure that the context has been initialized before using it.`);
15
16
  return instance;
16
17
  },
17
18
  tryUse() {
18
- return this.asyncLocalStorage.getStore();
19
+ return asyncLocalStorage.getStore();
19
20
  },
20
21
  call(instance, callback) {
21
- return this.asyncLocalStorage.run(instance, callback);
22
+ return asyncLocalStorage.run(instance, callback);
22
23
  },
23
24
  async callAsync(instance, callback) {
24
- return this.asyncLocalStorage.run(instance, callback);
25
+ return asyncLocalStorage.run(instance, callback);
25
26
  }
26
27
  });
27
28
  return globalStore[contextKey];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@power-plant/core",
3
- "version": "0.0.44",
3
+ "version": "0.0.46",
4
4
  "private": false,
5
5
  "description": "☢️ Generate anything from a specification",
6
6
  "keywords": ["power-plant", "storm-software"],
@@ -160,7 +160,7 @@
160
160
  "typings": "dist/index.d.mts",
161
161
  "files": ["dist"],
162
162
  "dependencies": {
163
- "@power-plant/schema": "^0.0.43",
163
+ "@power-plant/schema": "^0.0.44",
164
164
  "@stryke/string-format": "^0.17.40",
165
165
  "@stryke/type-checks": "^0.6.31",
166
166
  "@stryke/types": "^0.12.26",
@@ -184,5 +184,5 @@
184
184
  "typescript": "^6.0.3"
185
185
  },
186
186
  "publishConfig": { "access": "public" },
187
- "gitHead": "4c640e0f8d2afdf51154ce764d66ad53fa25ef6b"
187
+ "gitHead": "045ed62487e94e5ac0ae8189fa5e719897938b12"
188
188
  }