@olane/o-core 0.8.8 → 0.8.10

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.
@@ -1 +1 @@
1
- {"version":3,"file":"o-request-context.d.ts","sourceRoot":"","sources":["../../../src/context/o-request-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B;AAkBD,eAAO,MAAM,eAAe;QACtB,CAAC,SAAS,aAAa,MAAM,MAAM,CAAC,GAAG,CAAC;gBAoBhC,aAAa,GAAG,SAAS;eAO1B,mBAAmB,GAAG,SAAS;uBAIvB,aAAa,GAAG,SAAS;CAG7C,CAAC"}
1
+ {"version":3,"file":"o-request-context.d.ts","sourceRoot":"","sources":["../../../src/context/o-request-context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEhE,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE;QACN,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;QACxB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,YAAY,CAAC,EAAE,aAAa,CAAC;CAC9B;AAID,eAAO,MAAM,eAAe;QACtB,CAAC,SAAS,aAAa,MAAM,MAAM,CAAC,GAAG,CAAC;gBAIhC,aAAa,GAAG,SAAS;eAI1B,mBAAmB,GAAG,SAAS;uBAIvB,aAAa,GAAG,SAAS;CAG7C,CAAC"}
@@ -1,44 +1,11 @@
1
- // Runtime detection: use native AsyncLocalStorage if available (Node, Deno, Bun, CF Workers).
2
- // Falls back to a simple variable for browsers/React Native where concurrent
3
- // multi-user requests don't happen.
4
- // Uses synchronous require() instead of top-level await import() for Hermes compatibility.
5
- let nativeALS = null;
6
- try {
7
- // eslint-disable-next-line @typescript-eslint/no-require-imports
8
- const mod = require('node:async_hooks');
9
- nativeALS = new mod.AsyncLocalStorage();
10
- }
11
- catch {
12
- // Not available — browser or React Native runtime
13
- }
14
- // Browser fallback state
15
- let currentStore;
1
+ import { createOContext } from '@olane/o-context';
2
+ const ctx = createOContext();
16
3
  export const oRequestContext = {
17
4
  run(store, fn) {
18
- if (nativeALS) {
19
- return nativeALS.run(store, fn);
20
- }
21
- // Browser fallback: simple variable swap (safe for single-user environments)
22
- const prev = currentStore;
23
- currentStore = store;
24
- try {
25
- const result = fn();
26
- if (result instanceof Promise) {
27
- return result.finally(() => { currentStore = prev; });
28
- }
29
- currentStore = prev;
30
- return result;
31
- }
32
- catch (e) {
33
- currentStore = prev;
34
- throw e;
35
- }
5
+ return ctx.run(store, fn);
36
6
  },
37
7
  getStore() {
38
- if (nativeALS) {
39
- return nativeALS.getStore();
40
- }
41
- return currentStore;
8
+ return ctx.getStore();
42
9
  },
43
10
  getAuth() {
44
11
  return oRequestContext.getStore()?.auth;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@olane/o-core",
3
- "version": "0.8.8",
3
+ "version": "0.8.10",
4
4
  "type": "module",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -63,12 +63,13 @@
63
63
  "typescript": "^5.8.3"
64
64
  },
65
65
  "dependencies": {
66
- "@olane/o-protocol": "0.8.8",
66
+ "@olane/o-context": "0.8.10",
67
+ "@olane/o-protocol": "0.8.10",
67
68
  "chalk": "^5.4.1",
68
69
  "debug": "^4.4.1",
69
70
  "dotenv": "^16.5.0",
70
71
  "multiformats": "^13.3.7",
71
72
  "stream-json": "^1.9.1"
72
73
  },
73
- "gitHead": "3e8d25714b2ee178c851c92d0f05af94572b9959"
74
+ "gitHead": "fca15d711df7b21772157a7cd3081fdb065367f9"
74
75
  }