@cedarjs/context 5.0.6-rc.4 → 5.0.7-next.186
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/package.json +8 -22
- package/dist/cjs/context.d.ts +0 -13
- package/dist/cjs/context.d.ts.map +0 -1
- package/dist/cjs/context.js +0 -76
- package/dist/cjs/global.api-auto-imports.d.ts +0 -5
- package/dist/cjs/global.api-auto-imports.d.ts.map +0 -1
- package/dist/cjs/global.api-auto-imports.js +0 -1
- package/dist/cjs/index.d.ts +0 -4
- package/dist/cjs/index.d.ts.map +0 -1
- package/dist/cjs/index.js +0 -25
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/store.d.ts +0 -9
- package/dist/cjs/store.d.ts.map +0 -1
- package/dist/cjs/store.js +0 -35
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/context",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7-next.186",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -10,38 +10,25 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"
|
|
13
|
+
"default": {
|
|
14
14
|
"types": "./dist/index.d.ts",
|
|
15
15
|
"default": "./dist/index.js"
|
|
16
|
-
},
|
|
17
|
-
"default": {
|
|
18
|
-
"types": "./dist/cjs/index.d.ts",
|
|
19
|
-
"default": "./dist/cjs/index.js"
|
|
20
16
|
}
|
|
21
17
|
},
|
|
22
18
|
"./dist/store": {
|
|
23
|
-
"
|
|
19
|
+
"default": {
|
|
24
20
|
"types": "./dist/store.d.ts",
|
|
25
21
|
"default": "./dist/store.js"
|
|
26
|
-
},
|
|
27
|
-
"default": {
|
|
28
|
-
"types": "./dist/cjs/store.d.ts",
|
|
29
|
-
"default": "./dist/cjs/store.js"
|
|
30
22
|
}
|
|
31
23
|
},
|
|
32
24
|
"./dist/store.js": {
|
|
33
|
-
"
|
|
25
|
+
"default": {
|
|
34
26
|
"types": "./dist/store.d.ts",
|
|
35
27
|
"default": "./dist/store.js"
|
|
36
|
-
},
|
|
37
|
-
"default": {
|
|
38
|
-
"types": "./dist/cjs/store.d.ts",
|
|
39
|
-
"default": "./dist/cjs/store.js"
|
|
40
28
|
}
|
|
41
29
|
}
|
|
42
30
|
},
|
|
43
|
-
"main": "./dist/
|
|
44
|
-
"module": "./dist/index.js",
|
|
31
|
+
"main": "./dist/index.js",
|
|
45
32
|
"types": "./dist/index.d.ts",
|
|
46
33
|
"files": [
|
|
47
34
|
"dist"
|
|
@@ -50,17 +37,16 @@
|
|
|
50
37
|
"build": "node ./build.mts",
|
|
51
38
|
"build:pack": "yarn pack -o cedarjs-context.tgz",
|
|
52
39
|
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
53
|
-
"build:types-cjs": "tsc --build --verbose ./tsconfig.cjs.json",
|
|
54
40
|
"build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx\" --ignore dist --exec \"yarn build\"",
|
|
55
41
|
"check:attw": "yarn cedar-fwtools-attw",
|
|
56
42
|
"check:package": "concurrently npm:check:attw yarn:publint",
|
|
57
43
|
"prepublishOnly": "NODE_ENV=production yarn build"
|
|
58
44
|
},
|
|
59
45
|
"devDependencies": {
|
|
60
|
-
"@arethetypeswrong/cli": "0.18.
|
|
61
|
-
"@cedarjs/framework-tools": "5.0.
|
|
46
|
+
"@arethetypeswrong/cli": "0.18.5",
|
|
47
|
+
"@cedarjs/framework-tools": "5.0.7-next.186",
|
|
62
48
|
"concurrently": "9.2.4",
|
|
63
|
-
"publint": "0.3.
|
|
49
|
+
"publint": "0.3.22",
|
|
64
50
|
"typescript": "5.9.3"
|
|
65
51
|
},
|
|
66
52
|
"engines": {
|
package/dist/cjs/context.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface GlobalContext extends Record<string, unknown> {
|
|
2
|
-
}
|
|
3
|
-
export declare let context: GlobalContext;
|
|
4
|
-
/**
|
|
5
|
-
* Set the contents of the global context object.
|
|
6
|
-
*
|
|
7
|
-
* This completely replaces the existing context values such as currentUser.
|
|
8
|
-
*
|
|
9
|
-
* If you wish to extend the context simply use the `context` object directly,
|
|
10
|
-
* such as `context.magicNumber = 1`, or `setContext({ ...context, magicNumber: 1 })`
|
|
11
|
-
*/
|
|
12
|
-
export declare const setContext: (newContext: GlobalContext) => GlobalContext;
|
|
13
|
-
//# sourceMappingURL=context.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/context.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAc,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AA+BjE,eAAO,IAAI,OAAO,EAAE,aAAsC,CAAA;AAE1D;;;;;;;GAOG;AACH,eAAO,MAAM,UAAU,GAAI,YAAY,aAAa,KAAG,aA6BtD,CAAA"}
|
package/dist/cjs/context.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var context_exports = {};
|
|
20
|
-
__export(context_exports, {
|
|
21
|
-
context: () => context,
|
|
22
|
-
setContext: () => setContext
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(context_exports);
|
|
25
|
-
var import_store = require("./store.js");
|
|
26
|
-
function createContextProxy(target) {
|
|
27
|
-
return new Proxy(target, {
|
|
28
|
-
get: (_target, property) => {
|
|
29
|
-
const store = (0, import_store.getAsyncStoreInstance)().getStore();
|
|
30
|
-
const ctx = store?.get("context") || {};
|
|
31
|
-
if (process.env.DEBUG_CONTEXT === "true") {
|
|
32
|
-
console.log("[Context Debug]", {
|
|
33
|
-
property,
|
|
34
|
-
hasStore: !!store,
|
|
35
|
-
hasContext: !!ctx,
|
|
36
|
-
contextKeys: Object.keys(ctx),
|
|
37
|
-
currentUser: ctx.currentUser
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
return ctx[property];
|
|
41
|
-
},
|
|
42
|
-
set: (_target, property, newVal) => {
|
|
43
|
-
const store = (0, import_store.getAsyncStoreInstance)().getStore();
|
|
44
|
-
const ctx = store?.get("context") || {};
|
|
45
|
-
ctx[property] = newVal;
|
|
46
|
-
store?.set("context", ctx);
|
|
47
|
-
return true;
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
let context = createContextProxy({});
|
|
52
|
-
const setContext = (newContext) => {
|
|
53
|
-
if (process.env.DEBUG_CONTEXT === "true") {
|
|
54
|
-
console.log("[setContext Debug]", {
|
|
55
|
-
hasNewContext: !!newContext,
|
|
56
|
-
contextKeys: Object.keys(newContext),
|
|
57
|
-
currentUser: newContext.currentUser,
|
|
58
|
-
stackTrace: new Error().stack
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
context = createContextProxy(newContext);
|
|
62
|
-
const store = (0, import_store.getAsyncStoreInstance)().getStore();
|
|
63
|
-
if (process.env.DEBUG_CONTEXT === "true") {
|
|
64
|
-
console.log("[setContext Debug - Store]", {
|
|
65
|
-
hasStore: !!store,
|
|
66
|
-
storeHasContext: !!store?.get("context")
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
store?.set("context", newContext);
|
|
70
|
-
return context;
|
|
71
|
-
};
|
|
72
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
73
|
-
0 && (module.exports = {
|
|
74
|
-
context,
|
|
75
|
-
setContext
|
|
76
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"global.api-auto-imports.d.ts","sourceRoot":"","sources":["../../src/global.api-auto-imports.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAEjD,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,OAAO,EAAE,aAAa,CAAA;CAC7B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
package/dist/cjs/index.d.ts
DELETED
package/dist/cjs/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAG5B,OAAO,8BAA8B,CAAA;AACrC,cAAc,8BAA8B,CAAA"}
|
package/dist/cjs/index.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var index_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require("./context.js"), module.exports);
|
|
19
|
-
var import_global_api_auto_imports = require("./global.api-auto-imports.js");
|
|
20
|
-
__reExport(index_exports, require("./global.api-auto-imports.js"), module.exports);
|
|
21
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
22
|
-
0 && (module.exports = {
|
|
23
|
-
...require("./context.js"),
|
|
24
|
-
...require("./global.api-auto-imports.js")
|
|
25
|
-
});
|
package/dist/cjs/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"commonjs"}
|
package/dist/cjs/store.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AsyncLocalStorage } from 'async_hooks';
|
|
2
|
-
import type { GlobalContext } from './context.js';
|
|
3
|
-
/**
|
|
4
|
-
* This returns a AsyncLocalStorage instance, not the actual store.
|
|
5
|
-
* Should not be used by Redwood apps directly. The framework handles
|
|
6
|
-
* this.
|
|
7
|
-
*/
|
|
8
|
-
export declare const getAsyncStoreInstance: () => AsyncLocalStorage<Map<string, GlobalContext>>;
|
|
9
|
-
//# sourceMappingURL=store.d.ts.map
|
package/dist/cjs/store.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAIjD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qDAKjC,CAAA"}
|
package/dist/cjs/store.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var store_exports = {};
|
|
20
|
-
__export(store_exports, {
|
|
21
|
-
getAsyncStoreInstance: () => getAsyncStoreInstance
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(store_exports);
|
|
24
|
-
var import_async_hooks = require("async_hooks");
|
|
25
|
-
let CONTEXT_STORAGE;
|
|
26
|
-
const getAsyncStoreInstance = () => {
|
|
27
|
-
if (!CONTEXT_STORAGE) {
|
|
28
|
-
CONTEXT_STORAGE = new import_async_hooks.AsyncLocalStorage();
|
|
29
|
-
}
|
|
30
|
-
return CONTEXT_STORAGE;
|
|
31
|
-
};
|
|
32
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
33
|
-
0 && (module.exports = {
|
|
34
|
-
getAsyncStoreInstance
|
|
35
|
-
});
|