@unional/async-context 9.0.14 → 9.0.16

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 (37) hide show
  1. package/cjs/AsyncContext.d.ts +13 -10
  2. package/cjs/AsyncContext.d.ts.map +1 -1
  3. package/cjs/AsyncContext.js +61 -64
  4. package/cjs/AsyncContext.js.map +1 -1
  5. package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/assertClassBrand.js +7 -0
  6. package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/checkPrivateRedeclaration.js +6 -0
  7. package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js +7 -0
  8. package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js +7 -0
  9. package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js +7 -0
  10. package/cjs/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js +7 -0
  11. package/cjs/errors.d.ts +8 -5
  12. package/cjs/errors.d.ts.map +1 -1
  13. package/cjs/errors.js +15 -15
  14. package/cjs/errors.js.map +1 -1
  15. package/cjs/index.d.ts +3 -3
  16. package/cjs/index.js +6 -19
  17. package/esm/AsyncContext.d.ts +13 -10
  18. package/esm/AsyncContext.d.ts.map +1 -1
  19. package/esm/AsyncContext.js +61 -60
  20. package/esm/AsyncContext.js.map +1 -1
  21. package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/assertClassBrand.js +7 -0
  22. package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/checkPrivateRedeclaration.js +6 -0
  23. package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js +7 -0
  24. package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js +7 -0
  25. package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js +7 -0
  26. package/esm/_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js +7 -0
  27. package/esm/errors.d.ts +8 -5
  28. package/esm/errors.d.ts.map +1 -1
  29. package/esm/errors.js +15 -11
  30. package/esm/errors.js.map +1 -1
  31. package/esm/index.d.ts +3 -3
  32. package/esm/index.js +3 -3
  33. package/package.json +12 -25
  34. package/cjs/index.d.ts.map +0 -1
  35. package/cjs/index.js.map +0 -1
  36. package/esm/index.d.ts.map +0 -1
  37. package/esm/index.js.map +0 -1
@@ -1,13 +1,16 @@
1
- import type { LeftJoin } from 'type-plus';
2
- export declare class AsyncContext<Init extends Record<string | symbol, any>, Context extends Record<string | symbol, any> = Init> {
3
- #private;
4
- constructor(init?: Init | Promise<Init> | AsyncContext.Initializer<Init>);
5
- initialize<I extends Init = Init>(init: I | Promise<I> | AsyncContext.Initializer<I>): AsyncContext<I>;
6
- extend<CurrentContext extends Record<string | symbol, any> = Context, AdditionalContext extends Record<string | symbol, any> = Record<string | symbol, any>>(context: AdditionalContext | Promise<AdditionalContext> | AsyncContext.Transformer<Context, AdditionalContext>): AsyncContext<Init, LeftJoin<CurrentContext, AdditionalContext>>;
7
- get<C = Context>(): Promise<C>;
1
+ import { LeftJoin } from "type-plus";
2
+ //#region ts/AsyncContext.d.ts
3
+ declare class AsyncContext<Init extends Record<string | symbol, any>, Context extends Record<string | symbol, any> = Init> {
4
+ #private;
5
+ constructor(init?: Init | Promise<Init> | AsyncContext.Initializer<Init>);
6
+ initialize<I extends Init = Init>(init: I | Promise<I> | AsyncContext.Initializer<I>): AsyncContext<I>;
7
+ extend<CurrentContext extends Record<string | symbol, any> = Context, AdditionalContext extends Record<string | symbol, any> = Record<string | symbol, any>>(context: AdditionalContext | Promise<AdditionalContext> | AsyncContext.Transformer<Context, AdditionalContext>): AsyncContext<Init, LeftJoin<CurrentContext, AdditionalContext>>;
8
+ get<C = Context>(): Promise<C>;
8
9
  }
9
- export declare namespace AsyncContext {
10
- type Initializer<Init> = () => Init | Promise<Init>;
11
- type Transformer<CurrentContext, AdditionalContext> = (context: CurrentContext) => AdditionalContext | Promise<AdditionalContext>;
10
+ declare namespace AsyncContext {
11
+ type Initializer<Init> = () => Init | Promise<Init>;
12
+ type Transformer<CurrentContext, AdditionalContext> = (context: CurrentContext) => AdditionalContext | Promise<AdditionalContext>;
12
13
  }
14
+ //#endregion
15
+ export { AsyncContext };
13
16
  //# sourceMappingURL=AsyncContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncContext.d.ts","sourceRoot":"","sources":["../ts/AsyncContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGzC,qBAAa,YAAY,CACxB,IAAI,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACzC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;;IAOnD,YAAY,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAEvE;IACD,UAAU,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAMrG;IACD,MAAM,CACL,cAAc,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,EAC7D,iBAAiB,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAErF,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,GAC5G,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAejE;IACK,GAAG,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAInC;CAID;AACD,yBAAiB,YAAY,CAAC;IAC7B,KAAY,WAAW,CAAC,IAAI,IAAI,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1D,KAAY,WAAW,CAAC,cAAc,EAAE,iBAAiB,IAAI,CAC5D,OAAO,EAAE,cAAc,KACnB,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACnD"}
1
+ {"version":3,"file":"AsyncContext.d.ts","names":[],"sources":["../ts/AsyncContext.ts"],"mappings":";;cAGa,aACZ,aAAa,8BACb,gBAAgB,+BAA+B;;EAO/C,YAAY,OAAO,OAAO,QAAQ,QAAQ,aAAa,YAAY;EAGnE,WAAW,UAAU,OAAO,MAAM,MAAM,IAAI,QAAQ,KAAK,aAAa,YAAY,KAAK,aAAa;EAOpG,OACC,uBAAuB,+BAA+B,SACtD,0BAA0B,+BAA+B,8BAEzD,SAAS,oBAAoB,QAAQ,qBAAqB,aAAa,YAAY,SAAS,qBAC1F,aAAa,MAAM,SAAS,gBAAgB;EAgBzC,IAAI,IAAI,YAAY,QAAQ;;kBASlB;OACJ,YAAY,cAAc,OAAO,QAAQ;OACzC,YAAY,gBAAgB,sBACvC,SAAS,mBACL,oBAAoB,QAAQ"}
@@ -1,73 +1,70 @@
1
- "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1
+ const require_errors = require("./errors.js");
2
+ const require_classPrivateMethodInitSpec = require("./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js");
3
+ const require_classPrivateFieldInitSpec = require("./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js");
4
+ const require_assertClassBrand = require("./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/assertClassBrand.js");
5
+ const require_classPrivateFieldSet2 = require("./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js");
6
+ const require_classPrivateFieldGet2 = require("./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js");
7
+ //#region ts/AsyncContext.ts
8
+ var _resolving = /* @__PURE__ */ new WeakMap();
9
+ var _resolvers = /* @__PURE__ */ new WeakMap();
10
+ var _transforming = /* @__PURE__ */ new WeakMap();
11
+ var _init = /* @__PURE__ */ new WeakMap();
12
+ var _original = /* @__PURE__ */ new WeakMap();
13
+ var _AsyncContext_brand = /* @__PURE__ */ new WeakSet();
14
+ var AsyncContext = class AsyncContext {
15
+ constructor(init) {
16
+ require_classPrivateMethodInitSpec.default(this, _AsyncContext_brand);
17
+ require_classPrivateFieldInitSpec.default(this, _resolving, void 0);
18
+ require_classPrivateFieldInitSpec.default(this, _resolvers, []);
19
+ require_classPrivateFieldInitSpec.default(this, _transforming, false);
20
+ require_classPrivateFieldInitSpec.default(this, _init, void 0);
21
+ require_classPrivateFieldInitSpec.default(this, _original, void 0);
22
+ require_classPrivateFieldSet2.default(_init, this, init);
23
+ }
24
+ initialize(init) {
25
+ if (require_classPrivateFieldGet2.default(_init, this)) throw new require_errors.ContextAlreadyInitialized({ ssf: this.initialize });
26
+ require_classPrivateFieldSet2.default(_init, this, init);
27
+ if (require_classPrivateFieldGet2.default(_resolvers, this).length > 0) require_classPrivateFieldGet2.default(_resolvers, this).forEach((r) => void r(require_assertClassBrand.default(_AsyncContext_brand, this, _buildContext).call(this)));
28
+ return this;
29
+ }
30
+ extend(context) {
31
+ const newctx = new AsyncContext(async () => {
32
+ try {
33
+ const value = await this.get();
34
+ require_classPrivateFieldSet2.default(_transforming, newctx, true);
35
+ const newValue = await (isTransformer(context) ? context(value) : context);
36
+ return {
37
+ ...value,
38
+ ...newValue
39
+ };
40
+ } finally {
41
+ require_classPrivateFieldSet2.default(_transforming, newctx, false);
42
+ }
43
+ });
44
+ const ctx = require_classPrivateFieldGet2.default(_original, this) ?? this;
45
+ require_classPrivateFieldSet2.default(_original, newctx, ctx);
46
+ newctx.initialize = newctx.initialize.bind(ctx);
47
+ return newctx;
48
+ }
49
+ async get() {
50
+ if (require_classPrivateFieldGet2.default(_transforming, this)) throw new require_errors.BlockingGetDetected({ ssf: this.get });
51
+ if (require_classPrivateFieldGet2.default(_resolving, this)) return require_classPrivateFieldGet2.default(_resolving, this);
52
+ return require_classPrivateFieldSet2.default(_resolving, this, require_classPrivateFieldGet2.default(_init, this) ? require_assertClassBrand.default(_AsyncContext_brand, this, _buildContext).call(this) : new Promise((a) => require_classPrivateFieldGet2.default(_resolvers, this).push(a)));
53
+ }
7
54
  };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _AsyncContext_instances, _AsyncContext_resolving, _AsyncContext_resolvers, _AsyncContext_transforming, _AsyncContext_init, _AsyncContext_original, _AsyncContext_buildContext;
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.AsyncContext = void 0;
16
- const errors_js_1 = require("./errors.js");
17
- class AsyncContext {
18
- constructor(init) {
19
- _AsyncContext_instances.add(this);
20
- _AsyncContext_resolving.set(this, void 0);
21
- _AsyncContext_resolvers.set(this, []);
22
- _AsyncContext_transforming.set(this, false);
23
- _AsyncContext_init.set(this, void 0);
24
- _AsyncContext_original.set(this, void 0);
25
- __classPrivateFieldSet(this, _AsyncContext_init, init, "f");
26
- }
27
- initialize(init) {
28
- if (__classPrivateFieldGet(this, _AsyncContext_init, "f"))
29
- throw new errors_js_1.ContextAlreadyInitialized({ ssf: this.initialize });
30
- __classPrivateFieldSet(this, _AsyncContext_init, init, "f");
31
- if (__classPrivateFieldGet(this, _AsyncContext_resolvers, "f").length > 0)
32
- __classPrivateFieldGet(this, _AsyncContext_resolvers, "f").forEach((r) => void r(__classPrivateFieldGet(this, _AsyncContext_instances, "m", _AsyncContext_buildContext).call(this)));
33
- return this;
34
- }
35
- extend(context) {
36
- const newctx = new AsyncContext(async () => {
37
- try {
38
- const value = await this.get();
39
- __classPrivateFieldSet(newctx, _AsyncContext_transforming, true, "f");
40
- const newValue = await (isTransformer(context) ? context(value) : context);
41
- return { ...value, ...newValue };
42
- }
43
- finally {
44
- __classPrivateFieldSet(newctx, _AsyncContext_transforming, false, "f");
45
- }
46
- });
47
- const ctx = __classPrivateFieldGet(this, _AsyncContext_original, "f") ?? this;
48
- __classPrivateFieldSet(newctx, _AsyncContext_original, ctx, "f");
49
- newctx.initialize = newctx.initialize.bind(ctx);
50
- return newctx;
51
- }
52
- async get() {
53
- if (__classPrivateFieldGet(this, _AsyncContext_transforming, "f"))
54
- throw new errors_js_1.BlockingGetDetected({ ssf: this.get });
55
- if (__classPrivateFieldGet(this, _AsyncContext_resolving, "f"))
56
- return __classPrivateFieldGet(this, _AsyncContext_resolving, "f");
57
- return (__classPrivateFieldSet(this, _AsyncContext_resolving, __classPrivateFieldGet(this, _AsyncContext_init, "f") ? __classPrivateFieldGet(this, _AsyncContext_instances, "m", _AsyncContext_buildContext).call(this) : new Promise((a) => __classPrivateFieldGet(this, _AsyncContext_resolvers, "f").push(a)), "f"));
58
- }
55
+ async function _buildContext() {
56
+ return resolveInit(require_classPrivateFieldGet2.default(_init, this));
59
57
  }
60
- exports.AsyncContext = AsyncContext;
61
- _AsyncContext_resolving = new WeakMap(), _AsyncContext_resolvers = new WeakMap(), _AsyncContext_transforming = new WeakMap(), _AsyncContext_init = new WeakMap(), _AsyncContext_original = new WeakMap(), _AsyncContext_instances = new WeakSet(), _AsyncContext_buildContext = async function _AsyncContext_buildContext() {
62
- return resolveInit(__classPrivateFieldGet(this, _AsyncContext_init, "f"));
63
- };
64
58
  async function resolveInit(init) {
65
- return isInitializer(init) ? init() : init;
59
+ return isInitializer(init) ? init() : init;
66
60
  }
67
61
  function isTransformer(context) {
68
- return typeof context === 'function';
62
+ return typeof context === "function";
69
63
  }
70
64
  function isInitializer(context) {
71
- return typeof context === 'function';
65
+ return typeof context === "function";
72
66
  }
67
+ //#endregion
68
+ exports.AsyncContext = AsyncContext;
69
+
73
70
  //# sourceMappingURL=AsyncContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncContext.js","sourceRoot":"","sources":["../ts/AsyncContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,2CAA4E;AAE5E;IASC,YAAY,IAA4D;;QALxE,0CAAoC;QACpC,kCAAuD,EAAE,EAAA;QACzD,qCAAgB,KAAK,EAAA;QACrB,qCAAwE;QACxE,yCAA6C;QAE5C,uBAAA,IAAI,sBAAS,IAAI,MAAA,CAAA;IAClB,CAAC;IACD,UAAU,CAAwB,IAAkD;QACnF,IAAI,uBAAA,IAAI,0BAAM;YAAE,MAAM,IAAI,qCAAyB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QAC7E,uBAAA,IAAI,sBAAS,IAAI,MAAA,CAAA;QAEjB,IAAI,uBAAA,IAAI,+BAAW,CAAC,MAAM,GAAG,CAAC;YAAE,uBAAA,IAAI,+BAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,uBAAA,IA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AAC,uBAAA,IAAI,+BAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAA,CAAC,CAAA;IAChH,CAAC;CAID;;gRAHA,KAAK;IACJ,OAAO,WAAW,CAAC,uBAAA,IAAI,0BAAO,CAA4B,CAAA;AAC3D,CAAC;AASF,KAAK,UAAU,WAAW,CACzB,IAA2D;IAE3D,OAAO,aAAa,CAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AACjD,CAAC;AAED,SAAS,aAAa,CACrB,OAAgB;IAEhB,OAAO,OAAO,OAAO,KAAK,UAAU,CAAA;AACrC,CAAC;AAED,SAAS,aAAa,CAAI,OAAgB;IACzC,OAAO,OAAO,OAAO,KAAK,UAAU,CAAA;AACrC,CAAC"}
1
+ {"version":3,"file":"AsyncContext.js","names":["ContextAlreadyInitialized","BlockingGetDetected"],"sources":["../ts/AsyncContext.ts"],"sourcesContent":["import type { LeftJoin } from 'type-plus'\nimport { BlockingGetDetected, ContextAlreadyInitialized } from './errors.js'\n\nexport class AsyncContext<\n\tInit extends Record<string | symbol, any>,\n\tContext extends Record<string | symbol, any> = Init,\n> {\n\t#resolving: Promise<any> | undefined\n\t#resolvers: Array<(value: Promise<Context>) => void> = []\n\t#transforming = false\n\t#init: Init | Promise<Init> | AsyncContext.Initializer<Init> | undefined\n\t#original: AsyncContext<any, any> | undefined\n\tconstructor(init?: Init | Promise<Init> | AsyncContext.Initializer<Init>) {\n\t\tthis.#init = init\n\t}\n\tinitialize<I extends Init = Init>(init: I | Promise<I> | AsyncContext.Initializer<I>): AsyncContext<I> {\n\t\tif (this.#init) throw new ContextAlreadyInitialized({ ssf: this.initialize })\n\t\tthis.#init = init\n\n\t\tif (this.#resolvers.length > 0) this.#resolvers.forEach((r) => void r(this.#buildContext()))\n\t\treturn this as any as AsyncContext<I>\n\t}\n\textend<\n\t\tCurrentContext extends Record<string | symbol, any> = Context,\n\t\tAdditionalContext extends Record<string | symbol, any> = Record<string | symbol, any>,\n\t>(\n\t\tcontext: AdditionalContext | Promise<AdditionalContext> | AsyncContext.Transformer<Context, AdditionalContext>,\n\t): AsyncContext<Init, LeftJoin<CurrentContext, AdditionalContext>> {\n\t\tconst newctx = new AsyncContext(async () => {\n\t\t\ttry {\n\t\t\t\tconst value = await this.get()\n\t\t\t\tnewctx.#transforming = true\n\t\t\t\tconst newValue = await (isTransformer<any, any>(context) ? context(value) : context)\n\t\t\t\treturn { ...value, ...newValue }\n\t\t\t} finally {\n\t\t\t\tnewctx.#transforming = false\n\t\t\t}\n\t\t})\n\t\tconst ctx = this.#original ?? this\n\t\tnewctx.#original = ctx\n\t\tnewctx.initialize = newctx.initialize.bind(ctx)\n\t\treturn newctx\n\t}\n\tasync get<C = Context>(): Promise<C> {\n\t\tif (this.#transforming) throw new BlockingGetDetected({ ssf: this.get })\n\t\tif (this.#resolving) return this.#resolving\n\t\treturn (this.#resolving = this.#init ? this.#buildContext() : new Promise<any>((a) => this.#resolvers.push(a)))\n\t}\n\tasync #buildContext(): Promise<Context> {\n\t\treturn resolveInit(this.#init!) as any as Promise<Context>\n\t}\n}\nexport namespace AsyncContext {\n\texport type Initializer<Init> = () => Init | Promise<Init>\n\texport type Transformer<CurrentContext, AdditionalContext> = (\n\t\tcontext: CurrentContext,\n\t) => AdditionalContext | Promise<AdditionalContext>\n}\n\nasync function resolveInit<Init extends Record<string | symbol, any>>(\n\tinit: Init | Promise<Init> | AsyncContext.Initializer<Init>,\n): Promise<Init> {\n\treturn isInitializer<Init>(init) ? init() : init\n}\n\nfunction isTransformer<CurrentContext, AdditionalContext>(\n\tcontext: unknown,\n): context is AsyncContext.Transformer<CurrentContext, AdditionalContext> {\n\treturn typeof context === 'function'\n}\n\nfunction isInitializer<T>(context: unknown): context is AsyncContext.Initializer<T> {\n\treturn typeof context === 'function'\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAa,eAAb,MAAa,aAGX;CAMD,YAAY,MAA8D;;;EAJnB,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QAAA,qBAAa,MAAA,aAAA,CAAA,CAAA,KAAA,IAAmB,IAAI,IAAI,SAAc,MAAA,8BAAA,QAAA,YAAM,IAAA,CAAA,CAAgB,KAAK,CAAC,CAAC,CAAA;CAC9G;AAID;AAHC,eAAA,gBAAwC;CACvC,OAAO,YAAA,8BAAA,QAAA,OAAY,IAAA,CAAW;AAC/B;AASD,eAAe,YACd,MACgB;CAChB,OAAO,cAAoB,IAAI,IAAI,KAAK,IAAI;AAC7C;AAEA,SAAS,cACR,SACyE;CACzE,OAAO,OAAO,YAAY;AAC3B;AAEA,SAAS,cAAiB,SAA0D;CACnF,OAAO,OAAO,YAAY;AAC3B"}
@@ -0,0 +1,7 @@
1
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/assertClassBrand.js
2
+ function _assertClassBrand(e, t, n) {
3
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
4
+ throw new TypeError("Private element is not present on this object");
5
+ }
6
+ //#endregion
7
+ exports.default = _assertClassBrand;
@@ -0,0 +1,6 @@
1
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/checkPrivateRedeclaration.js
2
+ function _checkPrivateRedeclaration(e, t) {
3
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
4
+ }
5
+ //#endregion
6
+ exports.default = _checkPrivateRedeclaration;
@@ -0,0 +1,7 @@
1
+ const require_assertClassBrand = require("./assertClassBrand.js");
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js
3
+ function _classPrivateFieldGet2(s, a) {
4
+ return s.get(require_assertClassBrand.default(s, a));
5
+ }
6
+ //#endregion
7
+ exports.default = _classPrivateFieldGet2;
@@ -0,0 +1,7 @@
1
+ const require_checkPrivateRedeclaration = require("./checkPrivateRedeclaration.js");
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js
3
+ function _classPrivateFieldInitSpec(e, t, a) {
4
+ require_checkPrivateRedeclaration.default(e, t), t.set(e, a);
5
+ }
6
+ //#endregion
7
+ exports.default = _classPrivateFieldInitSpec;
@@ -0,0 +1,7 @@
1
+ const require_assertClassBrand = require("./assertClassBrand.js");
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js
3
+ function _classPrivateFieldSet2(s, a, r) {
4
+ return s.set(require_assertClassBrand.default(s, a), r), r;
5
+ }
6
+ //#endregion
7
+ exports.default = _classPrivateFieldSet2;
@@ -0,0 +1,7 @@
1
+ const require_checkPrivateRedeclaration = require("./checkPrivateRedeclaration.js");
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js
3
+ function _classPrivateMethodInitSpec(e, a) {
4
+ require_checkPrivateRedeclaration.default(e, a), a.add(e);
5
+ }
6
+ //#endregion
7
+ exports.default = _classPrivateMethodInitSpec;
package/cjs/errors.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { ModuleError } from 'iso-error';
2
- export declare class ContextAlreadyInitialized extends ModuleError {
3
- constructor(options?: ModuleError.Options);
1
+ import { ModuleError } from "iso-error";
2
+ //#region ts/errors.d.ts
3
+ declare class ContextAlreadyInitialized extends ModuleError {
4
+ constructor(options?: ModuleError.Options);
4
5
  }
5
- export declare class BlockingGetDetected extends ModuleError {
6
- constructor(options?: ModuleError.Options);
6
+ declare class BlockingGetDetected extends ModuleError {
7
+ constructor(options?: ModuleError.Options);
7
8
  }
9
+ //#endregion
10
+ export { BlockingGetDetected, ContextAlreadyInitialized };
8
11
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,qBAAa,yBAA0B,SAAQ,WAAW;IACzD,YAAY,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAExC;CACD;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IACnD,YAAY,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAExC;CACD"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../ts/errors.ts"],"mappings":";;cAEa,kCAAkC;EAC9C,YAAY,UAAU,YAAY;;cAKtB,4BAA4B;EACxC,YAAY,UAAU,YAAY"}
package/cjs/errors.js CHANGED
@@ -1,17 +1,17 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockingGetDetected = exports.ContextAlreadyInitialized = void 0;
4
- const iso_error_1 = require("iso-error");
5
- class ContextAlreadyInitialized extends iso_error_1.ModuleError {
6
- constructor(options) {
7
- super('@unional/async-context', 'context can only be initialized once.', options);
8
- }
9
- }
10
- exports.ContextAlreadyInitialized = ContextAlreadyInitialized;
11
- class BlockingGetDetected extends iso_error_1.ModuleError {
12
- constructor(options) {
13
- super('@unional/async-context', 'a blocking get() detected. Are you calling it within extend()?', options);
14
- }
15
- }
1
+ let iso_error = require("iso-error");
2
+ //#region ts/errors.ts
3
+ var ContextAlreadyInitialized = class extends iso_error.ModuleError {
4
+ constructor(options) {
5
+ super("@unional/async-context", "context can only be initialized once.", options);
6
+ }
7
+ };
8
+ var BlockingGetDetected = class extends iso_error.ModuleError {
9
+ constructor(options) {
10
+ super("@unional/async-context", "a blocking get() detected. Are you calling it within extend()?", options);
11
+ }
12
+ };
13
+ //#endregion
16
14
  exports.BlockingGetDetected = BlockingGetDetected;
15
+ exports.ContextAlreadyInitialized = ContextAlreadyInitialized;
16
+
17
17
  //# sourceMappingURL=errors.js.map
package/cjs/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":";;;AAAA,yCAAuC;AAEvC,+BAAuC,SAAQ,uBAAW;IACzD,YAAY,OAA6B;QACxC,KAAK,CAAC,wBAAwB,EAAE,uCAAuC,EAAE,OAAO,CAAC,CAAA;IAClF,CAAC;CACD;;AAED,yBAAiC,SAAQ,uBAAW;IACnD,YAAY,OAA6B;QACxC,KAAK,CAAC,wBAAwB,EAAE,gEAAgE,EAAE,OAAO,CAAC,CAAA;IAC3G,CAAC;CACD"}
1
+ {"version":3,"file":"errors.js","names":["ModuleError"],"sources":["../ts/errors.ts"],"sourcesContent":["import { ModuleError } from 'iso-error'\n\nexport class ContextAlreadyInitialized extends ModuleError {\n\tconstructor(options?: ModuleError.Options) {\n\t\tsuper('@unional/async-context', 'context can only be initialized once.', options)\n\t}\n}\n\nexport class BlockingGetDetected extends ModuleError {\n\tconstructor(options?: ModuleError.Options) {\n\t\tsuper('@unional/async-context', 'a blocking get() detected. Are you calling it within extend()?', options)\n\t}\n}\n"],"mappings":";;AAEA,IAAa,4BAAb,cAA+CA,UAAAA,YAAY;CAC1D,YAAY,SAA+B;EAC1C,MAAM,0BAA0B,yCAAyC,OAAO;CACjF;AACD;AAEA,IAAa,sBAAb,cAAyCA,UAAAA,YAAY;CACpD,YAAY,SAA+B;EAC1C,MAAM,0BAA0B,kEAAkE,OAAO;CAC1G;AACD"}
package/cjs/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './AsyncContext.js';
2
- export * from './errors.js';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { AsyncContext } from "./AsyncContext.js";
2
+ import { BlockingGetDetected, ContextAlreadyInitialized } from "./errors.js";
3
+ export { AsyncContext, BlockingGetDetected, ContextAlreadyInitialized };
package/cjs/index.js CHANGED
@@ -1,19 +1,6 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./AsyncContext.js"), exports);
18
- __exportStar(require("./errors.js"), exports);
19
- //# sourceMappingURL=index.js.map
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ const require_errors = require("./errors.js");
3
+ const require_AsyncContext = require("./AsyncContext.js");
4
+ exports.AsyncContext = require_AsyncContext.AsyncContext;
5
+ exports.BlockingGetDetected = require_errors.BlockingGetDetected;
6
+ exports.ContextAlreadyInitialized = require_errors.ContextAlreadyInitialized;
@@ -1,13 +1,16 @@
1
- import type { LeftJoin } from 'type-plus';
2
- export declare class AsyncContext<Init extends Record<string | symbol, any>, Context extends Record<string | symbol, any> = Init> {
3
- #private;
4
- constructor(init?: Init | Promise<Init> | AsyncContext.Initializer<Init>);
5
- initialize<I extends Init = Init>(init: I | Promise<I> | AsyncContext.Initializer<I>): AsyncContext<I>;
6
- extend<CurrentContext extends Record<string | symbol, any> = Context, AdditionalContext extends Record<string | symbol, any> = Record<string | symbol, any>>(context: AdditionalContext | Promise<AdditionalContext> | AsyncContext.Transformer<Context, AdditionalContext>): AsyncContext<Init, LeftJoin<CurrentContext, AdditionalContext>>;
7
- get<C = Context>(): Promise<C>;
1
+ import { LeftJoin } from "type-plus";
2
+ //#region ts/AsyncContext.d.ts
3
+ declare class AsyncContext<Init extends Record<string | symbol, any>, Context extends Record<string | symbol, any> = Init> {
4
+ #private;
5
+ constructor(init?: Init | Promise<Init> | AsyncContext.Initializer<Init>);
6
+ initialize<I extends Init = Init>(init: I | Promise<I> | AsyncContext.Initializer<I>): AsyncContext<I>;
7
+ extend<CurrentContext extends Record<string | symbol, any> = Context, AdditionalContext extends Record<string | symbol, any> = Record<string | symbol, any>>(context: AdditionalContext | Promise<AdditionalContext> | AsyncContext.Transformer<Context, AdditionalContext>): AsyncContext<Init, LeftJoin<CurrentContext, AdditionalContext>>;
8
+ get<C = Context>(): Promise<C>;
8
9
  }
9
- export declare namespace AsyncContext {
10
- type Initializer<Init> = () => Init | Promise<Init>;
11
- type Transformer<CurrentContext, AdditionalContext> = (context: CurrentContext) => AdditionalContext | Promise<AdditionalContext>;
10
+ declare namespace AsyncContext {
11
+ type Initializer<Init> = () => Init | Promise<Init>;
12
+ type Transformer<CurrentContext, AdditionalContext> = (context: CurrentContext) => AdditionalContext | Promise<AdditionalContext>;
12
13
  }
14
+ //#endregion
15
+ export { AsyncContext };
13
16
  //# sourceMappingURL=AsyncContext.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncContext.d.ts","sourceRoot":"","sources":["../ts/AsyncContext.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAGzC,qBAAa,YAAY,CACxB,IAAI,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACzC,OAAO,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI;;IAOnD,YAAY,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,EAEvE;IACD,UAAU,CAAC,CAAC,SAAS,IAAI,GAAG,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAMrG;IACD,MAAM,CACL,cAAc,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,EAC7D,iBAAiB,SAAS,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EAErF,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAAC,WAAW,CAAC,OAAO,EAAE,iBAAiB,CAAC,GAC5G,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC,CAejE;IACK,GAAG,CAAC,CAAC,GAAG,OAAO,KAAK,OAAO,CAAC,CAAC,CAAC,CAInC;CAID;AACD,yBAAiB,YAAY,CAAC;IAC7B,KAAY,WAAW,CAAC,IAAI,IAAI,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC1D,KAAY,WAAW,CAAC,cAAc,EAAE,iBAAiB,IAAI,CAC5D,OAAO,EAAE,cAAc,KACnB,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;CACnD"}
1
+ {"version":3,"file":"AsyncContext.d.ts","names":[],"sources":["../ts/AsyncContext.ts"],"mappings":";;cAGa,aACZ,aAAa,8BACb,gBAAgB,+BAA+B;;EAO/C,YAAY,OAAO,OAAO,QAAQ,QAAQ,aAAa,YAAY;EAGnE,WAAW,UAAU,OAAO,MAAM,MAAM,IAAI,QAAQ,KAAK,aAAa,YAAY,KAAK,aAAa;EAOpG,OACC,uBAAuB,+BAA+B,SACtD,0BAA0B,+BAA+B,8BAEzD,SAAS,oBAAoB,QAAQ,qBAAqB,aAAa,YAAY,SAAS,qBAC1F,aAAa,MAAM,SAAS,gBAAgB;EAgBzC,IAAI,IAAI,YAAY,QAAQ;;kBASlB;OACJ,YAAY,cAAc,OAAO,QAAQ;OACzC,YAAY,gBAAgB,sBACvC,SAAS,mBACL,oBAAoB,QAAQ"}
@@ -1,69 +1,70 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
1
+ import { BlockingGetDetected, ContextAlreadyInitialized } from "./errors.js";
2
+ import _classPrivateMethodInitSpec from "./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js";
3
+ import _classPrivateFieldInitSpec from "./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js";
4
+ import _assertClassBrand from "./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/assertClassBrand.js";
5
+ import _classPrivateFieldSet2 from "./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js";
6
+ import _classPrivateFieldGet2 from "./_virtual/_@oxc-project_runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js";
7
+ //#region ts/AsyncContext.ts
8
+ var _resolving = /* @__PURE__ */ new WeakMap();
9
+ var _resolvers = /* @__PURE__ */ new WeakMap();
10
+ var _transforming = /* @__PURE__ */ new WeakMap();
11
+ var _init = /* @__PURE__ */ new WeakMap();
12
+ var _original = /* @__PURE__ */ new WeakMap();
13
+ var _AsyncContext_brand = /* @__PURE__ */ new WeakSet();
14
+ var AsyncContext = class AsyncContext {
15
+ constructor(init) {
16
+ _classPrivateMethodInitSpec(this, _AsyncContext_brand);
17
+ _classPrivateFieldInitSpec(this, _resolving, void 0);
18
+ _classPrivateFieldInitSpec(this, _resolvers, []);
19
+ _classPrivateFieldInitSpec(this, _transforming, false);
20
+ _classPrivateFieldInitSpec(this, _init, void 0);
21
+ _classPrivateFieldInitSpec(this, _original, void 0);
22
+ _classPrivateFieldSet2(_init, this, init);
23
+ }
24
+ initialize(init) {
25
+ if (_classPrivateFieldGet2(_init, this)) throw new ContextAlreadyInitialized({ ssf: this.initialize });
26
+ _classPrivateFieldSet2(_init, this, init);
27
+ if (_classPrivateFieldGet2(_resolvers, this).length > 0) _classPrivateFieldGet2(_resolvers, this).forEach((r) => void r(_assertClassBrand(_AsyncContext_brand, this, _buildContext).call(this)));
28
+ return this;
29
+ }
30
+ extend(context) {
31
+ const newctx = new AsyncContext(async () => {
32
+ try {
33
+ const value = await this.get();
34
+ _classPrivateFieldSet2(_transforming, newctx, true);
35
+ const newValue = await (isTransformer(context) ? context(value) : context);
36
+ return {
37
+ ...value,
38
+ ...newValue
39
+ };
40
+ } finally {
41
+ _classPrivateFieldSet2(_transforming, newctx, false);
42
+ }
43
+ });
44
+ const ctx = _classPrivateFieldGet2(_original, this) ?? this;
45
+ _classPrivateFieldSet2(_original, newctx, ctx);
46
+ newctx.initialize = newctx.initialize.bind(ctx);
47
+ return newctx;
48
+ }
49
+ async get() {
50
+ if (_classPrivateFieldGet2(_transforming, this)) throw new BlockingGetDetected({ ssf: this.get });
51
+ if (_classPrivateFieldGet2(_resolving, this)) return _classPrivateFieldGet2(_resolving, this);
52
+ return _classPrivateFieldSet2(_resolving, this, _classPrivateFieldGet2(_init, this) ? _assertClassBrand(_AsyncContext_brand, this, _buildContext).call(this) : new Promise((a) => _classPrivateFieldGet2(_resolvers, this).push(a)));
53
+ }
6
54
  };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _AsyncContext_instances, _AsyncContext_resolving, _AsyncContext_resolvers, _AsyncContext_transforming, _AsyncContext_init, _AsyncContext_original, _AsyncContext_buildContext;
13
- import { BlockingGetDetected, ContextAlreadyInitialized } from './errors.js';
14
- export class AsyncContext {
15
- constructor(init) {
16
- _AsyncContext_instances.add(this);
17
- _AsyncContext_resolving.set(this, void 0);
18
- _AsyncContext_resolvers.set(this, []);
19
- _AsyncContext_transforming.set(this, false);
20
- _AsyncContext_init.set(this, void 0);
21
- _AsyncContext_original.set(this, void 0);
22
- __classPrivateFieldSet(this, _AsyncContext_init, init, "f");
23
- }
24
- initialize(init) {
25
- if (__classPrivateFieldGet(this, _AsyncContext_init, "f"))
26
- throw new ContextAlreadyInitialized({ ssf: this.initialize });
27
- __classPrivateFieldSet(this, _AsyncContext_init, init, "f");
28
- if (__classPrivateFieldGet(this, _AsyncContext_resolvers, "f").length > 0)
29
- __classPrivateFieldGet(this, _AsyncContext_resolvers, "f").forEach((r) => void r(__classPrivateFieldGet(this, _AsyncContext_instances, "m", _AsyncContext_buildContext).call(this)));
30
- return this;
31
- }
32
- extend(context) {
33
- const newctx = new AsyncContext(async () => {
34
- try {
35
- const value = await this.get();
36
- __classPrivateFieldSet(newctx, _AsyncContext_transforming, true, "f");
37
- const newValue = await (isTransformer(context) ? context(value) : context);
38
- return { ...value, ...newValue };
39
- }
40
- finally {
41
- __classPrivateFieldSet(newctx, _AsyncContext_transforming, false, "f");
42
- }
43
- });
44
- const ctx = __classPrivateFieldGet(this, _AsyncContext_original, "f") ?? this;
45
- __classPrivateFieldSet(newctx, _AsyncContext_original, ctx, "f");
46
- newctx.initialize = newctx.initialize.bind(ctx);
47
- return newctx;
48
- }
49
- async get() {
50
- if (__classPrivateFieldGet(this, _AsyncContext_transforming, "f"))
51
- throw new BlockingGetDetected({ ssf: this.get });
52
- if (__classPrivateFieldGet(this, _AsyncContext_resolving, "f"))
53
- return __classPrivateFieldGet(this, _AsyncContext_resolving, "f");
54
- return (__classPrivateFieldSet(this, _AsyncContext_resolving, __classPrivateFieldGet(this, _AsyncContext_init, "f") ? __classPrivateFieldGet(this, _AsyncContext_instances, "m", _AsyncContext_buildContext).call(this) : new Promise((a) => __classPrivateFieldGet(this, _AsyncContext_resolvers, "f").push(a)), "f"));
55
- }
55
+ async function _buildContext() {
56
+ return resolveInit(_classPrivateFieldGet2(_init, this));
56
57
  }
57
- _AsyncContext_resolving = new WeakMap(), _AsyncContext_resolvers = new WeakMap(), _AsyncContext_transforming = new WeakMap(), _AsyncContext_init = new WeakMap(), _AsyncContext_original = new WeakMap(), _AsyncContext_instances = new WeakSet(), _AsyncContext_buildContext = async function _AsyncContext_buildContext() {
58
- return resolveInit(__classPrivateFieldGet(this, _AsyncContext_init, "f"));
59
- };
60
58
  async function resolveInit(init) {
61
- return isInitializer(init) ? init() : init;
59
+ return isInitializer(init) ? init() : init;
62
60
  }
63
61
  function isTransformer(context) {
64
- return typeof context === 'function';
62
+ return typeof context === "function";
65
63
  }
66
64
  function isInitializer(context) {
67
- return typeof context === 'function';
65
+ return typeof context === "function";
68
66
  }
67
+ //#endregion
68
+ export { AsyncContext };
69
+
69
70
  //# sourceMappingURL=AsyncContext.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AsyncContext.js","sourceRoot":"","sources":["../ts/AsyncContext.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,OAAO,EAAE,mBAAmB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAE5E,MAAM,OAAO,YAAY;IASxB,YAAY,IAA4D;;QALxE,0CAAoC;QACpC,kCAAuD,EAAE,EAAA;QACzD,qCAAgB,KAAK,EAAA;QACrB,qCAAwE;QACxE,yCAA6C;QAE5C,uBAAA,IAAI,sBAAS,IAAI,MAAA,CAAA;IAClB,CAAC;IACD,UAAU,CAAwB,IAAkD;QACnF,IAAI,uBAAA,IAAI,0BAAM;YAAE,MAAM,IAAI,yBAAyB,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC,CAAA;QAC7E,uBAAA,IAAI,sBAAS,IAAI,MAAA,CAAA;QAEjB,IAAI,uBAAA,IAAI,+BAAW,CAAC,MAAM,GAAG,CAAC;YAAE,uBAAA,IAAI,+BAAW,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,uBAAA,IAAI,2DAAc,MAAlB,IAAI,CAAgB,CAAC,CA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AC,CAAC,CAAC,CAAC,MAAA,CAAC,CAAA;IAChH,CAAC;CAID;gRAHA,KAAK;IACJ,OAAO,WAAW,CAAC,uBAAA,IAAI,0BAAO,CAA4B,CAAA;AAC3D,CAAC;AASF,KAAK,UAAU,WAAW,CACzB,IAA2D;IAE3D,OAAO,aAAa,CAAO,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;AACjD,CAAC;AAED,SAAS,aAAa,CACrB,OAAgB;IAEhB,OAAO,OAAO,OAAO,KAAK,UAAU,CAAA;AACrC,CAAC;AAED,SAAS,aAAa,CAAI,OAAgB;IACzC,OAAO,OAAO,OAAO,KAAK,UAAU,CAAA;AACrC,CAAC"}
1
+ {"version":3,"file":"AsyncContext.js","names":[],"sources":["../ts/AsyncContext.ts"],"sourcesContent":["import type { LeftJoin } from 'type-plus'\nimport { BlockingGetDetected, ContextAlreadyInitialized } from './errors.js'\n\nexport class AsyncContext<\n\tInit extends Record<string | symbol, any>,\n\tContext extends Record<string | symbol, any> = Init,\n> {\n\t#resolving: Promise<any> | undefined\n\t#resolvers: Array<(value: Promise<Context>) => void> = []\n\t#transforming = false\n\t#init: Init | Promise<Init> | AsyncContext.Initializer<Init> | undefined\n\t#original: AsyncContext<any, any> | undefined\n\tconstructor(init?: Init | Promise<Init> | AsyncContext.Initializer<Init>) {\n\t\tthis.#init = init\n\t}\n\tinitialize<I extends Init = Init>(init: I | Promise<I> | AsyncContext.Initializer<I>): AsyncContext<I> {\n\t\tif (this.#init) throw new ContextAlreadyInitialized({ ssf: this.initialize })\n\t\tthis.#init = init\n\n\t\tif (this.#resolvers.length > 0) this.#resolvers.forEach((r) => void r(this.#buildContext()))\n\t\treturn this as any as AsyncContext<I>\n\t}\n\textend<\n\t\tCurrentContext extends Record<string | symbol, any> = Context,\n\t\tAdditionalContext extends Record<string | symbol, any> = Record<string | symbol, any>,\n\t>(\n\t\tcontext: AdditionalContext | Promise<AdditionalContext> | AsyncContext.Transformer<Context, AdditionalContext>,\n\t): AsyncContext<Init, LeftJoin<CurrentContext, AdditionalContext>> {\n\t\tconst newctx = new AsyncContext(async () => {\n\t\t\ttry {\n\t\t\t\tconst value = await this.get()\n\t\t\t\tnewctx.#transforming = true\n\t\t\t\tconst newValue = await (isTransformer<any, any>(context) ? context(value) : context)\n\t\t\t\treturn { ...value, ...newValue }\n\t\t\t} finally {\n\t\t\t\tnewctx.#transforming = false\n\t\t\t}\n\t\t})\n\t\tconst ctx = this.#original ?? this\n\t\tnewctx.#original = ctx\n\t\tnewctx.initialize = newctx.initialize.bind(ctx)\n\t\treturn newctx\n\t}\n\tasync get<C = Context>(): Promise<C> {\n\t\tif (this.#transforming) throw new BlockingGetDetected({ ssf: this.get })\n\t\tif (this.#resolving) return this.#resolving\n\t\treturn (this.#resolving = this.#init ? this.#buildContext() : new Promise<any>((a) => this.#resolvers.push(a)))\n\t}\n\tasync #buildContext(): Promise<Context> {\n\t\treturn resolveInit(this.#init!) as any as Promise<Context>\n\t}\n}\nexport namespace AsyncContext {\n\texport type Initializer<Init> = () => Init | Promise<Init>\n\texport type Transformer<CurrentContext, AdditionalContext> = (\n\t\tcontext: CurrentContext,\n\t) => AdditionalContext | Promise<AdditionalContext>\n}\n\nasync function resolveInit<Init extends Record<string | symbol, any>>(\n\tinit: Init | Promise<Init> | AsyncContext.Initializer<Init>,\n): Promise<Init> {\n\treturn isInitializer<Init>(init) ? init() : init\n}\n\nfunction isTransformer<CurrentContext, AdditionalContext>(\n\tcontext: unknown,\n): context is AsyncContext.Transformer<CurrentContext, AdditionalContext> {\n\treturn typeof context === 'function'\n}\n\nfunction isInitializer<T>(context: unknown): context is AsyncContext.Initializer<T> {\n\treturn typeof context === 'function'\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAa,eAAb,MAAa,aAGX;CAMD,YAAY,MAA8D;;;EAJnB,2BAAA,MAAA,YAAA,CAAC,CAAA;EACxC,2BAAA,MAAA,eAAA,KAAA;;;EAI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,IAAA,CAAW;AAC/B;AASD,eAAe,YACd,MACgB;CAChB,OAAO,cAAoB,IAAI,IAAI,KAAK,IAAI;AAC7C;AAEA,SAAS,cACR,SACyE;CACzE,OAAO,OAAO,YAAY;AAC3B;AAEA,SAAS,cAAiB,SAA0D;CACnF,OAAO,OAAO,YAAY;AAC3B"}
@@ -0,0 +1,7 @@
1
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/assertClassBrand.js
2
+ function _assertClassBrand(e, t, n) {
3
+ if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
4
+ throw new TypeError("Private element is not present on this object");
5
+ }
6
+ //#endregion
7
+ export { _assertClassBrand as default };
@@ -0,0 +1,6 @@
1
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/checkPrivateRedeclaration.js
2
+ function _checkPrivateRedeclaration(e, t) {
3
+ if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
4
+ }
5
+ //#endregion
6
+ export { _checkPrivateRedeclaration as default };
@@ -0,0 +1,7 @@
1
+ import _assertClassBrand from "./assertClassBrand.js";
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldGet2.js
3
+ function _classPrivateFieldGet2(s, a) {
4
+ return s.get(_assertClassBrand(s, a));
5
+ }
6
+ //#endregion
7
+ export { _classPrivateFieldGet2 as default };
@@ -0,0 +1,7 @@
1
+ import _checkPrivateRedeclaration from "./checkPrivateRedeclaration.js";
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldInitSpec.js
3
+ function _classPrivateFieldInitSpec(e, t, a) {
4
+ _checkPrivateRedeclaration(e, t), t.set(e, a);
5
+ }
6
+ //#endregion
7
+ export { _classPrivateFieldInitSpec as default };
@@ -0,0 +1,7 @@
1
+ import _assertClassBrand from "./assertClassBrand.js";
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateFieldSet2.js
3
+ function _classPrivateFieldSet2(s, a, r) {
4
+ return s.set(_assertClassBrand(s, a), r), r;
5
+ }
6
+ //#endregion
7
+ export { _classPrivateFieldSet2 as default };
@@ -0,0 +1,7 @@
1
+ import _checkPrivateRedeclaration from "./checkPrivateRedeclaration.js";
2
+ //#region \0@oxc-project+runtime@0.147.0/helpers/esm/classPrivateMethodInitSpec.js
3
+ function _classPrivateMethodInitSpec(e, a) {
4
+ _checkPrivateRedeclaration(e, a), a.add(e);
5
+ }
6
+ //#endregion
7
+ export { _classPrivateMethodInitSpec as default };
package/esm/errors.d.ts CHANGED
@@ -1,8 +1,11 @@
1
- import { ModuleError } from 'iso-error';
2
- export declare class ContextAlreadyInitialized extends ModuleError {
3
- constructor(options?: ModuleError.Options);
1
+ import { ModuleError } from "iso-error";
2
+ //#region ts/errors.d.ts
3
+ declare class ContextAlreadyInitialized extends ModuleError {
4
+ constructor(options?: ModuleError.Options);
4
5
  }
5
- export declare class BlockingGetDetected extends ModuleError {
6
- constructor(options?: ModuleError.Options);
6
+ declare class BlockingGetDetected extends ModuleError {
7
+ constructor(options?: ModuleError.Options);
7
8
  }
9
+ //#endregion
10
+ export { BlockingGetDetected, ContextAlreadyInitialized };
8
11
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,qBAAa,yBAA0B,SAAQ,WAAW;IACzD,YAAY,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAExC;CACD;AAED,qBAAa,mBAAoB,SAAQ,WAAW;IACnD,YAAY,OAAO,CAAC,EAAE,WAAW,CAAC,OAAO,EAExC;CACD"}
1
+ {"version":3,"file":"errors.d.ts","names":[],"sources":["../ts/errors.ts"],"mappings":";;cAEa,kCAAkC;EAC9C,YAAY,UAAU,YAAY;;cAKtB,4BAA4B;EACxC,YAAY,UAAU,YAAY"}
package/esm/errors.js CHANGED
@@ -1,12 +1,16 @@
1
- import { ModuleError } from 'iso-error';
2
- export class ContextAlreadyInitialized extends ModuleError {
3
- constructor(options) {
4
- super('@unional/async-context', 'context can only be initialized once.', options);
5
- }
6
- }
7
- export class BlockingGetDetected extends ModuleError {
8
- constructor(options) {
9
- super('@unional/async-context', 'a blocking get() detected. Are you calling it within extend()?', options);
10
- }
11
- }
1
+ import { ModuleError } from "iso-error";
2
+ //#region ts/errors.ts
3
+ var ContextAlreadyInitialized = class extends ModuleError {
4
+ constructor(options) {
5
+ super("@unional/async-context", "context can only be initialized once.", options);
6
+ }
7
+ };
8
+ var BlockingGetDetected = class extends ModuleError {
9
+ constructor(options) {
10
+ super("@unional/async-context", "a blocking get() detected. Are you calling it within extend()?", options);
11
+ }
12
+ };
13
+ //#endregion
14
+ export { BlockingGetDetected, ContextAlreadyInitialized };
15
+
12
16
  //# sourceMappingURL=errors.js.map
package/esm/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../ts/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,OAAO,yBAA0B,SAAQ,WAAW;IACzD,YAAY,OAA6B;QACxC,KAAK,CAAC,wBAAwB,EAAE,uCAAuC,EAAE,OAAO,CAAC,CAAA;IAClF,CAAC;CACD;AAED,MAAM,OAAO,mBAAoB,SAAQ,WAAW;IACnD,YAAY,OAA6B;QACxC,KAAK,CAAC,wBAAwB,EAAE,gEAAgE,EAAE,OAAO,CAAC,CAAA;IAC3G,CAAC;CACD"}
1
+ {"version":3,"file":"errors.js","names":[],"sources":["../ts/errors.ts"],"sourcesContent":["import { ModuleError } from 'iso-error'\n\nexport class ContextAlreadyInitialized extends ModuleError {\n\tconstructor(options?: ModuleError.Options) {\n\t\tsuper('@unional/async-context', 'context can only be initialized once.', options)\n\t}\n}\n\nexport class BlockingGetDetected extends ModuleError {\n\tconstructor(options?: ModuleError.Options) {\n\t\tsuper('@unional/async-context', 'a blocking get() detected. Are you calling it within extend()?', options)\n\t}\n}\n"],"mappings":";;AAEA,IAAa,4BAAb,cAA+C,YAAY;CAC1D,YAAY,SAA+B;EAC1C,MAAM,0BAA0B,yCAAyC,OAAO;CACjF;AACD;AAEA,IAAa,sBAAb,cAAyC,YAAY;CACpD,YAAY,SAA+B;EAC1C,MAAM,0BAA0B,kEAAkE,OAAO;CAC1G;AACD"}
package/esm/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export * from './AsyncContext.js';
2
- export * from './errors.js';
3
- //# sourceMappingURL=index.d.ts.map
1
+ import { AsyncContext } from "./AsyncContext.js";
2
+ import { BlockingGetDetected, ContextAlreadyInitialized } from "./errors.js";
3
+ export { AsyncContext, BlockingGetDetected, ContextAlreadyInitialized };
package/esm/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export * from './AsyncContext.js';
2
- export * from './errors.js';
3
- //# sourceMappingURL=index.js.map
1
+ import { BlockingGetDetected, ContextAlreadyInitialized } from "./errors.js";
2
+ import { AsyncContext } from "./AsyncContext.js";
3
+ export { AsyncContext, BlockingGetDetected, ContextAlreadyInitialized };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unional/async-context",
3
- "version": "9.0.14",
3
+ "version": "9.0.16",
4
4
  "description": "Asynchronous context for functional style programming",
5
5
  "keywords": [
6
6
  "async",
@@ -49,20 +49,17 @@
49
49
  ],
50
50
  "dependencies": {
51
51
  "iso-error": "^6.0.2",
52
- "type-plus": "8.0.0-beta.8"
52
+ "type-plus": "^7.6.2"
53
53
  },
54
54
  "devDependencies": {
55
- "@repobuddy/typescript": "^2.0.0",
56
- "@size-limit/preset-small-lib": "^13.0.0",
57
- "@types/setimmediate": "^1.0.2",
58
- "@vitest/coverage-v8": "^4.0.8",
59
- "assertron": "^11.0.1",
60
- "npm-run-all2": "^9.0.0",
61
- "repobuddy": "^1.0.2",
62
- "rimraf": "^6.0.0",
55
+ "@repobuddy/typescript": "^2.1.0",
56
+ "@types/setimmediate": "^1.0.4",
57
+ "@vitest/coverage-v8": "^4.1.11",
58
+ "assertron": "^11.5.3",
59
+ "rimraf": "^6.1.3",
63
60
  "setimmediate": "^1.0.5",
64
- "size-limit": "^13.0.0",
65
- "vitest": "^4.0.8"
61
+ "tsdown": "^0.22.14",
62
+ "vitest": "^4.1.11"
66
63
  },
67
64
  "engines": {
68
65
  "node": ">= 14.16"
@@ -70,24 +67,14 @@
70
67
  "publishConfig": {
71
68
  "access": "public"
72
69
  },
73
- "size-limit": [
74
- {
75
- "path": "./cjs/index.js"
76
- },
77
- {
78
- "path": "./esm/index.js"
79
- }
80
- ],
81
70
  "scripts": {
82
- "build": "run-p build:cjs build:esm",
83
- "build:cjs": "buddy ts build cjs",
84
- "build:esm": "tsc",
71
+ "build": "tsdown",
85
72
  "clean": "rimraf cjs esm coverage *.tsbuildinfo",
86
73
  "coverage": "vitest run --coverage",
87
74
  "lint": "biome check .",
88
75
  "nuke": "pnpm clean && rimraf node_modules",
89
- "size": "size-limit",
90
76
  "test": "vitest run",
91
- "verify": "npm-run-all -p lint build coverage size"
77
+ "typecheck": "tsc",
78
+ "verify": "pnpm run lint && pnpm run typecheck && pnpm run build && pnpm run coverage"
92
79
  }
93
80
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA"}
package/cjs/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,oDAAiC;AACjC,8CAA2B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA"}
package/esm/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../ts/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,aAAa,CAAA"}