on-zero 0.4.10 → 0.4.11
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/cjs/helpers/mutatorContext.cjs +3 -2
- package/dist/cjs/helpers/mutatorContext.native.js +5 -2
- package/dist/cjs/helpers/mutatorContext.native.js.map +1 -1
- package/dist/esm/helpers/mutatorContext.mjs +3 -2
- package/dist/esm/helpers/mutatorContext.mjs.map +1 -1
- package/dist/esm/helpers/mutatorContext.native.js +5 -2
- package/dist/esm/helpers/mutatorContext.native.js.map +1 -1
- package/package.json +2 -2
- package/src/helpers/mutatorContext.ts +13 -2
- package/types/helpers/mutatorContext.d.ts.map +1 -1
|
@@ -30,8 +30,9 @@ __export(mutatorContext_exports, {
|
|
|
30
30
|
});
|
|
31
31
|
module.exports = __toCommonJS(mutatorContext_exports);
|
|
32
32
|
var import_helpers = require("@take-out/helpers");
|
|
33
|
-
const
|
|
34
|
-
const
|
|
33
|
+
const contextStore = globalThis;
|
|
34
|
+
const asyncContext = contextStore.__onZeroMutatorContext__ ?? (contextStore.__onZeroMutatorContext__ = (0, import_helpers.createAsyncContext)());
|
|
35
|
+
const authScopeContext = contextStore.__onZeroAuthScopeContext__ ?? (contextStore.__onZeroAuthScopeContext__ = (0, import_helpers.createAsyncContext)());
|
|
35
36
|
function mutatorContext() {
|
|
36
37
|
const currentContext = asyncContext.get();
|
|
37
38
|
if (!currentContext) {
|
|
@@ -32,8 +32,11 @@ __export(mutatorContext_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(mutatorContext_exports);
|
|
34
34
|
var import_helpers = require("@take-out/helpers");
|
|
35
|
-
var
|
|
36
|
-
var
|
|
35
|
+
var contextStore = globalThis;
|
|
36
|
+
var _contextStore___onZeroMutatorContext__;
|
|
37
|
+
var asyncContext = (_contextStore___onZeroMutatorContext__ = contextStore.__onZeroMutatorContext__) !== null && _contextStore___onZeroMutatorContext__ !== void 0 ? _contextStore___onZeroMutatorContext__ : contextStore.__onZeroMutatorContext__ = (0, import_helpers.createAsyncContext)();
|
|
38
|
+
var _contextStore___onZeroAuthScopeContext__;
|
|
39
|
+
var authScopeContext = (_contextStore___onZeroAuthScopeContext__ = contextStore.__onZeroAuthScopeContext__) !== null && _contextStore___onZeroAuthScopeContext__ !== void 0 ? _contextStore___onZeroAuthScopeContext__ : contextStore.__onZeroAuthScopeContext__ = (0, import_helpers.createAsyncContext)();
|
|
37
40
|
function mutatorContext() {
|
|
38
41
|
var currentContext = asyncContext.get();
|
|
39
42
|
if (!currentContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","mutatorContext_exports","__export","getScopedAuthData","isInZeroMutation","mutatorContext","runWithAuthScope","runWithContext","module","exports","import_helpers","require","asyncContext","createAsyncContext","authScopeContext","currentContext","get","Error","context","fn","run","authData","_authScopeContext_get"],"sources":["../../../src/helpers/mutatorContext.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAb,YAAmC,CAAAK,sBAAA;
|
|
1
|
+
{"version":3,"names":["__toCommonJS","mod","__copyProps","__defProp","value","mutatorContext_exports","__export","getScopedAuthData","isInZeroMutation","mutatorContext","runWithAuthScope","runWithContext","module","exports","import_helpers","require","contextStore","globalThis","_contextStore___onZeroMutatorContext__","asyncContext","__onZeroMutatorContext__","createAsyncContext","_contextStore___onZeroAuthScopeContext__","authScopeContext","__onZeroAuthScopeContext__","currentContext","get","Error","context","fn","run","authData","_authScopeContext_get"],"sources":["../../../src/helpers/mutatorContext.ts"],"sourcesContent":[null],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,GAAA,IAAAC,WAAA,CAAAC,SAAA;EAAAC,KAAA;AAAA,IAAAH,GAAA;AAAA,IAAAI,sBAAA;AAAAC,QAAA,CAAAD,sBAAA;EAAAE,iBAAA,EAAAA,CAAA,KAAAA,iBAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA,cAAA;EAAAC,gBAAA,EAAAA,CAAA,KAAAA,gBAAA;EAAAC,cAAA,EAAAA,CAAA,KAAAA;AAAA;AAAAC,MAAA,CAAAC,OAAA,GAAAb,YAAmC,CAAAK,sBAAA;AAMnC,IAAAS,cAAM,GAAeC,OAAA;AAKrB,IAAAC,YAAM,GAAAC,UACJ;AAIF,IAAAC,sCACe;AAGR,IAAAC,YAAS,IAAAD,sCAAiC,GAAAF,YAAA,CAAAI,wBAAA,cAAAF,sCAAA,cAAAA,sCAAA,GAAAF,YAAA,CAAAI,wBAAA,OAAAN,cAAA,CAAAO,kBAAA;AAC/C,IAAAC,wCAAwC;AACxC,IAAAC,gBAAK,GAAgB,CAAAD,wCAAA,GAAAN,YAAA,CAAAQ,0BAAA,cAAAF,wCAAA,cAAAA,wCAAA,GAAAN,YAAA,CAAAQ,0BAAA,OAAAV,cAAA,CAAAO,kBAAA;AACnB,SAAAZ,cAAgBA,CAAA;EAClB,IAAAgB,cAAA,GAAAN,YAAA,CAAAO,GAAA;EAEA,KAAAD,cAAO;IACT,UAAAE,KAAA;EAEO;EACL,OAAOF,cAAE;AACX;AAEO,SAASjB,gBACdA,CAAA;EAGA,OAAO,EAAAW,YAAa,CAAAO,GAAI;AAC1B;AAGO,SAASf,eAAAiB,OAAiD,EAAAC,EAAA;EAC/D,OAAIV,YAAA,CAAAW,GAAiB,CAAGF,OAAA,EAAAC,EAAA;AACtB;AAAwB,SAC1BtB,kBAAA;EACA,IAAAC,gBAAO,IAAiB;IAC1B,OAAAC,cAAA,GAAAsB,QAAA;EAEO;EAIL,IAAAC,qBAAwB;EAC1B,QAAAA,qBAAA,GAAAT,gBAAA,CAAAG,GAAA,gBAAAM,qBAAA,cAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { createAsyncContext } from "@take-out/helpers";
|
|
2
|
-
const
|
|
3
|
-
const
|
|
2
|
+
const contextStore = globalThis;
|
|
3
|
+
const asyncContext = contextStore.__onZeroMutatorContext__ ?? (contextStore.__onZeroMutatorContext__ = createAsyncContext());
|
|
4
|
+
const authScopeContext = contextStore.__onZeroAuthScopeContext__ ?? (contextStore.__onZeroAuthScopeContext__ = createAsyncContext());
|
|
4
5
|
function mutatorContext() {
|
|
5
6
|
const currentContext = asyncContext.get();
|
|
6
7
|
if (!currentContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAsyncContext","asyncContext","authScopeContext","mutatorContext","currentContext","get","Error","isInZeroMutation","runWithContext","context","fn","run","getScopedAuthData","authData","runWithAuthScope"],"sources":["../../../src/helpers/mutatorContext.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;
|
|
1
|
+
{"version":3,"names":["createAsyncContext","contextStore","globalThis","asyncContext","__onZeroMutatorContext__","authScopeContext","__onZeroAuthScopeContext__","mutatorContext","currentContext","get","Error","isInZeroMutation","runWithContext","context","fn","run","getScopedAuthData","authData","runWithAuthScope"],"sources":["../../../src/helpers/mutatorContext.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AAMnC,MAAMC,YAAA,GAAeC,UAAA;AAKrB,MAAMC,YAAA,GACJF,YAAA,CAAaG,wBAAA,KACZH,YAAA,CAAaG,wBAAA,GAA2BJ,kBAAA,CAAmC;AAG9E,MAAMK,gBAAA,GACJJ,YAAA,CAAaK,0BAAA,KACZL,YAAA,CAAaK,0BAAA,GAA6BN,kBAAA,CAAoC;AAE1E,SAASO,eAAA,EAAiC;EAC/C,MAAMC,cAAA,GAAiBL,YAAA,CAAaM,GAAA,CAAI;EACxC,IAAI,CAACD,cAAA,EAAgB;IACnB,MAAM,IAAIE,KAAA,CAAM,gDAAgD;EAClE;EAEA,OAAOF,cAAA;AACT;AAEO,SAASG,iBAAA,EAAmB;EACjC,OAAO,CAAC,CAACR,YAAA,CAAaM,GAAA,CAAI;AAC5B;AAEO,SAASG,eACdC,OAAA,EACAC,EAAA,EACY;EACZ,OAAOX,YAAA,CAAaY,GAAA,CAAIF,OAAA,EAASC,EAAE;AACrC;AAGO,SAASE,kBAAA,EAAiD;EAC/D,IAAIL,gBAAA,CAAiB,GAAG;IACtB,OAAOJ,cAAA,CAAe,EAAEU,QAAA;EAC1B;EACA,OAAOZ,gBAAA,CAAiBI,GAAA,CAAI,KAAK;AACnC;AAEO,SAASS,iBACdD,QAAA,EACAH,EAAA,EACY;EACZ,OAAOT,gBAAA,CAAiBU,GAAA,CAAIE,QAAA,EAAUH,EAAE;AAC1C","ignoreList":[]}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createAsyncContext } from "@take-out/helpers";
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var contextStore = globalThis;
|
|
3
|
+
var _contextStore___onZeroMutatorContext__;
|
|
4
|
+
var asyncContext = (_contextStore___onZeroMutatorContext__ = contextStore.__onZeroMutatorContext__) !== null && _contextStore___onZeroMutatorContext__ !== void 0 ? _contextStore___onZeroMutatorContext__ : contextStore.__onZeroMutatorContext__ = createAsyncContext();
|
|
5
|
+
var _contextStore___onZeroAuthScopeContext__;
|
|
6
|
+
var authScopeContext = (_contextStore___onZeroAuthScopeContext__ = contextStore.__onZeroAuthScopeContext__) !== null && _contextStore___onZeroAuthScopeContext__ !== void 0 ? _contextStore___onZeroAuthScopeContext__ : contextStore.__onZeroAuthScopeContext__ = createAsyncContext();
|
|
4
7
|
function mutatorContext() {
|
|
5
8
|
var currentContext = asyncContext.get();
|
|
6
9
|
if (!currentContext) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createAsyncContext","asyncContext","authScopeContext","mutatorContext","currentContext","get","Error","isInZeroMutation","runWithContext","context","fn","run","getScopedAuthData","authData","_authScopeContext_get"
|
|
1
|
+
{"version":3,"names":["createAsyncContext","contextStore","globalThis","_contextStore___onZeroMutatorContext__","asyncContext","__onZeroMutatorContext__","_contextStore___onZeroAuthScopeContext__","authScopeContext","__onZeroAuthScopeContext__","mutatorContext","currentContext","get","Error","isInZeroMutation","runWithContext","context","fn","run","getScopedAuthData","authData","_authScopeContext_get"],"sources":["../../../src/helpers/mutatorContext.ts"],"sourcesContent":[null],"mappings":"AAAA,SAASA,kBAAA,QAA0B;AAMnC,IAAAC,YAAM,GAAAC,UAAe;AAKrB,IAAAC,sCACe;AAIf,IAAAC,YAAM,IAAAD,sCACS,GAAAF,YACZ,CAAAI,wBAAa,cAA6BF,sCAAoC,cAAAA,sCAAA,GAAAF,YAAA,CAAAI,wBAAA,GAAAL,kBAAA;AAE1E,IAAAM,wCAA0C;AAC/C,IAAAC,gBAAM,IAAAD,wCAAkC,GAAAL,YAAA,CAAAO,0BAAA,cAAAF,wCAAA,cAAAA,wCAAA,GAAAL,YAAA,CAAAO,0BAAA,GAAAR,kBAAA;AACxC,SAAKS,cAAgBA,CAAA;EACnB,IAAAC,cAAgB,GAAAN,YAAA,CAAAO,GAAA;EAClB,KAAAD,cAAA;IAEA,MAAO,IAAAE,KAAA;EACT;EAEO,OAASF,cAAA;AACd;AACF,SAAAG,iBAAA;EAEO,OAAS,EAAAT,YAAA,CACdO,GAAA;AAGA;AACF,SAAAG,eAAAC,OAAA,EAAAC,EAAA;EAGO,OAASZ,YAAA,CAAAa,GAAA,CAAAF,OAAiD,EAAAC,EAAA;AAC/D;AACE,SAAAE,iBAAsBA,CAAA,EAAE;EAC1B,IAAAL,gBAAA;IACA,OAAOJ,cAAA,CAAiB,EAAAU,QAAS;EACnC;EAEO,IAAAC,qBACL;EAGA,OAAO,CAAAA,qBAAqB,GAAAb,gBAAY,CAAAI,GAAA,gBAAAS,qBAAA,cAAAA,qBAAA;AAC1C","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "on-zero",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.11",
|
|
4
4
|
"description": "A typed layer over @rocicorp/zero with queries, mutations, and permissions",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"source": "src/index.ts",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"dependencies": {
|
|
80
|
-
"@take-out/helpers": "0.4.
|
|
80
|
+
"@take-out/helpers": "0.4.11",
|
|
81
81
|
"chokidar": "^4.0.3",
|
|
82
82
|
"citty": "^0.1.6",
|
|
83
83
|
"valibot": "^1.1.0"
|
|
@@ -2,10 +2,21 @@ import { createAsyncContext } from '@take-out/helpers'
|
|
|
2
2
|
|
|
3
3
|
import type { AuthData, MutatorContext } from '../types'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
type AsyncContext<T> = ReturnType<typeof createAsyncContext<T>>
|
|
6
|
+
|
|
7
|
+
const contextStore = globalThis as typeof globalThis & {
|
|
8
|
+
__onZeroMutatorContext__?: AsyncContext<MutatorContext>
|
|
9
|
+
__onZeroAuthScopeContext__?: AsyncContext<AuthData | null>
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const asyncContext =
|
|
13
|
+
contextStore.__onZeroMutatorContext__ ??
|
|
14
|
+
(contextStore.__onZeroMutatorContext__ = createAsyncContext<MutatorContext>())
|
|
6
15
|
|
|
7
16
|
// lightweight auth-only scope for asyncTasks (where mutation context is gone but authData is needed)
|
|
8
|
-
const authScopeContext =
|
|
17
|
+
const authScopeContext =
|
|
18
|
+
contextStore.__onZeroAuthScopeContext__ ??
|
|
19
|
+
(contextStore.__onZeroAuthScopeContext__ = createAsyncContext<AuthData | null>())
|
|
9
20
|
|
|
10
21
|
export function mutatorContext(): MutatorContext {
|
|
11
22
|
const currentContext = asyncContext.get()
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mutatorContext.d.ts","sourceRoot":"","sources":["../../src/helpers/mutatorContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"mutatorContext.d.ts","sourceRoot":"","sources":["../../src/helpers/mutatorContext.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAkBxD,wBAAgB,cAAc,IAAI,cAAc,CAO/C;AAED,wBAAgB,gBAAgB,YAE/B;AAED,wBAAgB,cAAc,CAAC,CAAC,EAC9B,OAAO,EAAE,cAAc,EACvB,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,CAAC,CAEZ;AAGD,wBAAgB,iBAAiB,IAAI,QAAQ,GAAG,IAAI,GAAG,SAAS,CAK/D;AAED,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,QAAQ,EAAE,QAAQ,GAAG,IAAI,EACzB,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACvB,OAAO,CAAC,CAAC,CAAC,CAEZ"}
|